Hello out there,
I need a fast executing assembly code for signed multiplication (8bitx8bit) using the MUL instruction
/Johan
Regards,
Mac
** Negate the 16 bit signed integer in the psuedo-accumulator.*NEG16 MACRO COM ACCUM1 ; 4 LDA ACCUM0 ; 3 COMA ; 1 ADD #1 ; 2 STA ACCUM0 ; 3 LDA ACCUM1 ; 3 ADC #0 ; 2 STA ACCUM1 ; 3 ENDM ; =21*
com value16 ; 4 - compliment the high byte ldhx value16 ; 4 - load all 16 bits into H:X comx ; 1 - compliment the low byte ais #1 ; 2 - increment all 16 bits
sthx value16 ; 4 - save it in place (optional)
; =15
com value16 ; 4 - compliment the high byte ldhx value16 ; 4 - load all 16 bits into H:X comx ; 1 - compliment the low byte aix #1 ; 2 - increment all 16 bits sthx value16 ; 4 - save it in place (optional); =15
Especially the 8x8=8 bit signed multiplication in simple, its the same as the unsigned one
For the 8x8=16 bit signed multiplication, the CW _BMULS runtime routine in lib\hc08c\src\rtshc08.c does just that, it first multiplies unsigned and then adapts the result if the operands have been negative.
And are both of your operands eventually negative, or is one known to be positive?
What do you need it for?
Daniel
Message Edited by CompilerGuru on 2007-06-14 11:21 PM