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

Programming, for all ages and all languages.
Locked
nicoobe
Posts: 8
Joined: Wed Feb 22, 2012 12:19 am

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

Post 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
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

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

Post 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.
Every good solution is obvious once you've found it.
Locked