mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 06:31:31 +00:00
53dd513176
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
48 lines
616 B
ArmAsm
48 lines
616 B
ArmAsm
;
|
|
; Ullrich von Bassewitz, 05.08.1998
|
|
;
|
|
; CC65 runtime: add ints
|
|
;
|
|
|
|
; Make this as fast as possible, even if it needs more space since it's
|
|
; called a lot!
|
|
|
|
.export tosadda0, tosaddax
|
|
.importzp sp, tmp1
|
|
|
|
tosadda0:
|
|
ldx #0
|
|
tosaddax:
|
|
ldy #0
|
|
clc
|
|
adc (sp),y ; lo byte
|
|
sta tmp1 ; save it
|
|
txa
|
|
iny
|
|
adc (sp),y ; hi byte
|
|
tax
|
|
clc
|
|
lda sp
|
|
adc #2
|
|
sta sp
|
|
bcc L1
|
|
inc sp+1
|
|
L1: txa ; Test high byte
|
|
bmi L2
|
|
bne L3
|
|
lda tmp1 ; Get low byte
|
|
rts
|
|
|
|
; Value is negative
|
|
|
|
L2: lda tmp1 ; Get low byte
|
|
ldy #$FF ; Force negative
|
|
rts
|
|
|
|
; Value is positive != 0
|
|
|
|
L3: lda tmp1 ; Get low byte
|
|
ldy #1
|
|
rts
|
|
|