//----------------------------------------------------------------- // xmastest.s // // This is the skeleton-code for a program that can automate // the testing of our 'xmas' demo-program, if you finish it. // (Why do you think we've linked in our 'base10io.o' file?) // // to assemble: $ as xmastest.s -o xmastest.o // and to link: $ ld xmastest.o base10io.o -o xmastest // // programmer: ALLAN CRUSE // written on: 28 FEB 2007 //----------------------------------------------------------------- # manifest constants .equ sys_FORK, 2 .equ sys_WAITPID, 7 .equ sys_EXECVE, 11 .equ sys_EXIT, 1 .section .data arg0: .asciz "xmas" # null-terminated program-name arg1: .asciz "2007" # null-terminated cmd-line arg argv: .long arg0, arg1, 0 # list of command-line strings .section .text _start: # here we need to enter a loop that will examine various years # (it is left as an exercise for you to construct such a loop) mov $sys_FORK, %eax # system-call ID-number int $0x80 # invoke kernel service or %eax, %eax # process is the child? jz child # yes, execute 'xmas' mov %eax, %ebx # child's process ID mov $sys_WAITPID, %eax # system-call ID-number xor %ecx, %ecx # ignore return-status xor %edx, %edx # no special options int $0x80 # invoke kernel service mov $sys_EXIT, %eax # system-call ID-number xor %ebx, %ebx # use zero as exit-code int $0x80 # invoke kernel service child: mov $sys_EXECVE, %eax # system-call ID-number lea arg0, %ebx # address of program-name lea argv, %ecx # address of arg-pointers xor %edx, %edx # no special environment int $0x80 # invoke kernel service .global _start # make entry-point visible .end # nothing else to assemble