2009-11-02 22:28:02 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2010-11-02
|
|
|
|
;
|
2014-05-11 14:43:06 +00:00
|
|
|
; CC65 runtime: 8x8 => 16 unsigned multiplication
|
2009-11-02 22:28:02 +00:00
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export umul8x8r16, umul8x8r16m
|
|
|
|
.importzp ptr1, ptr3
|
2009-11-02 22:28:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
;---------------------------------------------------------------------------
|
2014-05-11 14:43:06 +00:00
|
|
|
; 8x8 => 16 unsigned multiplication routine.
|
2009-11-02 22:28:02 +00:00
|
|
|
;
|
2014-05-11 14:43:06 +00:00
|
|
|
; LHS RHS result result in also
|
2009-11-02 22:28:02 +00:00
|
|
|
; -------------------------------------------------------------
|
2014-05-11 14:43:06 +00:00
|
|
|
; .A (ptr3-low) ptr1-low .XA ptr1
|
2009-11-02 22:28:02 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
umul8x8r16:
|
2009-11-12 15:48:11 +00:00
|
|
|
sta ptr3
|
|
|
|
umul8x8r16m:
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #0 ; Clear byte 1
|
|
|
|
ldy #8 ; Number of bits
|
2014-05-11 14:43:06 +00:00
|
|
|
lsr ptr1 ; Get first bit of RHS into carry
|
2009-11-02 22:28:02 +00:00
|
|
|
@L0: bcc @L1
|
|
|
|
clc
|
|
|
|
adc ptr3
|
|
|
|
@L1: ror
|
|
|
|
ror ptr1
|
|
|
|
dey
|
|
|
|
bne @L0
|
2009-11-03 13:40:03 +00:00
|
|
|
tax
|
2014-05-11 14:43:06 +00:00
|
|
|
stx ptr1+1 ; Result in .XA and ptr1
|
2013-05-09 11:56:54 +00:00
|
|
|
lda ptr1 ; Load the result
|
|
|
|
rts ; Done
|