A2osX/BIN/SH.S.txt

734 lines
14 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2019-08-15 12:48:58 +00:00
AUTO 3,1
2015-10-19 20:35:00 +00:00
.LIST OFF
2015-03-14 21:48:35 +00:00
.OP 65C02
.OR $2000
2019-12-11 13:14:56 +00:00
.TF bin/sh
2018-11-10 14:30:09 +00:00
*--------------------------------------
2021-04-29 11:56:34 +00:00
HIS.MAX .EQ 10
2019-04-01 06:07:56 +00:00
HISTORY.MAX .EQ 256
2019-04-01 15:24:01 +00:00
CORE.STACK.MAX .EQ 128
2019-07-31 05:42:04 +00:00
PUSHD.STACK.MAX .EQ 4
*--------------------------------------
2019-04-03 11:46:50 +00:00
C... .EQ 0
2019-11-30 13:37:55 +00:00
C.. .EQ 2
C.CD .EQ 4
C.NOHUP .EQ 6
C.DATE .EQ 8
C.ECHO .EQ 10
C.EXIT .EQ 12
C.MD .EQ 14
C.PAUSE .EQ 16
C.PWD .EQ 18
C.RD .EQ 20
C.READ .EQ 22
C.REN .EQ 24
C.SET .EQ 26
C.SLEEP .EQ 28
C.SHIFT .EQ 30
C.PUSHD .EQ 32
C.POPD .EQ 34
C.FUNCTION .EQ 36
C.CALL .EQ 38
C.BREAK .EQ 40
C.SWITCH .EQ 42
C.CASE .EQ 44
C.DEFAULT .EQ 46
2019-10-26 14:33:37 +00:00
*--------------------------------------
2019-11-30 13:37:55 +00:00
C.FOR .EQ 48
2019-03-06 16:29:51 +00:00
C.FOR.LIST .EQ 0
2019-09-18 15:33:00 +00:00
C.FOR.FILEEXEC .EQ 1
2019-11-30 13:37:55 +00:00
C.WHILE .EQ 50
C.IF .EQ 52
C.NEXT .EQ 54
C.LOOP .EQ 56
C.ELSE .EQ 58
C.FI .EQ 60
C.END .EQ 62
2018-11-19 16:15:16 +00:00
*--------------------------------------
2019-08-15 12:48:58 +00:00
C.CLEXEC .EQ 63
2015-03-14 21:48:35 +00:00
*--------------------------------------
2020-05-26 14:23:09 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
2015-03-14 21:48:35 +00:00
*--------------------------------------
2019-01-21 06:52:04 +00:00
.DUMMY
2019-01-18 16:06:44 +00:00
.OR ZPBIN
ZS.START
ZPCLBuf .BS 2
2019-02-06 16:20:51 +00:00
ZPInputBuf .BS 2
2019-02-04 14:29:52 +00:00
ZPInputBufPtr .BS 2
2019-02-06 16:20:51 +00:00
ZPInputCmdPtr .BS 2
2020-07-30 19:00:15 +00:00
2019-01-26 21:46:39 +00:00
ZPArgVBuf .BS 2
2019-02-12 16:47:34 +00:00
ZPArgVBufPrev .BS 2
2019-02-03 21:58:26 +00:00
ZPArgVBufPtr .BS 2
2019-02-06 16:20:51 +00:00
ZPVarNamePtr .BS 2
2019-04-01 06:07:56 +00:00
2019-08-12 07:40:16 +00:00
CORE.PSFlags .BS 1
2019-07-31 15:10:59 +00:00
CORE.IntCmd .BS 1
CORE.Operator .BS 1
CORE.LogicOp .BS 1
CORE.TestResult .BS 1
CORE.PrevTestResult .BS 1
2020-07-30 19:00:15 +00:00
ZPTmpW .BS 2
2019-07-31 15:10:59 +00:00
2019-04-02 15:28:50 +00:00
ZPPtr1 .BS 2
ZPPtr2 .BS 2
2019-08-12 07:40:16 +00:00
M32.ACC .BS 4
2019-10-03 06:25:27 +00:00
ZS.END .ED
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
* File Header (16 Bytes)
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.START cld
jmp (.1,x)
2015-06-03 18:30:57 +00:00
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2018-09-17 06:16:45 +00:00
.DA #S.PS.F.EVENT S.PS.F
.DA #0
2019-01-18 16:06:44 +00:00
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #64 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
2015-06-03 18:30:57 +00:00
.DA 0
*--------------------------------------
* Relocation Table
2015-10-19 20:35:00 +00:00
*--------------------------------------
2015-03-14 21:48:35 +00:00
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
*--------------------------------------
L.MSG.GREETINGS .DA MSG.GREETINGS
2021-05-09 17:04:44 +00:00
L.MSG.HIS .DA MSG.HIS
L.MSG.HISPROMPT .DA MSG.HISPROMPT
L.MSG.HISROMPTCLR .DA MSG.HISROMPTCLR
L.MSG.PROMPT .DA MSG.PROMPT
2019-05-12 20:45:11 +00:00
L.MSG.PROMPTCRLF .DA MSG.PROMPTCRLF
2018-11-10 14:30:09 +00:00
L.MSG.TRACE .DA MSG.TRACE
2018-09-09 08:11:42 +00:00
L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
2019-06-04 15:49:58 +00:00
L.MSG.BATCHLINE .DA MSG.BATCHLINE
2018-11-10 14:30:09 +00:00
L.MSG.BATCHERR .DA MSG.BATCHERR
L.MSG.ERROR .DA MSG.ERROR
L.MSG.PID .DA MSG.PID
L.FMT.DATE .DA FMT.DATE
2019-08-15 12:48:58 +00:00
L.FMT.Long .DA FMT.Long
2019-10-31 13:18:38 +00:00
L.FMT.Byte .DA FMT.Byte
J.ESC .DA CL.BS left arrow
.DA HIS.GetNext
.DA HIS.GetPrev
2019-07-19 06:41:33 +00:00
.DA CL.NAK right arrow
2019-09-17 20:37:52 +00:00
L.CD.. .DA CD..
2019-05-31 07:31:41 +00:00
L.IN .DA IN
2019-02-11 06:58:33 +00:00
L.CMD .DA CMD
2019-04-03 11:46:50 +00:00
J.CMD .DA CMD...
.DA CMD..
2019-02-01 16:32:29 +00:00
.DA CMD.CD
2019-04-03 11:46:50 +00:00
.DA CMD.NOHUP
2019-02-01 16:32:29 +00:00
.DA CMD.DATE
.DA CMD.ECHO
.DA CMD.EXIT
.DA CMD.MD
.DA CMD.PAUSE
.DA CMD.PWD
.DA CMD.RD
.DA CMD.READ
.DA CMD.REN
.DA CMD.SET
.DA CMD.SLEEP
.DA CMD.SHIFT
.DA CMD.PUSHD
.DA CMD.POPD
2019-08-12 07:40:16 +00:00
.DA CMD.FUNCTION
2019-04-01 06:07:56 +00:00
.DA CMD.CALL
2019-03-12 16:50:16 +00:00
.DA CMD.BREAK
2019-03-08 16:36:21 +00:00
.DA CMD.SWITCH
.DA CMD.CASE
.DA CMD.DEFAULT
2019-02-01 16:32:29 +00:00
.DA CMD.FOR
.DA CMD.WHILE
.DA CMD.IF
2019-03-04 16:44:33 +00:00
.DA CMD.NEXT
.DA CMD.LOOP
2019-02-01 16:32:29 +00:00
.DA CMD.ELSE
.DA CMD.FI
2019-05-31 20:04:41 +00:00
.DA CMD.END
2019-02-11 06:58:33 +00:00
L.CORE.IO .DA CORE.IO
J.CORE.IO .DA CORE.IO.AMP
.DA CORE.IO.IN
.DA CORE.IO.OUTA
.DA CORE.IO.OUT
.DA CORE.IO.1OUTA
.DA CORE.IO.1OUT
.DA CORE.IO.2OUTA
.DA CORE.IO.2OUT
2019-02-01 16:32:29 +00:00
L.EXP.BEGIN .DA EXP.BEGIN
L.EXP.OP.UNARY .DA EXP.OP.UNARY
J.EXP.OP.UNARY .DA EXP.OP.UNARY.D
.DA EXP.OP.UNARY.E
.DA EXP.OP.UNARY.F
2019-11-20 10:08:49 +00:00
.DA EXP.OP.UNARY.I
2019-02-14 14:51:24 +00:00
.DA EXP.OP.UNARY.N
2019-11-22 11:25:27 +00:00
.DA EXP.OP.UNARY.X
2019-02-14 14:51:24 +00:00
.DA EXP.OP.UNARY.Z
2019-02-01 16:32:29 +00:00
L.EXP.OP.BINARY .DA EXP.OP.BINARY
L.EXP.OP.MATH .DA EXP.OP.MATH
2019-04-01 06:07:56 +00:00
L.EXP.OP.LOGIC .DA EXP.OP.LOGIC
2019-01-23 16:26:48 +00:00
L.HOME.PROFILE .DA HOME.PROFILE
2020-08-20 13:20:33 +00:00
L.PtrZero .DA PtrZero
2019-08-15 12:48:58 +00:00
L.HOME .DA HOME
2019-04-16 15:54:56 +00:00
L.PS1 .DA PS1
2015-03-14 21:48:35 +00:00
.DA 0
*--------------------------------------
2018-11-10 14:30:09 +00:00
CS.INIT clc
2020-08-11 18:55:28 +00:00
rts
2018-11-10 14:30:09 +00:00
*--------------------------------------
2019-02-01 16:32:29 +00:00
CS.RUN jsr CL.Init
jsr CORE.Init
2019-05-03 13:08:12 +00:00
2018-11-22 16:39:41 +00:00
ldy #S.PS.ARGC
lda (pPS),y
2020-07-30 19:00:15 +00:00
beq .2 no arg, continue starting interactive
2019-02-11 06:58:33 +00:00
2019-04-03 11:46:50 +00:00
lda #$ff
>STA.G bExitOnEOF
2020-07-30 19:00:15 +00:00
inc lda #0
jsr CMD.SHIFTA Remove $0 = /bin/sh
2019-04-02 15:28:50 +00:00
2019-12-20 21:17:17 +00:00
jsr GetArgV
2020-07-30 19:00:15 +00:00
>STYA ZPPtr1
2020-08-11 18:55:28 +00:00
2020-07-30 19:00:15 +00:00
lda (ZPPtr1)
cmp #'-'
bne .1
2019-04-03 11:46:50 +00:00
2020-07-30 19:00:15 +00:00
ldy #1
lda (ZPPtr1),y
2020-08-02 12:19:43 +00:00
cmp #'c'
beq .10
2020-07-30 19:00:15 +00:00
cmp #'C'
bne .1
2020-08-02 12:19:43 +00:00
.10 iny
2020-07-30 19:00:15 +00:00
lda (ZPPtr1),y
bne .1
* lda #0
jsr CMD.SHIFTA Remove $0 = -C
jsr GetArgV
jmp CS.RUN.CMDLINE
2020-08-11 18:55:28 +00:00
.1 jsr GetArgV Load SH batch file
2020-12-15 13:23:22 +00:00
>SYSCALL LoadTxtFile
2020-08-11 18:55:28 +00:00
bcs .9
2019-12-20 21:17:17 +00:00
2020-08-11 18:55:28 +00:00
phx X = loaded file hMem
jsr GetArgV Y,A = Args
plx
jsr CMD..EXEC.YAX Execute . Batch file
bcc CS.RUN.LOOP
.9 rts
2019-05-03 13:08:12 +00:00
*--------------------------------------
2020-07-30 19:00:15 +00:00
.2 jsr CMD.CD.HOME
2018-11-21 13:08:11 +00:00
jsr HIS.Init
2020-08-11 18:55:28 +00:00
bcs .9
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.GREETINGS
2021-03-17 19:49:39 +00:00
>PUSHW A2osX.KVER
2018-08-22 15:23:27 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-08-11 18:55:28 +00:00
bcs .9
2019-07-19 14:05:22 +00:00
2019-01-23 16:26:48 +00:00
>LDYA L.HOME.PROFILE
2020-12-15 13:23:22 +00:00
>SYSCALL LoadTxtFile
2019-08-15 12:48:58 +00:00
bcs CS.RUN.LOOP No profile...
2019-04-01 06:07:56 +00:00
2019-01-23 22:03:10 +00:00
>LDYA L.HOME.PROFILE
2020-08-11 18:55:28 +00:00
jsr CMD..EXEC.YAX Execute . ${home}profile
2015-03-14 21:48:35 +00:00
*--------------------------------------
2019-02-21 14:34:35 +00:00
CS.RUN.LOOP >SLEEP
2019-02-21 14:34:35 +00:00
.1 jsr CheckSleep
2019-08-15 12:48:58 +00:00
beq .2
2019-04-03 15:52:24 +00:00
2019-02-21 16:26:21 +00:00
ldy #S.PS.hStdIn
lda (pPS),y
2020-03-09 16:24:08 +00:00
>SYSCALL FEOF
2019-02-21 14:34:35 +00:00
bcs .9
2021-03-17 19:49:39 +00:00
2019-02-21 14:34:35 +00:00
tay
2019-06-01 11:59:41 +00:00
bne CS.RUN.LOOP
2021-05-14 20:58:20 +00:00
2019-02-21 14:34:35 +00:00
>SYSCALL GetChar
bcs .9 I/O err
2021-03-17 19:49:39 +00:00
2019-02-21 14:34:35 +00:00
cmp #3 Ctrl-C
2019-08-15 12:48:58 +00:00
bne .11
2021-03-17 19:49:39 +00:00
2019-04-05 05:59:06 +00:00
lda (pData) batch mode ?
2019-02-21 14:34:35 +00:00
beq CS.RUN.LOOP
2021-03-17 19:49:39 +00:00
2019-02-21 14:34:35 +00:00
>LDA.G bSET.C
beq .8
2021-03-17 19:49:39 +00:00
2019-02-21 14:34:35 +00:00
bra CS.RUN.LOOP
2021-03-17 19:49:39 +00:00
2019-08-15 12:48:58 +00:00
.11 cmp #19 test Ctrl-s
bne CS.RUN.LOOP
2019-08-15 12:48:58 +00:00
lda #$80
>STA.G bPause
2019-10-03 06:25:27 +00:00
bra CS.RUN.LOOP
2019-08-15 12:48:58 +00:00
*--------------------------------------
.8 lda #3 User Interrupt
sec
.9 rts
*--------------------------------------
.2 >LDA.G bPause
2018-11-12 14:48:28 +00:00
bpl .6
2019-10-18 11:41:27 +00:00
2019-08-15 12:48:58 +00:00
.3 >SYSCALL GetChar
2019-02-20 06:30:36 +00:00
bcs .9 I/O err
2019-10-18 11:41:27 +00:00
2019-08-15 12:48:58 +00:00
cmp #3 Ctrl-C
bne .4
2019-10-18 15:07:14 +00:00
2019-04-05 05:59:06 +00:00
lda (pData) batch mode ?
2019-08-15 12:48:58 +00:00
beq .5
2019-10-18 11:41:27 +00:00
2019-01-23 16:26:48 +00:00
>LDA.G bSET.C
beq .8
2019-10-18 11:41:27 +00:00
2019-08-15 12:48:58 +00:00
bra .5
2019-10-18 11:41:27 +00:00
2019-08-15 12:48:58 +00:00
.4 tax
2019-05-02 15:59:11 +00:00
>LDA.G bPause
2019-08-15 12:48:58 +00:00
asl $ff ?
bpl .5 not from PAUSE command
2019-10-18 11:41:27 +00:00
2019-05-02 15:59:11 +00:00
cpx #C.CR
2019-10-18 15:07:14 +00:00
bne .5
jsr CheckLFAfterCR Check for any extra LF
bcs .9
2019-10-18 11:41:27 +00:00
2019-08-15 12:48:58 +00:00
.5 >STZ.G bPause
*--------------------------------------
.6 lda (pData) batch mode ?
bne CS.RUN.BATCH
2018-11-10 14:30:09 +00:00
*--------------------------------------
2018-12-03 06:59:30 +00:00
CS.RUN.INTERACTIVE
2019-08-15 12:48:58 +00:00
jsr IO.Reset
2019-02-26 16:50:42 +00:00
jsr CL.Reset
2019-08-15 12:48:58 +00:00
2021-05-11 18:44:13 +00:00
jsr CL.ReadResetV
2018-09-25 06:25:32 +00:00
jsr CL.PrintPrompt
2020-07-30 19:00:15 +00:00
bcs CS.RUN.CMDLINE.9
2021-03-17 19:49:39 +00:00
2019-02-20 06:30:36 +00:00
.1 >SYSCALL GetChar
2020-07-30 19:00:15 +00:00
bcs CS.RUN.CMDLINE.9 I/O error
2021-03-17 19:49:39 +00:00
2018-11-12 14:48:28 +00:00
.2 cmp #C.EOF ....or Ctrl-D
2020-07-30 19:00:15 +00:00
beq CS.RUN.CMDLINE.9 CS
2018-09-19 15:25:42 +00:00
2018-07-19 15:33:55 +00:00
jsr CL.CHARIN
2017-01-12 17:43:45 +00:00
2020-07-30 19:00:15 +00:00
>LDA.G CL.bReady Something to execute ?
2015-06-24 20:41:38 +00:00
bpl .1
2020-01-20 15:24:53 +00:00
2020-02-14 07:21:56 +00:00
>PUSHW L.MSG.PROMPTCRLF
2019-02-18 12:52:10 +00:00
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-07-30 19:00:15 +00:00
bcs CS.RUN.CMDLINE.9
2021-03-17 19:49:39 +00:00
lda (ZPCLBuf)
2021-03-17 19:49:39 +00:00
beq CS.RUN.LOOP.END Empty line
2018-10-29 08:41:10 +00:00
2018-10-23 15:36:57 +00:00
jsr HIS.Add
2019-02-04 14:29:52 +00:00
>LDYA ZPCLBuf
2020-07-30 19:00:15 +00:00
CS.RUN.CMDLINE >SYSCALL StrDup
2021-03-17 19:49:39 +00:00
bcs CS.RUN.CMDLINE.9
2019-12-20 21:17:17 +00:00
2020-08-11 18:55:28 +00:00
phx
jsr GetArgV
plx Y,A=ARGV, X=strdup
2019-12-20 21:17:17 +00:00
2019-08-15 12:48:58 +00:00
jsr CORE.Load.YAX Exec CL
2020-07-30 19:00:15 +00:00
bcs CS.RUN.CMDLINE.9
2021-03-17 19:49:39 +00:00
2019-08-15 12:48:58 +00:00
lda #$C0+C.CLEXEC
jsr CORE.StkPush
2019-02-04 14:29:52 +00:00
2021-03-17 19:49:39 +00:00
bra CS.RUN.LOOP.RUN
2019-02-20 06:30:36 +00:00
2020-07-30 19:00:15 +00:00
CS.RUN.CMDLINE.9
rts
*--------------------------------------
2019-08-15 12:48:58 +00:00
CS.RUN.BATCH >LDA.G bSET.X
2021-03-17 19:49:39 +00:00
beq CS.RUN.LOOP.RUN
2018-12-03 06:59:30 +00:00
2019-02-11 16:44:56 +00:00
ldy #$ff
2020-01-20 15:24:53 +00:00
2019-02-11 16:44:56 +00:00
.3 iny
lda (ZPInputBufPtr),y
2020-01-20 15:24:53 +00:00
sta (ZPCLBuf),y
2019-02-11 16:44:56 +00:00
beq .4
2020-01-06 07:03:37 +00:00
2019-02-11 16:44:56 +00:00
eor #C.CR
bne .3
2020-01-06 07:03:37 +00:00
2020-01-20 15:24:53 +00:00
sta (ZPCLBuf),y
2020-01-06 07:03:37 +00:00
2020-02-14 07:21:56 +00:00
.4 >PUSHW L.MSG.TRACE
>PUSHW ZPCLBuf
2019-02-11 16:44:56 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-02-20 16:07:43 +00:00
bcs CS.RUN.LOOP.RTS
2019-02-01 16:32:29 +00:00
2021-03-17 19:49:39 +00:00
CS.RUN.LOOP.RUN jsr CORE.Run
2019-11-30 13:37:55 +00:00
2018-11-10 14:30:09 +00:00
CS.RUN.LOOP.END ldy #S.PS.RC
2020-02-28 07:21:46 +00:00
sta (pPS),y
2019-04-05 13:02:42 +00:00
bcc CS.RUN.LOOP.80
2019-02-04 14:29:52 +00:00
tay
2019-08-15 12:48:58 +00:00
beq CS.RUN.LOOP.80 0 = EOF
2019-04-05 13:02:42 +00:00
2019-04-02 15:28:50 +00:00
>LDA.G bSET.E
2019-04-05 13:02:42 +00:00
bmi CS.RUN.LOOP.80
2019-08-15 12:48:58 +00:00
2019-11-30 13:37:55 +00:00
.1 jsr CORE.StkGet
2019-08-15 12:48:58 +00:00
cmp #$C0+C.CLEXEC
2019-11-30 13:37:55 +00:00
beq .8
cmp #$C0+C.. in . ?
beq .7
cmp #$C0+C.CALL in CALL ?
beq .7
jsr CORE.StkPopCtx
bcc .1
.7 jsr IO.PrintBatchErrMsg
2018-11-10 14:30:09 +00:00
bcs CS.RUN.LOOP.RTS
2019-11-30 13:37:55 +00:00
jsr CORE.StkPull
jsr CMD.EXIT.FILE
.8 jsr IO.PrintErrMsg
2018-11-10 14:30:09 +00:00
bcs CS.RUN.LOOP.RTS
2019-04-05 13:02:42 +00:00
2019-08-12 07:40:16 +00:00
CS.RUN.LOOP.80 lda (pData) something on stack ?
2019-11-30 13:37:55 +00:00
bne CS.RUN.LOOP.88
2019-04-05 13:02:42 +00:00
>LDA.G bExitOnEOF
bmi CS.RUN.LOOP.EXIT
2019-11-30 13:37:55 +00:00
CS.RUN.LOOP.88 jmp CS.RUN.LOOP
2019-04-05 13:02:42 +00:00
CS.RUN.LOOP.EXIT
2018-12-05 15:12:10 +00:00
ldy #S.PS.RC
2020-02-28 07:21:46 +00:00
lda (pPS),y
sec
2018-11-10 14:30:09 +00:00
CS.RUN.LOOP.RTS rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9
jsr CheckSleep
beq .9
* ldy #Sleep already set by CheckSleep
2018-11-12 14:48:28 +00:00
ldx #4
clc
.1 lda (pData),y
sbc #0
sta (pData),y
iny
2018-11-12 14:48:28 +00:00
dex
bne .1
.9 sec
2015-12-13 21:29:51 +00:00
rts
2017-01-12 17:43:45 +00:00
*--------------------------------------
2019-12-20 21:17:17 +00:00
CS.QUIT jsr CORE.FUNCRESET
2019-08-15 12:48:58 +00:00
2020-02-02 18:24:40 +00:00
>LDA.G HIS.hBuf
beq .1
>SYSCALL FreeStkObj
2019-12-20 21:17:17 +00:00
2021-05-14 20:58:20 +00:00
.1 ldy #CL.hBuf
2019-12-20 21:17:17 +00:00
jsr .7
2020-08-17 13:03:39 +00:00
.2 jsr CMD.POPD
bcc .2
2019-12-20 21:17:17 +00:00
ldy #CORE.hArgVBuf
.7 lda (pData),y
beq .8
>SYSCALL FreeMem
.8 clc
rts
*--------------------------------------
2020-08-11 18:55:28 +00:00
GetCWD ldy #S.PS.hCWD
2019-12-20 21:17:17 +00:00
bra GetArgV.1
*--------------------------------------
2020-08-11 18:55:28 +00:00
GetArgV ldy #S.PS.hARGV
2019-12-20 21:17:17 +00:00
GetArgV.1 lda (pPS),y
>SYSCALL GetMemPtr
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
2019-10-18 15:07:14 +00:00
CheckLFAfterCR ldy #S.PS.hStdIn Check for any extra LF
lda (pPS),y
2020-03-09 16:24:08 +00:00
>SYSCALL FEOF
2019-10-18 15:07:14 +00:00
bcs .9
tay
bne .9
>SYSCALL GetChar
.9 rts
*--------------------------------------
CheckSleep ldy #Sleep+3
lda (pData),y
dey
ora (pData),y
dey
ora (pData),y
dey
ora (pData),y
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2020-01-06 07:03:37 +00:00
GetPtr1NextChar lda (ZPPtr1)
2019-07-31 15:10:59 +00:00
beq IncPtr1.8
IncPtr1 inc ZPPtr1
bne IncPtr1.8
2019-07-31 05:42:04 +00:00
inc ZPPtr1+1
2019-10-03 06:25:27 +00:00
IncPtr1.8 rts
2019-07-31 05:42:04 +00:00
*--------------------------------------
2019-08-05 13:30:58 +00:00
GetPtr1LenY ldy #$ff
2019-07-31 05:42:04 +00:00
.1 iny
lda (ZPPtr1),y
bne .1
rts
*--------------------------------------
2020-01-06 07:03:37 +00:00
GetPtr1NextString
jsr GetPtr1LenY
*--------------------------------------
2020-02-06 16:23:59 +00:00
tya
2019-07-31 15:10:59 +00:00
AddAp1Ptr1 sec
2020-02-06 16:23:59 +00:00
2019-07-31 05:42:04 +00:00
adc ZPPtr1
sta ZPPtr1
bcc .8
inc ZPPtr1+1
.8 rts
*--------------------------------------
2019-03-05 16:49:34 +00:00
ToUpperCase cmp #'a'
bcc .8
cmp #'z'+1
bcs .8
eor #$20
.8 clc exit CC to allow Jmp to
rts
2020-01-08 07:13:42 +00:00
*--------------------------------------
IncPStack4 inc pStack
IncPStack3 inc pStack
inc pStack
inc pStack
rts
*--------------------------------------
2020-05-26 14:23:09 +00:00
.INB usr/src/bin/sh.s.cl
.INB usr/src/bin/sh.s.his
.INB usr/src/bin/sh.s.core
.INB usr/src/bin/sh.s.io
.INB usr/src/bin/sh.s.cmd
.INB usr/src/bin/sh.s.exp
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.END
*--------------------------------------
2019-02-08 16:13:43 +00:00
MSG.GREETINGS .AZ "\r\nA2osX-SH %d.%d\r\n\r\n"
2021-05-09 17:04:44 +00:00
MSG.HIS .AZ "\r\n%3d : %s"
MSG.HISPROMPT .AZ "\r\n\r\n? "
2021-05-14 20:58:20 +00:00
MSG.HISROMPTCLR .DA #C.BS,#C.BS,#0
2019-10-11 20:05:54 +00:00
MSG.PROMPT .AZ "\e[?7h$ " Enable Line Wrap
MSG.PROMPTCRLF .AZ "\e[?7l\r\n" Disable Line Wrap
2019-06-04 15:49:58 +00:00
MSG.TRACE .AS ">"
MSG.BATCHLINE .AZ "%s\r\n"
MSG.BATCHERR .AZ "%s^\r\nLine #%D:"
2020-05-17 17:34:32 +00:00
MSG.ERROR .AS "[$%h]:%s."
2018-11-27 21:26:03 +00:00
MSG.ECHOCRLF .AZ "\r\n"
MSG.PID .AZ "PID=%d\r\n"
2019-10-26 14:33:37 +00:00
FMT.DATE .AZ "%A, %B %d %Y %H:%M:%S"
2019-08-15 12:48:58 +00:00
FMT.Long .AZ "%L"
2019-10-31 13:18:38 +00:00
FMT.Byte .AZ "%d"
2018-09-17 06:16:45 +00:00
*--------------------------------------
2019-12-11 13:14:56 +00:00
HOME.PROFILE .AZ "${HOME}profile"
2020-08-20 13:20:33 +00:00
PtrZero .HS 00 To Make It ArgV
2019-08-15 12:48:58 +00:00
PS1 .AZ "${PS1}"
HOME .AZ "${HOME}"
*--------------------------------------
2019-07-31 15:10:59 +00:00
EscChars .AS 'DBAC'
EscChars.Cnt .EQ *-EscChars
EscChars.Remap .DA #C.BS,#C.VT,#C.LF,#C.FS
*--------------------------------------
2020-12-15 13:23:22 +00:00
DEV .AS "/dev/"
*--------------------------------------
2019-09-17 20:37:52 +00:00
CD.. .AZ ".."
*--------------------------------------
2019-05-31 07:31:41 +00:00
IN .AZ "IN"
*--------------------------------------
2019-08-15 12:48:58 +00:00
CMD .AT ".."
.AT "."
.AT "CD"
.AT "NOHUP"
.AT "DATE"
.AT "ECHO"
.AT "EXIT"
.AT "MD"
.AT "PAUSE"
.AT "PWD"
.AT "RD"
.AT "READ"
.AT "REN"
.AT "SET"
.AT "SLEEP"
.AT "SHIFT"
.AT "PUSHD"
.AT "POPD"
.AT "FUNCTION"
.AT "CALL"
.AT "BREAK"
.AT "SWITCH"
.AT "CASE"
.AT "DEFAULT"
.AT "FOR"
.AT "WHILE"
.AT "IF"
.AT "NEXT"
.AT "LOOP"
.AT "ELSE"
.AT "FI"
.AT "END"
2015-10-19 20:35:00 +00:00
.HS 00
2019-08-15 12:48:58 +00:00
CORE.IO .AT "&"
.AT "<"
.AT ">>"
.AT ">"
.AT "1>>"
.AT "1>"
.AT "2>>"
.AT "2>"
2019-02-07 16:52:25 +00:00
.HS 00
2019-08-15 12:48:58 +00:00
EXP.BEGIN .AT "!["
.AT "["
2018-11-09 15:59:04 +00:00
.HS 00
2019-08-15 12:48:58 +00:00
EXP.OP.UNARY .AT "-D"
.AT "-E"
.AT "-F"
2019-11-20 10:08:49 +00:00
.AT "-I"
2019-08-15 12:48:58 +00:00
.AT "-N"
2019-11-22 11:25:27 +00:00
.AT "-X"
2019-08-15 12:48:58 +00:00
.AT "-Z"
2018-11-09 15:59:04 +00:00
.HS 00
2021-05-04 17:31:21 +00:00
EXP.OP.BINARY .AT "-LT"
.AT "-LE"
.AT "-GT"
.AT "-GE"
.AT "-EQ"
.AT "-NE"
2019-08-15 12:48:58 +00:00
.AT ".<"
.AT "<="
.AT ".>"
.AT ">="
2021-05-09 17:04:44 +00:00
.AT "="
.AT "!="
.HS 00
2021-05-04 17:31:21 +00:00
EXP.OP.MATH .AT "*"
2019-08-15 12:48:58 +00:00
.AT "/"
.AT "MOD"
2021-05-04 17:31:21 +00:00
.AT "+"
.AT "-"
2019-08-15 12:48:58 +00:00
.HS 00
EXP.OP.LOGIC .AT "AND"
.AT "OR"
.HS 00
*--------------------------------------
2019-02-01 16:32:29 +00:00
EXP.OP.BINARY.BITS
2018-11-26 10:40:19 +00:00
.DA #%100
.DA #%110
.DA #%001
.DA #%011
2021-05-09 17:04:44 +00:00
.DA #%010
.DA #%101
*--------------------------------------
2021-05-04 17:31:21 +00:00
EXP.OP.MATH.FPU .DA #FPU.lMUL,#FPU.lDIV,#FPU.lMOD,#FPU.lADD,#FPU.lSUB
2020-01-20 15:24:53 +00:00
*--------------------------------------
SET.FLAGS .AS "CXE"
SET.VARS .DA #bSET.C,#bSET.X,#bSET.E
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
.DUMMY
.OR 0
2015-03-14 21:48:35 +00:00
DS.START
2019-01-30 16:23:00 +00:00
CORE.STACK .BS CORE.STACK.MAX+1 pData (0 = Stack Ptr)
2018-11-26 06:57:11 +00:00
PUSHD.STACK .BS PUSHD.STACK.MAX+1
2018-11-19 16:15:16 +00:00
2019-03-13 16:29:24 +00:00
hFuncList .BS 1
2019-04-01 06:07:56 +00:00
bExitOnEOF .BS 1
2019-02-06 16:20:51 +00:00
bPause .BS 1
2019-02-12 16:47:34 +00:00
2019-01-23 16:26:48 +00:00
bSET.C .BS 1
2019-04-02 15:28:50 +00:00
bSET.E .BS 1
2018-10-16 15:48:03 +00:00
bSET.X .BS 1
2019-02-12 16:47:34 +00:00
Sleep .BS 4
2021-05-14 20:58:20 +00:00
CL.hBuf .BS 1
2021-05-11 18:44:13 +00:00
2018-11-10 14:30:09 +00:00
CL.Ptr .BS 1
CL.Len .BS 1
2019-02-06 16:20:51 +00:00
CL.bReady .BS 1
2019-10-31 13:18:38 +00:00
CL.bEscMode .BS 1
2021-05-11 18:44:13 +00:00
CL.MaxCnt .BS 1
CL.bSilent .BS 1
2018-11-10 14:30:09 +00:00
2019-01-30 16:23:00 +00:00
CORE.hArgVBuf .BS 1
2019-10-26 14:33:37 +00:00
CORE.bPipeIn .BS 1
CORE.bPipeOut .BS 1
2018-10-15 06:25:40 +00:00
HIS.hBuf .BS 1
HIS.Count .BS 1
HIS.Index .BS 1
2021-04-29 11:56:34 +00:00
HIS.LRU .BS 1
IO.hIn .BS 1
IO.hOut .BS 1
IO.hErr .BS 1
2019-06-02 08:58:46 +00:00
2020-07-30 19:00:15 +00:00
*TimeBuf .BS S.TIME 8 bytes
2019-07-31 15:10:59 +00:00
*M32.BUF .BS 12 -1234567890\0
2020-01-07 13:44:38 +00:00
TimeBuf .EQ *
2019-06-02 08:58:46 +00:00
M32.BUF .EQ *
2020-12-15 13:23:22 +00:00
IO.DEVFIFO .BS 12 /dev/fifoXX\0
2019-01-21 06:52:04 +00:00
*--------------------------------------
DS.END .ED
2015-03-14 21:48:35 +00:00
*--------------------------------------
MAN
2020-08-09 19:47:42 +00:00
SAVE usr/src/bin/sh.s
2015-03-14 21:48:35 +00:00
ASM