I am playing with my first program in assembly, and I've got it to return status codes that can be displayed with echo $?
. Out of curiosity, I tried to see what would happen if I returned a negative integer as my status code, like so:
.section .data
.section .text
.globl _start
_start:
mov $1, %eax # set syscall to exit
mov $0, %ebx # set status code to 0
subl $1, %ebx # subtract 1 from it!
int $0x80
When I assemble and run my program I get the following output:
hc06@HC06:~$ echo $?
255
I'm a complete infant in assembly and I'm sure this is obvious behavior to the rest of you, but I'm very curious why this happens. Thanks!