2009-11-02 22:28:02 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2010-11-02
|
|
|
|
;
|
|
|
|
; CC65 runtime: 8x8 => 16 multiplication
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export umul8x8r16, umul8x8r16m
|
|
|
|
.importzp ptr1, ptr3
|
2009-11-02 22:28:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
;---------------------------------------------------------------------------
|
|
|
|
; 8x8 => 16 multiplication routine.
|
|
|
|
;
|
|
|
|
; lhs rhs result result also in
|
|
|
|
; -------------------------------------------------------------
|
2009-11-03 13:40:03 +00:00
|
|
|
; ptr1-lo ptr3-lo ax 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
|
2009-11-02 22:28:02 +00:00
|
|
|
lsr ptr1 ; Get first bit of lhs into carry
|
|
|
|
@L0: bcc @L1
|
|
|
|
clc
|
|
|
|
adc ptr3
|
|
|
|
@L1: ror
|
|
|
|
ror ptr1
|
|
|
|
dey
|
|
|
|
bne @L0
|
2009-11-03 13:40:03 +00:00
|
|
|
tax
|
2009-11-02 22:28:02 +00:00
|
|
|
stx ptr1+1 ; Result in a/x and ptr1
|
2013-05-09 11:56:54 +00:00
|
|
|
lda ptr1 ; Load the result
|
|
|
|
rts ; Done
|
2009-11-12 15:48:11 +00:00
|
|
|
|
2009-11-02 22:28:02 +00:00
|
|
|
|