Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. print macro cadena
  2. LOCAL ETIQUETA
  3. ETIQUETA:
  4. MOV ah,09h
  5. MOV dx,@data
  6. MOV ds,dx
  7. MOV dx, offset cadena
  8. int 21h
  9. endm
  10.  
  11. getChar macro
  12. mov ah,01h
  13. int 21h
  14. endm
  15.  
  16. getRuta macro buffer
  17. LOCAL INICIO,FIN
  18. xor si,si
  19. INICIO:
  20. getChar
  21. cmp al,0dh
  22. je FIN
  23. mov buffer[si],al
  24. inc si
  25. jmp INICIO
  26. FIN:
  27. mov buffer[si],00h
  28. endm
  29.  
  30. abrirF macro ruta,handle
  31. mov ah,3dh
  32. mov al,00h
  33. lea dx,ruta
  34. int 21h
  35. mov handle,ax
  36. jc ErrorAbrir
  37. endm
  38.  
  39. leerF macro numbytes,buffer,handle
  40. mov ah,3fh
  41. mov bx,handle
  42. mov cx,numbytes
  43. lea dx,buffer
  44. int 21h
  45. jc ErrorLeer
  46. endm
  47.  
  48. cerrarF macro handle
  49. mov ah,3eh
  50. mov handle,bx
  51. int 21h
  52. jc ErrorCerrar
  53. endm
  54.  
  55. operar macro sumando,restando,multiplicando,dividiendo
  56. LOCAL SUMA,RESTA,MULTIPLICACION,DIVICION,FIN
  57. cmp ax,43
  58. je SUMA
  59. cmp ax,45
  60. je RESTA
  61. cmp ax,42
  62. je MULTIPLICACION
  63. cmp ax,47
  64. je DIVICION
  65. jmp FIN
  66. SUMA:
  67. print sumando
  68. push ax
  69. jmp FIN
  70. RESTA:
  71. print restando
  72. push ax
  73. jmp FIN
  74. MULTIPLICACION:
  75. print multiplicando
  76. push ax
  77. jmp FIN
  78. DIVICION:
  79. print dividiendo
  80. push ax
  81. jmp FIN
  82. FIN:
  83. endm
  84.  
  85.  
  86. automata macro buffer,ApCorchete,CiCorchete,Reconocio,ReconocioMul,ReconocioDiv,ReconocioSum,ReconocioRes,ReconocioNum,ReconocioId,ReconocioObjeto,divisor,sumando,restando,multiplicando,dividiendo,almacenando,obteniendo,negativ,positiv,digito
  87. LOCAL INICIO,SUMARCORCHETE,RESTACORCHETE,FIN,OPERADOR
  88. xor ax,ax
  89. xor bx,bx
  90. xor cx,cx
  91. xor si,si
  92. INICIO:
  93. mov bl,buffer[si]
  94. cmp bl,123
  95. je SUMARCORCHETE
  96. cmp bl,125
  97. je RESTACORCHETE
  98. cmp bl,34
  99. je OPERADOR
  100. inc si
  101. jmp INICIO
  102.  
  103. SUMARCORCHETE:
  104. ;print ApCorchete
  105. inc cx
  106. inc si
  107. jmp INICIO
  108. RESTACORCHETE:
  109. sub cx,1b
  110. inc si
  111. cmp cx,0
  112. je FIN
  113. cmp cx,2
  114. je OBTENER
  115. cmp cx,1
  116. je GUARDAR
  117. print CiCorchete
  118. pop ax
  119. pop ax
  120. pop ax
  121. operar sumando,restando,multiplicando,dividiendo,almacenando
  122. print divisor
  123. jmp INICIO
  124. OBTENER:
  125. print obteniendo
  126. jmp INICIO
  127. GUARDAR:
  128. print almacenando
  129. jmp INICIO
  130. OPERADOR:
  131. inc si
  132. mov bl,buffer[si]
  133. cmp bl,42
  134. je MULTIPLICACION
  135. cmp bl,109
  136. je MULTIPLICACION2
  137. cmp bl,47
  138. je DIVICION
  139. cmp bl,100
  140. je DIVICION2
  141. cmp bl,43
  142. je SUMA
  143. cmp bl,97
  144. je SUMA2
  145. cmp bl,45
  146. je RESTA
  147. cmp bl,115
  148. je RESTA2
  149. cmp bl,35
  150. je NUMERO
  151. cmp bl,105
  152. je ID
  153. cmp bl,111
  154. je OBJETO
  155.  
  156. inc si
  157. jmp INICIO
  158.  
  159. MULTIPLICACION:
  160. print ReconocioMul
  161. getChar
  162. mov ax,42
  163. push ax
  164. inc si
  165. jmp INICIO
  166.  
  167.  
  168. MULTIPLICACION2:
  169. inc si
  170. mov bl,buffer[si]
  171. cmp bl,117
  172. jne INICIO
  173. inc si
  174. mov bl,buffer[si]
  175. cmp bl,108
  176. jne INICIO
  177. print ReconocioMul
  178. getChar
  179. mov ax,42
  180. push ax
  181. inc si
  182. jmp INICIO
  183.  
  184. DIVICION:
  185. print ReconocioDiv
  186. getChar
  187. mov ax,47
  188. push ax
  189. inc si
  190. jmp INICIO
  191. DIVICION2:
  192. inc si
  193. mov bl,buffer[si]
  194. cmp bl,105
  195. jne INICIO
  196. inc si
  197. mov bl,buffer[si]
  198. cmp bl,118
  199. jne INICIO
  200. print ReconocioDiv
  201. getChar
  202. mov ax,47
  203. push ax
  204. inc si
  205. jmp INICIO
  206. SUMA:
  207. print ReconocioSum
  208. getChar
  209. mov ax,43
  210. push ax
  211. inc si
  212. jmp INICIO
  213. SUMA2:
  214. inc si
  215. mov bl,buffer[si]
  216. cmp bl,100
  217. jne INICIO
  218. inc si
  219. mov bl,buffer[si]
  220. cmp bl,100
  221. jne INICIO
  222. print ReconocioSum
  223. getChar
  224. mov ax,43
  225. push ax
  226. inc si
  227. jmp INICIO
  228.  
  229. RESTA:
  230. print ReconocioRes
  231. getChar
  232. mov ax,45
  233. push ax
  234. inc si
  235. jmp INICIO
  236. RESTA2:
  237. inc si
  238. mov bl,buffer[si]
  239. cmp bl,117
  240. jne INICIO
  241. inc si
  242. mov bl,buffer[si]
  243. cmp bl,98
  244. jne INICIO
  245. print ReconocioRes
  246. getChar
  247. mov ax,45
  248. push ax
  249. inc si
  250. jmp INICIO
  251. NUMERO:
  252. xor dx,dx
  253. add si,3
  254. mov bl,buffer[si]
  255. cmp bl,45
  256. jne POSITIVO
  257. inc si
  258. jmp NEGATIVO
  259. POSITIVO:
  260. mov bl,buffer[si]
  261. cmp bl,48
  262. jl POSITIVO2
  263. cmp bl,57
  264. jg POSITIVO2
  265. inc si
  266. inc dl
  267. print digito
  268. jmp POSITIVO
  269. POSITIVO2:
  270. print positiv
  271. getChar
  272. mov ax,45
  273. push ax
  274. jmp INICIO
  275. NEGATIVO:
  276. mov bl,buffer[si]
  277. cmp bl,48
  278. jl NEGATIVO2
  279. cmp bl,57
  280. jg NEGATIVO2
  281. inc si
  282. inc dl
  283. print digito
  284. getChar
  285. jmp NEGATIVO
  286. NEGATIVO2:
  287. print negativ
  288. mov ax,45
  289. push ax
  290. jmp INICIO
  291.  
  292. ID:
  293. print ReconocioId
  294. getChar
  295. mov ax,45
  296. push ax
  297. inc si
  298. jmp INICIO
  299. OBJETO:
  300. print ReconocioObjeto
  301. getChar
  302. mov ax,45
  303. push ax
  304. inc si
  305. jmp INICIO
  306.  
  307. FIN:
  308. print Reconocio
  309. endm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement