//---------------------------------------------------------------- // testmulb.s // // This interactive program tests our 'softmulb.s' function. // // programmer: ALLAN CRUSE // written on: 16 FEB 2005 //---------------------------------------------------------------- .section .data legend: .asciz "\nThis program computes x times y \n\n" format: .asciz "%d" report: .asciz "OK, %d times %d equals %d \n\n" ask_x: .asciz "Please type your x value: " ask_y: .asciz "Please type your y value: " x: .int 0 y: .int 0 z: .int 0 .section .text main: # show the program's legend pushl $legend # push function argument call printf # call library function addl $4, %esp # discard the argument # show prompt #1 and get reply pushl $ask_x # push function argument call printf # call library function addl $4, %esp # discard the argument pushl $x # push argument #2 pushl $format # push argument #1 call scanf # call library function addl $8, %esp # discard two arguments # show prompt #2 and get reply pushl $ask_y # push function argument call printf # call library function addl $4, %esp # discard the argument pushl $y # push argument #2 pushl $format # push argument #1 call scanf # call library function addl $8, %esp # discard two arguments # now compute the product movb x, %al # copy multiplicand to AL movb y, %bl # copy multiplier to BL call softmulb # software multiplication movw %ax, z # copy product to storage # report the result, then exit pushl z # push argument #4 pushl y # push argument #3 pushl x # push argument #2 pushl $report # push argument #1 call printf # call library function addl $16, %esp # discard all arguments ret # return to the caller .global main # entry-point is visible .end # no further statements