//---------------------------------------------------------------- // esp.s // // This program shows how to display the initial contents of // the processor's ESP register in hexadecimal format. // // assemble using: $ as esp.s -o esp.o // and link using: $ ld esp.o eax2hex.o -o esp // // programmer: ALLAN CRUSE // written on: 01 FEB 2006 //---------------------------------------------------------------- .equ sys_write, 4 .equ sys_exit, 1 .equ device_ID, 1 .section .data msg: .ascii "\n\tESP=" buf: .ascii "xxxxxxxx \n\n" len: .int . - msg .section .text _start: # transfer contents of ESP to register EAX movl %esp, %eax # use external subroutine to convert EAX into hex format movl $buf, %edi call eax2hex # write our message to the display device movl $sys_write, %eax movl $device_ID, %ebx movl $msg, %ecx movl len, %edx int $0x80 # terminate this program movl $sys_exit, %eax movl $0, %ebx int $0x80 .global _start .end