1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2026-03-15 04:16:23 +00:00

Minor changes to include/ .a02 files

This commit is contained in:
Curtis F Kaylor
2019-03-22 21:18:49 -04:00
parent 5289bb8717
commit 976dd4cf44
5 changed files with 31 additions and 29 deletions

View File

@@ -29,16 +29,16 @@ STRCMR: RTS ;
;Args: A = Character to look for
; X,Y = Pointer to string to search in
;Sets: SRCLO,SRCHI = Pointer to string
; TEMP0 = Character being searched for
; TEMP3 = Character being searched for
;Affects: N,Z
;Returns: A = Position in string, C=1 if found
; A = $FF, C=0 if not found
; Y = Position of last character scanned
STRCHR: JSR SETSRC ;Initialize Source String
STRCHA: STA TEMP0; ;Save Search Character (alternate entry point)
STRCHA: STA TEMP3; ;Save Search Character (alternate entry point)
STRCHL: LDA (SRCLO),Y ;Get Next Character
BEQ STRCLC ;If NUL, Return $FF and Carry Clear
CMP TEMP0 ;Compare Character
CMP TEMP3 ;Compare Character
BEQ STRLEX ;If Found, Return Index
INY ;Increment Counter and Loop if < 128
BPL STRCHL ;Else Return $FF and Carry Clear
@@ -71,7 +71,7 @@ STRDST EQU SETDST ;Aliased to System Header function
;Requires: DSTLO, DSTHI - Pointer to destination string
;Args: X,Y = Pointer to source string
;Sets: SRCLO,SRCHI = Pointer to source string
; TEMP0 = Length of source prior to concatenation
; TEMP3 = Length of source prior to concatenation
;Affects: C,N,Z
;Returns: A,Y = Total length of concatenated string
STRCAT: JSR SETSRC ;Initialize Source String
@@ -79,10 +79,10 @@ STRCAL: LDA (DSTLO),Y ;Find end of Destination String
BEQ STRCAX ;
INY ;
BPL STRCAL ;
STRCAX: STY TEMP0 ;Subtract Destination String Length
STRCAX: STY TEMP3 ;Subtract Destination String Length
LDA SRCLO ; from Source String Pointer
SEC
SBC TEMP0
SBC TEMP3
STA SRCLO
LDA SRCHI
SBC #$00
@@ -125,13 +125,13 @@ STRCUT: JSR SETSRC ;Initialize Source String
;Sets: DSTLO,DSTHI = Pointer to position in source string
; End of string if not found
; SRCLO,SRCHI = Pointer to source string
; TEMP0 = Last position checked in destination string
; TEMP3 = Last position checked in destination string
;Affects: N,Z
;Returns: A = Position, C=1 if found
; A = $FF, C=0 if not found
; Y = Last position checked in source string
STRSTR: JSR SETSRC ;Initialize Source String
STY TEMP0 ;Initialize Position
STY TEMP3 ;Initialize Position
STRSTL: LDY #$00; ;Initialize Compare Offset
LDA (DSTLO),Y ;Get Start Character in Destination
BEQ STRCLC ;If NUL return $FF and Carry Clear
@@ -140,7 +140,7 @@ STRSTL: LDY #$00; ;Initialize Compare Offset
BMI STRSTN ; If Source is Greater
LDA (SRCLO),Y ; If at End of Source String
BEQ STRSTX ; Return Current Position
STRSTN: INC TEMP0 ; Else Increment Position
STRSTN: INC TEMP3 ; Else Increment Position
BMI STRCLC ; If > 127 return $FF and Carry Clear
INC DSTLO ; Increment Source Pointer
BNE STRSTL
@@ -148,30 +148,29 @@ STRSTN: INC TEMP0 ; Else Increment Position
BNE STRSTL ; Loop
BEQ STRCLC ; Else return $FF and Carry Clear
STRSTX: SEC ;Else Set Carry
LDA TEMP0 ; Load Position
LDA TEMP3 ; Load Position
RTS ; and Return
;strrch(c, &s) - Find Last Occurance Character in String
;Args: A = Character to look for
; X,Y = Pointer to string to search in
;Sets: SRCLO,SRCHI = Pointer to string
; TEMP0 = Character being searched for
; TEMP1 = Position of character
; TEMP3 = Character being searched for
;Affects: Y,C,N,Z
;Returns: A = Position of last occurance in string
; A = $FF if not found
; Y = Position of last character scanned
;Returns: A,X = Position of last occurance in string
; $FF if not found
; Y = Length of String
STRRCH: JSR SETSRC ;Initialize Source String
STA TEMP0; ;Save Search Character (alternate entry point)
LDA #$FF ;Initialize Position
STA TEMP1 ; to 255
STA TEMP3; ;Save Search Character (alternate entry point)
LDX #$FF ;Initialize Position
STRRCL: LDA (SRCLO),Y ;Get Next Character
BEQ STRRCX ;If NUL, Exit with Position
CMP TEMP0 ;Compare Character
CMP TEMP3 ;Compare Character
BNE STRRCS ;If Found
STY TEMP1 ; Store Counter
TYA ; Store Counter
TAX
STRRCS: INY ;Increment Counter
BPL STRRCL ; and Loop if < 128
STRRCX: LDA TEMP1 ;Load Position Accumulater
STRRCX: TXA ;Copy Position to Accumulater
RTS ; and Return