1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-24 11:31:31 +00:00

Several SBC optimizations suggested by Piotr Fusik

git-svn-id: svn://svn.cc65.org/cc65/trunk@1121 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-11-17 11:25:12 +00:00
parent 834eff684f
commit c413c5feeb
6 changed files with 53 additions and 58 deletions

View File

@ -5,13 +5,13 @@
;
.export deceaxy
.importzp ptr4, sreg
.importzp sreg, tmp1
deceaxy:
sty ptr4
sty tmp1
sec
sbc ptr4
sta ptr4
sbc tmp1
sta tmp1
txa
sbc #0
tax
@ -21,6 +21,6 @@ deceaxy:
lda sreg+1
sbc #0
sta sreg+1
lda ptr4
lda tmp1
rts

View File

@ -9,19 +9,18 @@
;
.export tossubeax
.import addysp1
.importzp sp, sreg, tmp1, tmp2
.importzp sp, sreg
tossubeax:
ldy #0
sec
sta tmp1
lda (sp),y
sbc tmp1 ; byte 0
sta tmp2 ; use as temp storage
eor #$FF
adc (sp),y ; byte 0
pha ; Save low byte
iny
stx tmp1
lda (sp),y
sbc tmp1 ; byte 1
txa
eor #$FF
adc (sp),y ; byte 1
tax
iny
lda (sp),y
@ -31,6 +30,6 @@ tossubeax:
lda (sp),y
sbc sreg+1 ; byte 3
sta sreg+1
lda tmp2 ; load byte 0
jmp addysp1 ; drop TOS
pla ; Restore byte 0
jmp addysp1 ; Drop TOS

View File

@ -8,7 +8,7 @@
;
.export lsubeq1, lsubeqa, lsubeq
.importzp sreg, ptr1, tmp1
.importzp sreg, ptr1
lsubeq1:
@ -23,16 +23,15 @@ lsubeq: sty ptr1+1 ; Store high byte of address
ldy #$00 ; Address low byte
sec
sta tmp1
lda (ptr1),y ; Load byte 0
sbc tmp1
eor #$FF
adc (ptr1),y ; Subtract byte 0
sta (ptr1),y
pha ; Save byte 0 of result for later
iny ; Address byte 1
stx tmp1
lda (ptr1),y ; Load byte 1
sbc tmp1
txa
eor #$FF
adc (ptr1),y ; Subtract byte 1
sta (ptr1),y
tax
@ -48,9 +47,9 @@ lsubeq: sty ptr1+1 ; Store high byte of address
sta (ptr1),y
sta sreg+1
pla ; Retrieve byte 0 of result
pla ; Retrieve byte 0 of result
rts ; Done
rts ; Done

View File

@ -5,21 +5,20 @@
;
.export lsubeq0sp, lsubeqysp
.importzp sp, sreg, tmp1, tmp2
.importzp sp, sreg
lsubeq0sp:
ldy #0
lsubeqysp:
sec
sta tmp1
stx tmp2
lda (sp),y
sbc tmp1
eor #$FF
adc (sp),y
sta (sp),y
pha
pha ; Save low byte
iny
lda (sp),y
sbc tmp2
txa
eor #$FF
adc (sp),y
sta (sp),y
tax
iny

View File

@ -6,7 +6,7 @@
.export tossuba0, tossubax
.import addysp1
.importzp sp, ptr1
.importzp sp
;
; AX = TOS - AX
@ -15,22 +15,21 @@
tossuba0:
ldx #0
tossubax:
sta ptr1
stx ptr1+1
sec
eor #$FF
.ifpc02
lda (sp) ; Get lo byte
ldy #1 ; Hi index
adc (sp)
ldy #1
.else
ldy #0
lda (sp),y ; Lo byte
iny ; Hi index
adc (sp),y ; Subtract low byte
iny
.endif
sec
sbc ptr1
sta ptr1 ; save lo byte
lda (sp),y
sbc ptr1+1
tax
lda ptr1
jmp addysp1 ; drop TOS, set condition codes
pha ; Save high byte
txa
eor #$FF
adc (sp),y ; Subtract high byte
tax ; High byte into X
pla ; Restore low byte
jmp addysp1 ; drop TOS

View File

@ -5,23 +5,22 @@
;
.export subeq0sp, subeqysp
.importzp sp, tmp1, tmp2
.importzp sp
subeq0sp:
ldy #0
subeqysp:
sec
sta tmp1
stx tmp2
lda (sp),y
sbc tmp1
eor #$FF
adc (sp),y
sta (sp),y
pha
pha ; Save low byte
iny
lda (sp),y
sbc tmp2
txa
eor #$FF
adc (sp),y
sta (sp),y
tax
pla
pla ; Restore low byte
rts