cis-lclient05:~/2012/system>more exit.s # Text segment begins .section .text .globl _start # Program entry point _start: /* Return value */ movl $2, %ebx # For sys_exit system call set %eax to 1 movl $1, %eax # Call the OS with an "int" instruction int $0x80 cis-lclient05:~/2012/system>more runexit #!/bin/sh -e # echo on termination, enter \"echo \$?\" as -o exit.o exit.s ld -o myexit exit.o myexit cis-lclient05:~/2012/system>runexit on termination, enter "echo $?" cis-lclient05:~/2012/system>echo $? 2 cis-lclient05:~/2012/system> cis-lclient05:~/2012/system>more exit.s # Text segment begins .section .text .globl _start # Program entry point _start: /* Return value */ movl $2, %ebx # For sys_exit system call set %eax to 1 # movl $1, %eax # Call the OS with an "int" instruction # int $0x80 cis-lclient05:~/2012/system> wonderw:~/cis72/syscalls>more exit2.s # Text segment begins .section .text .globl _start # Program entry point _start: /* Return value */ movl $2, %ebx # Code number "1" for system call "sys_exit" movl $1, %eax # Call the OS with an "int" instruction int $0x80 # Could replace last two instructions with "sys_exit wonderw:~/cis72/syscalls>more runexit2 #!/bin/sh -e # echo on termination, enter \"echo \$?\" as -o exit2.o exit2.s ld -o exit2 exit2.o exit2 wonderw:~/cis72/syscalls>runexit2 on termination, enter "echo $?" wonderw:~/cis72/syscalls>echo $? 2 wonderw:~/cis72/syscalls>