//---------------------------------------------------------------- // softmulb.s // // This file uses shift/rotate instructions to emulate with // software the Pentium's hardware multiplication operation // for the case when the multiplier is held in register BL. // // programmer: ALLAN CRUSE // written on: 12 OCT 2003 // revised on: 15 MAR 2009 -- for x86_64 Linux environment //---------------------------------------------------------------- .section .text softmulb: # # EXPECTS: AL = multiplicand # BL = multiplier # RETURNS: AX = product # push %rcx # preserve register's value mov $9, %rcx # setup for 8-bit multiplier sub %ah, %ah # clear high result register nxbit8: rcr $1, %ax # next multiplier bit to CF jnc noadd8 # skip addition if bit == 0 add %bl, %ah # else add the multiplicand noadd8: loop nxbit8 # and shift the result sub %ah, %cl # set CF if 8-bits exceeded pop %rcx # restore register's value ret .global softmulb