2019-01-21 06:52:04 +00:00
|
|
|
|
NEW
|
|
|
|
|
PREFIX
|
|
|
|
|
AUTO 4,1 Enable MASM3 auto line num
|
|
|
|
|
.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-01-26 16:33:03 +00:00
|
|
|
|
ZPPtr1 .BS 2
|
|
|
|
|
ZPPtr2 .BS 2
|
2019-02-07 07:19:02 +00:00
|
|
|
|
ZPPtr3 .BS 2
|
|
|
|
|
ZPFileBuf .BS 2
|
2019-01-26 16:33:03 +00:00
|
|
|
|
ZPFileBufPtr .BS 2
|
2019-02-08 16:13:43 +00:00
|
|
|
|
ZPFnDefPtr .BS 2
|
2019-01-26 16:33:03 +00:00
|
|
|
|
|
2019-01-21 06:52:04 +00:00
|
|
|
|
ZPCSHSymbols .BS 2
|
2019-02-13 16:20:44 +00:00
|
|
|
|
ZPCSHConst .BS 2
|
2019-01-21 06:52:04 +00:00
|
|
|
|
ZPCSHData .BS 2
|
|
|
|
|
ZPCSHValue .BS 2
|
|
|
|
|
ZPCSHStack .BS 2
|
|
|
|
|
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
|
|
|
|
|
.DA #16 Stack Size
|
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
2019-02-07 07:19:02 +00:00
|
|
|
|
L.MSG.GREETINGS .DA MSG.GREETINGS
|
|
|
|
|
L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
|
|
|
|
|
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
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Called until exit with CS
|
|
|
|
|
* if RUN exits with CC, RN entered again
|
|
|
|
|
*--------------------------------------
|
2019-02-06 16:20:51 +00:00
|
|
|
|
CS.RUN >PUSHWI K.VER
|
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>LDYA L.MSG.GREETINGS
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
bcs .99
|
2019-01-21 06:52:04 +00:00
|
|
|
|
|
2019-02-06 16:20:51 +00:00
|
|
|
|
jsr CSH.Init
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.ARGC
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
beq .90 no arg, usage
|
|
|
|
|
|
|
|
|
|
>PUSHWI 0 Aux type
|
|
|
|
|
>PUSHBI S.FI.T.TXT
|
|
|
|
|
>PUSHBI O.RDONLY
|
|
|
|
|
lda #1
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
>SYSCALL LoadTxtFile
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hFileBuf
|
|
|
|
|
>SYSCALL GetMemPtr
|
2019-02-07 07:19:02 +00:00
|
|
|
|
>STYA ZPFileBuf
|
2019-02-06 16:20:51 +00:00
|
|
|
|
>STYA ZPFileBufPtr
|
|
|
|
|
|
|
|
|
|
.1 >SLEEP
|
|
|
|
|
jsr CSH.Run
|
|
|
|
|
bcc .1
|
2019-01-21 06:52:04 +00:00
|
|
|
|
|
2019-02-07 07:19:02 +00:00
|
|
|
|
cmp #MLI.E.EOF
|
|
|
|
|
beq .8
|
|
|
|
|
pha
|
|
|
|
|
jsr PrintErrMsg
|
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 lda #0
|
|
|
|
|
sec
|
2019-01-21 06:52:04 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2019-02-06 16:20:51 +00:00
|
|
|
|
.90 lda #E.SYN Exit Code = Succes
|
2019-01-21 06:52:04 +00:00
|
|
|
|
sec QUIT Process
|
2019-02-06 16:20:51 +00:00
|
|
|
|
.99 rts
|
2019-01-21 06:52:04 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Called if option S.PS.F.EVENT enabled in Header
|
|
|
|
|
* Timer Event : every 10th seconds
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Called once, when RUN exited with CS
|
|
|
|
|
* Put code for unloading LIB here
|
|
|
|
|
*--------------------------------------
|
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-02-13 16:20:44 +00:00
|
|
|
|
lda #1
|
|
|
|
|
sta ZPPtr3
|
2019-02-07 07:19:02 +00:00
|
|
|
|
stz ZPPtr3+1
|
|
|
|
|
|
|
|
|
|
.1 >LDYA ZPPtr1
|
|
|
|
|
>STYA ZPPtr2 Save actual line start
|
|
|
|
|
|
|
|
|
|
inc ZPPtr3
|
|
|
|
|
bne .2
|
|
|
|
|
inc ZPPtr3+1
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPPtr1)
|
|
|
|
|
beq .6 EoF
|
|
|
|
|
inc ZPPtr1
|
|
|
|
|
bne .3
|
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
.3 cmp #C.CR
|
|
|
|
|
bne .2 Scan until EoL
|
|
|
|
|
|
|
|
|
|
ldx ZPPtr1
|
|
|
|
|
cpx ZPFileBufPtr
|
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
sbc ZPFileBufPtr+1
|
|
|
|
|
bcc .1 not this line....
|
|
|
|
|
|
2019-02-13 16:20:44 +00:00
|
|
|
|
ldy #$ff
|
2019-02-07 07:19:02 +00:00
|
|
|
|
|
2019-02-13 16:20:44 +00:00
|
|
|
|
.5 iny
|
|
|
|
|
lda (ZPPtr2),y
|
2019-02-07 07:19:02 +00:00
|
|
|
|
beq .6
|
|
|
|
|
cmp #C.CR
|
|
|
|
|
beq .6
|
2019-02-13 16:20:44 +00:00
|
|
|
|
|
2019-02-07 07:19:02 +00:00
|
|
|
|
phy
|
|
|
|
|
>PUSHA
|
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fputc
|
|
|
|
|
ply
|
|
|
|
|
bra .5
|
|
|
|
|
|
2019-02-13 16:20:44 +00:00
|
|
|
|
.6 phy
|
|
|
|
|
>PUSHBI 0
|
2019-02-07 07:19:02 +00:00
|
|
|
|
>PUSHW L.MSG.ECHOCRLF
|
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fprintf
|
2019-02-13 16:20:44 +00:00
|
|
|
|
ply
|
2019-02-07 07:19:02 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
.7 phy
|
|
|
|
|
>PUSHBI '-'
|
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fputc
|
|
|
|
|
ply
|
|
|
|
|
dey
|
|
|
|
|
bne .7
|
|
|
|
|
|
|
|
|
|
.8 >PUSHW ZPPtr3
|
|
|
|
|
|
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>PUSHW L.MSG.ERR
|
|
|
|
|
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-02-07 07:19:02 +00:00
|
|
|
|
MSG.ECHOCRLF .AZ "\r\n"
|
|
|
|
|
MSG.ERR .AZ "^\r\nLine #%D:"
|
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-01-21 06:52:04 +00:00
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE USR/SRC/BIN/CSH.S
|
|
|
|
|
ASM
|