Advertisement
Pdroman

Calculos matematicos

Jan 19th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ;Title Calcula suma,resta,incremento,decremento de dos numeros
  3.  
  4. section .bss
  5. res resb 1  ;Se reserva un espacio de memoria
  6.  
  7. section  .data ;Declarar variables
  8.  
  9. msg1 db "La suma de 4+5 es: ",10,13
  10. len1 equ $ -msg1
  11.  
  12. msg2 db 10,13, "La resta de 5-4 es: ",10,13  ; 10,13 detras de db inserta un final de linea
  13. len2 equ $ -msg2
  14.  
  15. msg3 db 10,13,"El incremento de eax=4 es: ",10,13
  16. len3 equ $ -msg3  
  17.  
  18. msg4 db 10,13, "El decremento de eax=4 es: ",10,13
  19. len4 equ $ -msg4
  20.  
  21.  
  22. section .text  ; section de intrucciones
  23.  
  24. global _start
  25.  
  26. _start:
  27.  
  28. ;********************** Imprime los mensajes *****************
  29. mov eax,4
  30. mov ebx,1
  31. mov ecx,msg1
  32. mov edx,len1
  33. int 0x80
  34.  
  35. mov eax,4
  36. mov ebx,5
  37.  
  38. add eax,ebx
  39. add eax,'0'
  40. mov [res],eax
  41.  
  42.  
  43. mov eax,4
  44. mov ebx,1
  45. mov ecx,res
  46. mov edx,1
  47. int 0x80
  48.  
  49. ;********************** Imprime los mensajes *****************
  50. mov eax,4
  51. mov ebx,1
  52. mov ecx,msg2
  53. mov edx,len2
  54. int 0x80
  55.  
  56. mov eax,5
  57. mov ebx,4
  58.  
  59. sub eax,ebx
  60. add eax,'0'
  61. mov [res],eax
  62.  
  63.  
  64. mov eax,4
  65. mov ebx,1
  66. mov ecx,res
  67. mov edx,1
  68. int 0x80
  69.  
  70. ;********************** Imprime los mensajes *****************
  71. mov eax,4
  72. mov ebx,1
  73. mov ecx,msg3
  74. mov edx,len3
  75. int 0x80
  76.  
  77. mov eax,4
  78. inc eax
  79. add eax,'0'
  80. mov [res],eax
  81.  
  82. mov eax,4
  83. mov ebx,1
  84. mov ecx,res
  85. mov edx,1
  86. int 0x80
  87.  
  88. ;********************** Imprime los mensajes *****************
  89. mov eax,4
  90. mov ebx,1
  91. mov ecx,msg3
  92. mov edx,len3
  93. int 0x80
  94.  
  95. mov eax,4
  96. dec eax
  97. add eax,'0'
  98. mov [res],eax
  99.  
  100. mov eax,4
  101. mov ebx,1
  102. mov ecx,res
  103. mov edx,1
  104. int 0x80
  105.  
  106. mov eax,1 ; Salida del programa return 0
  107. int 0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement