1
0
mirror of https://github.com/cc65/cc65.git synced 2026-04-22 01:16:54 +00:00

Added "popptr1" which is of common use to save some bytes.

This commit is contained in:
IrgendwerA8
2018-05-20 15:30:18 +02:00
parent 3a6430b13d
commit c95ed4b8b5
35 changed files with 113 additions and 151 deletions
+3 -5
View File
@@ -5,7 +5,7 @@
;
.export __swap
.import popax
.import popax, popptr1
.importzp ptr1, ptr2, ptr3
@@ -19,13 +19,11 @@ __swap: eor #$FF
sta ptr2
stx ptr2+1
jsr popax ; Get p
sta ptr1
stx ptr1+1
jsr popptr1 ; Get p
; Prepare for swap
ldy #$00
; ldy #$00 is guaranteed by popptr1
; Swap loop
+3 -5
View File
@@ -6,7 +6,7 @@
.export _getcwd
.import popax
.import popptr1
.import __cwd
.importzp ptr1, ptr2
@@ -25,13 +25,11 @@
eor #$FF
sta ptr2+1
jsr popax ; Get buf
sta ptr1
stx ptr1+1 ; Save buf
jsr popptr1 ; Get buf to ptr1
; Copy __cwd to the given buffer checking the length
ldy #$00
; ldy #$00 is guaranteed by popptr10
loop: inc ptr2
bne @L1
inc ptr2+1
+3 -5
View File
@@ -6,7 +6,7 @@
;
.export _longjmp
.import popax
.import popptr1
.importzp sp, ptr1, ptr2
_longjmp:
@@ -16,10 +16,8 @@ _longjmp:
bne @L1
inc ptr2 ; 0 is illegal, according to the standard ...
; ... and, must be replaced by 1
@L1: jsr popax ; get buf
sta ptr1
stx ptr1+1
ldy #0
@L1: jsr popptr1 ; get buf
; ldy #0 is guaranteed by popptr1
; Get the old parameter stack
+4 -5
View File
@@ -5,7 +5,7 @@
;
.export _memchr
.import popax, return0
.import popax, popptr1 return0
.importzp ptr1, ptr2
@@ -18,11 +18,10 @@
sta ptr2+1 ; Save ones complement of n
jsr popax ; get c
pha
jsr popax ; get p
sta ptr1
stx ptr1+1
ldy #$00
jsr popptr1 ; get p
; ldy #$00 is guaranteed by popptr1
pla ; Get c
ldx ptr2 ; Use X as low counter byte
+3 -5
View File
@@ -5,7 +5,7 @@
;
.export _memcmp
.import popax, return0
.import popax, popptr1, return0
.importzp ptr1, ptr2, ptr3
_memcmp:
@@ -24,14 +24,12 @@ _memcmp:
jsr popax ; Get p2
sta ptr2
stx ptr2+1
jsr popax ; Get p1
sta ptr1
stx ptr1+1
jsr popptr1 ; Get p1
; Loop initialization
;ldy #$00 ; Initialize pointer (Y=0 guaranteed by popptr1)
ldx ptr3 ; Load low counter byte into X
ldy #$00 ; Initialize pointer
; Head of compare loop: Test for the end condition
+4 -5
View File
@@ -11,7 +11,7 @@
;
.export _memcpy, memcpy_upwards, memcpy_getparams
.import popax
.import popax, popptr1
.importzp sp, ptr1, ptr2, ptr3
; ----------------------------------------------------------------------
@@ -64,12 +64,11 @@ memcpy_getparams: ; IMPORTANT! Function has to leave with Y=0!
sta ptr3
stx ptr3+1 ; save n to ptr3
jsr popax
sta ptr1
stx ptr1+1 ; save src to ptr1
jsr popptr1 ; save src to ptr1
; save dest to ptr2
ldy #1 ; (direct stack access is three cycles faster
iny ; Y=0 guaranteed by popptr1, we need '1' here...
; (direct stack access is three cycles faster
; (total cycle count with return))
lda (sp),y
tax
+3 -5
View File
@@ -5,16 +5,14 @@
;
.export _strcmp
.import popax
.import popptr1
.importzp ptr1, ptr2
_strcmp:
sta ptr2 ; Save s2
stx ptr2+1
jsr popax ; Get s1
sta ptr1
stx ptr1+1
ldy #0
jsr popptr1 ; Get s1
;ldy #0 ; Y=0 guaranteed by popptr1
loop: lda (ptr1),y
cmp (ptr2),y
+3 -5
View File
@@ -6,7 +6,7 @@
;
.export _stricmp, _strcasecmp
.import popax
.import popptr1
.import __ctype
.importzp ptr1, ptr2, tmp1
@@ -16,10 +16,8 @@ _stricmp:
_strcasecmp:
sta ptr2 ; Save s2
stx ptr2+1
jsr popax ; get s1
sta ptr1
stx ptr1+1
ldy #0
jsr popptr1 ; get s1
; ldy #0 ; Y=0 guaranteed by popptr1
loop: lda (ptr2),y ; get char from second string
tax
+2 -4
View File
@@ -6,7 +6,7 @@
;
.export _strncat
.import popax
.import popax, popptr1
.importzp ptr1, ptr2, ptr3, tmp1, tmp2
.macpack cpu
@@ -17,9 +17,7 @@ _strncat:
eor #$FF
sta tmp2
jsr popax ; get src
sta ptr1
stx ptr1+1
jsr popptr1 ; get src
jsr popax ; get dest
sta ptr3 ; remember for function return
+3 -5
View File
@@ -5,7 +5,7 @@
;
.export _strncmp
.import popax
.import popax, popptr1
.importzp ptr1, ptr2, ptr3
@@ -28,13 +28,11 @@ _strncmp:
jsr popax ; get s2
sta ptr2
stx ptr2+1
jsr popax ; get s1
sta ptr1
stx ptr1+1
jsr popptr1 ; get s1
; Loop setup
ldy #0
;ldy #0 Y=0 guaranteed by popptr1
; Start of compare loop. Check the counter.
+2 -4
View File
@@ -5,7 +5,7 @@
;
.export _strncpy
.import popax
.import popptr1
.importzp ptr1, ptr2, tmp1, tmp2, tmp3
.proc _strncpy
@@ -16,9 +16,7 @@
eor #$FF
sta tmp2 ; Store -size - 1
jsr popax ; get src
sta ptr1
stx ptr1+1
jsr popptr1 ; get src
jsr popax ; get dest
sta ptr2
stx ptr2+1
+3 -5
View File
@@ -7,7 +7,7 @@
;
.export _strnicmp, _strncasecmp
.import popax, __ctype
.import popax, popptr1, __ctype
.importzp ptr1, ptr2, ptr3, tmp1
.include "ctype.inc"
@@ -32,13 +32,11 @@ _strncasecmp:
jsr popax ; get s2
sta ptr2
stx ptr2+1
jsr popax ; get s1
sta ptr1
stx ptr1+1
jsr popptr1 ; get s1
; Loop setup
ldy #0
; ldy #0 Y=0 guaranteed by popptr1
; Start of compare loop. Check the counter.
+3 -5
View File
@@ -5,17 +5,15 @@
;
.export _strpbrk
.import popax, return0
.import popax, popptr1, return0
.importzp ptr1, ptr2, tmp1, tmp2, tmp3
_strpbrk:
jsr popax ; get s2
sta ptr2
stx ptr2+1
jsr popax ; get s1
sta ptr1
stx ptr1+1
ldy #$00
jsr popptr1 ; get s1
; ldy #$00 Y=0 guaranteed by popptr1
L1: lda (ptr1),y ; get next char from s1
beq L9 ; jump if done
+3 -5
View File
@@ -5,7 +5,7 @@
;
.export _strstr
.import popax
.import popptr1
.importzp ptr1, ptr2, ptr3, ptr4, tmp1
_strstr:
@@ -13,13 +13,11 @@ _strstr:
stx ptr2+1
sta ptr4 ; Setup temp copy for later
jsr popax ; Get haystack
sta ptr1
stx ptr1+1 ; Save haystack
jsr popptr1 ; Get haystack to ptr1
; If needle is empty, return haystack
ldy #$00
; ldy #$00 Y=0 guaranteed by popptr1
lda (ptr2),y ; Get first byte of needle
beq @Found ; Needle is empty --> we're done