This is my first assembly code:
;program name - first.asm
section .data ;stores initialised var
section .bss ;stores uninit var
section .text ;actual code
global _start
_start:
mov eax,1
mov ebx,256
int 0x80
ebx is a 32-bit register, and from what I understood, eax=1 is syscall for program termination, and it returns the value stored in ebx. But when I ran the program, it’s returning 0. Why is there an overflow?
#run.bash
#!/bin/bash
nasm -felf64 $1.asm
ld $1.o -o $1
./$1
echo $?
rm -rf $1.o $1
in the terminal I ran sh run.bash first
, and it returned 0 instead of 256.
New contributor
Angadh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.