diff --git a/.Floppies/A2OSX.BUILD.po b/.Floppies/A2OSX.BUILD.po index 44c32fa7..b322ec97 100644 Binary files a/.Floppies/A2OSX.BUILD.po and b/.Floppies/A2OSX.BUILD.po differ diff --git a/.Floppies/A2OSX.SRC.po b/.Floppies/A2OSX.SRC.po index 0e52713a..7d2970b3 100644 Binary files a/.Floppies/A2OSX.SRC.po and b/.Floppies/A2OSX.SRC.po differ diff --git a/SBIN/SHELL.C.CSH.txt b/SBIN/SHELL.C.CSH.txt new file mode 100644 index 00000000..3c8d1353 --- /dev/null +++ b/SBIN/SHELL.C.CSH.txt @@ -0,0 +1,105 @@ +PR#3 +PREFIX /A2OSX.BUILD +LOMEM $A00 +INC 1 +AUTO 6 + .LIST OFF +*-------------------------------------- +CSH.OPChars .AS "!~+-*/%=&|^&<>" +*-------------------------------------- +* Pre Operators: + - ! ~ ++ -- +*-------------------------------------- +CSH.PREOOPS >PSTR "+" + >PSTR "-" + >PSTR "!" + >PSTR "~" +*-------------------------------------- +* Post Operators: ++ -- +*-------------------------------------- +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 prececence ----- +* 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 +*-------------------------------------- +* Reserved Keywords: +*-------------------------------------- +CSH.KW >PSTR "if" + >PSTR "while" + >PSTR "else" + >PSTR "do" + >PSTR "for" + >PSTR "switch" + >PSTR "case" + >PSTR "break" + >PSTR "continue" + >PSTR "float" + >PSTR "signed" char,int,long + >PSTR "unsigned" char,int,long +CSH.STYPES >PSTR "char" + >PSTR "int" + >PSTR "long" + .HS 00 +CSH.TSIZE .HS 0001020401020405 00,CHAR,INT,LONG,UCHAR,UINT,ULONG,FLOAT.... +*-------------------------------------- +* int printf ( const char * format, ... ); +CSH.FN >PSTR "printf" + .DA #CSH.T.INT returned value + .DA #CSH.Q.CONST+CSH.T.CHAR + .DA #CSH.Q.POINTER + .DA #CSH.T.VARIADIC + .DA #0 +* float cos ( float x ); + >PSTR "cos" + .DA #CSH.T.FLOAT returned value + .DA #CSH.T.FLOAT + .DA #0 +* int getchar ( void ); + >PSTR "getchar" + .DA #CSH.T.INT returned value + .DA #0 +*-------------------------------------- +MAN +SAVE /A2OSX.SRC/SBIN/SHELL.C.CSH +LOAD /A2OSX.SRC/SBIN/SHELL.S +ASM diff --git a/SBIN/SHELL.G.CSH.txt b/SBIN/SHELL.G.CSH.txt new file mode 100644 index 00000000..5848c400 --- /dev/null +++ b/SBIN/SHELL.G.CSH.txt @@ -0,0 +1,39 @@ +PR#3 +PREFIX /A2OSX.BUILD +LOMEM $A00 +INC 1 +AUTO 6 + .LIST OFF +*-------------------------------------- +CSH.hBuf .BS 1 +CSH.BufPtrSave .BS 2 + +CSH.LineNum .BS 2 + +CSH.hSymbols .BS 1 +CSH.SymbolsPtr .BS 1 + +CSH.hData .BS 1 +CSH.DataPtr .BS 1 + +CSH.hStack .BS 1 +CSH.StackPtr .BS 1 + +CSH.CmdSave .BS 1 + +CSH.ACCT .BS 1 +CSH.ACC .BS 5 + +CSH.EXPBOP1 .BS 1 + +CSH.ARGT .BS 1 +CSH.ARG .BS 5 + +CSH.EXPBOP2 .BS 1 + +CSH.LookupOpt .BS 1 +*-------------------------------------- +MAN +SAVE /A2OSX.SRC/SBIN/SHELL.G.CSH +LOAD /A2OSX.SRC/SBIN/SHELL.S +ASM diff --git a/SBIN/SHELL.S.CSH.txt b/SBIN/SHELL.S.CSH.txt index dde01cfa..ae68db44 100644 --- a/SBIN/SHELL.S.CSH.txt +++ b/SBIN/SHELL.S.CSH.txt @@ -5,20 +5,28 @@ INC 1 AUTO 6 .LIST OFF *-------------------------------------- -CSH.TQ.POINTER .EQ %10000000 -CSH.TQ.CONST .EQ %01000000 -CSH.TQ.SIGNED .EQ %00100000 +CSH.E.SYNTAX .EQ $7F +CSH.E.SOVERFLW .EQ $7E +CSH.E.NOVERFLW .EQ $7D +CSH.E.OOM .EQ $7C +CSH.E.DUP .EQ $7B +CSH.E.UNDEF .EQ $7A +CSH.E.TMISMATCH .EQ $79 + +CSH.Q.POINTER .EQ %10000000 +CSH.Q.CONST .EQ %01000000 +CSH.Q.ARRAY .EQ %11000000 CSH.T.CHAR .EQ 1 CSH.T.INT .EQ 2 CSH.T.LONG .EQ 3 -CSH.T.FLOAT .EQ 4 -CSH.T.VARIADIC .EQ $FF +CSH.T.UCHAR .EQ 4 +CSH.T.UINT .EQ 5 +CSH.T.ULONG .EQ 6 +CSH.T.FLOAT .EQ 7 +CSH.T.VARIADIC .EQ $F *-------------------------------------- -CSH.Init lda #$FF - >STA.G bExitOnEOF - - inc +CSH.Init lda #$0 >STA.G CSH.SymbolsPtr >STA.G CSH.DataPtr >STA.G CSH.StackPtr @@ -72,7 +80,7 @@ CSH.Run jsr CL.RESET jsr CSH.Pop was expected, get stacked Cmd... tax - jmp (J.CSH.KEYWORDS.END,x) + jmp (J.CSH.KW.END,x) .1 cmp #$0D bne .2 @@ -90,7 +98,7 @@ CSH.Run jsr CL.RESET bra .9 error, todo : PREOPS ++ --..... -.3 >LDYA L.CSH.KEYWORDS +.3 >LDYA L.CSH.KW jsr CSH.LookupID bcs .4 not an internal CSH keyword.... @@ -98,7 +106,7 @@ CSH.Run jsr CL.RESET txa >STA.G CSH.CmdSave - jmp (J.CSH.KEYWORDS,x) + jmp (J.CSH.KW,x) .4 jsr CSH.GetVar bcs .5 @@ -253,7 +261,7 @@ CSH.IF jsr CSH.GetCharNB .99 rts CSH.Keyword.Start - jmp (J.CSH.KEYWORDS.START,x) + jmp (J.CSH.KW.START,x) *-------------------------------------- CSH.IF.START jmp CSH.Push *-------------------------------------- @@ -288,12 +296,58 @@ CSH.CONTINUE sec rts *-------------------------------------- +CSH.SIGNED jsr CSH.GetChar + bcs .9 + cmp #' ' + bne .9 + + jsr CSH.GetNextCharNB + bcs .9 + + >LDYA L.CSH.STYPES + jsr CSH.LookupID + + bcs .9 + + jmp (J.CSH.STYPES,x) + +.9 lda #CSH.E.SYNTAX + sec + rts +*-------------------------------------- +CSH.UNSIGNED jsr CSH.GetChar + bcs .9 + cmp #' ' + bne .9 + + jsr CSH.GetNextCharNB + bcs .9 + + >LDYA L.CSH.STYPES + jsr CSH.LookupID + + bcs .9 + + jmp (J.CSH.UTYPES,x) + +.9 lda #CSH.E.SYNTAX + sec + rts +*-------------------------------------- CSH.CHAR lda #CSH.T.CHAR bra CSH.TYPE +CSH.UCHAR lda #CSH.T.CHAR + bra CSH.TYPE CSH.INT lda #CSH.T.INT + >DEBUG + bra CSH.TYPE +CSH.UINT lda #CSH.T.INT bra CSH.TYPE CSH.LONG lda #CSH.T.LONG bra CSH.TYPE +CSH.ULONG lda #CSH.T.LONG + bra CSH.TYPE + CSH.FLOAT lda #CSH.T.FLOAT CSH.TYPE >STA.G CSH.ACCT @@ -328,7 +382,7 @@ CSH.TYPE >STA.G CSH.ACCT jsr CSH.ExpEval - bcs .9 + bcs .99 jsr CSH.StoreACCToVar Update value to this var @@ -364,9 +418,14 @@ CSH.ExpEval jsr CSH.ZeroACC jsr CSH.LoadACCFromVar bcs .9 - bra .11 + bra .11 -.1 bra .9 TO DO : Functions +.1 >LDYA L.CSH.FN + jsr CSH.LookupFn + bcs .9 + jsr CSH.FnEval + bcs .99 + bra .11 .2 jsr CSH.IsDigit10 number ? bcs .9 @@ -429,6 +488,36 @@ CSH.ExpEval jsr CSH.ZeroACC .80 clc rts *-------------------------------------- +CSH.FnEval jsr CSH.GetCharNB + + bcs .9 + cmp #'(' + bne .9 + + lda (ZPPtr1) + >CMP.G CSH.ACCT + bne .99 + + +* TODO : eval params + + +.7 jsr CSH.GetNextCharNB + bcs .9 + cmp #')' + bne .9 + + clc + rts + +.9 lda #CSH.E.SYNTAX + sec + rts + +.99 lda #CSH.E.TMISMATCH + sec + rts +*-------------------------------------- CSH.SavePtr >LDYA ZPCSHBufPtr >STYA.G CSH.BufPtrSave rts @@ -437,11 +526,18 @@ CSH.RestorePtr >LDYA.G CSH.BufPtrSave >STYA ZPCSHBufPtr rts *-------------------------------------- -CSH.LookupID >STYA ZPPtr1 +CSH.LookupFN sec + .HS 90 BCC +CSH.LookupID clc + >STYA ZPPtr1 + ror + >STA.G CSH.LookupOpt + jsr CSH.GetIDLen bra CSH.Lookup CSH.LookupOP >STYA ZPPtr1 + >STZ.G CSH.LookupOpt jsr CSH.GetOPLen CSH.Lookup phy Y = len @@ -472,8 +568,16 @@ CSH.Lookup phy Y = len clc adc ZPCSHBufPtr ..advance Ptr to char after it.. sta ZPCSHBufPtr + bcc .31 + inc ZPCSHBufPtr+1 + +.31 lda ZPPtr1 + sec + adc (ZPPtr1) + sta ZPPtr1 bcc .8 - inc ZPCSHBufPtr+1 + inc ZPPtr1+1 + clc .8 rts @@ -484,6 +588,21 @@ CSH.Lookup phy Y = len sec adc (ZPPtr1) sta ZPPtr1 + bcc .5 + inc ZPPtr1+1 + +.5 >LDA.G CSH.LookupOpt + bpl .1 + + ldy #$ff +.6 iny + lda (ZPPtr1),y + bne .6 + + tya + sec + adc ZPPtr1 + sta ZPPtr1 bcc .1 inc ZPPtr1+1 bra .1 @@ -728,6 +847,7 @@ CSH.StoreACCToVar CSH.IsACC0 >LDA.G CSH.ACCT cmp #CSH.T.FLOAT bne .1 char,int,long + >LDA.G CSH.ACC bne .9 @@ -911,7 +1031,7 @@ CSH.GetChar lda (ZPCSHBufPtr) sec rts *--------------------------------------- -CSH.IsOPChar ldx #OPChars.Count-1 +CSH.IsOPChar ldx #13 .1 cmp CSH.OPChars,x beq .8 diff --git a/SBIN/SHELL.S.txt b/SBIN/SHELL.S.txt index 6e457efb..6bb0a772 100644 --- a/SBIN/SHELL.S.txt +++ b/SBIN/SHELL.S.txt @@ -24,14 +24,6 @@ ZPCSHStack .EQ ZPBIN+14 CmdLine.MAX .EQ 255 VarLen.MAX .EQ 15 History.MAX .EQ 256 - -CSH.E.SYNTAX .EQ $7F -CSH.E.SOVERFLW .EQ $7E -CSH.E.NOVERFLW .EQ $7D -CSH.E.OOM .EQ $7C -CSH.E.DUP .EQ $7B -CSH.E.UNDEF .EQ $7A -CSH.E.TMISMATCH .EQ $79 *-------------------------------------- * File Header (16 Bytes) *-------------------------------------- @@ -100,8 +92,9 @@ J.CSH.BOPS .DA CSH.BOPS.ADD .DA CSH.BOPS.EOR .DA CSH.BOPS.LAND .DA CSH.BOPS.LOR -L.CSH.KEYWORDS .DA CSH.KEYWORDS -J.CSH.KEYWORDS .DA CSH.IF +L.CSH.FN .DA CSH.FN +L.CSH.KW .DA CSH.KW +J.CSH.KW .DA CSH.IF .DA CSH.WHILE .DA CSH.ELSE .DA CSH.DO @@ -110,15 +103,19 @@ J.CSH.KEYWORDS .DA CSH.IF .DA CSH.CASE .DA CSH.BREAK .DA CSH.CONTINUE - .DA CSH.CHAR + .DA CSH.FLOAT + .DA CSH.SIGNED + .DA CSH.UNSIGNED +L.CSH.STYPES .DA CSH.STYPES +J.CSH.STYPES .DA CSH.CHAR .DA CSH.INT .DA CSH.LONG - .DA CSH.FLOAT -J.CSH.KEYWORDS.START - .DA CSH.IF.START +J.CSH.UTYPES .DA CSH.UCHAR + .DA CSH.UINT + .DA CSH.ULONG +J.CSH.KW.START .DA CSH.IF.START .DA CSH.WHILE.START -J.CSH.KEYWORDS.END - .DA CSH.IF.END +J.CSH.KW.END .DA CSH.IF.END .DA CSH.WHILE.END L.ERR.Codes .DA ERR.Codes L.ERR.Messages .DA ERR.Messages @@ -260,13 +257,7 @@ CS.RUN.BATCH >SYSCALL GetChar ldy #S.PS.RC sta (pPs),y - pha - - ldy #bExitOnEOF - lda (pData),y - asl CS if bExitOnEOF - - pla + sec rts .7 >LDA.G bCmdBufExec @@ -361,93 +352,6 @@ INTCMDS >CSTR "CD" >CSTR "TIME" .HS 00 *-------------------------------------- -OPChars.Count .EQ 14 -CSH.OPChars >PSTR "!~+-*/%=&|^&<>" -*-------------------------------------- -* Pre Operators: + - ! ~ ++ -- -*-------------------------------------- -CSH.PREOOPS >PSTR "+" - >PSTR "-" - >PSTR "!" - >PSTR "~" -*-------------------------------------- -* Post Operators: ++ -- -*-------------------------------------- -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 prececence ----- -* 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 -*-------------------------------------- -* Reserved Keywords: -*-------------------------------------- -CSH.KEYWORDS >PSTR "if" - >PSTR "while" - >PSTR "else" - >PSTR "do" - >PSTR "for" - >PSTR "switch" - >PSTR "case" - >PSTR "break" - >PSTR "continue" -CSH.TYPES >PSTR "char" - >PSTR "int" - >PSTR "long" - >PSTR "float" - .HS 00 -*-------------------------------------- -* int printf ( const char * format, ... ); -CSH.FUNCTIONS >PSTR "printf" - .DA #CSH.T.INT returned value - .DA #CSH.TQ.CONST+CSH.T.CHAR+CSH.TQ.POINTER - .DA #CSH.T.VARIADIC - .DA #0 -* float cos ( float x ); - >PSTR "cos" - .DA #CSH.T.FLOAT - .DA #CSH.T.FLOAT - .DA #0 -*-------------------------------------- MSG.GREETINGS >CSTR "\r\nA2osX-Shell 0.9.1\r\n\r\n" MSG.PROMPT >CSTR "$ " MSG.ECHO >CSTR ">%s\r\n" @@ -457,12 +361,11 @@ MSG.CSHERR >CSTR "^\r\nLine #%D:" FMT.DATE >CSTR "%A (%w), %B %d %Y" FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)" *-------------------------------------- + .INB /A2OSX.SRC/SBIN/SHELL.C.CSH .INB /A2OSX.SRC/X.ERRORS.S *-------------------------------------- EscChars.Count .EQ 4 EscChars .AS 'DBAC' - -CSH.TSIZE .HS 0001020405 VOID,CHAR,INT,LONG,FLOAT.... *-------------------------------------- .DUMMY .OR 0 @@ -476,7 +379,6 @@ bEscMode .BS 1 bPause .BS 1 bExit .BS 1 bEcho .BS 1 -bExitOnEOF .BS 1 bReadMode .BS 1 bSecureRead .BS 1 @@ -498,32 +400,8 @@ IO.hIn .BS 1 IO.hOut .BS 1 IO.hErr .BS 1 -CSH.hBuf .BS 1 -CSH.BufPtrSave .BS 2 - -CSH.LineNum .BS 2 - -CSH.hSymbols .BS 1 -CSH.SymbolsPtr .BS 1 - -CSH.hData .BS 1 -CSH.DataPtr .BS 1 - -CSH.hStack .BS 1 -CSH.StackPtr .BS 1 - -CSH.CmdSave .BS 1 - -CSH.ACCT .BS 1 -CSH.ACC .BS 5 - -CSH.EXPBOP1 .BS 1 - -CSH.ARGT .BS 1 -CSH.ARG .BS 5 - -CSH.EXPBOP2 .BS 1 - + .INB /A2OSX.SRC/SBIN/SHELL.G.CSH + DS.END .ED *-------------------------------------- MAN