mirror of
https://github.com/cc65/cc65.git
synced 2024-07-05 21:29:03 +00:00
Shrink atoi by using negeax instead of inlined code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4179 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
96637a8c35
commit
2f2bced531
@ -6,7 +6,7 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
.export _atoi, _atol
|
.export _atoi, _atol
|
||||||
.import __ctype
|
.import negeax, __ctype
|
||||||
.importzp sreg, ptr1, ptr2, tmp1
|
.importzp sreg, ptr1, ptr2, tmp1
|
||||||
|
|
||||||
.include "ctype.inc"
|
.include "ctype.inc"
|
||||||
@ -111,48 +111,28 @@ L7: iny
|
|||||||
inc ptr1+1
|
inc ptr1+1
|
||||||
bne L6
|
bne L6
|
||||||
|
|
||||||
; Conversion done. Be shure to negate the value if needed.
|
; Conversion done. Load the low 16 bit into A/X
|
||||||
|
|
||||||
|
L8: lda ptr2
|
||||||
|
ldx ptr2+1
|
||||||
|
|
||||||
|
; Negate the value if necessary, otherwise we're done
|
||||||
|
|
||||||
L8: lda ptr2
|
|
||||||
ldx ptr2+1
|
|
||||||
ldy tmp1 ; sign
|
ldy tmp1 ; sign
|
||||||
beq L9
|
beq L9 ; Branch if positive
|
||||||
|
|
||||||
; Negate the 32 bit value in ptr2/sreg
|
; Negate the 32 bit value in ptr2/sreg
|
||||||
|
|
||||||
sec
|
jmp negeax
|
||||||
lda ptr2
|
|
||||||
eor #$FF
|
|
||||||
adc #0
|
|
||||||
sta ptr2
|
|
||||||
lda ptr2+1
|
|
||||||
eor #$FF
|
|
||||||
adc #0
|
|
||||||
sta ptr2+1
|
|
||||||
lda sreg
|
|
||||||
eor #$FF
|
|
||||||
adc #0
|
|
||||||
sta sreg
|
|
||||||
lda sreg+1
|
|
||||||
eor #$FF
|
|
||||||
adc #0
|
|
||||||
sta sreg+1
|
|
||||||
|
|
||||||
; Done, load the low 16 bit into A/X
|
|
||||||
|
|
||||||
L9: lda ptr2
|
|
||||||
ldx ptr2+1 ; get value
|
|
||||||
rts
|
|
||||||
|
|
||||||
;
|
;
|
||||||
; Helper functions
|
; Helper functions
|
||||||
;
|
;
|
||||||
|
|
||||||
mul2:
|
mul2: asl ptr2
|
||||||
asl ptr2
|
|
||||||
rol ptr2+1
|
rol ptr2+1
|
||||||
rol sreg
|
rol sreg
|
||||||
rol sreg+1 ; * 2
|
rol sreg+1 ; * 2
|
||||||
rts
|
L9: rts
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user