]> git.sur5r.net Git - cc65/blobdiff - libsrc/runtime/add.s
Added mouse module from C64
[cc65] / libsrc / runtime / add.s
index 5d83ef9a290ce3c26f944e9a06df53512415fde5..b22e16ecc72b2f517d84473fa38d632e2a455cef 100644 (file)
@@ -8,18 +8,23 @@
 ; called a lot!
 
                .export         tosadda0, tosaddax
-       .importzp       sp, tmp1
+       .importzp       sp
 
 tosadda0:
        ldx     #0
 tosaddax:
-       ldy     #0
-       clc
-       adc     (sp),y          ; lo byte
-       sta     tmp1            ; save it
-       txa
-       iny
-       adc     (sp),y          ; hi byte
+       clc
+.ifpc02
+       adc     (sp)            ; 65C02 version - saves 2 cycles
+       ldy     #1
+.else
+       ldy     #0
+       adc     (sp),y          ; lo byte
+       iny
+.endif
+               pha                     ; save it
+       txa
+       adc     (sp),y          ; hi byte
        tax
        clc
        lda     sp
@@ -27,21 +32,6 @@ tosaddax:
        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
+L1:            pla                     ; Restore low byte
        rts