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 .export deceaxy
.importzp ptr4, sreg .importzp sreg, tmp1
deceaxy: deceaxy:
sty ptr4 sty tmp1
sec sec
sbc ptr4 sbc tmp1
sta ptr4 sta tmp1
txa txa
sbc #0 sbc #0
tax tax
@ -21,6 +21,6 @@ deceaxy:
lda sreg+1 lda sreg+1
sbc #0 sbc #0
sta sreg+1 sta sreg+1
lda ptr4 lda tmp1
rts rts

View File

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

View File

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

View File

@ -2,24 +2,23 @@
; Ullrich von Bassewitz, 08.10.1998 ; Ullrich von Bassewitz, 08.10.1998
; ;
; CC65 runtime: -= operator for longs on the stack ; CC65 runtime: -= operator for longs on the stack
; ;
.export lsubeq0sp, lsubeqysp .export lsubeq0sp, lsubeqysp
.importzp sp, sreg, tmp1, tmp2 .importzp sp, sreg
lsubeq0sp: lsubeq0sp:
ldy #0 ldy #0
lsubeqysp: lsubeqysp:
sec sec
sta tmp1 eor #$FF
stx tmp2 adc (sp),y
lda (sp),y
sbc tmp1
sta (sp),y sta (sp),y
pha pha ; Save low byte
iny iny
lda (sp),y txa
sbc tmp2 eor #$FF
adc (sp),y
sta (sp),y sta (sp),y
tax tax
iny iny

View File

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

View File

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