A2osX/BIN/CSH.S.txt

855 lines
18 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
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.T.VOID .EQ 1
CSH.T.UCHAR .EQ 2
CSH.T.SCHAR .EQ 3
CSH.T.UINT .EQ 4
CSH.T.SINT .EQ 5
CSH.T.ULONG .EQ 6
CSH.T.SLONG .EQ 7
CSH.T.FLOAT .EQ 8
2021-05-04 17:31:21 +00:00
CSH.T.VARIADIC .EQ $FF
*--------------------------------------
CSH.Q.POINTER .EQ %01000000
CSH.Q.PPOINTER .EQ %10000000
CSH.Q.PPPOINTER .EQ %11000000
CSH.Q.CONST .EQ %00010000
CSH.Q.FUNC .EQ %00001000
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
2021-05-30 20:34:03 +00:00
ZPCSHfDecl .BS 2
ZPInputBufPtr .BS 2
hDefine .BS 1
hInclude .BS 1
2020-07-31 14:46:11 +00:00
ZPVarID .BS 2
2021-05-30 20:34:03 +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
2021-05-30 20:34:03 +00:00
ZPVarDefPtr .BS 2
2019-08-26 06:29:18 +00:00
2021-05-30 20:34:03 +00:00
ArgIndex .BS 1
2020-12-23 14:54:57 +00:00
bFastCall .BS 1
2020-02-19 16:42:05 +00:00
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPPtr3 .BS 2
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
2021-04-10 17:17:40 +00:00
L.CSH.BOPS .DA CSH.BOPS
2021-05-09 17:04:44 +00:00
J.CSH.bBOPS .DA CSH.BOPS.bMUL
.DA CSH.BOPS.bDIV
.DA CSH.BOPS.bMOD
.DA CSH.BOPS.ADD
.DA CSH.BOPS.SUB
.DA CSH.BOPS.SHL
.DA CSH.BOPS.SHR
.DA CSH.BOPS.L
.DA CSH.BOPS.LE
.DA CSH.BOPS.G
.DA CSH.BOPS.GE
.DA CSH.BOPS.EQ
.DA CSH.BOPS.NE
.DA CSH.BOPS.AND
.DA CSH.BOPS.OR
.DA CSH.BOPS.EOR
.DA CSH.BOPS.LAND
.DA CSH.BOPS.LOR
J.CSH.cBOPS .DA CSH.BOPS.cMUL
.DA CSH.BOPS.cDIV
.DA CSH.BOPS.cMOD
2021-05-04 17:31:21 +00:00
.DA CSH.BOPS.ADD
.DA CSH.BOPS.SUB
2021-04-10 17:17:40 +00:00
.DA CSH.BOPS.SHL
.DA CSH.BOPS.SHR
.DA CSH.BOPS.L
.DA CSH.BOPS.LE
2021-05-04 17:31:21 +00:00
.DA CSH.BOPS.G
2021-04-10 17:17:40 +00:00
.DA CSH.BOPS.GE
.DA CSH.BOPS.EQ
.DA CSH.BOPS.NE
.DA CSH.BOPS.AND
.DA CSH.BOPS.OR
.DA CSH.BOPS.EOR
.DA CSH.BOPS.LAND
.DA CSH.BOPS.LOR
L.CSH.FN .DA CSH.FN
L.CSH.DIRS .DA CSH.DIRS
L.CSH.KW .DA CSH.KW
2021-05-22 21:05:12 +00:00
L.CSH.TMODS .DA CSH.TMODS
L.CSH.TMODS2 .DA CSH.TMODS2
2021-04-10 17:17:40 +00:00
L.CSH.TYPES .DA CSH.TYPES
L.CSH.FTYPES .DA CSH.FTYPES
J.CSH.DIRS .DA CSH.DIR.DEFINE
.DA CSH.DIR.INCLUDE
J.CSH.KW .DA CSH.IF
.DA CSH.WHILE
.DA CSH.ELSE
.DA CSH.DO
.DA CSH.FOR
.DA CSH.SWITCH
.DA CSH.CASE
.DA CSH.BREAK
.DA CSH.CONTINUE
.DA CSH.SIZEOF
*--------------------------------------
.DA CSH.TYPEDEF
.DA CSH.STRUCT
*--------------------------------------
2021-05-22 21:05:12 +00:00
J.CSH.TMODS .DA CSH.CONST
J.CSH.TMODS2 .DA CSH.SIGNED
2021-04-10 17:17:40 +00:00
.DA CSH.UNSIGNED
.DA CSH.SHORT
J.CSH.TYPES .DA CSH.VOID
.DA CSH.CHAR
.DA CSH.INT
.DA CSH.LONG
.DA CSH.FLOAT
J.CSH.UTYPES .DA CSH.UCHAR
.DA CSH.UINT
.DA CSH.ULONG
J.CSH.STYPES .DA CSH.SCHAR
.DA CSH.SINT
.DA CSH.SLONG
2021-05-30 20:34:03 +00:00
*--------------------------------------
2021-04-10 17:17:40 +00:00
J.CSH.KW.END .DA CSH.IF.END
.DA CSH.WHILE.END
*--------------------------------------
2021-05-30 20:34:03 +00:00
L.CSH.LIBC .DA CSH.LIBC
*--------------------------------------
2021-05-14 20:58:20 +00:00
J.CSH.EXEC .DA EXEC.pwr
.DA EXEC.log
2021-04-10 17:17:40 +00:00
.DA EXEC.sqr
.DA EXEC.exp
.DA EXEC.cos
.DA EXEC.sin
.DA EXEC.tan
.DA EXEC.atan
.DA EXEC.getchar
.DA EXEC.puts
.DA EXEC.execl
.DA EXEC.printf
.DA EXEC.putenv
.DA EXEC.setenv
.DA EXEC.getenv
.DA EXEC.unsetenv
.DA EXEC.MD5
.DA EXEC.malloc
2021-05-14 20:58:20 +00:00
.DA EXEC.fopen
.DA EXEC.fclose
.DA EXEC.fread
.DA EXEC.fwrite
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
*--------------------------------------
2021-05-30 20:34:03 +00:00
CS.RUN.ARGS inc ArgIndex
2019-09-05 15:49:05 +00:00
lda ArgIndex
2020-02-28 07:21:46 +00:00
>SYSCALL ArgV
2019-09-05 15:49:05 +00:00
bcs .7
2021-05-30 20:34:03 +00:00
2019-09-05 15:49:05 +00:00
>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
2021-05-30 20:34:03 +00:00
2020-12-23 14:54:57 +00:00
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
2021-05-30 20:34:03 +00:00
2021-01-12 21:14:13 +00:00
.10 lda hInclude
beq .11
2021-05-30 20:34:03 +00:00
2021-01-12 21:14:13 +00:00
bra .12
.11 >LDA.G hFileBuf
.12 >SYSCALL GetMemPtr
2019-02-07 07:19:02 +00:00
>STYA ZPPtr1
2021-05-30 20:34:03 +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
2021-05-30 20:34:03 +00:00
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
2021-05-30 20:34:03 +00:00
2019-02-07 07:19:02 +00:00
inc ZPPtr1+1
.3 cmp #C.CR
2019-08-27 15:13:00 +00:00
bne .20 Scan until EoL
2021-05-30 20:34:03 +00:00
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
2021-05-30 20:34:03 +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
2021-05-30 20:34:03 +00:00
cmp ZPInputBufPtr+1
2019-08-27 15:13:00 +00:00
beq .8
2020-12-23 14:54:57 +00:00
2021-05-14 20:58:20 +00:00
.6 ldy #S.PS.hStdErr
2019-02-07 07:19:02 +00:00
lda (pPS),y
2021-05-14 20:58:20 +00:00
>PUSHA
>PUSHBI '-'
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
2021-05-30 20:34:03 +00:00
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
2021-05-30 20:34:03 +00:00
2020-02-21 13:24:16 +00:00
>PUSHW ZPPtr2
2021-05-30 20:34:03 +00:00
2019-09-03 15:35:13 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2021-06-03 17:43:28 +00:00
>DEBUG
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
2021-05-14 20:58:20 +00:00
PrintTraceMsg.3 ldy #S.PS.hStdErr
2019-02-07 07:19:02 +00:00
lda (pPS),y
2021-05-14 20:58:20 +00:00
>PUSHA
>PUSHBI '>'
2020-02-28 07:21:46 +00:00
>SYSCALL FPutC
2021-05-30 20:34:03 +00:00
2019-08-27 15:13:00 +00:00
ldy #$ff
.1 iny
lda (ZPPtr3),y
beq .8
2021-05-30 20:34:03 +00:00
2019-08-27 15:13:00 +00:00
cmp #C.CR
beq .8
2021-05-30 20:34:03 +00:00
2019-08-27 15:13:00 +00:00
phy
2021-05-14 20:58:20 +00:00
pha
2019-08-27 15:13:00 +00:00
ldy #S.PS.hStdErr
lda (pPS),y
2021-05-14 20:58:20 +00:00
>PUSHA
pla
>PUSHA
2020-02-28 07:21:46 +00:00
>SYSCALL FPutC
2019-08-27 15:13:00 +00:00
ply
bra .1
2021-05-30 20:34:03 +00:00
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
2021-05-30 20:34:03 +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"
2021-05-30 20:34:03 +00:00
MSG.DEBUG .AZ "pStack=%H\r\n"
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
*--------------------------------------
2021-04-10 17:17:40 +00:00
*--------------------------------------
CSH.OPChars .AS "!~+-*/%=&|^<>"
CSH.OPChars.Cnt .EQ *-CSH.OPChars
*--------------------------------------
* Pre Operators: + - ! ~ ++ --
*--------------------------------------
CSH.PREOPS >PSTR "+"
>PSTR "-"
>PSTR "!"
>PSTR "~"
*--------------------------------------
2021-05-30 20:34:03 +00:00
* Post Operators: ++ --
2021-04-10 17:17:40 +00:00
*--------------------------------------
CSH.POSTOPS >PSTR "++"
>PSTR "--"
.HS 00
*--------------------------------------
* Assignment Operators: = += -= *= /= %= <<= >>= &= ^= |=
*--------------------------------------
CSH.AOPS >PSTR "="
>PSTR "+="
>PSTR "-="
>PSTR "*="
>PSTR "/="
>PSTR "%="
>PSTR "<<="
>PSTR ">>="
>PSTR "&="
>PSTR "^="
>PSTR "!="
.HS 00
*-- Binary ---- H to L precedence -----
* Arithmetic Operators: * / %
* Arithmetic Operators: + -
* Shift Operators: << >>
* Relational Operators: < > >= < >= == !=
* Bitwise Operators: & | ^ ~
* Logical Operators: && ||
*--------------------------------------
2021-05-04 17:31:21 +00:00
CSH.BOPS >PSTR "*"
2021-04-10 17:17:40 +00:00
>PSTR "/"
>PSTR "%"
2021-05-04 17:31:21 +00:00
>PSTR "+"
>PSTR "-"
2021-04-10 17:17:40 +00:00
>PSTR "<<"
>PSTR ">>"
>PSTR "<"
>PSTR "<="
2021-05-04 17:31:21 +00:00
>PSTR ">"
2021-04-10 17:17:40 +00:00
>PSTR ">="
>PSTR "=="
>PSTR "!="
>PSTR "&"
>PSTR "|"
>PSTR "^"
>PSTR "&&"
>PSTR "||"
.HS 00
*--------------------------------------
* Reserved Directives:
*--------------------------------------
CSH.DIRS >PSTR "define"
>PSTR "include"
.HS 00
*--------------------------------------
* Reserved Keywords:
*--------------------------------------
CSH.KW >PSTR "if"
>PSTR "while"
>PSTR "else"
>PSTR "do"
>PSTR "for"
>PSTR "switch"
>PSTR "case"
>PSTR "break"
>PSTR "continue"
>PSTR "sizeof"
>PSTR "typedef"
>PSTR "struct"
2021-05-22 21:05:12 +00:00
.HS 00
*--------------------------------------
* Type Declaration
*--------------------------------------
CSH.TMODS >PSTR "const" ALL
CSH.TMODS2 >PSTR "signed" char,int,long
2021-04-10 17:17:40 +00:00
>PSTR "unsigned" char,int,long
>PSTR "short" int
CSH.TYPES >PSTR "void"
>PSTR "char"
>PSTR "int"
>PSTR "long"
>PSTR "float"
.HS 00
*--------------------------------------
2021-05-09 17:04:44 +00:00
CSH.Type2FPU .DA #FPU.wMUL,#FPU.iMUL,#FPU.uMUL,#FPU.lMUL,FPU.fMUL
*--------------------------------------
2021-04-10 17:17:40 +00:00
CSH.FTYPES >PSTR "fastcall"
* .HS 00
*--------------------------------------
2021-05-04 17:31:21 +00:00
CSH.TYPESIZE .HS 0001010202040405
2021-04-10 17:17:40 +00:00
*--------------------------------------
2021-05-30 20:34:03 +00:00
CSH.LIBC >PSTR "chtyp"
>PSTR "chmod"
>PSTR "fstat"
>PSTR "stat"
>PSTR "mkdir"
>PSTR "mknod"
>PSTR "mkfifo"
>PSTR "pipe"
>PSTR "opendir"
>PSTR "readdir"
>PSTR "closedir"
>PSTR "open"
>PSTR "close"
>PSTR "read"
>PSTR "write"
>PSTR "chown"
>PSTR "fputc"
>PSTR "putchar"
>PSTR "getc"
>PSTR "getchar"
>PSTR "fputs"
>PSTR "puts"
>PSTR "fgets"
>PSTR "ungetc"
>PSTR "fopen"
>PSTR "fclose"
>PSTR "fread"
>PSTR "fwrite"
>PSTR "fflush"
>PSTR "fseek"
>PSTR "ftell"
>PSTR "feof"
>PSTR "remove"
>PSTR "rename"
>PSTR "printf"
>PSTR "fprintf"
>PSTR "sprintf"
>PSTR "scanf"
>PSTR "fscanf"
>PSTR "sscanf"
>PSTR "$50"
>PSTR "$52"
>PSTR "$54"
>PSTR "$56"
>PSTR "$58"
>PSTR "$5A"
>PSTR "$5C"
>PSTR "setattr"
>PSTR "mount"
>PSTR "umount"
>PSTR "online"
>PSTR "getstkobj"
>PSTR "shift"
>PSTR "argv"
>PSTR "argvDup"
>PSTR "geterrmsg"
>PSTR "atof"
>PSTR "atoi"
>PSTR "atol"
>PSTR "strtof"
>PSTR "strtol"
>PSTR "strtoul"
>PSTR "realpath"
>PSTR "expand"
>PSTR "strlen"
>PSTR "strcpy"
>PSTR "strcat"
>PSTR "strdup"
>PSTR "strupr"
>PSTR "strlwr"
>PSTR "strcmp"
>PSTR "strcasecmp"
>PSTR "getdevbyname"
>PSTR "getdevstatus"
>PSTR "mkdev"
>PSTR "ioctl"
>PSTR "loadlib"
>PSTR "unloadlib"
>PSTR "loaddrv"
>PSTR "insdrv"
>PSTR "execl"
>PSTR "execv"
>PSTR "fork"
>PSTR "kill"
>PSTR "loadfile"
>PSTR "loadtxtfile"
>PSTR "filesearch"
>PSTR "getmemstat"
>PSTR "strvnew"
>PSTR "strvset"
>PSTR "strvget"
>PSTR "strvfree"
>PSTR "putenv"
>PSTR "setenv"
>PSTR "getenv"
>PSTR "unsetenv"
>PSTR "time"
>PSTR "strftime"
>PSTR "ctime2time"
>PSTR "md5"
>PSTR "md5init"
>PSTR "md5update"
>PSTR "md5finalize"
>PSTR "getpwuid"
>PSTR "getpwname"
>PSTR "putpw"
>PSTR "getgrpgid"
>PSTR "getgrpname"
>PSTR "putgr"
>PSTR "opensession"
>PSTR "closesession"
>PSTR "slistgetdata"
>PSTR "slistadddata"
>PSTR "slistsetdata"
>PSTR "slistgetbyid"
>PSTR "slistnewkey"
>PSTR "slistlookup"
>PSTR "slistfree"
>PSTR "slistnew"
>PSTR "malloc"
>PSTR "realloc"
>PSTR "getmemptr"
>PSTR "free"
>PSTR "newstkobj"
>PSTR "loadstkobj"
>PSTR "getstkobjptr"
>PSTR "freestkobj"
.HS 00
*--------------------------------------
2021-04-10 17:17:40 +00:00
CSH.FN
2021-05-14 20:58:20 +00:00
* float pwr (float x, float y);
>PSTR "pwr"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
.DA #CSH.T.FLOAT,#0
2021-05-14 20:58:20 +00:00
.DA #0
* float cos (float x);
2021-04-10 17:17:40 +00:00
>PSTR "log"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
2021-04-10 17:17:40 +00:00
.DA #0
>PSTR "sqr"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
2021-04-10 17:17:40 +00:00
.DA #0
>PSTR "exp"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
2021-04-10 17:17:40 +00:00
.DA #0
>PSTR "cos"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
2021-04-10 17:17:40 +00:00
.DA #0
>PSTR "sin"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
2021-04-10 17:17:40 +00:00
.DA #0
>PSTR "tan"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
2021-04-10 17:17:40 +00:00
.DA #0
>PSTR "atan"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.FLOAT,#0 returned value
.DA #CSH.T.FLOAT,#0
2021-04-10 17:17:40 +00:00
.DA #0
* char getchar ( void );
>PSTR "getchar"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.UCHAR,#0 returned value
2021-04-10 17:17:40 +00:00
.DA #0
* int puts ( const char * str );
>PSTR "puts"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0 returned value
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
2021-04-10 17:17:40 +00:00
.DA #0
* int execl(const char* cmdline, short int flags);
>PSTR "execl"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0 returned value
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
.DA #CSH.T.UCHAR,#0
2021-04-10 17:17:40 +00:00
.DA #0
* int printf ( const char * format, ... );
>PSTR "printf"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0 returned value
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
.DA #CSH.T.VARIADIC,#0
2021-04-10 17:17:40 +00:00
.DA #0
* int putenv(const char *string);
>PSTR "putenv"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0 returned value
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
2021-04-10 17:17:40 +00:00
.DA #0
* int setenv(const char *name, const char *value);
>PSTR "setenv"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0 returned value
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
2021-04-10 17:17:40 +00:00
.DA #0
* char *getenv(const char *name, char *value);
>PSTR "getenv"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.UCHAR,#CSH.Q.POINTER
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
.DA #CSH.T.UCHAR,#CSH.Q.POINTER
2021-04-10 17:17:40 +00:00
.DA #0
* int unsetenv(const char *name);
>PSTR "unsetenv"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0 returned value
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
2021-04-10 17:17:40 +00:00
.DA #0
* void md5 (const char* str, char* digest);
>PSTR "md5"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.VOID,#0
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
.DA #CSH.T.UCHAR,#CSH.Q.POINTER
2021-04-10 17:17:40 +00:00
.DA #0
* void * malloc ( int size );
>PSTR "malloc"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.VOID,#CSH.Q.POINTER returned value
.DA #CSH.T.SINT,#0
2021-04-10 17:17:40 +00:00
.DA #0
2021-05-14 20:58:20 +00:00
* short int fopen(const char*,short int,short int,int);
>PSTR "fopen"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SCHAR,#0
.DA #CSH.T.UCHAR,#CSH.Q.CONST+CSH.Q.POINTER
.DA #CSH.T.SCHAR,#0
.DA #CSH.T.SCHAR,#0
.DA #CSH.T.SINT,#0
2021-05-14 20:58:20 +00:00
.DA #0
* int fclose(short int);
>PSTR "fclose"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0
.DA #CSH.T.SCHAR,#0
2021-05-14 20:58:20 +00:00
.DA #0
* int fread (short int,void*,int);
>PSTR "fread"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0
.DA #CSH.T.SCHAR,#0
.DA #CSH.T.VOID,#CSH.Q.POINTER
.DA #CSH.T.SINT,#0
2021-05-14 20:58:20 +00:00
.DA #0
* int fwrite (short int,const void*,int);
>PSTR "fwrite"
2021-05-30 20:34:03 +00:00
.DA #CSH.T.SINT,#0
.DA #CSH.T.SCHAR,#0
.DA #CSH.T.VOID,#CSH.Q.CONST+CSH.Q.POINTER
.DA #CSH.T.SINT,#0
.DA #0
2021-04-10 17:17:40 +00:00
*--------------------------------------
.DA #0
2019-01-21 06:52:04 +00:00
*--------------------------------------
.DUMMY
.OR 0
2021-05-30 20:34:03 +00:00
DS.START
2021-04-10 17:17:40 +00:00
PathBuf .BS 65
hFileBuf .BS 1
CSH.BufPtrSave .BS 2
CSH.CmdSave .BS 1
CSH.LookupOpt .BS 1
CSH.hDefines .BS 1
CSH.hSymbols .BS 1
CSH.hTags .BS 1
CSH.hCode .BS 1
CSH.CodePtr .BS 2
CSH.hConst .BS 1
CSH.ConstPtr .BS 2
CSH.hData .BS 1
CSH.DataPtr .BS 2
CSH.hStack .BS 1
CSH.StackPtr .BS 1
2021-05-22 21:05:12 +00:00
CSH.hfDecl .BS 1
CSH.fDeclBuf .BS 2
2021-04-10 17:17:40 +00:00
CSH.SaveInclude .BS 2
CSH.SaveDefine .BS 2
2021-05-30 20:34:03 +00:00
CSH.VarDef .BS 8
2021-04-10 17:17:40 +00:00
2019-09-05 06:43:09 +00:00
bDebug .BS 1
2019-08-27 15:13:00 +00:00
bTrace .BS 1
2021-04-10 17:17:40 +00:00
DS.END .ED
2019-01-21 06:52:04 +00:00
*--------------------------------------
MAN
2020-07-31 14:46:11 +00:00
SAVE usr/src/bin/csh.s
2019-01-21 06:52:04 +00:00
ASM