Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. ;S.C.1 2012 - Prof. Diego Corsi
  2. ;T.P. #7 - Programaci�n NASM #1
  3. ;
  4. ;1� en consola de NASM:
  5. ; nasm -f win32 c:\TP7-1.asm --PREFIX _
  6. ;
  7. ;2� en consola de Visual Studio:
  8. ; link /out:c:\TP7-1.exe c:\TP7-1.obj libcmt.lib
  9. ; c:\TP7-1
  10. ;
  11. ;#1. Dado un entero N, tal que 0 < N < 11,
  12. ; la computadora muestra la tabla de multiplicar de N.
  13.  
  14. global main
  15. global _start
  16.  
  17. extern printf
  18. extern scanf
  19.  
  20. extern exit
  21. extern gets
  22.  
  23. section .bss
  24.  
  25. numero:
  26. resd 1
  27.  
  28. numero2:
  29. resd 1
  30.  
  31. cadena:
  32. resb 0x0100
  33.  
  34. caracter:
  35. resb 1
  36. resb 3
  37.  
  38. section .data
  39.  
  40. encabezado:
  41. db "S.C.1 2012 - Prof. Diego Corsi", 0
  42.  
  43. trabajo:
  44. db "T.P. #7 - Programacion NASM #1", 0
  45.  
  46. enunciado:
  47. db "#1. Ingrese un entero N, tal que 0 < N < 11, la computadora muestra la tabla de multiplicar de N : ", 0
  48.  
  49. multiplicacion:
  50. db " x ", 0
  51.  
  52. igual:
  53. db " = ", 0
  54.  
  55. fmtInt:
  56. db "%d", 0
  57.  
  58. fmtString:
  59. db "%s", 0
  60.  
  61. fmtChar:
  62. db "%c", 0
  63.  
  64. fmtLF:
  65. db 0xA, 0
  66.  
  67. section .text
  68.  
  69. leerCadena:
  70. push cadena
  71. call gets
  72. add esp, 4
  73. ret
  74.  
  75. leerNumero:
  76. push numero
  77. push fmtInt
  78. call scanf
  79. add esp, 8
  80. ret
  81.  
  82. mostrarCadena:
  83. push cadena
  84. push fmtString
  85. call printf
  86. add esp, 8
  87. ret
  88.  
  89. mostrarNumero:
  90. push dword [numero]
  91. push fmtInt
  92. call printf
  93. add esp, 8
  94. ret
  95.  
  96. mostrarNumero2:
  97. push dword [numero2]
  98. push fmtInt
  99. call printf
  100. add esp, 8
  101. ret
  102.  
  103. mostrarCaracter:
  104. push dword [caracter]
  105. push fmtChar
  106. call printf
  107. add esp, 8
  108. ret
  109.  
  110. mostrarSaltoDeLinea:
  111. push fmtLF
  112. call printf
  113. add esp, 4
  114. ret
  115.  
  116. salirDelPrograma:
  117. push 0
  118. call exit
  119.  
  120. _start:
  121. main:
  122. call mostrarSaltoDeLinea
  123. push encabezado
  124. call printf
  125. add esp, 4
  126. call mostrarSaltoDeLinea
  127. push trabajo
  128. call printf
  129. add esp, 4
  130. call mostrarSaltoDeLinea
  131. call mostrarSaltoDeLinea
  132. push enunciado
  133. call printf
  134. add esp, 4
  135. call leerNumero
  136. mov ax, [numero]
  137. cmp ax, -1
  138. jle salirDelPrograma
  139. mov bx, 1
  140. call mostrarSaltoDeLinea
  141.  
  142. ciclo:
  143. div bx
  144. mov [numero2], ah
  145. mov ax, [numero2]
  146. cmp ax, 0
  147. je mostrarDivisor
  148. jmp seguirCiclo
  149.  
  150. seguirCiclo
  151. inc bx
  152. mov ax, [numero]
  153. cmp bx, ax
  154. je salirDelPrograma
  155. jmp ciclo
  156.  
  157. mostrarDivisor:
  158. call mostrarNumero2
  159. call mostrarSaltoDeLinea
  160. jmp seguirCiclo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement