//---------------------------------------------------------------- // myplus.s // // This file defines a function that computes the sum of // the two integers whose values are transmitted via the // stack (and returns their total in the %eax register). // The values in other cpus register (except EFLAGS) are // preserved. The function's entry-point is declared to // be a global symbol so that the linker can combine the // object-code with other, separately assembled modules. // // assemble using: $ as myplus.s -o myplus.o // or alternately: $ gcc -c myplus.s // // programmer: ALLAN CRUSE // written on: 09 OCT 2003 //---------------------------------------------------------------- .text myplus: pushl %ebp # preserve caller's stackframe movl %esp, %ebp # set up our own frame-pointer movl 8(%ebp), %eax # get function argument #1 addl 12(%ebp), %eax # add function argument #2 popl %ebp # recover caller's stackframe ret # return with value in %eax .globl myplus # make entry-point visible