Page 1 of 1

Adding 2 Values in Assembly Language (Linux x86 & NASM)

Posted: Wed Feb 22, 2012 11:27 pm
by nicoobe
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:

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
Thanks you very much

Re: Adding 2 Values in Assembly Language (Linux x86 & NASM)

Posted: Thu Feb 23, 2012 12:29 am
by Solar
It was already pointed out to you that this forum is not for learning assembly programming. Such questions are better answered in Assembly forums, or general Q&A websites like stackoverflow.com.

If you check out the Required Knowledge, you will find that experience with the language you are using - including the ability to read documentation and debug problems - is a premise for OSDev.