//---------------------------------------------------------------- // theframe.s // // This program shows the stack-frame on entry to 'main()'. // // programmer: ALLAN CRUSE // written on: 07 OCT 2003 //---------------------------------------------------------------- .equ N_ELTS, 4 # number of elements to display .data msg: .asciz "\nThe stack-frame on entry to \'main()\' \n\n" fmt: .ascii "\t%02X: %08X " eol: .asciz "\n" .text main: # show an explanatory message pushl $msg # push the format-string call printf # call C runtime library addl $4, %esp # discard the argument # loop to display the topmost stack elements xorl %esi, %esi # initialize array-index again: # show the current array-element pushl (%esp, %esi, 1) # push the array-entry pushl %esi # push the array-index pushl $fmt # push the format-string call printf # call C runtime library addl $12, %esp # discard the arguments # increment the array-index and check exit-condition addl $4, %esi # advance array-index cmpl $N_ELTS*4, %esi # more entries to show? jl again # yes, show another one # print an end-of-line pushl $eol # push the format-string call printf # call C runtime library addl $4, %esp # discard the argument # return control to system ret .globl main