Adding 2 Values in Assembly Language (Linux x86 & NASM)
Posted: Wed Feb 22, 2012 11:27 pm
Hello Again,
I was wondering if anyone could help me with this program. It asks two values and then add them.
The problem is that this program does not show the result.
I write this code:
Thanks you very much
I was wondering if anyone could help me with this program. It asks two values and then add them.
The problem is that this program does not show the result.
I write this code:
Code: Select all
section .bss
num1 resb 1
num2 resb 1
section .text
global _start
_start:
; Get first number
mov eax,3
mov ebx,0
mov ecx,num1
mov edx,2
int 80h
;Get second number
mov eax,3
mov ebx,0
mov ecx,num2
mov edx,2
int 80h
;Add both values
mov ecx,[num1]
add ecx,[num2]
;Print the result
mov eax,4
mov ebx,1
mov edx,2
int 80h
;Close the program
mov eax,1
mov ebx,0
int 80h