I'm trying to write this little program which accepts 2 integers and adds them and displays them to the user. I manage to write the entire program and save the variables (number1
, number2
), and now I have to store number1 + number2
in result
.
Here's the code. Where does the add function go?
segment .data
msg db "Please enter a digit ", 0xA,0xD
len equ $ - msg
segment .bss
number1 resb 10
number2 resb 10
result resb 10
segment .text
msg2 db "Please enter a second digit", 0xA,0xD
len2 equ $ - msg2
msg3 db "The sum is : ", 0xA,0xD
len3 equ $ - msg3
global _start
_start:
mov eax, 4
mov ebx, 1
mov ecx, msg
mov edx, len
int 0x80
mov eax, 3
mov ebx, 0
mov ecx, number1
mov edx, 10
int 0x80
mov eax, 4
mov ebx, 1
mov ecx, msg2
mov edx, len2
int 0x80
mov eax, 3
mov ebx, 0
mov ecx, number2
mov edx, 10
int 0x80
mov eax, 4
mov ebx, 1
mov ecx, msg3
mov edx, len3
int 0x80
;add result, number1
;add result, number2
mov eax, 4
mov ebx, 1
mov ecx, $result
mov edx, len3
int 0x80
exit:
mov eax, 1
xor ebx, ebx
int 0x80
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…