fork download
  1. include "emu8086.inc"
  2. ;******Some defs******
  3. prnt_msg equ 09h
  4. cr equ 0dh
  5. nl equ 0ah
  6. _in equ 01h
  7. _out equ 02h
  8. ;*********************
  9.  
  10.  
  11. ;******Data Segement******
  12. data segment
  13. nim_desc db 'THE GAME OF NIM'
  14. db cr, nl, nl, '$'
  15.  
  16. pilesAsk db 'how many piles? (no more than 5)'
  17. db cr, nl, '$'
  18.  
  19. wrong db cr, nl
  20. db 'your input is wrong'
  21. db cr, nl, '$'
  22.  
  23. sticks db cr, nl
  24. db , 'how many sticks in ', '$'
  25. sticks2 db ' pile? (no more than 9)'
  26. db cr, nl, '$'
  27.  
  28. piles dw ?
  29. pile1 db 5 dup ?
  30.  
  31. shape db '| ', '$'
  32. new db cr, nl, '$'
  33.  
  34. ends
  35. ;*************************
  36.  
  37.  
  38. ;******Stack Segment******
  39. stack segment
  40. dw 128 dup(?)
  41. ends
  42. ;*************************
  43.  
  44.  
  45. ;******Code Segemnt*******
  46. code segment
  47.  
  48. start:
  49. ;set segment registers:
  50. mov ax, data
  51. mov ds, ax
  52. mov es, ax
  53. ;======================
  54.  
  55. ;set video mode
  56. ; mov ax, 02h
  57. ; int 10h
  58. ;======================
  59.  
  60. ;print description
  61. lea dx, nim_desc
  62. call print_msg
  63. ;======================
  64.  
  65. ;ask for the number of piles
  66. lea dx, pilesAsk
  67. call print_msg
  68. ;===========================
  69.  
  70.  
  71. ;get them
  72. jmp get_pile
  73. wrong_pile:
  74. lea dx, wrong
  75. call print_msg
  76.  
  77. get_pile:
  78. call get_ch
  79. sub al, 30h
  80. cmp al, 5
  81. jg wrong_pile
  82. mov b. piles, al
  83.  
  84.  
  85. mov cl, '1'
  86. mov si, 0
  87. mov bx, 0
  88.  
  89. INPUT:
  90.  
  91. ;asking how many sticks each pile contains:
  92. lea dx, sticks
  93. call print_msg
  94.  
  95. mov dl, cl
  96. call print_ch
  97.  
  98. mov dx, offset sticks2
  99. call print_msg
  100. inc cl
  101. ;==========================
  102.  
  103. xor al, al
  104. call get_ch
  105.  
  106. sub al, 30h
  107. mov pile1[si], al
  108. inc bx
  109. cmp bx, piles
  110. jb INPUT
  111.  
  112.  
  113. call print_pile
  114.  
  115.  
  116. jmp exit
  117.  
  118.  
  119. print_pile proc
  120. pusha
  121. mov si, 0
  122. mov cx, piles
  123. xor bl, bl
  124.  
  125. pile_loop:
  126. lea dx, shape
  127. mov bl, pile1[si]
  128.  
  129. print_loop:
  130. call print_msg
  131. dec bl
  132. cmp bl, 0
  133. jnz print_loop
  134.  
  135. lea dx, new
  136. call print_msg
  137. inc si
  138. dec cx
  139. cmp cx, 0
  140. jnz pile_loop
  141.  
  142. popa
  143. ret
  144. print_pile endp
  145.  
  146.  
  147. get_cursor proc
  148. mov ah, 03h
  149. int 10h
  150. ret
  151. get_cursor endp
  152.  
  153. print_msg proc
  154. pusha
  155. mov ah, prnt_msg
  156. int 21h
  157. popa
  158. ret
  159. print_msg endp
  160.  
  161.  
  162. print_ch proc
  163. pusha
  164. mov ah, _out
  165. int 21h
  166. popa
  167. ret
  168. print_ch endp
  169.  
  170.  
  171. get_ch proc
  172. mov ah, _in
  173. int 21h
  174. ret
  175. get_ch endp
  176.  
  177.  
  178. play_again proc
  179. ;to be written
  180. play_again endp
  181. ends
  182.  
  183. exit:
  184. mov ax, 4c00h
  185. int 21h
  186.  
  187. end start
  188.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.asm:1: error: parser: instruction expected
prog.asm:12: error: parser: instruction expected
prog.asm:24: error: expression syntax error
prog.asm:29: error: comma expected after operand 1
prog.asm:39: error: parser: instruction expected
prog.asm:40: error: comma expected after operand 1
prog.asm:41: error: symbol `ends' redefined
prog.asm:46: error: parser: instruction expected
prog.asm:82: error: comma, colon, decorator or end of line expected after operand
prog.asm:98: error: comma, colon, decorator or end of line expected after operand
prog.asm:107: error: comma, colon, decorator or end of line expected after operand
prog.asm:119: error: parser: instruction expected
prog.asm:127: error: comma, colon, decorator or end of line expected after operand
prog.asm:144: error: symbol `print_pile' redefined
prog.asm:144: error: parser: instruction expected
prog.asm:147: error: parser: instruction expected
prog.asm:151: error: symbol `get_cursor' redefined
prog.asm:151: error: parser: instruction expected
prog.asm:153: error: parser: instruction expected
prog.asm:159: error: symbol `print_msg' redefined
prog.asm:159: error: parser: instruction expected
prog.asm:162: error: parser: instruction expected
prog.asm:168: error: symbol `print_ch' redefined
prog.asm:168: error: parser: instruction expected
prog.asm:171: error: parser: instruction expected
prog.asm:175: error: symbol `get_ch' redefined
prog.asm:175: error: parser: instruction expected
prog.asm:178: error: parser: instruction expected
prog.asm:180: error: symbol `play_again' redefined
prog.asm:180: error: parser: instruction expected
prog.asm:181: error: symbol `ends' redefined
prog.asm:187: error: parser: instruction expected
ld: cannot find prog.o: No such file or directory
stdout
Standard output is empty