2019-01-21 06:52:04 +00:00
|
|
|
|
NEW
|
2019-06-28 15:15:58 +00:00
|
|
|
|
AUTO 3,1 Enable MASM3 auto line num
|
2019-01-21 06:52:04 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02 Target CPU, must match CPU level in header
|
|
|
|
|
.OR $2000 usualy $2000, but any value > $100 allowed
|
|
|
|
|
.TF BIN/CSH
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
2019-02-06 16:20:51 +00:00
|
|
|
|
.INB INC/MLI.I
|
2019-01-26 16:33:03 +00:00
|
|
|
|
.INB INC/MLI.E.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB USR/SRC/BIN/CSH.E
|
2019-01-21 06:52:04 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Zero Page Segment, up to 32 bytes
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
2019-02-07 07:19:02 +00:00
|
|
|
|
ZPFileBuf .BS 2
|
2019-01-26 16:33:03 +00:00
|
|
|
|
ZPFileBufPtr .BS 2
|
2019-02-13 16:20:44 +00:00
|
|
|
|
ZPCSHConst .BS 2
|
2019-01-21 06:52:04 +00:00
|
|
|
|
ZPCSHStack .BS 2
|
2019-08-26 06:29:18 +00:00
|
|
|
|
|
|
|
|
|
ZPPtr1 .BS 2
|
|
|
|
|
ZPPtr2 .BS 2
|
|
|
|
|
ZPPtr3 .BS 2
|
|
|
|
|
|
|
|
|
|
ZPVarID .BS 2
|
2019-09-03 15:35:13 +00:00
|
|
|
|
|
2019-08-26 15:27:28 +00:00
|
|
|
|
ZPVarData .BS 6
|
2019-09-03 15:35:13 +00:00
|
|
|
|
ZPVarType .BS 1
|
2019-08-26 06:29:18 +00:00
|
|
|
|
|
2019-09-05 15:49:05 +00:00
|
|
|
|
ArgIndex .BS 1
|
|
|
|
|
|
2019-01-21 06:52:04 +00:00
|
|
|
|
ZS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA #0 S.PS.F.EVENT
|
|
|
|
|
.DA #0
|
|
|
|
|
.DA CS.END-CS.START Code Size (without Constants)
|
|
|
|
|
.DA DS.END-DS.START Data SegmentSize
|
2019-07-22 06:31:01 +00:00
|
|
|
|
.DA #64 Stack Size
|
2019-01-21 06:52:04 +00:00
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
2019-09-03 15:35:13 +00:00
|
|
|
|
*--------------------------------------
|
2019-01-21 06:52:04 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
2019-09-03 15:35:13 +00:00
|
|
|
|
.DA CS.DOEVENT
|
2019-01-21 06:52:04 +00:00
|
|
|
|
.DA CS.QUIT
|
2019-02-07 07:19:02 +00:00
|
|
|
|
L.MSG.GREETINGS .DA MSG.GREETINGS
|
2019-09-05 06:43:09 +00:00
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
2019-02-07 07:19:02 +00:00
|
|
|
|
L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
|
2019-09-05 15:49:05 +00:00
|
|
|
|
L.MSG.DEBUG .DA MSG.DEBUG
|
2019-09-03 15:35:13 +00:00
|
|
|
|
L.MSG.ERR .DA MSG.ERR
|
2019-01-26 16:33:03 +00:00
|
|
|
|
.INB USR/SRC/BIN/CSH.R
|
2019-01-21 06:52:04 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Called once at process creation
|
|
|
|
|
* Put code for loading LIB here
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT clc
|
2019-09-05 15:49:05 +00:00
|
|
|
|
CS.INIT.RTS rts
|
2019-01-21 06:52:04 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Called until exit with CS
|
|
|
|
|
* if RUN exits with CC, RN entered again
|
|
|
|
|
*--------------------------------------
|
2019-09-05 15:49:05 +00:00
|
|
|
|
CS.RUN >PUSHWI K.VER
|
2019-02-06 16:20:51 +00:00
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>LDYA L.MSG.GREETINGS
|
|
|
|
|
>SYSCALL printf
|
2019-09-05 15:49:05 +00:00
|
|
|
|
bcs CS.INIT.RTS
|
2019-01-21 06:52:04 +00:00
|
|
|
|
|
2019-09-05 15:49:05 +00:00
|
|
|
|
jsr CS.RUN.ARGS
|
|
|
|
|
bcs CS.INIT.RTS
|
|
|
|
|
|
2019-02-06 16:20:51 +00:00
|
|
|
|
jsr CSH.Init
|
2019-09-05 15:49:05 +00:00
|
|
|
|
bcs CS.INIT.RTS
|
2019-02-06 16:20:51 +00:00
|
|
|
|
|
|
|
|
|
.1 >SLEEP
|
2019-08-27 15:13:00 +00:00
|
|
|
|
|
2019-09-05 15:49:05 +00:00
|
|
|
|
>LDA.G bDebug
|
2019-08-27 15:13:00 +00:00
|
|
|
|
bpl .2
|
2019-09-05 15:49:05 +00:00
|
|
|
|
jsr PrintDebugMsg
|
|
|
|
|
|
|
|
|
|
.2 >LDA.G bTrace
|
|
|
|
|
bpl .3
|
2019-08-27 15:13:00 +00:00
|
|
|
|
|
|
|
|
|
>LDYA ZPFileBufPtr
|
|
|
|
|
jsr PrintTraceMsg
|
|
|
|
|
|
2019-09-05 15:49:05 +00:00
|
|
|
|
.3 jsr CSH.Run
|
2019-02-06 16:20:51 +00:00
|
|
|
|
bcc .1
|
2019-01-21 06:52:04 +00:00
|
|
|
|
|
2019-02-07 07:19:02 +00:00
|
|
|
|
cmp #MLI.E.EOF
|
|
|
|
|
beq .8
|
2019-08-27 15:13:00 +00:00
|
|
|
|
|
2019-02-07 07:19:02 +00:00
|
|
|
|
pha
|
|
|
|
|
jsr PrintErrMsg
|
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
2019-09-05 06:43:09 +00:00
|
|
|
|
.8 lda #0 Exit Code = Success
|
2019-02-07 07:19:02 +00:00
|
|
|
|
sec
|
2019-01-21 06:52:04 +00:00
|
|
|
|
rts
|
2019-09-05 15:49:05 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.ARGS inc ArgIndex
|
|
|
|
|
|
|
|
|
|
lda ArgIndex
|
|
|
|
|
>SYSCALL ARGV
|
|
|
|
|
bcs .7
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
ldx #OptionVars-OptionList-1
|
|
|
|
|
|
|
|
|
|
.1 cmp OptionList,x
|
|
|
|
|
beq .2
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
bra .90
|
|
|
|
|
|
|
|
|
|
.2 ldy OptionVars,x
|
|
|
|
|
lda #$ff
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra CS.RUN.ARGS
|
|
|
|
|
|
|
|
|
|
.4 >LDA.G hFileBuf
|
|
|
|
|
bne .90
|
|
|
|
|
|
|
|
|
|
>PUSHWZ Aux type
|
|
|
|
|
>PUSHBI S.FI.T.TXT
|
|
|
|
|
>PUSHBI O.RDONLY
|
|
|
|
|
>LDYA ZPPtr1
|
|
|
|
|
>SYSCALL LoadTxtFile
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hFileBuf
|
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>STYA ZPFileBuf
|
|
|
|
|
>STYA ZPFileBufPtr
|
|
|
|
|
bra CS.RUN.ARGS
|
|
|
|
|
|
|
|
|
|
.7 >LDA.G hFileBuf
|
|
|
|
|
beq .90
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
2019-01-21 06:52:04 +00:00
|
|
|
|
|
2019-09-05 06:43:09 +00:00
|
|
|
|
.90 >PUSHBI 0
|
|
|
|
|
>LDYA L.MSG.USAGE
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
|
|
|
|
|
lda #E.SYN
|
2019-01-21 06:52:04 +00:00
|
|
|
|
sec QUIT Process
|
2019-09-05 15:49:05 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2019-01-21 06:52:04 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-02-06 16:20:51 +00:00
|
|
|
|
CS.QUIT jsr CSH.Quit
|
|
|
|
|
clc
|
2019-01-21 06:52:04 +00:00
|
|
|
|
rts
|
2019-01-26 16:33:03 +00:00
|
|
|
|
*--------------------------------------
|
2019-02-07 07:19:02 +00:00
|
|
|
|
PrintErrMsg >LDYA ZPFileBuf
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
stz ZPPtr2
|
|
|
|
|
stz ZPPtr2+1 Line counter
|
2019-02-07 07:19:02 +00:00
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
.1 inc ZPPtr2
|
2019-02-07 07:19:02 +00:00
|
|
|
|
bne .2
|
2019-08-27 15:13:00 +00:00
|
|
|
|
inc ZPPtr2+1
|
2019-02-07 07:19:02 +00:00
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
.2 >LDYA ZPPtr1
|
|
|
|
|
>STYA ZPPtr3 save line start
|
|
|
|
|
|
|
|
|
|
.20 lda (ZPPtr1)
|
|
|
|
|
beq .4 EoF
|
2019-08-26 06:29:18 +00:00
|
|
|
|
|
2019-02-07 07:19:02 +00:00
|
|
|
|
inc ZPPtr1
|
|
|
|
|
bne .3
|
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
.3 cmp #C.CR
|
2019-08-27 15:13:00 +00:00
|
|
|
|
bne .20 Scan until EoL
|
2019-02-07 07:19:02 +00:00
|
|
|
|
|
|
|
|
|
ldx ZPPtr1
|
|
|
|
|
cpx ZPFileBufPtr
|
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
sbc ZPFileBufPtr+1
|
|
|
|
|
bcc .1 not this line....
|
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
.4 >LDA.G bTrace
|
|
|
|
|
bmi .5
|
|
|
|
|
|
|
|
|
|
jsr PrintTraceMsg.3
|
|
|
|
|
|
|
|
|
|
.5 lda ZPPtr3
|
|
|
|
|
cmp ZPFileBufPtr
|
|
|
|
|
bne .6
|
|
|
|
|
|
|
|
|
|
lda ZPPtr3+1
|
|
|
|
|
cmp ZPFileBufPtr+1
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
.6 >PUSHBI '-'
|
2019-02-07 07:19:02 +00:00
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fputc
|
2019-08-27 15:13:00 +00:00
|
|
|
|
|
|
|
|
|
inc ZPPtr3
|
|
|
|
|
bne .5
|
|
|
|
|
inc ZPPtr3+1
|
2019-02-07 07:19:02 +00:00
|
|
|
|
bra .5
|
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
.8 >PUSHW ZPPtr2 Line counter
|
|
|
|
|
|
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>PUSHW L.MSG.ERR
|
2019-02-07 07:19:02 +00:00
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fprintf
|
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-09-05 15:49:05 +00:00
|
|
|
|
PrintDebugMsg >PUSHW pStack
|
2019-09-03 15:35:13 +00:00
|
|
|
|
>PUSHBI 2
|
2019-09-05 15:49:05 +00:00
|
|
|
|
>LDYA L.MSG.DEBUG
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintTraceMsg >STYA ZPPtr3
|
2019-08-27 15:13:00 +00:00
|
|
|
|
|
|
|
|
|
PrintTraceMsg.3 >PUSHBI '>'
|
2019-02-07 07:19:02 +00:00
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fputc
|
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPtr3),y
|
|
|
|
|
beq .8
|
|
|
|
|
cmp #C.CR
|
|
|
|
|
beq .8
|
2019-02-07 07:19:02 +00:00
|
|
|
|
|
2019-08-27 15:13:00 +00:00
|
|
|
|
phy
|
|
|
|
|
>PUSHA
|
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fputc
|
|
|
|
|
ply
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 >PUSHBI 0
|
|
|
|
|
>PUSHW L.MSG.ECHOCRLF
|
2019-02-07 07:19:02 +00:00
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fprintf
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-01-26 16:33:03 +00:00
|
|
|
|
.INB USR/SRC/BIN/CSH.S.CORE
|
2019-01-21 06:52:04 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Initialized DATA
|
|
|
|
|
*--------------------------------------
|
2019-02-06 16:20:51 +00:00
|
|
|
|
MSG.Greetings .AZ "\r\nCSH-Shell %d.%d\r\n\r\n"
|
2019-09-05 15:49:05 +00:00
|
|
|
|
MSG.USAGE .AS "Usage : CSH <option> file\r\n"
|
2019-09-05 06:43:09 +00:00
|
|
|
|
.AS " -D : Debug Mode\r\n"
|
|
|
|
|
.AS " -T : Trace On"
|
2019-02-07 07:19:02 +00:00
|
|
|
|
MSG.ECHOCRLF .AZ "\r\n"
|
2019-09-05 15:49:05 +00:00
|
|
|
|
MSG.DEBUG .AZ "DEBUG:pStack=%H\r\n"
|
|
|
|
|
MSG.ERR .AZ "^\r\nLine #%D:"
|
2019-09-05 06:43:09 +00:00
|
|
|
|
*--------------------------------------
|
2019-09-05 15:49:05 +00:00
|
|
|
|
OptionList .AS "DdTt"
|
2019-09-05 06:43:09 +00:00
|
|
|
|
OptionVars .DA #bDebug,#bDebug,#bTrace,#bTrace
|
2019-08-26 06:29:18 +00:00
|
|
|
|
*--------------------------------------
|
2019-01-26 16:33:03 +00:00
|
|
|
|
.INB USR/SRC/BIN/CSH.I
|
2019-01-21 06:52:04 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
2019-01-26 16:33:03 +00:00
|
|
|
|
DS.START .INB USR/SRC/BIN/CSH.D
|
2019-09-05 06:43:09 +00:00
|
|
|
|
bDebug .BS 1
|
2019-08-27 15:13:00 +00:00
|
|
|
|
bTrace .BS 1
|
2019-01-21 06:52:04 +00:00
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE USR/SRC/BIN/CSH.S
|
|
|
|
|
ASM
|