1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-06 12:31:12 +00:00

Merge pull request #606 from pfusik/ldec

Optimize deceaxy
This commit is contained in:
Oliver Schmidt 2018-03-10 11:28:46 +00:00 committed by GitHub
commit be30c0bd70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
; ;
; Ullrich von Bassewitz, 29.12.1999 ; Piotr Fusik, 09.03.2018
; originally by Ullrich von Bassewitz
; ;
; CC65 runtime: Decrement eax by value in Y ; CC65 runtime: Decrement eax by value in Y
; ;
@ -11,16 +12,25 @@ deceaxy:
sty tmp1 sty tmp1
sec sec
sbc tmp1 sbc tmp1
sta tmp1 bcs @L9
txa
sbc #0 ; Borrow from X.
tax
lda sreg dex
sbc #0 cpx #$FF
sta sreg bne @L9
lda sreg+1
sbc #0 ; X wrapped from zero to $FF, borrow from sreg.
sta sreg+1
lda tmp1 dec sreg
rts cpx sreg
bne @L9
; sreg wrapped from zero to $FF, borrow from sreg+1.
dec sreg+1
; Done.
@L9: rts