mirror of
https://github.com/nathanriggs/AppleIIAsm-Collection.git
synced 2024-11-24 07:31:09 +00:00
82d0e74c1a
some minor bugfixes, directory shuffling, added demo and utility disks
48 lines
1.3 KiB
Plaintext
48 lines
1.3 KiB
Plaintext
STRCMP
|
|
PLA
|
|
STA RETADR
|
|
PLA
|
|
STA RETADR+1
|
|
PLA
|
|
STA ADDR2
|
|
PLA
|
|
STA ADDR2+1
|
|
PLA
|
|
STA ADDR1
|
|
PLA
|
|
STA ADDR1+1
|
|
LDY #0
|
|
LDA (ADDR1),Y ; GET LENGTH OF STRING 1
|
|
CMP (ADDR2),Y
|
|
BCC :BEGCMP ; IF STRING 2 IS SHORTER THEN
|
|
LDA (ADDR2),Y ; USE ITS LENGTH INSTEAD
|
|
:BEGCMP
|
|
TAX ; X IS LENGTH OF SHORTER STRING
|
|
BEQ :TSTLEN ; BR IF LENGTH IS 0
|
|
LDY #1 ; POINT AT FIRST CHAR OF STRINGS
|
|
:CMPLP
|
|
LDA (ADDR1),Y
|
|
CMP (ADDR2),Y
|
|
BNE :EXIT ; BR IF CHARS NOT EQUAL
|
|
; Z,C WILL BE PROPERLY SET
|
|
; OR CLEARED
|
|
; ELSE
|
|
INY ; NEXT CHAR
|
|
DEX ; DECREMENT COUNTER
|
|
BNE :CMPLP ; CONTINUE UNTIL ALL BYTES PAIRED
|
|
:TSTLEN
|
|
LDY #0 ; COMPARE LENGTHS
|
|
LDA (ADDR1),Y
|
|
CMP (ADDR2),Y ; SET OR CLEAR THE FLAGS
|
|
:EXIT
|
|
LDA RETADR+1
|
|
PHA
|
|
LDA RETADR
|
|
PHA
|
|
LDY #0
|
|
LDA (ADDR1),Y ; GET STR1 LENGTH
|
|
TAX ; RETURN IN X
|
|
LDA (ADDR2),Y ; STR2 LENGTH
|
|
TAY ; RETURN IN Y
|
|
RTS
|