X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fcommon%2Fatoi.s;h=d55ddb9e8b71c04654c2e7a445b9238d923a58ec;hb=ff746b119ced0a50914175baf52e9ee196c107dc;hp=6732755733e75757241d0e21ae4f2c83e461aebb;hpb=feb31603da5087306ae92f452a1fe43be6914d50;p=cc65 diff --git a/libsrc/common/atoi.s b/libsrc/common/atoi.s index 673275573..d55ddb9e8 100644 --- a/libsrc/common/atoi.s +++ b/libsrc/common/atoi.s @@ -6,7 +6,7 @@ ; .export _atoi, _atol - .import __ctype + .import negeax, __ctype .importzp sreg, ptr1, ptr2, tmp1 .include "ctype.inc" @@ -111,48 +111,28 @@ L7: iny inc ptr1+1 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 - ldy tmp1 ; sign - beq L9 +L8: lda ptr2 + ldx ptr2+1 -; Negate the 32 bit value in ptr2/sreg +; Negate the value if necessary, otherwise we're done - sec - 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 + ldy tmp1 ; sign + beq L9 ; Branch if positive -; Done, load the low 16 bit into A/X +; Negate the 32 bit value in ptr2/sreg -L9: lda ptr2 - ldx ptr2+1 ; get value - rts + jmp negeax ; ; Helper functions ; -mul2: - asl ptr2 +mul2: asl ptr2 rol ptr2+1 rol sreg rol sreg+1 ; * 2 - rts +L9: rts