Hi all,
I am very new to assembly and have now got bored of "Hello World". I am trying to write my own program to simply add two numbers together and display the result. I have written the following program for nasm on Linux;
bits 32
section .data
num1 db 4
num2 db 5
bytes equ $-num2
section .text
global _start
mov ecx, num1 ; first number in ecx
add ecx, num2 ; add num2 to num1
mov eax, 4 ; system call to write()
mov ebx, 1 ; write to STDOUT
mov edx, bytes ; length of num2
int 0x80 ; call kernel
; Return to system from program
mov eax, 1
mov ebx, 0
int 0x80
The above program compiles and links with no problems at all and when I run the resulting executable I just get no output.
If someone would point out to me the error of my ways I would be very grateful.
thanks, greadey
I am very new to assembly and have now got bored of "Hello World". I am trying to write my own program to simply add two numbers together and display the result. I have written the following program for nasm on Linux;
bits 32
section .data
num1 db 4
num2 db 5
bytes equ $-num2
section .text
global _start
mov ecx, num1 ; first number in ecx
add ecx, num2 ; add num2 to num1
mov eax, 4 ; system call to write()
mov ebx, 1 ; write to STDOUT
mov edx, bytes ; length of num2
int 0x80 ; call kernel
; Return to system from program
mov eax, 1
mov ebx, 0
int 0x80
The above program compiles and links with no problems at all and when I run the resulting executable I just get no output.
If someone would point out to me the error of my ways I would be very grateful.
thanks, greadey