Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;********************************************
- ;* *
- ;* MULT16 *
- ;* *
- ;* 16bit multiplication 32bit result *
- ;* *
- ;* /1 Variable a 16-bit *
- ;* /2 Variable b 16 bit *
- ;* /3 Destination 32 bit *
- ;* *
- ;********************************************
- .macro MULT16
- lda \2
- pha
- lda \2 + 1
- pha
- lda #0 ;initialize result to 0
- sta \3 + 2
- ldx #16 ;there are 16 bits in num2
- @l1
- lsr \2 + 1 ;get low bit of num2
- ror \2
- bcc @l2 ; 0 or 1?
- tay ; if 1, add num1 (hi byte of result is in a)
- clc
- lda \1
- adc \3 + 2
- sta \3 + 2
- tya
- adc \1 + 1
- @l2
- ror ;"stairstep" shift
- ror \3 + 2
- ror \3 + 1
- ror \3
- dex
- bne @l1
- sta \3 + 3
- pla
- sta \2 + 1
- pla
- sta \2
- .endm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement