Software - Math - Integer Multiplication
8-bit * 8-bit = 8-bit product (signed or unsigned)
- Inputs:
- F = 8-bit integer
- S = 8-bit integer
- Output:
- accumulator = product of F * S
; Note that it is not necessary to initialize the accumulator!
;
LDX #8
L1 ASL
ASL F
BCC L2
CLC
ADC S
L2 DEX
BNE L1
8-bit * 8-bit = 16-bit product (unsigned)
- Inputs:
- FPL = 8-bit integer
- S = 8-bit integer
- Output:
- PH = bits 15 to 8 of the product of FPL * S
- FPL = bits 7 to 0 of the product of FPL * S
;
LDA #0
;
; alternate entry point: P = FPL * S + accumulator
;
LDX #8
LSR FPL
L1 BCC L2
CLC
ADC S
L2 ROR
ROR FPL
DEX
BNE L1
STA PH
page revision: 1, last edited: 14 Dec 2007 02:07