Reputation: 28753
In a Linux environment, if I write some NASM code as follows:
mov eax, 1 ; system call 1 - sys_exit
mov ebx, 0
int 0x80
... what is the value in ebx?
Upvotes: 3
Views: 3311
Reputation: 25051
In general the Linux x86 system call interface uses eax to store the system call number and then the following registers for function arguments from to right
There's a very nice system call table here that outlines most of the Linux system calls:
http://bluemaster.iu.hio.no/edu/dark/lin-asm/syscalls.html
Upvotes: 1
Reputation: 1
mov eax, 1 ;
is the sys_exit code
mov ebx, 0 ;
the value of ebx could be either 0 or 1, 0 means normal exit, 1 means error.
Upvotes: 0
Reputation: 93468
%ebx is the status code for the exit system call
This means that whatever is stored in %ebx will be returned to the Operating System. Therefore, after executing your application on a terminal, issuing this command:
echo $?
will print the return code of your app.
Pages 20,21,22 of Programming from the Ground Up explains this very well.
Upvotes: 3