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:
47
libsrc/runtime/add.s
Normal file
47
libsrc/runtime/add.s
Normal file
@@ -0,0 +1,47 @@
|
||||
;
|
||||
; 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
|
||||
|
||||
Reference in New Issue
Block a user