1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-11 16:07:04 +00:00
cc65/libsrc/runtime/mul.s
uz 53dd513176 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
2000-05-28 13:40:48 +00:00

44 lines
782 B
ArmAsm

;
; 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