Assembly Error

Reply

Join Date: Jun 2009
Posts: 2
Reputation: nagash07 is an unknown quantity at this point 
Solved Threads: 0
nagash07 nagash07 is offline Offline
Newbie Poster

Assembly Error

 
0
  #1
Jul 15th, 2009
Well I have sum assembly homework to do... its supposed to be the snake game. I managed to make a program using parts of others ones, since Im lazy.. anyhow I got the program almost ready but I get only 1 error when assembling:

Fatal C:\TASM\emu8086\M3\M3.asm(243) Unexpected end of file encountered ...

The line 243 is last one of the program but I cant figure out whats wrong, can sum1 please check out the code and see if you can find out? PLease... txs ; The comments are in portuguese but I dont think that'll bother..

  1. .model small
  2. .stack 100h
  3.  
  4. ;org 100h
  5.  
  6. ; pular seção de dados:
  7. ;jmp inicio
  8.  
  9. ; ------ data section ------
  10. .data
  11.  
  12. s_tamanho equ 7
  13.  
  14. ; coordenadas da cobra
  15. ; (da cauda à cabeça)
  16. ; low byte à esquerda, high byte
  17. ; no top - [top, esquerda]
  18. cobra dw s_tamanho dup(0)
  19.  
  20. cauda dw ?
  21.  
  22. ; direcao
  23. ; (codigos de tecla da bios):
  24. esquerda equ 4bh
  25. direita equ 4dh
  26. up equ 48h
  27. baixo equ 50h
  28.  
  29. ; direçao atual da cobra:
  30. cur_dir db direita
  31.  
  32. espera_tempo dw 0
  33.  
  34. ; mensagem inicial
  35. msg db "==== como jogar ====", 0dh,0ah
  36. db "controle a cobra utilizando as setas direcionais", 0dh,0ah
  37. db "qualquer outra tecla fará a cobra parar.", 0dh,0ah, 0ah
  38.  
  39. db "aperte ESC para sair.", 0dh,0ah
  40. db "====================", 0dh,0ah, 0ah
  41. db "aperte qualquer tecla para iniciar...$"
  42.  
  43. ; ------ seção de codigo ------
  44.  
  45. .code
  46.  
  47. inicio:
  48.  
  49. ; imprime msg inicial:
  50. mov dx, offset msg
  51. mov ah, 9
  52. int 21h
  53.  
  54.  
  55. ; espera teclado:
  56. mov ah, 00h
  57. int 16h
  58.  
  59.  
  60. ; esconde o cursor:
  61. mov ah, 1
  62. mov ch, 2bh
  63. mov cl, 0bh
  64. int 10h
  65.  
  66.  
  67. jogo_loop:
  68.  
  69. ; escolhe primeira tela do video
  70. mov al, 0 ; numero da tela.
  71. mov ah, 05h
  72. int 10h
  73.  
  74. ; mostra nova cabeça:
  75. mov dx, cobra[0]
  76.  
  77. ; posiciona cursor em dl,dh
  78. mov ah, 02h
  79. int 10h
  80.  
  81. ; imprime '*' no local:
  82. mov al, '*'
  83. mov ah, 09h
  84. mov bl, 0eh ; attribute.
  85. mov cx, 1 ; single char.
  86. int 10h
  87.  
  88. ; mantem a cauda:
  89. mov ax, cobra[s_tamanho * 2 - 2]
  90. mov cauda, ax
  91.  
  92. call movimento_cobra
  93.  
  94.  
  95. ; esconde a cauda velha:
  96. mov dx, cauda
  97.  
  98. ; posiciona o curso em dl,dh
  99. mov ah, 02h
  100. int 10h
  101.  
  102. ; imprime ' ' no local:
  103. mov al, ' '
  104. mov ah, 09h
  105. mov bl, 0eh ; atribuir.
  106. mov cx, 1 ; único char.
  107. int 10h
  108.  
  109.  
  110.  
  111. aguarda_entrada_teclado:
  112.  
  113. ; buscar comando:
  114. mov ah, 01h
  115. int 16h
  116. jz no_key
  117.  
  118. mov ah, 00h
  119. int 16h
  120.  
  121. cmp al, 1bh ; tecla - ESC?
  122. je parar_jogo ;
  123.  
  124. mov cur_dir, ah
  125.  
  126. no_key:
  127.  
  128.  
  129.  
  130. ; aguardar:
  131. ; pegar intervalos do relogio
  132. ; (aprox 18 por segundo)
  133. ; desde 00:00 ateh cx:dx
  134. mov ah, 00h
  135. int 1ah
  136. cmp dx, espera_tempo
  137. jb aguarda_entrada_teclado
  138. add dx, 4
  139. mov espera_tempo, dx
  140.  
  141.  
  142.  
  143. ; loop infinito:
  144. jmp jogo_loop
  145.  
  146.  
  147. parar_jogo:
  148.  
  149. ; mostrar cursor:
  150. mov ah, 1
  151. mov ch, 0bh
  152. mov cl, 0bh
  153. int 10h
  154.  
  155. ret
  156.  
  157. ; ------ seção das funções ------
  158.  
  159. ; este procedimento cria a
  160. ; animação movimentando todas as
  161. ; partes ateh a cauda,
  162. ; a ultima parte da cauda some:
  163. ; [ultima parte (cauda)]-> some
  164. ; [parte i] -> [parte i+1]
  165.  
  166.  
  167. ;------------------------------------------------------------------
  168. movimento_cobra proc near
  169.  
  170. ; seta es para o segmento de informação da bios:
  171. mov ax, 40h
  172. mov es, ax
  173.  
  174. ; aponta di para a cauda
  175. mov di, s_tamanho * 2 - 2
  176. ; movimenta todo o corpo
  177. ; (ultima parte some)
  178. mov cx, s_tamanho-1
  179. movimento_array:
  180. mov ax, cobra[di-2]
  181. mov cobra[di], ax
  182. sub di, 2
  183. loop movimento_array
  184.  
  185.  
  186. cmp cur_dir, esquerda
  187. je movimento_esquerda
  188. cmp cur_dir, direita
  189. je movimento_direita
  190. cmp cur_dir, up
  191. je movimento_up
  192. cmp cur_dir, baixo
  193. je movimento_baixo
  194.  
  195. jmp parar_movimento ; sem direção.
  196.  
  197.  
  198. movimento_esquerda:
  199. mov al, b.cobra[0]
  200. dec al
  201. mov b.cobra[0], al
  202. cmp al, -1
  203. jne parar_movimento
  204. mov al, es:[4ah] ; numero da coluna.
  205. dec al
  206. mov b.cobra[0], al ; retornar a direita.
  207. jmp parar_movimento
  208.  
  209. movimento_direita:
  210. mov al, b.cobra[0]
  211. inc al
  212. mov b.cobra[0], al
  213. cmp al, es:[4ah] ; col number.
  214. jb parar_movimento
  215. mov b.cobra[0], 0 ; return to esquerda.
  216. jmp parar_movimento
  217.  
  218. movimento_up:
  219. mov al, b.cobra[1]
  220. dec al
  221. mov b.cobra[1], al
  222. cmp al, -1
  223. jne parar_movimento
  224. mov al, es:[84h] ; numero da fileira -1.
  225. mov b.cobra[1], al ; voltar para baixo.
  226. jmp parar_movimento
  227.  
  228. movimento_baixo:
  229. mov al, b.cobra[1]
  230. inc al
  231. mov b.cobra[1], al
  232. cmp al, es:[84h] ; numero da fileira -1.
  233. jbe parar_movimento
  234. mov b.cobra[1], 0 ; voltar ao topo.
  235. jmp parar_movimento
  236.  
  237. parar_movimento:
  238. ret
  239. movimento_cobra endp
  240. ;------------------------------------------------------------------
  241. mov ah,4ch
  242. int 21h
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Assembly Error

 
0
  #2
Jul 16th, 2009
This should be the last edit line of your ASM file.
(Leave atleast one blank line below it!)

  1. END

Believe it or not, assemblers still require the END keyword.

Does this help?

One question though. Why do you have this DOS code at the bottom of your file? There's no label thus no way to get there!

  1. mov ah,4ch
  2. int 21h
Last edited by wildgoose; Jul 16th, 2009 at 12:49 am.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC