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
82 lines
1.9 KiB
Plaintext
82 lines
1.9 KiB
Plaintext
SUBDEL
|
|
PLA
|
|
TAY
|
|
PLA
|
|
TAX
|
|
PLA
|
|
STA :SCNT
|
|
PLA
|
|
STA :SINDEX
|
|
PLA
|
|
STA ADDR1
|
|
PLA
|
|
STA ADDR1+1
|
|
TXA
|
|
PHA
|
|
TYA
|
|
PHA
|
|
LDY #0
|
|
STY :SCERR
|
|
LDA (ADDR1),Y
|
|
STA :S1LEN ; GET STRING LENGTH
|
|
LDA :SCNT
|
|
BEQ :OKEXIT
|
|
LDA :SINDEX
|
|
BEQ :ERREXIT ; ERR EXIT IF START = 0
|
|
LDA :S1LEN
|
|
CMP :SINDEX
|
|
BCC :ERREXIT
|
|
LDA :SINDEX
|
|
CLC
|
|
ADC :SCNT
|
|
BCS :TRUNC ;TRUNCATE IF INDEX
|
|
STA :SIDX ; SAVE INDEX + COUNT AS
|
|
TAX ; X = INDEX + COUNT
|
|
DEX
|
|
CPX :S1LEN
|
|
BCC :CNTOK ; BR IF IND + CNT - 1
|
|
BEQ :TRUNC ; TRUNC BUT NO ERROR--
|
|
LDA #$0FF
|
|
STA :SCERR ; INDICATE ERROR - NOT
|
|
:TRUNC
|
|
LDX :SINDEX ; STRING LENGTH =
|
|
DEX
|
|
STX :S1LEN
|
|
LDA :SCERR
|
|
BEQ :OKEXIT
|
|
BNE :ERREXIT
|
|
:CNTOK
|
|
LDA :S1LEN ; GET STR LENGTH
|
|
SEC
|
|
SBC :SIDX ; SUBTRACT START INDEX
|
|
TAX
|
|
INX
|
|
BEQ :OKEXIT ; ADD 1 TO INCLUDE LAST
|
|
:MVLP
|
|
LDY :SIDX
|
|
LDA (ADDR1),Y ; GET NEXT CHAR
|
|
LDY :SINDEX
|
|
STA (ADDR1),Y ;MOVE IT DOWN
|
|
INC :SINDEX
|
|
INC :SIDX ; INC DEST, SRC INDEXES
|
|
DEX
|
|
BNE :MVLP ; CONT UNTIL CNT = 0
|
|
LDX :SINDEX
|
|
DEX ; START LENGTH = FINAL
|
|
STX :S1LEN
|
|
:OKEXIT
|
|
CLC
|
|
BCC :EXIT
|
|
:ERREXIT
|
|
SEC
|
|
:EXIT
|
|
LDA :S1LEN
|
|
LDY #0
|
|
STA (ADDR1),Y ; SET LENGTH OF STRING
|
|
RTS
|
|
:S1LEN DS 1
|
|
:SCNT DS 1
|
|
:SINDEX DS 1
|
|
:SIDX DS 1
|
|
:SCERR DS 1
|