This commit was generated by cvs2svn to compensate for changes in r2,
which included commits to RCS files with non-trunk default branches. git-svn-id: svn://svn.cc65.org/cc65/trunk@3 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
43
libsrc/runtime/mul.s
Normal file
43
libsrc/runtime/mul.s
Normal file
@@ -0,0 +1,43 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 07.08.1998
|
||||
;
|
||||
; CC65 runtime: multiplication for ints
|
||||
;
|
||||
|
||||
.export tosumula0, tosumulax, tosmula0, tosmulax
|
||||
.import popsreg
|
||||
.importzp sreg, tmp1, ptr4
|
||||
|
||||
tosmula0:
|
||||
tosumula0:
|
||||
ldx #0
|
||||
tosmulax:
|
||||
tosumulax:
|
||||
mul16: sta ptr4
|
||||
stx ptr4+1 ; Save right operand
|
||||
jsr popsreg ; Get left operand
|
||||
|
||||
; Do ptr4*sreg --> AX (see mult-div.s from "The Fridge").
|
||||
|
||||
lda #0
|
||||
sta tmp1
|
||||
ldx sreg+1 ; Get into register for speed
|
||||
ldy #16 ; Number of bits
|
||||
L0: lsr tmp1
|
||||
ror a
|
||||
ror ptr4+1
|
||||
ror ptr4
|
||||
bcc L1
|
||||
clc
|
||||
adc sreg
|
||||
pha
|
||||
txa ; hi byte of left op
|
||||
adc tmp1
|
||||
sta tmp1
|
||||
pla
|
||||
L1: dey
|
||||
bpl L0
|
||||
lda ptr4 ; Load the result
|
||||
ldx ptr4+1
|
||||
rts ; Done
|
||||
|
||||
Reference in New Issue
Block a user