2019-01-26 16:33:03 +00:00
|
|
|
|
NEW
|
2019-06-28 15:15:58 +00:00
|
|
|
|
AUTO 3,1
|
2019-01-26 16:33:03 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2019-08-26 06:29:18 +00:00
|
|
|
|
CSH.Q.CONST .EQ %10000000
|
|
|
|
|
CSH.Q.POINTER .EQ %00100000
|
|
|
|
|
CSH.Q.PPOINTER .EQ %01000000
|
|
|
|
|
CSH.Q.PPPOINTER .EQ %01100000
|
2020-08-02 12:19:43 +00:00
|
|
|
|
CSH.Q.FUNC .EQ %00010000
|
2020-01-22 16:31:48 +00:00
|
|
|
|
CSH.T.VOID .EQ 0
|
2019-08-26 06:29:18 +00:00
|
|
|
|
CSH.T.CHAR .EQ 1
|
|
|
|
|
CSH.T.INT .EQ 2
|
|
|
|
|
CSH.T.LONG .EQ 3
|
|
|
|
|
CSH.T.UCHAR .EQ 4
|
|
|
|
|
CSH.T.UINT .EQ 5
|
|
|
|
|
CSH.T.ULONG .EQ 6
|
|
|
|
|
CSH.T.FLOAT .EQ 7
|
2020-08-02 12:19:43 +00:00
|
|
|
|
CSH.T.VARIADIC .EQ $F
|
2019-08-26 06:29:18 +00:00
|
|
|
|
*--------------------------------------
|
2020-03-02 16:49:47 +00:00
|
|
|
|
CSH.OPChars .AS "!~+-*/%=&|^<>"
|
2019-02-07 16:52:25 +00:00
|
|
|
|
CSH.OPChars.Cnt .EQ *-CSH.OPChars
|
2019-01-26 16:33:03 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Pre Operators: + - ! ~ ++ --
|
|
|
|
|
*--------------------------------------
|
2019-08-26 06:29:18 +00:00
|
|
|
|
CSH.PREOPS >PSTR "+"
|
2019-01-26 16:33:03 +00:00
|
|
|
|
>PSTR "-"
|
|
|
|
|
>PSTR "!"
|
|
|
|
|
>PSTR "~"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Post Operators: ++ --
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.POSTOPS >PSTR "++"
|
|
|
|
|
>PSTR "--"
|
2019-10-03 06:25:27 +00:00
|
|
|
|
.HS 00
|
2019-01-26 16:33:03 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Assignment Operators: = += -= *= /= %= <<= >>= &= ^= |=
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.AOPS >PSTR "="
|
|
|
|
|
>PSTR "+="
|
|
|
|
|
>PSTR "-="
|
|
|
|
|
>PSTR "*="
|
|
|
|
|
>PSTR "/="
|
|
|
|
|
>PSTR "%="
|
|
|
|
|
>PSTR "<<="
|
|
|
|
|
>PSTR ">>="
|
|
|
|
|
>PSTR "&="
|
|
|
|
|
>PSTR "^="
|
|
|
|
|
>PSTR "!="
|
|
|
|
|
.HS 00
|
2019-08-26 06:29:18 +00:00
|
|
|
|
*-- Binary ---- H to L precedence -----
|
2019-01-26 16:33:03 +00:00
|
|
|
|
* Arithmetic Operators: * / %
|
|
|
|
|
* Arithmetic Operators: + -
|
|
|
|
|
* Shift Operators: << >>
|
|
|
|
|
* Relational Operators: < > >= < >= == !=
|
|
|
|
|
* Bitwise Operators: & | ^ ~
|
|
|
|
|
* Logical Operators: && ||
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.BOPS >PSTR "+"
|
|
|
|
|
>PSTR "-"
|
|
|
|
|
>PSTR "*"
|
|
|
|
|
>PSTR "/"
|
|
|
|
|
>PSTR "%"
|
|
|
|
|
>PSTR "<<"
|
|
|
|
|
>PSTR ">>"
|
|
|
|
|
>PSTR "<"
|
|
|
|
|
>PSTR ">"
|
|
|
|
|
>PSTR "<="
|
|
|
|
|
>PSTR ">="
|
|
|
|
|
>PSTR "=="
|
|
|
|
|
>PSTR "!="
|
|
|
|
|
>PSTR "&"
|
|
|
|
|
>PSTR "|"
|
|
|
|
|
>PSTR "^"
|
|
|
|
|
>PSTR "&&"
|
|
|
|
|
>PSTR "||"
|
|
|
|
|
.HS 00
|
|
|
|
|
*--------------------------------------
|
2020-01-25 18:56:36 +00:00
|
|
|
|
* Reserved Directives:
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.DIRS >PSTR "define"
|
2020-07-31 14:46:11 +00:00
|
|
|
|
>PSTR "include"
|
2020-01-25 18:56:36 +00:00
|
|
|
|
.HS 00
|
|
|
|
|
*--------------------------------------
|
2019-01-26 16:33:03 +00:00
|
|
|
|
* Reserved Keywords:
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CSH.KW >PSTR "if"
|
|
|
|
|
>PSTR "while"
|
|
|
|
|
>PSTR "else"
|
|
|
|
|
>PSTR "do"
|
|
|
|
|
>PSTR "for"
|
|
|
|
|
>PSTR "switch"
|
|
|
|
|
>PSTR "case"
|
|
|
|
|
>PSTR "break"
|
2019-09-05 06:43:09 +00:00
|
|
|
|
>PSTR "continue"
|
2020-02-21 16:31:46 +00:00
|
|
|
|
>PSTR "typedef"
|
|
|
|
|
>PSTR "struct"
|
|
|
|
|
>PSTR "sizeof"
|
2020-08-02 12:19:43 +00:00
|
|
|
|
CSH.TYPES >PSTR "void"
|
2019-01-26 16:33:03 +00:00
|
|
|
|
>PSTR "float"
|
|
|
|
|
>PSTR "signed" char,int,long
|
|
|
|
|
>PSTR "unsigned" char,int,long
|
|
|
|
|
CSH.STYPES >PSTR "char"
|
|
|
|
|
>PSTR "int"
|
|
|
|
|
>PSTR "long"
|
2019-08-26 06:29:18 +00:00
|
|
|
|
* .HS 00
|
2019-09-05 15:49:05 +00:00
|
|
|
|
*--------------------------------------
|
2019-09-02 06:09:28 +00:00
|
|
|
|
CSH.TYPESIZE .HS 0001020401020405 VOID,CHAR,INT,LONG,UCHAR,UINT,ULONG,FLOAT....
|
2019-01-26 16:33:03 +00:00
|
|
|
|
*--------------------------------------
|
2020-01-22 21:52:00 +00:00
|
|
|
|
CSH.FN
|
|
|
|
|
* float cos ( float x );
|
|
|
|
|
>PSTR "log"
|
|
|
|
|
.DA #CSH.T.FLOAT returned value
|
|
|
|
|
.DA #CSH.T.FLOAT
|
2019-01-26 16:33:03 +00:00
|
|
|
|
.DA #0
|
2020-01-22 21:52:00 +00:00
|
|
|
|
>PSTR "sqr"
|
|
|
|
|
.DA #CSH.T.FLOAT returned value
|
|
|
|
|
.DA #CSH.T.FLOAT
|
|
|
|
|
.DA #0
|
|
|
|
|
>PSTR "exp"
|
|
|
|
|
.DA #CSH.T.FLOAT returned value
|
|
|
|
|
.DA #CSH.T.FLOAT
|
2019-02-11 06:58:33 +00:00
|
|
|
|
.DA #0
|
2019-01-26 16:33:03 +00:00
|
|
|
|
>PSTR "cos"
|
|
|
|
|
.DA #CSH.T.FLOAT returned value
|
|
|
|
|
.DA #CSH.T.FLOAT
|
|
|
|
|
.DA #0
|
2020-01-22 21:52:00 +00:00
|
|
|
|
>PSTR "sin"
|
|
|
|
|
.DA #CSH.T.FLOAT returned value
|
|
|
|
|
.DA #CSH.T.FLOAT
|
|
|
|
|
.DA #0
|
|
|
|
|
>PSTR "tan"
|
|
|
|
|
.DA #CSH.T.FLOAT returned value
|
|
|
|
|
.DA #CSH.T.FLOAT
|
|
|
|
|
.DA #0
|
|
|
|
|
>PSTR "atan"
|
|
|
|
|
.DA #CSH.T.FLOAT returned value
|
|
|
|
|
.DA #CSH.T.FLOAT
|
|
|
|
|
.DA #0
|
2019-09-04 06:09:20 +00:00
|
|
|
|
* char getchar ( void );
|
2019-01-26 16:33:03 +00:00
|
|
|
|
>PSTR "getchar"
|
2019-09-04 06:09:20 +00:00
|
|
|
|
.DA #CSH.T.CHAR returned value
|
2019-01-26 16:33:03 +00:00
|
|
|
|
.DA #0
|
2020-01-22 21:52:00 +00:00
|
|
|
|
* int puts ( const char * str );
|
|
|
|
|
>PSTR "puts"
|
|
|
|
|
.DA #CSH.T.INT returned value
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #0
|
2020-01-24 14:21:08 +00:00
|
|
|
|
* int execl(const char* cmdline, short int flags);
|
|
|
|
|
>PSTR "execl"
|
|
|
|
|
.DA #CSH.T.INT returned value
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #CSH.T.UCHAR
|
|
|
|
|
.DA #0
|
2020-01-22 21:52:00 +00:00
|
|
|
|
* int printf ( const char * format, ... );
|
|
|
|
|
>PSTR "printf"
|
|
|
|
|
.DA #CSH.T.INT returned value
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #CSH.T.VARIADIC
|
|
|
|
|
.DA #0
|
|
|
|
|
* int putenv(const char *string);
|
|
|
|
|
>PSTR "putenv"
|
|
|
|
|
.DA #CSH.T.INT returned value
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #0
|
|
|
|
|
* int setenv(const char *name, const char *value);
|
|
|
|
|
>PSTR "setenv"
|
|
|
|
|
.DA #CSH.T.INT returned value
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #0
|
|
|
|
|
* char *getenv(const char *name, char *value);
|
|
|
|
|
>PSTR "getenv"
|
|
|
|
|
.DA #CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #0
|
|
|
|
|
* int unsetenv(const char *name);
|
|
|
|
|
>PSTR "unsetenv"
|
|
|
|
|
.DA #CSH.T.INT returned value
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #0
|
2020-01-24 14:21:08 +00:00
|
|
|
|
* void md5 (const char* str, char* digest);
|
|
|
|
|
>PSTR "md5"
|
|
|
|
|
.DA #CSH.T.VOID
|
|
|
|
|
.DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #CSH.Q.POINTER+CSH.T.CHAR
|
|
|
|
|
.DA #0
|
2020-01-22 16:31:48 +00:00
|
|
|
|
* void * malloc ( int size );
|
|
|
|
|
>PSTR "malloc"
|
|
|
|
|
.DA #CSH.Q.POINTER+CSH.T.VOID returned value
|
|
|
|
|
.DA #CSH.T.INT
|
|
|
|
|
.DA #0
|
|
|
|
|
*--------------------------------------
|
2019-08-26 06:29:18 +00:00
|
|
|
|
.DA #0
|
2019-01-26 16:33:03 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2020-07-31 14:46:11 +00:00
|
|
|
|
SAVE usr/src/bin/csh.i
|
|
|
|
|
LOAD usr/src/bin/csh.s
|
2019-01-26 16:33:03 +00:00
|
|
|
|
ASM
|