A2osX/BIN/CSH.S.txt

353 lines
6.4 KiB
Plaintext
Raw Normal View History

2019-01-21 06:52:04 +00:00
NEW
2020-01-25 18:56:36 +00:00
AUTO 3,1
2019-01-21 06:52:04 +00:00
.LIST OFF
2020-01-25 18:56:36 +00:00
.OP 65C02
.OR $2000
2020-02-18 15:34:56 +00:00
.TF bin/csh
2019-01-21 06:52:04 +00:00
*--------------------------------------
2020-07-31 14:46:11 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
2019-01-26 16:33:03 +00:00
*--------------------------------------
2020-07-31 14:46:11 +00:00
.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
2020-08-02 12:19:43 +00:00
ZPCSHCode .BS 2
2019-02-13 16:20:44 +00:00
ZPCSHConst .BS 2
2020-02-19 16:42:05 +00:00
ZPCSHData .BS 2
2019-01-21 06:52:04 +00:00
ZPCSHStack .BS 2
2019-08-26 06:29:18 +00:00
2020-07-31 14:46:11 +00:00
ZPVarID .BS 2
2020-08-02 12:19:43 +00:00
ZPVarDef .EQ *
2021-01-12 21:14:13 +00:00
ZPVarType .BS 1
ZPVarQual .BS 1
2020-02-19 16:42:05 +00:00
ZPVarSizeOf .BS 2
ZPVarDataPtr .BS 2
2019-08-26 06:29:18 +00:00
2020-12-23 14:54:57 +00:00
ZPInputBufPtr .BS 2
2020-08-02 12:19:43 +00:00
2020-12-23 14:54:57 +00:00
bFastCall .BS 1
bCompil .BS 1
hDefine .BS 1
hInclude .BS 1
2020-02-19 16:42:05 +00:00
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
2020-12-23 14:54:57 +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
2020-08-02 12:19:43 +00:00
L.ENV.INCLUDE .DA ENV.INCLUDE
2020-07-31 14:46:11 +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
*--------------------------------------
2020-01-31 20:26:51 +00:00
CS.RUN >PUSHW L.MSG.GREETINGS
2020-12-23 14:54:57 +00:00
>PUSHW A2osX.KVER
2019-02-06 16:20:51 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-09-05 15:49:05 +00:00
bcs CS.INIT.RTS
2020-01-22 16:31:48 +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
2020-01-25 18:56:36 +00:00
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
2020-12-23 14:54:57 +00:00
2019-09-05 15:49:05 +00:00
jsr PrintDebugMsg
.2 >LDA.G bTrace
bpl .3
2020-12-23 14:54:57 +00:00
>LDYA ZPInputBufPtr
2019-08-27 15:13:00 +00:00
jsr PrintTraceMsg
2019-09-05 15:49:05 +00:00
.3 jsr CSH.Run
2019-02-06 16:20:51 +00:00
bcc .1
2020-12-23 14:54:57 +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
2020-01-22 16:31:48 +00:00
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
2020-02-28 07:21:46 +00:00
>SYSCALL ArgV
2019-09-05 15:49:05 +00:00
bcs .7
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
2020-01-22 16:31:48 +00:00
2019-09-05 15:49:05 +00:00
ldy #1
lda (ZPPtr1),y
2020-01-22 16:31:48 +00:00
2019-09-05 15:49:05 +00:00
ldx #OptionVars-OptionList-1
2020-01-22 16:31:48 +00:00
2019-09-05 15:49:05 +00:00
.1 cmp OptionList,x
beq .2
2020-01-22 16:31:48 +00:00
2019-09-05 15:49:05 +00:00
dex
bpl .1
bra .90
2020-01-22 16:31:48 +00:00
2019-09-05 15:49:05 +00:00
.2 ldy OptionVars,x
lda #$ff
sta (pData),y
bra CS.RUN.ARGS
2020-01-22 16:31:48 +00:00
2019-09-05 15:49:05 +00:00
.4 >LDA.G hFileBuf
bne .90
2020-01-22 16:31:48 +00:00
2020-08-27 06:30:03 +00:00
>LDYA ZPPtr1
jsr CS.RUN.LoadFile
2019-09-05 15:49:05 +00:00
bcs .9
2020-01-22 16:31:48 +00:00
2020-12-23 14:54:57 +00:00
>STYA ZPInputBufPtr
txa
2019-09-05 15:49:05 +00:00
>STA.G hFileBuf
bra CS.RUN.ARGS
2020-01-22 16:31:48 +00:00
2019-09-05 15:49:05 +00:00
.7 >LDA.G hFileBuf
beq .90
clc
2020-01-22 16:31:48 +00:00
.9 rts
2020-01-31 20:26:51 +00:00
.90 >PUSHW L.MSG.USAGE
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-01-22 16:31:48 +00:00
2019-09-05 06:43:09 +00:00
lda #E.SYN
2019-01-21 06:52:04 +00:00
sec QUIT Process
2020-01-22 16:31:48 +00:00
rts
2019-01-21 06:52:04 +00:00
*--------------------------------------
2020-12-15 13:23:22 +00:00
CS.RUN.LoadFile >SYSCALL LoadTxtFile
2020-08-27 06:30:03 +00:00
bcs .9
phx
txa
>SYSCALL GetMemPtr
2020-12-23 14:54:57 +00:00
plx
2020-08-27 06:30:03 +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
*--------------------------------------
2020-12-23 14:54:57 +00:00
PrintErrMsg lda hDefine
2020-01-26 19:36:49 +00:00
beq .10
2020-12-23 14:54:57 +00:00
>LDYA.G CSH.SaveDefine
>STYA ZPInputBufPtr
2020-01-26 19:36:49 +00:00
2021-01-12 21:14:13 +00:00
.10 lda hInclude
beq .11
bra .12
.11 >LDA.G hFileBuf
.12 >SYSCALL GetMemPtr
2019-02-07 07:19:02 +00:00
>STYA ZPPtr1
2021-01-12 21:14:13 +00:00
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
2020-12-23 14:54:57 +00:00
cpx ZPInputBufPtr
2019-02-07 07:19:02 +00:00
lda ZPPtr1+1
2020-12-23 14:54:57 +00:00
sbc ZPInputBufPtr+1
2019-02-07 07:19:02 +00:00
bcc .1 not this line....
2019-08-27 15:13:00 +00:00
.4 >LDA.G bTrace
bmi .5
2020-02-18 15:34:56 +00:00
2019-08-27 15:13:00 +00:00
jsr PrintTraceMsg.3
2020-02-18 15:34:56 +00:00
2019-08-27 15:13:00 +00:00
.5 lda ZPPtr3
2020-12-23 14:54:57 +00:00
cmp ZPInputBufPtr
2019-08-27 15:13:00 +00:00
bne .6
2020-12-23 14:54:57 +00:00
2019-08-27 15:13:00 +00:00
lda ZPPtr3+1
2020-12-23 14:54:57 +00:00
cmp ZPInputBufPtr+1
2019-08-27 15:13:00 +00:00
beq .8
2020-12-23 14:54:57 +00:00
2019-08-27 15:13:00 +00:00
.6 >PUSHBI '-'
2019-02-07 07:19:02 +00:00
ldy #S.PS.hStdErr
lda (pPS),y
2020-02-28 07:21:46 +00:00
>SYSCALL FPutC
2019-08-27 15:13:00 +00:00
inc ZPPtr3
bne .5
2020-12-23 14:54:57 +00:00
2019-08-27 15:13:00 +00:00
inc ZPPtr3+1
2019-02-07 07:19:02 +00:00
bra .5
2020-02-14 07:21:56 +00:00
.8 ldy #S.PS.hStdErr
2019-02-07 07:19:02 +00:00
lda (pPS),y
2020-02-14 07:21:56 +00:00
>PUSHA
>PUSHW L.MSG.ERR
2021-01-12 21:14:13 +00:00
>PUSHW ZPPtr2 Line counter
2020-02-14 07:21:56 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL FPrintF
2019-02-07 07:19:02 +00:00
2019-08-27 15:13:00 +00:00
rts
*--------------------------------------
2020-02-21 13:24:16 +00:00
PrintDebugMsg >LDYA pStack
>STYA ZPPtr2
>PUSHW L.MSG.DEBUG
>PUSHW ZPPtr2
2019-09-03 15:35:13 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-09-05 15:49:05 +00:00
rts
2019-10-03 06:25:27 +00:00
*--------------------------------------
2019-09-05 15:49:05 +00:00
PrintTraceMsg >STYA ZPPtr3
2020-02-18 15:34:56 +00:00
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
2020-02-28 07:21:46 +00:00
>SYSCALL FPutC
2020-02-18 15:34:56 +00:00
2019-08-27 15:13:00 +00:00
ldy #$ff
.1 iny
lda (ZPPtr3),y
beq .8
2020-02-18 15:34:56 +00:00
2019-08-27 15:13:00 +00:00
cmp #C.CR
beq .8
2020-02-18 15:34:56 +00:00
2019-08-27 15:13:00 +00:00
phy
>PUSHA
ldy #S.PS.hStdErr
lda (pPS),y
2020-02-28 07:21:46 +00:00
>SYSCALL FPutC
2019-08-27 15:13:00 +00:00
ply
bra .1
2020-02-14 07:21:56 +00:00
.8 ldy #S.PS.hStdErr
2019-02-07 07:19:02 +00:00
lda (pPS),y
2020-02-14 07:21:56 +00:00
>PUSHA
2020-02-18 15:34:56 +00:00
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.ECHOCRLF
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL FPrintF
2019-02-07 07:19:02 +00:00
rts
*--------------------------------------
2020-07-31 14:46:11 +00:00
.INB usr/src/bin/csh.s.core
2021-01-12 21:14:13 +00:00
.INB usr/src/bin/csh.s.dir
2020-08-02 12:19:43 +00:00
.INB usr/src/bin/csh.s.kw
.INB usr/src/bin/csh.s.exp
2020-07-31 14:46:11 +00:00
.INB usr/src/bin/csh.s.exec
2019-01-21 06:52:04 +00:00
*--------------------------------------
CS.END
*--------------------------------------
* Initialized DATA
*--------------------------------------
2020-02-28 07:21:46 +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"
2020-01-23 14:48:22 +00:00
MSG.DEBUG .AZ "pStack=%H"
2019-09-05 15:49:05 +00:00
MSG.ERR .AZ "^\r\nLine #%D:"
2019-09-05 06:43:09 +00:00
*--------------------------------------
2020-08-02 12:19:43 +00:00
ENV.INCLUDE .AZ "INCLUDE"
*--------------------------------------
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
*--------------------------------------
2020-07-31 14:46:11 +00:00
.INB usr/src/bin/csh.i
2019-01-21 06:52:04 +00:00
*--------------------------------------
.DUMMY
.OR 0
2020-07-31 14:46:11 +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
2020-07-31 14:46:11 +00:00
SAVE usr/src/bin/csh.s
2019-01-21 06:52:04 +00:00
ASM