exit.s (912B)
1 #PURPOSE: Simple program that exits and returns a 2 # status code back to the Linux kernel 3 # 4 5 #INPUT: none 6 # 7 8 #OUTPUT: returns a status code This can be viewed 9 # by typing 10 # 11 # echo $? 12 # 13 # after running the program 14 # 15 16 #VARIABLES: 17 # %rax holds the system call number 18 # %rbx holds the return status 19 # 20 .section .data 21 22 .section .text 23 .globl _start 24 25 _start: 26 mov $1, %rax # this is the linux kernel command 27 # number (system call) for exiting 28 # $ means immediate mode addressing, 29 # without $ it defaults to direct 30 # mode, looking up a number in 31 # address 1 32 33 mov $0, %rbx # this is the status number we will 34 # return to the OS 35 36 int $0x80 # this wakes up the kernel to run the 37 # exit command