> You might want to look into the shift and add method of multiplication
> which is much more efficient time-wise.
Here's the shift-and-add. When you start, one 16-bit number will be in 50-51, low byte first as usual for 6502, and the other 16-bit number will be in 52-53, same way. When you're done, the 32-bit answer will take all four bytes, with the high cell first. IOW, $12345678 will be in the order 34 12 78 56. Addresses 54 and 55 will be used as a scratchpad.
Code:
LDA 52 ; Get the multiplicand and
STA 54 ; put it in the scratchpad.
LDA 53
STA 55
STZ 52 ; Zero-out the original multiplicand area.
STZ 53
LDY #10H ; We'll loop 16 times.
1$: ASL 52 ; Shift the entire 32 bits over one bit position.
ROL 53
ROL 50
ROL 51
BCC 2$ ; Skip the adding-in to the result if
; the high bit shifted out was 0.
CLC ; Else, add multiplier to intermediate result.
LDA 54
ADC 52
STA 52
LDA 55
ADC 53
STA 53
LDA #0 ; If C=1, incr lo byte of hi cell.
ADC 50
STA 50
2$: DEY ; If we haven't done 16 iterations yet,
BNE 1$ ; then go around again.
RTS
;---------------------
In your code however, you use Y without showing that it is initialized to any particular value. Also STA 52 followed immediately by LDA 52 is pointless. And one more thing-- you will get shorter, faster code if you put LDA 52 instead of LDA 0052. LDA 52 will use zero-page addressing.
[
Edit: Please see also
viewtopic.php?f=9&t=689 for improvements.]