2009-11-04 13:45:27 +00:00
|
|
|
;
|
|
|
|
; Ullrich von Bassewitz, 2010-11-03
|
|
|
|
;
|
|
|
|
; CC65 runtime: 16x16 => 32 signed multiplication
|
|
|
|
;
|
|
|
|
|
2009-11-04 18:23:40 +00:00
|
|
|
.export imul16x16r32
|
|
|
|
.import negax, umul16x16r32m, negeax
|
2009-11-04 19:41:54 +00:00
|
|
|
|
|
|
|
.include "zeropage.inc"
|
2009-11-04 13:45:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
;---------------------------------------------------------------------------
|
|
|
|
; 16x16 => 32 signed multiplication routine.
|
|
|
|
;
|
2014-05-11 14:43:06 +00:00
|
|
|
; LHS RHS result result also in
|
2009-11-04 13:45:27 +00:00
|
|
|
; -------------------------------------------------------------
|
2014-05-11 14:43:06 +00:00
|
|
|
; ax ptr1 ax:sreg
|
2009-11-04 13:45:27 +00:00
|
|
|
;
|
|
|
|
; There is probably a faster way to do this.
|
|
|
|
;
|
|
|
|
|
|
|
|
imul16x16r32:
|
|
|
|
stx tmp1
|
|
|
|
cpx #0
|
|
|
|
bpl @L1
|
|
|
|
jsr negax
|
|
|
|
@L1: sta ptr3
|
|
|
|
stx ptr3+1
|
|
|
|
|
|
|
|
lda ptr1+1
|
|
|
|
eor tmp1
|
|
|
|
sta tmp1
|
|
|
|
lda ptr1
|
|
|
|
ldx ptr1+1
|
|
|
|
bpl @L2
|
|
|
|
jsr negax
|
|
|
|
sta ptr1
|
|
|
|
stx ptr1+1
|
|
|
|
@L2: jsr umul16x16r32m
|
|
|
|
ldy tmp1
|
|
|
|
bpl @L3
|
|
|
|
jmp negeax
|
|
|
|
@L3: rts
|
|
|
|
|