//----------------------------------------------------------------- // expo.s // // Here is one possible solution to the in-class exercise on // making 'exponent.cpp' call an external assembly function. // // to assemble: $ expo.s -o expo.o // // programmer: ALLAN CRUSE // written on: 19 MAR 2007 //----------------------------------------------------------------- # make this function's entry-point visible to the linker .global expo # define stack-offsets for the function's two arguments .equ N, 8 .equ K, 12 .section .text expo: push %ebp mov %esp, %ebp push %edx cmp $0, K(%ebp) jne recur mov $1, %eax jmp expox recur: mov K(%ebp), %eax dec %eax push %eax pushl N(%ebp) call expo add $8, %esp mull N(%ebp) expox: pop %edx pop %ebp ret .end