Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Title Calcula suma,resta,incremento,decremento de dos numeros
- section .bss
- res resb 1 ;Se reserva un espacio de memoria
- section .data ;Declarar variables
- msg1 db "La suma de 4+5 es: ",10,13
- len1 equ $ -msg1
- msg2 db 10,13, "La resta de 5-4 es: ",10,13 ; 10,13 detras de db inserta un final de linea
- len2 equ $ -msg2
- msg3 db 10,13,"El incremento de eax=4 es: ",10,13
- len3 equ $ -msg3
- msg4 db 10,13, "El decremento de eax=4 es: ",10,13
- len4 equ $ -msg4
- section .text ; section de intrucciones
- global _start
- _start:
- ;********************** Imprime los mensajes *****************
- mov eax,4
- mov ebx,1
- mov ecx,msg1
- mov edx,len1
- int 0x80
- mov eax,4
- mov ebx,5
- add eax,ebx
- add eax,'0'
- mov [res],eax
- mov eax,4
- mov ebx,1
- mov ecx,res
- mov edx,1
- int 0x80
- ;********************** Imprime los mensajes *****************
- mov eax,4
- mov ebx,1
- mov ecx,msg2
- mov edx,len2
- int 0x80
- mov eax,5
- mov ebx,4
- sub eax,ebx
- add eax,'0'
- mov [res],eax
- mov eax,4
- mov ebx,1
- mov ecx,res
- mov edx,1
- int 0x80
- ;********************** Imprime los mensajes *****************
- mov eax,4
- mov ebx,1
- mov ecx,msg3
- mov edx,len3
- int 0x80
- mov eax,4
- inc eax
- add eax,'0'
- mov [res],eax
- mov eax,4
- mov ebx,1
- mov ecx,res
- mov edx,1
- int 0x80
- ;********************** Imprime los mensajes *****************
- mov eax,4
- mov ebx,1
- mov ecx,msg3
- mov edx,len3
- int 0x80
- mov eax,4
- dec eax
- add eax,'0'
- mov [res],eax
- mov eax,4
- mov ebx,1
- mov ecx,res
- mov edx,1
- int 0x80
- mov eax,1 ; Salida del programa return 0
- int 0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement