base:8bit_multiplication_16bit_product_fast_no_tables
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
base:8bit_multiplication_16bit_product_fast_no_tables [2020-08-30 01:44] – djmips | base:8bit_multiplication_16bit_product_fast_no_tables [2023-03-15 03:25] (current) – djmips | ||
---|---|---|---|
Line 7: | Line 7: | ||
; by djmips | ; by djmips | ||
; | ; | ||
- | ; inputs are mul1 and mul2 and should be zero page. | + | ; inputs are mul1 and X. mul1 and mul2 should be zp locations |
; A should be zero entering but if you want it will factor in as 1/2 A added to the result. | ; A should be zero entering but if you want it will factor in as 1/2 A added to the result. | ||
; | ; | ||
Line 19: | Line 19: | ||
MUL: | MUL: | ||
- | dec mul2 ; decrement mul2 because we will be adding with carry set for speed (an extra one) | + | cpx #$00 |
+ | beq zro | ||
+ | | ||
+ | stx mul2 | ||
ror mul1 | ror mul1 | ||
bcc b1 | bcc b1 | ||
Line 53: | Line 56: | ||
b8: ror | b8: ror | ||
ror mul1 | ror mul1 | ||
- | inc mul2 | + | inx ; Optional - this preserves X across the call - could also do inc mul2 or leave out |
rts | rts | ||
+ | |||
+ | zro: stx mul1 | ||
+ | txa | ||
+ | | ||
</ | </ | ||
base/8bit_multiplication_16bit_product_fast_no_tables.1598744678.txt.gz · Last modified: 2020-08-30 01:44 by djmips