mirror of
https://github.com/cc65/cc65.git
synced 2024-07-07 04:29:01 +00:00
Added 16*16=32 multiplication routine.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4434 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6078953baa
commit
0c1703f8fd
@ -152,6 +152,7 @@ OBJS = add.o \
|
|||||||
makebool.o \
|
makebool.o \
|
||||||
mod.o \
|
mod.o \
|
||||||
mul.o \
|
mul.o \
|
||||||
|
mul16x16r32.o \
|
||||||
mul8.o \
|
mul8.o \
|
||||||
mul8x8r16.o \
|
mul8x8r16.o \
|
||||||
mulax3.o \
|
mulax3.o \
|
||||||
|
49
libsrc/runtime/mul16x16r32.s
Normal file
49
libsrc/runtime/mul16x16r32.s
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
;
|
||||||
|
; Ullrich von Bassewitz, 2010-11-03
|
||||||
|
;
|
||||||
|
; CC65 runtime: 16x16 => 32 multiplication
|
||||||
|
;
|
||||||
|
|
||||||
|
.export umul16x16r32
|
||||||
|
.export mul16x16r32 := umul16x16r32
|
||||||
|
.importzp ptr1, ptr2, ptr3, ptr4, sreg
|
||||||
|
|
||||||
|
|
||||||
|
;---------------------------------------------------------------------------
|
||||||
|
; 16x16 => 32 multiplication routine.
|
||||||
|
;
|
||||||
|
; lhs rhs result result also in
|
||||||
|
; -------------------------------------------------------------
|
||||||
|
; ptr1 ptr3 ax:sreg ptr1:sreg
|
||||||
|
;
|
||||||
|
|
||||||
|
umul16x16r32:
|
||||||
|
lda #0
|
||||||
|
ldx ptr3+1 ; Get high byte into register for speed
|
||||||
|
sta sreg+1
|
||||||
|
ldy #16 ; Number of bits
|
||||||
|
|
||||||
|
lsr ptr1+1
|
||||||
|
ror ptr1 ; Get first bit into carry
|
||||||
|
@L0: bcc @L1
|
||||||
|
|
||||||
|
clc
|
||||||
|
adc ptr3
|
||||||
|
pha
|
||||||
|
txa ; hi byte of left op
|
||||||
|
adc sreg+1
|
||||||
|
sta sreg+1
|
||||||
|
pla
|
||||||
|
|
||||||
|
@L1: ror sreg+1
|
||||||
|
ror a
|
||||||
|
ror ptr1+1
|
||||||
|
ror ptr1
|
||||||
|
dey
|
||||||
|
bne @L0
|
||||||
|
|
||||||
|
sta sreg ; Save byte 3
|
||||||
|
lda ptr1 ; Load the result
|
||||||
|
ldx ptr1+1
|
||||||
|
rts ; Done
|
||||||
|
|
@ -4,7 +4,8 @@
|
|||||||
; CC65 runtime: 8x8 => 16 multiplication
|
; CC65 runtime: 8x8 => 16 multiplication
|
||||||
;
|
;
|
||||||
|
|
||||||
.export mul8x8r16, umul8x8r16
|
.export umul8x8r16
|
||||||
|
.export mul8x8r16 := umul8x8r16
|
||||||
.importzp ptr1, ptr3
|
.importzp ptr1, ptr3
|
||||||
|
|
||||||
|
|
||||||
@ -13,10 +14,9 @@
|
|||||||
;
|
;
|
||||||
; lhs rhs result result also in
|
; lhs rhs result result also in
|
||||||
; -------------------------------------------------------------
|
; -------------------------------------------------------------
|
||||||
; ptr1-lo ptr3-lo a/x ptr1
|
; ptr1-lo ptr3-lo ax ptr1
|
||||||
;
|
;
|
||||||
|
|
||||||
mul8x8r16:
|
|
||||||
umul8x8r16:
|
umul8x8r16:
|
||||||
lda #0 ; Clear byte 1
|
lda #0 ; Clear byte 1
|
||||||
ldy #8 ; Number of bits
|
ldy #8 ; Number of bits
|
||||||
@ -28,7 +28,7 @@ umul8x8r16:
|
|||||||
ror ptr1
|
ror ptr1
|
||||||
dey
|
dey
|
||||||
bne @L0
|
bne @L0
|
||||||
tax
|
tax
|
||||||
stx ptr1+1 ; Result in a/x and ptr1
|
stx ptr1+1 ; Result in a/x and ptr1
|
||||||
lda ptr1 ; Load the result
|
lda ptr1 ; Load the result
|
||||||
rts ; Done
|
rts ; Done
|
||||||
|
Loading…
Reference in New Issue
Block a user