2018-12-23 01:35:05 +00:00
|
|
|
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
|
2019-01-21 18:27:30 +00:00
|
|
|
STA :S1LEN ; GET STRING LENGTH
|
2018-12-23 01:35:05 +00:00
|
|
|
LDA :SCNT
|
|
|
|
BEQ :OKEXIT
|
|
|
|
LDA :SINDEX
|
2019-01-21 18:27:30 +00:00
|
|
|
BEQ :ERREXIT ; ERR EXIT IF START = 0
|
2018-12-23 01:35:05 +00:00
|
|
|
LDA :S1LEN
|
|
|
|
CMP :SINDEX
|
|
|
|
BCC :ERREXIT
|
|
|
|
LDA :SINDEX
|
|
|
|
CLC
|
|
|
|
ADC :SCNT
|
2019-01-21 18:27:30 +00:00
|
|
|
BCS :TRUNC ;TRUNCATE IF INDEX
|
|
|
|
STA :SIDX ; SAVE INDEX + COUNT AS
|
|
|
|
TAX ; X = INDEX + COUNT
|
2018-12-23 01:35:05 +00:00
|
|
|
DEX
|
|
|
|
CPX :S1LEN
|
2019-01-21 18:27:30 +00:00
|
|
|
BCC :CNTOK ; BR IF IND + CNT - 1
|
|
|
|
BEQ :TRUNC ; TRUNC BUT NO ERROR--
|
2018-12-23 01:35:05 +00:00
|
|
|
LDA #$0FF
|
2019-01-21 18:27:30 +00:00
|
|
|
STA :SCERR ; INDICATE ERROR - NOT
|
2018-12-23 01:35:05 +00:00
|
|
|
:TRUNC
|
2019-01-21 18:27:30 +00:00
|
|
|
LDX :SINDEX ; STRING LENGTH =
|
2018-12-23 01:35:05 +00:00
|
|
|
DEX
|
|
|
|
STX :S1LEN
|
|
|
|
LDA :SCERR
|
|
|
|
BEQ :OKEXIT
|
|
|
|
BNE :ERREXIT
|
|
|
|
:CNTOK
|
2019-01-21 18:27:30 +00:00
|
|
|
LDA :S1LEN ; GET STR LENGTH
|
2018-12-23 01:35:05 +00:00
|
|
|
SEC
|
2019-01-21 18:27:30 +00:00
|
|
|
SBC :SIDX ; SUBTRACT START INDEX
|
2018-12-23 01:35:05 +00:00
|
|
|
TAX
|
|
|
|
INX
|
2019-01-21 18:27:30 +00:00
|
|
|
BEQ :OKEXIT ; ADD 1 TO INCLUDE LAST
|
2018-12-23 01:35:05 +00:00
|
|
|
:MVLP
|
|
|
|
LDY :SIDX
|
2019-01-21 18:27:30 +00:00
|
|
|
LDA (ADDR1),Y ; GET NEXT CHAR
|
2018-12-23 01:35:05 +00:00
|
|
|
LDY :SINDEX
|
2019-01-21 18:27:30 +00:00
|
|
|
STA (ADDR1),Y ;MOVE IT DOWN
|
2018-12-23 01:35:05 +00:00
|
|
|
INC :SINDEX
|
2019-01-21 18:27:30 +00:00
|
|
|
INC :SIDX ; INC DEST, SRC INDEXES
|
2018-12-23 01:35:05 +00:00
|
|
|
DEX
|
2019-01-21 18:27:30 +00:00
|
|
|
BNE :MVLP ; CONT UNTIL CNT = 0
|
2018-12-23 01:35:05 +00:00
|
|
|
LDX :SINDEX
|
2019-01-21 18:27:30 +00:00
|
|
|
DEX ; START LENGTH = FINAL
|
2018-12-23 01:35:05 +00:00
|
|
|
STX :S1LEN
|
|
|
|
:OKEXIT
|
|
|
|
CLC
|
|
|
|
BCC :EXIT
|
|
|
|
:ERREXIT
|
|
|
|
SEC
|
|
|
|
:EXIT
|
|
|
|
LDA :S1LEN
|
|
|
|
LDY #0
|
2019-01-21 18:27:30 +00:00
|
|
|
STA (ADDR1),Y ; SET LENGTH OF STRING
|
2018-12-23 01:35:05 +00:00
|
|
|
RTS
|
|
|
|
:S1LEN DS 1
|
|
|
|
:SCNT DS 1
|
|
|
|
:SINDEX DS 1
|
|
|
|
:SIDX DS 1
|
|
|
|
:SCERR DS 1
|