; signed multiply a * b ; save sign of result, make both positive ; multiply, set result sign, shift accuracy ; return high order byte of result ; basically this multiplies signed byte1 bits 0-7 ; by signed byte2 bits 0-7 and returns bits 7-14 ; of the 16 bit result preserving the sign bit. ; mpy: mov r0,a ; save multiplier xrl a,b ; xor signs mov c,acc.7 push psw ; save result sign clr c mov a,r0 ; get multiplier jnb acc.7,mpy2 cpl a inc a mpy2: xch a,b jnb acc.7,mpy3 cpl a inc a mpy3: mul ab ; unsigned math pop psw ; get result sign jnc mpy1 ; result is positive cpl a addc a,#0 ; make result negative xch a,b cpl a addc a,#0 xch a,b mpy1: rlc a ; low order bit 7 to carry xch a,b ; get high order rlc a ; shift in 1 bit more of accuracy mov acc.7,c ; insure sign ret