]> git.sur5r.net Git - cc65/blobdiff - libsrc/runtime/lsubeq.s
few 6502 and some 65SC02 optimizations
[cc65] / libsrc / runtime / lsubeq.s
index 9f5853d29f4e66be62627dbfc401823ee02194eb..5e3d25783375329749b6c6d415600b750398a4d0 100644 (file)
@@ -1,5 +1,6 @@
 ;                                 
 ; Ullrich von Bassewitz, 07.04.2000
+; Christian Krueger, 12-Mar-2017, added 65SC02 optimization
 ;
 ; CC65 runtime: -= operator
 ;
@@ -10,6 +11,7 @@
         .export         lsubeq1, lsubeqa, lsubeq
         .importzp       sreg, ptr1
 
+        .macpack        cpu
 
 lsubeq1:
         lda     #$01
@@ -20,15 +22,20 @@ lsubeqa:
         stx     sreg+1
 
 lsubeq: sty     ptr1+1                  ; Store high byte of address
-        ldy     #$00                    ; Address low byte
+    
         sec
-
         eor     #$FF
+ .if (.cpu .bitand ::CPU_ISET_65SC02)
+        adc     (ptr1)                  ; Subtract byte 0
+        sta     (ptr1)
+        ldy     #$01                    ; Address byte 1               
+ .else
+        ldy     #$00                    ; Address low byte
         adc     (ptr1),y                ; Subtract byte 0
         sta     (ptr1),y
+        iny                             ; Address byte 1       
+ .endif  
         pha                             ; Save byte 0 of result for later
-
-        iny                             ; Address byte 1
         txa
         eor     #$FF
         adc     (ptr1),y                ; Subtract byte 1