mirror of https://github.com/A2osX/A2osX.git
Kernel 0.94
This commit is contained in:
parent
6ad471abcc
commit
fbaa06a3af
|
@ -911,7 +911,7 @@ CC = success
|
|||
Get char from StdIn
|
||||
|
||||
## C
|
||||
`int getchar ();`
|
||||
`short int getchar ( );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -925,7 +925,7 @@ Get char from StdIn
|
|||
Get char from Node
|
||||
|
||||
## C
|
||||
`int getc ( hFILE stream );`
|
||||
`short int getc ( short int stream );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -940,7 +940,7 @@ Get char from Node
|
|||
push byte back into input stream
|
||||
|
||||
## C
|
||||
`int ungetc(short int c, hFILE stream);
|
||||
`short int ungetc(short int c, short int stream);`
|
||||
|
||||
## ASM
|
||||
`>PUSHB c`
|
||||
|
@ -987,7 +987,7 @@ TODO: replace flags/ftype/auxtype with mode="w+,t=TYP,x=AUXTYPE"
|
|||
Close a file
|
||||
|
||||
## C
|
||||
int fclose ( hFILE stream );
|
||||
`int fclose ( short int stream );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1000,7 +1000,7 @@ int fclose ( hFILE stream );
|
|||
Read bytes from file
|
||||
|
||||
## C
|
||||
int fread (hFILE stream, void * ptr, int count );
|
||||
`int fread (short int stream, void * ptr, int count );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1016,7 +1016,7 @@ int fread (hFILE stream, void * ptr, int count );
|
|||
Write bytes to file
|
||||
|
||||
## C
|
||||
`int fwrite (hFILE stream, const void * ptr, int count );`
|
||||
`int fwrite (short int stream, const void * ptr, int count );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1031,7 +1031,7 @@ Write bytes to file
|
|||
# FFlush
|
||||
|
||||
## C
|
||||
int fflush(hFILE stream);
|
||||
`int fflush( short int stream );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1042,7 +1042,7 @@ int fflush(hFILE stream);
|
|||
Set the file-position indicator for hFILE
|
||||
|
||||
## C
|
||||
`int fseek(hFILE stream, long offset, short int whence);`
|
||||
`int fseek( short int stream, long offset, short int whence );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1055,7 +1055,7 @@ Set the file-position indicator for hFILE
|
|||
Test the end-of-file indicator for hFILE
|
||||
|
||||
## C
|
||||
`int feof(hFILE stream);`
|
||||
`int feof( short int stream );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1072,7 +1072,7 @@ Test the end-of-file indicator for hFILE
|
|||
Return the current value of the file-position indicator
|
||||
|
||||
## C
|
||||
`long ftell(hFILE stream);`
|
||||
`long ftell( short int stream );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1086,7 +1086,7 @@ On stack (long)
|
|||
Remove a file or directory
|
||||
|
||||
## C
|
||||
int remove(const char *pathname);
|
||||
`int remove ( const char *pathname );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1099,7 +1099,7 @@ int remove(const char *pathname);
|
|||
Rename a file
|
||||
|
||||
## C
|
||||
`int rename(const char *oldpath, const char *newpath);`
|
||||
`int rename ( const char * oldpath, const char * newpath );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1189,8 +1189,8 @@ Modifiers for len and padding :
|
|||
Read formatted data from string
|
||||
|
||||
## C
|
||||
`int scanf(const char *format, ...);`
|
||||
`int fscanf(short int stream, const char *format, ...);`
|
||||
`int scanf( const char *format, ... );`
|
||||
`int fscanf( short int stream, const char *format, ... );`
|
||||
`int sscanf ( const char *s, const char *format, ... );`
|
||||
|
||||
## ASM
|
||||
|
@ -1235,7 +1235,7 @@ A = Number of arguments filled.
|
|||
Convert String to 40 bits Float
|
||||
|
||||
## C
|
||||
`float strtof (const char* str, char** endptr);`
|
||||
`float strtof (const char* str, char** endptr );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
@ -1250,7 +1250,7 @@ On stack (float)
|
|||
Convert String to 40 bits Float
|
||||
|
||||
## C
|
||||
`float atof (const char* str);`
|
||||
`float atof ( const char* str );`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,6 +2,8 @@ NEW
|
|||
AUTO 3,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
PathBuf .BS 65
|
||||
|
||||
hFileBuf .BS 1
|
||||
|
||||
CSH.BufPtrSave .BS 2
|
||||
|
@ -12,11 +14,13 @@ 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.DataBase .BS 2
|
||||
CSH.DataPtr .BS 2
|
||||
|
||||
CSH.hStack .BS 1
|
||||
|
|
|
@ -6,6 +6,7 @@ CSH.Q.CONST .EQ %10000000
|
|||
CSH.Q.POINTER .EQ %00100000
|
||||
CSH.Q.PPOINTER .EQ %01000000
|
||||
CSH.Q.PPPOINTER .EQ %01100000
|
||||
CSH.Q.FUNC .EQ %00010000
|
||||
CSH.T.VOID .EQ 0
|
||||
CSH.T.CHAR .EQ 1
|
||||
CSH.T.INT .EQ 2
|
||||
|
@ -14,7 +15,7 @@ CSH.T.UCHAR .EQ 4
|
|||
CSH.T.UINT .EQ 5
|
||||
CSH.T.ULONG .EQ 6
|
||||
CSH.T.FLOAT .EQ 7
|
||||
CSH.T.VARIADIC .EQ $1F
|
||||
CSH.T.VARIADIC .EQ $F
|
||||
*--------------------------------------
|
||||
CSH.OPChars .AS "!~+-*/%=&|^<>"
|
||||
CSH.OPChars.Cnt .EQ *-CSH.OPChars
|
||||
|
@ -94,7 +95,7 @@ CSH.KW >PSTR "if"
|
|||
>PSTR "typedef"
|
||||
>PSTR "struct"
|
||||
>PSTR "sizeof"
|
||||
>PSTR "void"
|
||||
CSH.TYPES >PSTR "void"
|
||||
>PSTR "float"
|
||||
>PSTR "signed" char,int,long
|
||||
>PSTR "unsigned" char,int,long
|
||||
|
|
|
@ -48,6 +48,7 @@ J.CSH.BOPS.SHLt .DA CSH.TMISMATCH
|
|||
L.CSH.FN .DA CSH.FN
|
||||
L.CSH.DIRS .DA CSH.DIRS
|
||||
L.CSH.KW .DA CSH.KW
|
||||
L.CSH.TYPES .DA CSH.TYPES
|
||||
L.CSH.STYPES .DA CSH.STYPES
|
||||
J.CSH.DIRS .DA CSH.DIR.DEFINE
|
||||
.DA CSH.DIR.INCLUDE
|
||||
|
|
|
@ -21,6 +21,14 @@ CSH.Init >SYSCALL SListNew
|
|||
>SYSCALL GetMem
|
||||
bcs .9
|
||||
|
||||
>STYA ZPCSHCode
|
||||
txa
|
||||
>STA.G CSH.hCode
|
||||
|
||||
>LDYAI 256
|
||||
>SYSCALL GetMem
|
||||
bcs .9
|
||||
|
||||
>STYA ZPCSHConst
|
||||
txa
|
||||
>STA.G CSH.hConst
|
||||
|
@ -83,6 +91,9 @@ CSH.Quit >LDA.G CSH.hSymbols
|
|||
jsr .7
|
||||
|
||||
>LDA.G CSH.hConst
|
||||
jsr .7
|
||||
|
||||
>LDA.G CSH.hCode
|
||||
|
||||
.7 beq CSH.Quit.RTS
|
||||
>SYSCALL FreeMem
|
||||
|
@ -169,7 +180,7 @@ CSH.Run.1 cmp #C.CR empty line....
|
|||
bcs .9
|
||||
|
||||
jsr CSH.GetVarSize X = returned value type
|
||||
clc A = Sizeof
|
||||
clc A = Sizeof CC to ignore Pointer hMem
|
||||
adc pStack
|
||||
sta pStack Discard value on stack
|
||||
|
||||
|
@ -260,31 +271,53 @@ CSH.DIR.DEFINE jsr CSH.CheckSpace
|
|||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
CSH.DIR.INCLUDE jsr CSH.CheckSpace
|
||||
CSH.DIR.INCLUDE >STZ.G PathBuf
|
||||
|
||||
jsr CSH.CheckSpace
|
||||
bcs .99
|
||||
|
||||
cmp #'"'
|
||||
beq .1
|
||||
|
||||
cmp #'<'
|
||||
bne .80
|
||||
|
||||
|
||||
|
||||
bne .90
|
||||
|
||||
>PUSHW L.ENV.INCLUDE
|
||||
>PUSHEA.G PathBuf
|
||||
>SYSCALL getenv
|
||||
|
||||
lda #'>'
|
||||
|
||||
.1 sta ArgIndex
|
||||
|
||||
ldy #PathBuf
|
||||
|
||||
.2 lda (pData),y
|
||||
beq .3
|
||||
|
||||
iny
|
||||
bra .2
|
||||
|
||||
.3 jsr CSH.GetNextChar
|
||||
beq .90
|
||||
|
||||
cmp ArgIndex
|
||||
beq .8
|
||||
|
||||
|
||||
|
||||
|
||||
bra CSH.SkipLine
|
||||
sta (pData),y
|
||||
iny
|
||||
cpy #64
|
||||
bne .3
|
||||
|
||||
.90 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
.99 rts
|
||||
|
||||
.8 jsr CSH.GetNextChar skip " or >
|
||||
|
||||
>LDYA pdata
|
||||
>SYSCALL puts
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.SkipLine jsr CSH.GetNextChar
|
||||
bcs .9
|
||||
|
@ -294,535 +327,6 @@ CSH.SkipLine jsr CSH.GetNextChar
|
|||
clc
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
* Built in Keywords
|
||||
*--------------------------------------
|
||||
CSH.KW.JMP txa
|
||||
>STA.G CSH.CmdSave
|
||||
jmp (J.CSH.KW,x)
|
||||
*--------------------------------------
|
||||
CSH.WHILE
|
||||
CSH.IF jsr CSH.GetCharNB
|
||||
bcs .9
|
||||
cmp #'('
|
||||
bne .9
|
||||
jsr CSH.GetNextCharNB
|
||||
bcs .9
|
||||
|
||||
lda #0 Any var type
|
||||
jsr CSH.ExpEval
|
||||
bcs .99
|
||||
jsr CSH.GetCharNB
|
||||
bcs .99
|
||||
cmp #')'
|
||||
bne .9
|
||||
jsr CSH.GetNextCharNB skip ')'
|
||||
bcs .99
|
||||
cmp #'{'
|
||||
bne .9
|
||||
jsr CSH.GetNextCharNB Skip '{'
|
||||
bcs .99
|
||||
|
||||
jsr CSH.IsValue0 X = var type from ExpEval
|
||||
bcc .6 Value=0, skip {{....}}
|
||||
|
||||
>LDA.G CSH.CmdSave
|
||||
beq .1 IF
|
||||
|
||||
pha
|
||||
>LDA.G CSH.BufPtrSave+1 WHILE : push loop address...
|
||||
jsr CSH.Push
|
||||
>LDA.G CSH.BufPtrSave
|
||||
jsr CSH.Push
|
||||
pla
|
||||
.1 jsr CSH.Push
|
||||
bcs .99
|
||||
lda #'}' Tell '}' is expected at the end of block
|
||||
jsr CSH.Push
|
||||
bcs .99
|
||||
|
||||
rts
|
||||
.6 jsr CSH.SkipBlock
|
||||
|
||||
bcc .99
|
||||
.9 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
*CSH.Keyword.Start
|
||||
* >LDA.G CSH.CmdSave get back Token ("IF" or "WHILE")
|
||||
* tax
|
||||
* jmp (J.CSH.KW.START,x)
|
||||
*--------------------------------------
|
||||
*CSH.IF.START jmp CSH.Push Push "IF" Token
|
||||
*--------------------------------------
|
||||
*CSH.WHILE.START pha
|
||||
* >LDA.G CSH.BufPtrSave+1 WHILE : push loop address...
|
||||
* jsr CSH.Push
|
||||
* >LDA.G CSH.BufPtrSave
|
||||
* jsr CSH.Push
|
||||
* pla
|
||||
* jmp CSH.Push Push "WHILE" Token
|
||||
*--------------------------------------
|
||||
CSH.IF.END clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.WHILE.END jsr CSH.Pop
|
||||
sta ZPFileBufPtr
|
||||
jsr CSH.Pop
|
||||
sta ZPFileBufPtr+1
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.ELSE
|
||||
*--------------------------------------
|
||||
CSH.DO
|
||||
CSH.FOR
|
||||
CSH.SWITCH
|
||||
CSH.CASE
|
||||
CSH.BREAK
|
||||
CSH.CONTINUE
|
||||
CSH.TYPEDEF
|
||||
CSH.SIZEOF
|
||||
lda #CSH.E.SYNTAX
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.STRUCT >ENTER 4
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .99
|
||||
|
||||
>LDA.G CSH.hTags
|
||||
jsr CSH.NewKey
|
||||
bcs .99
|
||||
|
||||
sta (pStack)
|
||||
|
||||
|
||||
jsr CSH.GetNextCharNB
|
||||
bcs .99
|
||||
cmp #'{'
|
||||
bne .99
|
||||
|
||||
.1 jsr CSH.GetNextCharNB
|
||||
bcs .99
|
||||
cmp #'}'
|
||||
bne .1
|
||||
|
||||
jsr CSH.GetNextCharNB skip }
|
||||
|
||||
clc
|
||||
.99 >LEAVE
|
||||
rts
|
||||
*--------------------------------------
|
||||
* Built in Types
|
||||
*--------------------------------------
|
||||
CSH.SIGNED sec
|
||||
.HS 90 BCC
|
||||
*--------------------------------------
|
||||
CSH.UNSIGNED clc
|
||||
php
|
||||
|
||||
jsr CSH.CheckSpace
|
||||
bcs .9
|
||||
|
||||
>LDYA L.CSH.STYPES
|
||||
jsr CSH.LookupID
|
||||
|
||||
bcs .9
|
||||
|
||||
plp
|
||||
bcs .8
|
||||
jmp (J.CSH.UTYPES,x)
|
||||
|
||||
.8 jmp (J.CSH.STYPES,x)
|
||||
|
||||
.9 plp
|
||||
lda #CSH.E.SYNTAX
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.VOID ldx #CSH.T.VOID
|
||||
bra CSH.TYPE
|
||||
CSH.CHAR ldx #CSH.T.CHAR
|
||||
bra CSH.TYPE
|
||||
CSH.UCHAR ldx #CSH.T.UCHAR
|
||||
bra CSH.TYPE
|
||||
CSH.INT ldx #CSH.T.INT
|
||||
bra CSH.TYPE
|
||||
CSH.UINT ldx #CSH.T.UINT
|
||||
bra CSH.TYPE
|
||||
CSH.LONG ldx #CSH.T.LONG
|
||||
bra CSH.TYPE
|
||||
CSH.ULONG ldx #CSH.T.ULONG
|
||||
bra CSH.TYPE
|
||||
|
||||
CSH.FLOAT ldx #CSH.T.FLOAT
|
||||
|
||||
CSH.TYPE stx ZPVarType
|
||||
jsr CSH.CheckSpace
|
||||
bcs .9
|
||||
|
||||
.11 cmp #'*'
|
||||
bne .10
|
||||
|
||||
lda #CSH.Q.POINTER
|
||||
tsb ZPVarType
|
||||
jsr CSH.GetNextCharNB Skip *
|
||||
bra .11
|
||||
|
||||
.10 jsr CSH.IsLetter
|
||||
bcs .9
|
||||
|
||||
jsr CSH.AddVar add with undef value...
|
||||
bcs .99 OOM or DUP
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .9
|
||||
cmp #';'
|
||||
beq .8
|
||||
|
||||
.2 cmp #'='
|
||||
bne .9
|
||||
|
||||
jsr CSH.GetNextCharNB Skip =
|
||||
bcs .9
|
||||
|
||||
lda ZPVarType
|
||||
jsr CSH.ExpEval
|
||||
bcs .99
|
||||
|
||||
.7 jsr CSH.SetVarValueFromStack X= Type, Set value to this var
|
||||
bcs .99
|
||||
|
||||
jsr CSH.GetChar
|
||||
bcs .9
|
||||
|
||||
cmp #';'
|
||||
bne .9
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
|
||||
.9 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
* Input:
|
||||
* ZPFileBufPtr, A = Expected type
|
||||
* Output:
|
||||
* CS, A = EC
|
||||
* CC, Result on Stack, X = Type
|
||||
*--------------------------------------
|
||||
CSH.fCall ldx ZPPtr1
|
||||
phx
|
||||
ldx ZPPtr1+1 local : fdef
|
||||
phx
|
||||
ldx ZPPtr2 local : type
|
||||
phx
|
||||
ldx ZPPtr2+1 local : variadic size
|
||||
phx
|
||||
|
||||
sta ZPPtr2 save Type
|
||||
stz ZPPtr2+1 Reset VARIADIC byte count
|
||||
>LDYA L.CSH.FN
|
||||
jsr CSH.LookupFN
|
||||
phx X = function index
|
||||
bcs .10
|
||||
|
||||
>STYA ZPPtr1 f() definition, starting at returned type
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .10
|
||||
|
||||
cmp #'('
|
||||
bne .52
|
||||
jsr CSH.GetNextCharNB skip '('
|
||||
.10 bcs .90
|
||||
|
||||
lda ZPPtr2
|
||||
bne .11
|
||||
|
||||
lda (ZPPtr1)
|
||||
sta ZPPtr2
|
||||
bra .1 expected type is 0, no check
|
||||
|
||||
.11 cmp (ZPPtr1) Get Return value Type
|
||||
bne .91
|
||||
|
||||
.1 jsr CSH.ZPPtr1Next advance to arg list type
|
||||
|
||||
lda (ZPPtr1) get type of first arg
|
||||
beq .7 end of list, go check ending ')'
|
||||
*--------------------------------------
|
||||
.3 eor #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0
|
||||
beq .4
|
||||
eor #CSH.T.VARIADIC restore type...
|
||||
.4 jsr CSH.ExpEval A=0 if VARIADIC
|
||||
bcs .9 X = Var Type
|
||||
|
||||
lda (ZPPtr1) get current arg type
|
||||
eor #CSH.T.VARIADIC
|
||||
bne .5
|
||||
jsr CSH.GetVarSize X = Var Type
|
||||
* clc
|
||||
|
||||
adc ZPPtr2+1
|
||||
sta ZPPtr2+1 Add to byte count
|
||||
bra .51
|
||||
|
||||
.5 jsr CSH.ZPPtr1Next
|
||||
|
||||
.51 jsr CSH.GetCharNB
|
||||
bcs .90
|
||||
|
||||
cmp #','
|
||||
bne .6
|
||||
|
||||
jsr CSH.GetNextCharNB Skip ,
|
||||
lda (ZPPtr1)
|
||||
bne .3 Another ARG....
|
||||
|
||||
.52 bra .90 extra args....error
|
||||
|
||||
.6 cmp #')'
|
||||
bne .90
|
||||
lda (ZPPtr1)
|
||||
beq .8 no more arg after ')', exit
|
||||
eor #CSH.T.VARIADIC
|
||||
bne .90 missing arg
|
||||
|
||||
>PUSHB ZPPtr2+1 push VARIADIC byte count
|
||||
bra .8
|
||||
.7 jsr CSH.GetCharNB
|
||||
bcs .90
|
||||
cmp #')'
|
||||
bne .90
|
||||
|
||||
.8 jsr CSH.GetNextCharNB Skip )
|
||||
|
||||
plx restore X = function index
|
||||
ldy ZPPtr2 get type in Y
|
||||
pla
|
||||
sta ZPPtr2+1
|
||||
pla
|
||||
sta ZPPtr2
|
||||
pla
|
||||
sta ZPPtr1+1
|
||||
pla
|
||||
sta ZPPtr1
|
||||
phy
|
||||
jsr CSH.fCall.Exec
|
||||
plx restore returned type
|
||||
rts
|
||||
|
||||
.90 lda #CSH.E.SYNTAX
|
||||
.HS 2C BIT ABS
|
||||
.91 lda #CSH.E.TMISMATCH
|
||||
sec
|
||||
|
||||
.9 plx Discard function index
|
||||
|
||||
plx
|
||||
stx ZPPtr2+1
|
||||
plx
|
||||
stx ZPPtr2
|
||||
plx
|
||||
stx ZPPtr1+1
|
||||
plx
|
||||
stx ZPPtr1
|
||||
|
||||
.99 rts
|
||||
|
||||
*--------------------------------------
|
||||
CSH.fCall.Exec jmp (J.CSH.EXEC,x)
|
||||
*--------------------------------------
|
||||
* Input:
|
||||
* ZPFileBufPtr, A = Expected type
|
||||
* Output:
|
||||
* CS, A = EC
|
||||
* CC, X = Var Type, Value on Stack
|
||||
*--------------------------------------
|
||||
CSH.ExpEval ldx ZPPtr1
|
||||
phx
|
||||
ldx ZPPtr1+1 local : used by lookup
|
||||
phx
|
||||
ldx ZPPtr2 local : VarType
|
||||
phx
|
||||
ldx ZPPtr2+1 local : BOP
|
||||
phx
|
||||
|
||||
sta ZPPtr2 local : expected type
|
||||
|
||||
lda #$ff
|
||||
pha
|
||||
*--------------------------------------
|
||||
.10 jsr CSH.GetCharNB
|
||||
bcs .19
|
||||
|
||||
.11 cmp #'('
|
||||
bne .20
|
||||
|
||||
jsr CSH.GetNextCharNB skip (
|
||||
bcs .19
|
||||
|
||||
lda ZPPtr2
|
||||
|
||||
jsr CSH.ExpEval
|
||||
bcs .19
|
||||
stx ZPPtr2
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .19
|
||||
cmp #')'
|
||||
bne .19
|
||||
|
||||
jsr CSH.GetNextCharNB skip )
|
||||
bcc .31
|
||||
.19 jmp .90
|
||||
*--------------------------------------
|
||||
.20 jsr CSH.IsLetter define, Fnc or Var ?
|
||||
bcs .22
|
||||
|
||||
jsr CSH.GetDefine
|
||||
bcc .10
|
||||
|
||||
jsr CSH.GetVar
|
||||
bcs .21
|
||||
|
||||
ldx ZPPtr2 YA=VarID, X=expected var type (or 0=any)
|
||||
|
||||
jsr CSH.GetVarValueOnStack Y,A = VarID, Get value on stack
|
||||
bcs .29
|
||||
|
||||
stx ZPPtr2 store real var type
|
||||
bra .30
|
||||
|
||||
.21 lda ZPPtr2 var type
|
||||
jsr CSH.fCall X = function index
|
||||
bcs .29
|
||||
|
||||
stx ZPPtr2 store real var type
|
||||
bra .30
|
||||
|
||||
.22 jsr CSH.IsDigit10 number ?
|
||||
bcs .24
|
||||
|
||||
ldx ZPPtr2
|
||||
bne .23
|
||||
|
||||
ldx #CSH.T.INT
|
||||
stx ZPPtr2
|
||||
|
||||
.23 jsr CSH.GetNumOnStack
|
||||
bcs .29
|
||||
bra .30
|
||||
|
||||
.24 cmp #'"' String literal
|
||||
bne .90
|
||||
jsr CSH.AddContCharP
|
||||
.29 bcs .99
|
||||
*--------------------------------------
|
||||
.30 jsr CSH.GetCharNB
|
||||
bcs .90
|
||||
|
||||
.31 cmp #','
|
||||
beq .80
|
||||
cmp #')'
|
||||
beq .80
|
||||
cmp #';'
|
||||
beq .80
|
||||
|
||||
jsr CSH.IsOPChar
|
||||
bcs .90
|
||||
|
||||
>LDYA L.CSH.BOPS we are at V1 op1 V2 op2...
|
||||
jsr CSH.LookupOP
|
||||
bcs .90
|
||||
|
||||
stx ZPPtr2+1 save OP(n)
|
||||
|
||||
.32 pla get OP(n-1)
|
||||
bmi .33 $ff....
|
||||
|
||||
cmp ZPPtr2+1
|
||||
bcc .33 OP(n) has precedence, on stack : V1,V2
|
||||
|
||||
tax OP(n-1) has precedence...
|
||||
|
||||
lda ZPPtr2 Var Type
|
||||
jsr CSH.BOP.EXEC compute V(n-1) <OP(n-1)> V(n)
|
||||
bcc .32
|
||||
|
||||
bcs .99
|
||||
|
||||
.33 pha push back OP(n-1)
|
||||
lda ZPPtr2+1 get OP(n)
|
||||
pha push OP(n) on stack
|
||||
|
||||
jmp .10 go check for next token
|
||||
*--------------------------------------
|
||||
.80 plx any OP on stack ?
|
||||
bmi .88
|
||||
|
||||
lda ZPPtr2 Var Type
|
||||
jsr CSH.BOP.EXEC
|
||||
bcc .80
|
||||
|
||||
bcs .99
|
||||
|
||||
.90 lda #CSH.E.SYNTAX
|
||||
|
||||
.99 plx
|
||||
bpl .99
|
||||
|
||||
sec
|
||||
.HS 90 BCC
|
||||
.88 clc
|
||||
|
||||
ldx ZPPtr2 X = Var Type
|
||||
|
||||
ply
|
||||
sty ZPPtr2+1
|
||||
ply
|
||||
sty ZPPtr2
|
||||
ply
|
||||
sty ZPPtr1+1
|
||||
ply
|
||||
sty ZPPtr1
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.AddContCharP
|
||||
ldy #0
|
||||
|
||||
.1 jsr CSH.GetNextChar
|
||||
bcs .9
|
||||
cmp #C.CR
|
||||
beq .9
|
||||
cmp #'"'
|
||||
beq .2
|
||||
sta (ZPCSHConst),y
|
||||
iny
|
||||
bra .1
|
||||
|
||||
.2 lda #0
|
||||
sta (ZPCSHConst),y
|
||||
>PUSHW ZPCSHConst Push PTR on stack
|
||||
|
||||
tya
|
||||
sec
|
||||
adc ZPCSHConst
|
||||
sta ZPCSHConst
|
||||
bcc .3
|
||||
inc ZPCSHConst+1
|
||||
.3 jsr CSH.GetNextChar Skip "
|
||||
|
||||
clc
|
||||
rts
|
||||
.9 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.SavePtr >LDYA ZPFileBufPtr
|
||||
>STYA.G CSH.BufPtrSave
|
||||
rts
|
||||
|
@ -907,74 +411,22 @@ CSH.ZPPtr1AddAp1
|
|||
inc ZPPtr1+1
|
||||
.1 rts
|
||||
*--------------------------------------
|
||||
CSH.GetNumOnStack
|
||||
txa
|
||||
beq .99
|
||||
|
||||
.10 cpx #CSH.T.FLOAT
|
||||
bcc .1
|
||||
bne .99
|
||||
|
||||
>PUSHW ZPFileBufPtr
|
||||
>PUSHWI ZPFileBufPtr
|
||||
>SYSCALL StrToF
|
||||
clc
|
||||
rts
|
||||
|
||||
.1 >PUSHW ZPFileBufPtr
|
||||
>PUSHWI ZPFileBufPtr
|
||||
>PUSHBI 10
|
||||
phx
|
||||
cpx #CSH.T.UCHAR
|
||||
bcc .2
|
||||
>SYSCALL StrToUL
|
||||
bra .3
|
||||
|
||||
.2 >SYSCALL StrToL
|
||||
|
||||
.3 plx
|
||||
bcs .9
|
||||
|
||||
lda CSH.TYPESIZE,x
|
||||
cmp #4
|
||||
beq .8
|
||||
|
||||
cmp #2
|
||||
bne .4
|
||||
ldy #1
|
||||
>PULLA
|
||||
sta (pStack),y
|
||||
>PULLA
|
||||
sta (pStack),y
|
||||
clc
|
||||
rts
|
||||
|
||||
.4 >PULLA
|
||||
inc pStack
|
||||
inc pStack
|
||||
sta (pStack)
|
||||
.8 clc
|
||||
.9 rts
|
||||
|
||||
.99 lda #CSH.E.TMISMATCH
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
* Input : ZPFileBufPtr
|
||||
* Output : Y,A = VarID
|
||||
*--------------------------------------
|
||||
CSH.AddVar >LDA.G CSH.hSymbols
|
||||
CSH.AddSymbol >LDA.G CSH.hSymbols
|
||||
jsr CSH.NewKey
|
||||
bcs .9
|
||||
|
||||
>STYA ZPVarID
|
||||
ldx ZPVarType
|
||||
jsr CSH.GetVarSize
|
||||
jsr CSH.GetVarSize CS if pointer
|
||||
sta ZPVarSizeOf
|
||||
|
||||
* clc / sec
|
||||
|
||||
lda ZPCSHData
|
||||
sta ZPVarDataPtr
|
||||
clc
|
||||
adc ZPVarSizeOf
|
||||
sta ZPCSHData
|
||||
|
||||
|
@ -1008,6 +460,32 @@ CSH.TMISMATCH lda #CSH.E.TMISMATCH
|
|||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.AddFunction lda #CSH.Q.FUNC
|
||||
tsb ZPVarType
|
||||
|
||||
jsr CSH.GetNextCharNB Skip (
|
||||
bcs .9
|
||||
|
||||
.1 cmp #')'
|
||||
beq .5
|
||||
|
||||
>LDYA L.CSH.TYPES
|
||||
jsr CSH.LookupID
|
||||
bcs .9
|
||||
|
||||
|
||||
|
||||
.5 jsr CSH.GetNextCharNB Skip )
|
||||
|
||||
jsr CSH.SkipLine
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
.9 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
CSH.NewKey >PUSHA
|
||||
>PUSHW ZPFileBufPtr
|
||||
>SYSCALL SListNewKey
|
||||
|
@ -1434,9 +912,12 @@ CSH.GetVarSize txa
|
|||
tax
|
||||
lda CSH.TYPESIZE,x
|
||||
plx
|
||||
|
||||
clc
|
||||
rts
|
||||
|
||||
.2 lda #2
|
||||
.2 sec +1 for hMem Storage
|
||||
lda #2
|
||||
rts
|
||||
*--------------------------------------
|
||||
DEBUG.VAR >SYSCALL PutChar
|
||||
|
|
|
@ -0,0 +1,247 @@
|
|||
NEW
|
||||
AUTO 3,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
* Input:
|
||||
* ZPFileBufPtr, A = Expected type
|
||||
* Output:
|
||||
* CS, A = EC
|
||||
* CC, X = Var Type, Value on Stack
|
||||
*--------------------------------------
|
||||
CSH.ExpEval ldx ZPPtr1
|
||||
phx
|
||||
ldx ZPPtr1+1 local : used by lookup
|
||||
phx
|
||||
ldx ZPPtr2 local : VarType
|
||||
phx
|
||||
ldx ZPPtr2+1 local : BOP
|
||||
phx
|
||||
|
||||
sta ZPPtr2 local : expected type
|
||||
|
||||
lda #$ff
|
||||
pha
|
||||
*--------------------------------------
|
||||
.10 jsr CSH.GetCharNB
|
||||
bcs .19
|
||||
|
||||
.11 cmp #'('
|
||||
bne .20
|
||||
|
||||
jsr CSH.GetNextCharNB skip (
|
||||
bcs .19
|
||||
|
||||
lda ZPPtr2
|
||||
|
||||
jsr CSH.ExpEval
|
||||
bcs .19
|
||||
stx ZPPtr2
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .19
|
||||
cmp #')'
|
||||
bne .19
|
||||
|
||||
jsr CSH.GetNextCharNB skip )
|
||||
bcc .31
|
||||
.19 jmp .90
|
||||
*--------------------------------------
|
||||
.20 jsr CSH.IsLetter define, Fnc or Var ?
|
||||
bcs .22
|
||||
|
||||
jsr CSH.GetDefine
|
||||
bcc .10
|
||||
|
||||
jsr CSH.GetVar
|
||||
bcs .21
|
||||
|
||||
ldx ZPPtr2 YA=VarID, X=expected var type (or 0=any)
|
||||
|
||||
jsr CSH.GetVarValueOnStack Y,A = VarID, Get value on stack
|
||||
bcs .29
|
||||
|
||||
stx ZPPtr2 store real var type
|
||||
bra .30
|
||||
|
||||
.21 lda ZPPtr2 var type
|
||||
jsr CSH.fCall X = function index
|
||||
bcs .29
|
||||
|
||||
stx ZPPtr2 store real var type
|
||||
bra .30
|
||||
|
||||
.22 jsr CSH.IsDigit10 number ?
|
||||
bcs .24
|
||||
|
||||
ldx ZPPtr2
|
||||
bne .23
|
||||
|
||||
ldx #CSH.T.INT
|
||||
stx ZPPtr2
|
||||
|
||||
.23 jsr CSH.GetNumOnStack
|
||||
bcs .29
|
||||
bra .30
|
||||
|
||||
.24 cmp #'"' String literal
|
||||
bne .90
|
||||
jsr CSH.AddContCharP
|
||||
.29 bcs .99
|
||||
*--------------------------------------
|
||||
.30 jsr CSH.GetCharNB
|
||||
bcs .90
|
||||
|
||||
.31 cmp #','
|
||||
beq .80
|
||||
cmp #')'
|
||||
beq .80
|
||||
cmp #';'
|
||||
beq .80
|
||||
|
||||
jsr CSH.IsOPChar
|
||||
bcs .90
|
||||
|
||||
>LDYA L.CSH.BOPS we are at V1 op1 V2 op2...
|
||||
jsr CSH.LookupOP
|
||||
bcs .90
|
||||
|
||||
stx ZPPtr2+1 save OP(n)
|
||||
|
||||
.32 pla get OP(n-1)
|
||||
bmi .33 $ff....
|
||||
|
||||
cmp ZPPtr2+1
|
||||
bcc .33 OP(n) has precedence, on stack : V1,V2
|
||||
|
||||
tax OP(n-1) has precedence...
|
||||
|
||||
lda ZPPtr2 Var Type
|
||||
jsr CSH.BOP.EXEC compute V(n-1) <OP(n-1)> V(n)
|
||||
bcc .32
|
||||
|
||||
bcs .99
|
||||
|
||||
.33 pha push back OP(n-1)
|
||||
lda ZPPtr2+1 get OP(n)
|
||||
pha push OP(n) on stack
|
||||
|
||||
jmp .10 go check for next token
|
||||
*--------------------------------------
|
||||
.80 plx any OP on stack ?
|
||||
bmi .88
|
||||
|
||||
lda ZPPtr2 Var Type
|
||||
jsr CSH.BOP.EXEC
|
||||
bcc .80
|
||||
|
||||
bcs .99
|
||||
|
||||
.90 lda #CSH.E.SYNTAX
|
||||
|
||||
.99 plx
|
||||
bpl .99
|
||||
|
||||
sec
|
||||
.HS 90 BCC
|
||||
.88 clc
|
||||
|
||||
ldx ZPPtr2 X = Var Type
|
||||
|
||||
ply
|
||||
sty ZPPtr2+1
|
||||
ply
|
||||
sty ZPPtr2
|
||||
ply
|
||||
sty ZPPtr1+1
|
||||
ply
|
||||
sty ZPPtr1
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.AddContCharP
|
||||
ldy #0
|
||||
|
||||
.1 jsr CSH.GetNextChar
|
||||
bcs .9
|
||||
cmp #C.CR
|
||||
beq .9
|
||||
cmp #'"'
|
||||
beq .2
|
||||
sta (ZPCSHConst),y
|
||||
iny
|
||||
bra .1
|
||||
|
||||
.2 lda #0
|
||||
sta (ZPCSHConst),y
|
||||
>PUSHW ZPCSHConst Push PTR on stack
|
||||
|
||||
tya
|
||||
sec
|
||||
adc ZPCSHConst
|
||||
sta ZPCSHConst
|
||||
bcc .3
|
||||
inc ZPCSHConst+1
|
||||
.3 jsr CSH.GetNextChar Skip "
|
||||
|
||||
clc
|
||||
rts
|
||||
.9 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.GetNumOnStack
|
||||
txa
|
||||
beq .99
|
||||
|
||||
.10 cpx #CSH.T.FLOAT
|
||||
bcc .1
|
||||
bne .99
|
||||
|
||||
>PUSHW ZPFileBufPtr
|
||||
>PUSHWI ZPFileBufPtr
|
||||
>SYSCALL StrToF
|
||||
clc
|
||||
rts
|
||||
|
||||
.1 >PUSHW ZPFileBufPtr
|
||||
>PUSHWI ZPFileBufPtr
|
||||
>PUSHBI 10
|
||||
phx
|
||||
cpx #CSH.T.UCHAR
|
||||
bcc .2
|
||||
>SYSCALL StrToUL
|
||||
bra .3
|
||||
|
||||
.2 >SYSCALL StrToL
|
||||
|
||||
.3 plx
|
||||
bcs .9
|
||||
|
||||
lda CSH.TYPESIZE,x
|
||||
cmp #4
|
||||
beq .8
|
||||
|
||||
cmp #2
|
||||
bne .4
|
||||
ldy #1
|
||||
>PULLA
|
||||
sta (pStack),y
|
||||
>PULLA
|
||||
sta (pStack),y
|
||||
clc
|
||||
rts
|
||||
|
||||
.4 >PULLA
|
||||
inc pStack
|
||||
inc pStack
|
||||
sta (pStack)
|
||||
.8 clc
|
||||
.9 rts
|
||||
|
||||
.99 lda #CSH.E.TMISMATCH
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE usr/src/bin/csh.s.exp
|
||||
LOAD usr/src/bin/csh.s
|
||||
ASM
|
|
@ -0,0 +1,355 @@
|
|||
NEW
|
||||
AUTO 3,1
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
* Built in Keywords
|
||||
*--------------------------------------
|
||||
CSH.KW.JMP txa
|
||||
>STA.G CSH.CmdSave
|
||||
jmp (J.CSH.KW,x)
|
||||
*--------------------------------------
|
||||
CSH.WHILE
|
||||
CSH.IF jsr CSH.GetCharNB
|
||||
bcs .9
|
||||
cmp #'('
|
||||
bne .9
|
||||
jsr CSH.GetNextCharNB
|
||||
bcs .9
|
||||
|
||||
lda #0 Any var type
|
||||
jsr CSH.ExpEval
|
||||
bcs .99
|
||||
jsr CSH.GetCharNB
|
||||
bcs .99
|
||||
cmp #')'
|
||||
bne .9
|
||||
jsr CSH.GetNextCharNB skip ')'
|
||||
bcs .99
|
||||
cmp #'{'
|
||||
bne .9
|
||||
jsr CSH.GetNextCharNB Skip '{'
|
||||
bcs .99
|
||||
|
||||
jsr CSH.IsValue0 X = var type from ExpEval
|
||||
bcc .6 Value=0, skip {{....}}
|
||||
|
||||
>LDA.G CSH.CmdSave
|
||||
beq .1 IF
|
||||
|
||||
pha
|
||||
>LDA.G CSH.BufPtrSave+1 WHILE : push loop address...
|
||||
jsr CSH.Push
|
||||
>LDA.G CSH.BufPtrSave
|
||||
jsr CSH.Push
|
||||
pla
|
||||
.1 jsr CSH.Push
|
||||
bcs .99
|
||||
lda #'}' Tell '}' is expected at the end of block
|
||||
jsr CSH.Push
|
||||
bcs .99
|
||||
|
||||
rts
|
||||
.6 jsr CSH.SkipBlock
|
||||
|
||||
bcc .99
|
||||
.9 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
*CSH.Keyword.Start
|
||||
* >LDA.G CSH.CmdSave get back Token ("IF" or "WHILE")
|
||||
* tax
|
||||
* jmp (J.CSH.KW.START,x)
|
||||
*--------------------------------------
|
||||
*CSH.IF.START jmp CSH.Push Push "IF" Token
|
||||
*--------------------------------------
|
||||
*CSH.WHILE.START pha
|
||||
* >LDA.G CSH.BufPtrSave+1 WHILE : push loop address...
|
||||
* jsr CSH.Push
|
||||
* >LDA.G CSH.BufPtrSave
|
||||
* jsr CSH.Push
|
||||
* pla
|
||||
* jmp CSH.Push Push "WHILE" Token
|
||||
*--------------------------------------
|
||||
CSH.IF.END clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.WHILE.END jsr CSH.Pop
|
||||
sta ZPFileBufPtr
|
||||
jsr CSH.Pop
|
||||
sta ZPFileBufPtr+1
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.ELSE
|
||||
*--------------------------------------
|
||||
CSH.DO
|
||||
CSH.FOR
|
||||
CSH.SWITCH
|
||||
CSH.CASE
|
||||
CSH.BREAK
|
||||
CSH.CONTINUE
|
||||
CSH.TYPEDEF
|
||||
CSH.SIZEOF
|
||||
lda #CSH.E.SYNTAX
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.STRUCT >ENTER 4
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .99
|
||||
|
||||
>LDA.G CSH.hTags
|
||||
jsr CSH.NewKey
|
||||
bcs .99
|
||||
|
||||
sta (pStack)
|
||||
|
||||
|
||||
jsr CSH.GetNextCharNB
|
||||
bcs .99
|
||||
cmp #'{'
|
||||
bne .99
|
||||
|
||||
.1 jsr CSH.GetNextCharNB
|
||||
bcs .99
|
||||
cmp #'}'
|
||||
bne .1
|
||||
|
||||
jsr CSH.GetNextCharNB skip }
|
||||
|
||||
clc
|
||||
.99 >LEAVE
|
||||
rts
|
||||
*--------------------------------------
|
||||
* Built in Types
|
||||
*--------------------------------------
|
||||
CSH.SIGNED sec
|
||||
.HS 90 BCC
|
||||
*--------------------------------------
|
||||
CSH.UNSIGNED clc
|
||||
php
|
||||
|
||||
jsr CSH.CheckSpace
|
||||
bcs .9
|
||||
|
||||
>LDYA L.CSH.STYPES
|
||||
jsr CSH.LookupID
|
||||
|
||||
bcs .9
|
||||
|
||||
plp
|
||||
bcs .8
|
||||
jmp (J.CSH.UTYPES,x)
|
||||
|
||||
.8 jmp (J.CSH.STYPES,x)
|
||||
|
||||
.9 plp
|
||||
lda #CSH.E.SYNTAX
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
CSH.VOID ldx #CSH.T.VOID
|
||||
bra CSH.TYPE
|
||||
CSH.CHAR ldx #CSH.T.CHAR
|
||||
bra CSH.TYPE
|
||||
CSH.UCHAR ldx #CSH.T.UCHAR
|
||||
bra CSH.TYPE
|
||||
CSH.INT ldx #CSH.T.INT
|
||||
bra CSH.TYPE
|
||||
CSH.UINT ldx #CSH.T.UINT
|
||||
bra CSH.TYPE
|
||||
CSH.LONG ldx #CSH.T.LONG
|
||||
bra CSH.TYPE
|
||||
CSH.ULONG ldx #CSH.T.ULONG
|
||||
bra CSH.TYPE
|
||||
|
||||
CSH.FLOAT ldx #CSH.T.FLOAT
|
||||
|
||||
CSH.TYPE stx ZPVarType
|
||||
jsr CSH.CheckSpace
|
||||
bcs .9
|
||||
|
||||
.11 cmp #'*'
|
||||
bne .10
|
||||
|
||||
lda #CSH.Q.POINTER
|
||||
tsb ZPVarType
|
||||
jsr CSH.GetNextCharNB Skip *
|
||||
bra .11
|
||||
|
||||
.10 jsr CSH.IsLetter
|
||||
bcs .9
|
||||
|
||||
jsr CSH.AddSymbol add with undef value...
|
||||
bcs .99 OOM or DUP
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .9
|
||||
cmp #';'
|
||||
beq .8
|
||||
|
||||
cmp #'='
|
||||
beq .2
|
||||
|
||||
cmp #'('
|
||||
bne .9
|
||||
|
||||
jmp CSH.AddFunction
|
||||
|
||||
.2 jsr CSH.GetNextCharNB Skip =
|
||||
bcs .9
|
||||
|
||||
lda ZPVarType
|
||||
jsr CSH.ExpEval
|
||||
bcs .99
|
||||
|
||||
.7 jsr CSH.SetVarValueFromStack X= Type, Set value to this var
|
||||
bcs .99
|
||||
|
||||
jsr CSH.GetChar
|
||||
bcs .9
|
||||
|
||||
cmp #';'
|
||||
bne .9
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
|
||||
.9 lda #CSH.E.SYNTAX
|
||||
sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
* Input:
|
||||
* ZPFileBufPtr, A = Expected type
|
||||
* Output:
|
||||
* CS, A = EC
|
||||
* CC, Result on Stack, X = Type
|
||||
*--------------------------------------
|
||||
CSH.fCall ldx ZPPtr1
|
||||
phx
|
||||
ldx ZPPtr1+1 local : fdef
|
||||
phx
|
||||
ldx ZPPtr2 local : type
|
||||
phx
|
||||
ldx ZPPtr2+1 local : variadic size
|
||||
phx
|
||||
|
||||
sta ZPPtr2 save Type
|
||||
stz ZPPtr2+1 Reset VARIADIC byte count
|
||||
>LDYA L.CSH.FN
|
||||
jsr CSH.LookupFN
|
||||
phx X = function index
|
||||
bcs .10
|
||||
|
||||
>STYA ZPPtr1 f() definition, starting at returned type
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
bcs .10
|
||||
|
||||
cmp #'('
|
||||
bne .52
|
||||
jsr CSH.GetNextCharNB skip '('
|
||||
.10 bcs .90
|
||||
|
||||
lda ZPPtr2
|
||||
bne .11
|
||||
|
||||
lda (ZPPtr1)
|
||||
sta ZPPtr2
|
||||
bra .1 expected type is 0, no check
|
||||
|
||||
.11 cmp (ZPPtr1) Get Return value Type
|
||||
bne .91
|
||||
|
||||
.1 jsr CSH.ZPPtr1Next advance to arg list type
|
||||
|
||||
lda (ZPPtr1) get type of first arg
|
||||
beq .7 end of list, go check ending ')'
|
||||
*--------------------------------------
|
||||
.3 eor #CSH.T.VARIADIC if VARIADIC, don't advance to next arg and assume type = 0
|
||||
beq .4
|
||||
eor #CSH.T.VARIADIC restore type...
|
||||
.4 jsr CSH.ExpEval A=0 if VARIADIC
|
||||
bcs .9 X = Var Type
|
||||
|
||||
lda (ZPPtr1) get current arg type
|
||||
eor #CSH.T.VARIADIC
|
||||
bne .5
|
||||
jsr CSH.GetVarSize X = Var Type
|
||||
|
||||
clc make sure pointer only 2 bytes
|
||||
adc ZPPtr2+1
|
||||
sta ZPPtr2+1 Add to byte count
|
||||
bra .51
|
||||
|
||||
.5 jsr CSH.ZPPtr1Next
|
||||
|
||||
.51 jsr CSH.GetCharNB
|
||||
bcs .90
|
||||
|
||||
cmp #','
|
||||
bne .6
|
||||
|
||||
jsr CSH.GetNextCharNB Skip ,
|
||||
lda (ZPPtr1)
|
||||
bne .3 Another ARG....
|
||||
|
||||
.52 bra .90 extra args....error
|
||||
|
||||
.6 cmp #')'
|
||||
bne .90
|
||||
lda (ZPPtr1)
|
||||
beq .8 no more arg after ')', exit
|
||||
eor #CSH.T.VARIADIC
|
||||
bne .90 missing arg
|
||||
|
||||
>PUSHB ZPPtr2+1 push VARIADIC byte count
|
||||
bra .8
|
||||
.7 jsr CSH.GetCharNB
|
||||
bcs .90
|
||||
cmp #')'
|
||||
bne .90
|
||||
|
||||
.8 jsr CSH.GetNextCharNB Skip )
|
||||
|
||||
plx restore X = function index
|
||||
ldy ZPPtr2 get type in Y
|
||||
pla
|
||||
sta ZPPtr2+1
|
||||
pla
|
||||
sta ZPPtr2
|
||||
pla
|
||||
sta ZPPtr1+1
|
||||
pla
|
||||
sta ZPPtr1
|
||||
phy
|
||||
jsr CSH.fCall.Exec
|
||||
plx restore returned type
|
||||
rts
|
||||
|
||||
.90 lda #CSH.E.SYNTAX
|
||||
.HS 2C BIT ABS
|
||||
.91 lda #CSH.E.TMISMATCH
|
||||
sec
|
||||
|
||||
.9 plx Discard function index
|
||||
|
||||
plx
|
||||
stx ZPPtr2+1
|
||||
plx
|
||||
stx ZPPtr2
|
||||
plx
|
||||
stx ZPPtr1+1
|
||||
plx
|
||||
stx ZPPtr1
|
||||
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
CSH.fCall.Exec jmp (J.CSH.EXEC,x)
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE usr/src/bin/csh.s.kw
|
||||
LOAD usr/src/bin/csh.s
|
||||
ASM
|
|
@ -17,22 +17,22 @@ NEW
|
|||
.DUMMY
|
||||
.OR ZPBIN
|
||||
ZS.START
|
||||
ZPFileBuf .BS 2
|
||||
ZPFileBufPtr .BS 2
|
||||
ZPFileBufPtrBak .BS 2
|
||||
|
||||
|
||||
ZPCSHCode .BS 2
|
||||
ZPCSHConst .BS 2
|
||||
ZPCSHData .BS 2
|
||||
ZPCSHStack .BS 2
|
||||
|
||||
|
||||
ZPVarID .BS 2
|
||||
ZPVarDef .EQ *
|
||||
ZPVarDef .EQ *
|
||||
ZPVarType .BS 2
|
||||
ZPVarSizeOf .BS 2
|
||||
ZPVarDataPtr .BS 2
|
||||
|
||||
ZPFileBuf .BS 2
|
||||
ZPFileBufPtr .BS 2
|
||||
ZPFileBufPtrBak .BS 2
|
||||
|
||||
|
||||
ZPhMacro .BS 1
|
||||
ArgIndex .BS 1
|
||||
ZPPtr1 .BS 2
|
||||
|
@ -67,6 +67,7 @@ L.MSG.ECHOCRLF .DA MSG.ECHOCRLF
|
|||
L.MSG.DEBUG .DA MSG.DEBUG
|
||||
L.MSG.ERR .DA MSG.ERR
|
||||
L.MSG.DBGVAR .DA MSG.DBGVAR
|
||||
L.ENV.INCLUDE .DA ENV.INCLUDE
|
||||
.INB usr/src/bin/csh.r
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
|
@ -293,6 +294,8 @@ PrintTraceMsg.3 >PUSHBI '>'
|
|||
rts
|
||||
*--------------------------------------
|
||||
.INB usr/src/bin/csh.s.core
|
||||
.INB usr/src/bin/csh.s.kw
|
||||
.INB usr/src/bin/csh.s.exp
|
||||
.INB usr/src/bin/csh.s.exec
|
||||
*--------------------------------------
|
||||
CS.END
|
||||
|
@ -308,6 +311,8 @@ MSG.DEBUG .AZ "pStack=%H"
|
|||
MSG.ERR .AZ "^\r\nLine #%D:"
|
||||
MSG.DBGVAR .AZ "K=%H, T=%H, S=%H, P=%H, V=%L\r\n"
|
||||
*--------------------------------------
|
||||
ENV.INCLUDE .AZ "INCLUDE"
|
||||
*--------------------------------------
|
||||
OptionList .AS "DdTt"
|
||||
OptionVars .DA #bDebug,#bDebug,#bTrace,#bTrace
|
||||
*--------------------------------------
|
||||
|
|
|
@ -347,7 +347,10 @@ CS.RUN.LL.DISKII
|
|||
|
||||
ldx #0
|
||||
|
||||
.1 jsr CS.RUN.SeekToX
|
||||
.1 jsr CS.RUN.CheckCtrlC
|
||||
bcs .9
|
||||
|
||||
jsr CS.RUN.SeekToX
|
||||
bcs .9
|
||||
|
||||
>SLEEP
|
||||
|
@ -423,7 +426,10 @@ CS.RUN.LL.DISKII.V
|
|||
|
||||
.1 ldx #8
|
||||
|
||||
.2 phx
|
||||
.2 jsr CS.RUN.CheckCtrlC
|
||||
bcs .9
|
||||
|
||||
phx
|
||||
jsr CS.RUN.LL.DISKII.VP
|
||||
plx
|
||||
bcs .9
|
||||
|
@ -662,6 +668,29 @@ CS.RUN.CheckOpt ldy #1
|
|||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN.CheckCtrlC
|
||||
phx
|
||||
phy
|
||||
|
||||
ldy #S.PS.hStdIn
|
||||
lda (pPS),y
|
||||
>SYSCALL FEOF
|
||||
bcs .9
|
||||
tay
|
||||
bne .9 CC
|
||||
|
||||
>SYSCALL GetChar
|
||||
bcs .9
|
||||
|
||||
cmp #$03 Ctrl-C
|
||||
beq .9 CS
|
||||
|
||||
clc
|
||||
|
||||
.9 ply
|
||||
plx
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.END
|
||||
*--------------------------------------
|
||||
LIBBLKDEV .AZ "libblkdev"
|
||||
|
|
|
@ -201,10 +201,13 @@ CS.RUN jsr CL.Init
|
|||
|
||||
ldy #1
|
||||
lda (ZPPtr1),y
|
||||
cmp #'c'
|
||||
beq .10
|
||||
|
||||
cmp #'C'
|
||||
bne .1
|
||||
|
||||
iny
|
||||
.10 iny
|
||||
lda (ZPPtr1),y
|
||||
bne .1
|
||||
|
||||
|
@ -228,14 +231,14 @@ CS.RUN jsr CL.Init
|
|||
*--------------------------------------
|
||||
.2 jsr CMD.CD.HOME
|
||||
jsr HIS.Init
|
||||
bcs CS.INIT.RTS
|
||||
.99 bcs CS.INIT.RTS
|
||||
|
||||
>PUSHW L.MSG.GREETINGS
|
||||
>PUSHB #K.VER
|
||||
>PUSHB /K.VER
|
||||
>PUSHBI 2
|
||||
>SYSCALL PrintF
|
||||
bcs CS.INIT.RTS
|
||||
bcs .99
|
||||
|
||||
>LDYA L.HOME.PROFILE
|
||||
jsr IO.Load
|
||||
|
|
93
BIN/WC.S.txt
93
BIN/WC.S.txt
|
@ -25,11 +25,16 @@ ZPFileStat .BS 2
|
|||
|
||||
ZPFullPath .BS 2
|
||||
ZPRelPath .BS 2
|
||||
|
||||
ZPLineBuf .BS 2
|
||||
|
||||
bPause .BS 1
|
||||
ArgIndex .BS 1
|
||||
hSrcFullPath .BS 1
|
||||
hFile .BS 1
|
||||
hMem .BS 1
|
||||
|
||||
bTabbed .BS 1
|
||||
|
||||
bPause .BS 1
|
||||
bContinue .BS 1
|
||||
bRecurse .BS 1
|
||||
bChar .BS 1
|
||||
|
@ -61,6 +66,7 @@ CS.START cld
|
|||
.DA CS.QUIT
|
||||
L.MSG.USAGE .DA MSG.USAGE
|
||||
L.MSG.ERR .DA MSG.ERR
|
||||
L.MSG.LONGTAB .DA MSG.LONGTAB
|
||||
L.MSG.LONG .DA MSG.LONG
|
||||
L.MSG.TOTAL .DA MSG.TOTAL
|
||||
.DA 0
|
||||
|
@ -68,13 +74,16 @@ L.MSG.TOTAL .DA MSG.TOTAL
|
|||
CS.INIT clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN >INC.G ArgIndex
|
||||
CS.RUN inc ArgIndex
|
||||
lda ArgIndex
|
||||
>SYSCALL ArgV
|
||||
bcs .5
|
||||
|
||||
>STYA ZPPtr1
|
||||
lda (ZPPtr1)
|
||||
cmp #'-'
|
||||
bne .4
|
||||
|
||||
jsr CS.RUN.CheckOpt
|
||||
bcc CS.RUN
|
||||
|
||||
|
@ -121,8 +130,7 @@ CS.RUN >INC.G ArgIndex
|
|||
>SYSCALL GetMem
|
||||
bcs .99
|
||||
>STYA ZPFullPath
|
||||
txa
|
||||
>STA.G hSrcFullPath
|
||||
stx hSrcFullPath
|
||||
|
||||
>LDA.G hSrcBasePath
|
||||
>SYSCALL GetMemPtr
|
||||
|
@ -146,8 +154,7 @@ CS.RUN >INC.G ArgIndex
|
|||
>SYSCALL GetMem
|
||||
bcs .99
|
||||
>STYA ZPLineBuf
|
||||
txa
|
||||
>STA.G hMem
|
||||
stx hMem
|
||||
*--------------------------------------
|
||||
CS.RUN.LOOP ldy #S.PS.hStdIn
|
||||
lda (pPS),y
|
||||
|
@ -205,13 +212,12 @@ CS.RUN.PIPE >LDYAI 256
|
|||
>SYSCALL GetMem
|
||||
bcs .99
|
||||
>STYA ZPLineBuf
|
||||
txa
|
||||
>STA.G hMem
|
||||
stx hMem
|
||||
|
||||
ldy #S.PS.hStdIn
|
||||
lda (pPS),y
|
||||
|
||||
>STA.G hFile
|
||||
sta hFile
|
||||
|
||||
jsr CS.RUN.FILE.LOOP
|
||||
jsr CS.RUN.PrintFstat
|
||||
|
@ -280,7 +286,7 @@ CS.RUN.FILE jsr FilterMatch
|
|||
CS.RUN.FILE.LOOP
|
||||
.1 >PUSHWI 256
|
||||
>PUSHW ZPLineBuf
|
||||
>LDA.G hFile
|
||||
lda hFile
|
||||
>SYSCALL fgets
|
||||
bcs .8
|
||||
|
||||
|
@ -363,15 +369,17 @@ CS.RUN.OpenFile ldx #12
|
|||
>SYSCALL FOpen
|
||||
bcs .9
|
||||
|
||||
>STA.G hFile
|
||||
sta hFile
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CS.RUN.CloseFile
|
||||
>LDA.G hFile
|
||||
lda hFile
|
||||
>SYSCALL FClose
|
||||
bcs .9
|
||||
>STZ.G hFile
|
||||
|
||||
stz hFile
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
CS.RUN.IncFChar phy
|
||||
|
@ -417,10 +425,33 @@ CS.RUN.AddFstat2Tstat
|
|||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN.PrintFstat
|
||||
sec
|
||||
bit bTotal
|
||||
bmi .19
|
||||
|
||||
ldx #0
|
||||
|
||||
bit bWord
|
||||
bpl .10
|
||||
|
||||
inx
|
||||
|
||||
.10 bit bLine
|
||||
bpl .11
|
||||
|
||||
inx
|
||||
|
||||
.11 bit bChar
|
||||
|
||||
inx
|
||||
|
||||
.12 cpx #2
|
||||
.19 ror bTabbed
|
||||
|
||||
bit bWord
|
||||
bpl .1
|
||||
|
||||
>PUSHW L.MSG.LONG
|
||||
jsr CS.RUN.PUSHFMT
|
||||
>PUSHL.G fWordCount
|
||||
>PUSHBI 4
|
||||
>SYSCALL PrintF
|
||||
|
@ -429,7 +460,7 @@ CS.RUN.PrintFstat
|
|||
.1 bit bLine
|
||||
bpl .2
|
||||
|
||||
>PUSHW L.MSG.LONG
|
||||
jsr CS.RUN.PUSHFMT
|
||||
>PUSHL.G fLineCount
|
||||
>PUSHBI 4
|
||||
>SYSCALL PrintF
|
||||
|
@ -438,7 +469,7 @@ CS.RUN.PrintFstat
|
|||
.2 bit bChar
|
||||
bpl .3
|
||||
|
||||
>PUSHW L.MSG.LONG
|
||||
jsr CS.RUN.PUSHFMT
|
||||
>PUSHL.G fCharCount
|
||||
>PUSHBI 4
|
||||
>SYSCALL PrintF
|
||||
|
@ -450,9 +481,18 @@ CS.RUN.PrintFstat
|
|||
CS.RUN.PrintFstat.RTS
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN.PUSHFMT bit bTabbed
|
||||
bmi .1
|
||||
|
||||
>PUSHW L.MSG.LONG
|
||||
rts
|
||||
|
||||
.1 >PUSHW L.MSG.LONGTAB
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN.PrintTstat
|
||||
clc
|
||||
lda bTotal
|
||||
bit bTotal
|
||||
bpl CS.RUN.PrintFstat.RTS
|
||||
|
||||
bit bWord
|
||||
|
@ -496,11 +536,11 @@ CS.QUIT jsr LeaveSubDir
|
|||
beq .1
|
||||
|
||||
>SYSCALL FreeMem
|
||||
.1 >LDA.G hSrcFullPath
|
||||
.1 lda hSrcFullPath
|
||||
beq .2
|
||||
|
||||
>SYSCALL FreeMem
|
||||
.2 >LDA.G hMem
|
||||
.2 lda hMem
|
||||
beq .8
|
||||
|
||||
>SYSCALL FreeMem
|
||||
|
@ -542,16 +582,13 @@ MSG.USAGE .AS "Usage : WC File(s) (*,? wildcards allowed)\r\n"
|
|||
.AS " -L : Print the LINE counts\r\n"
|
||||
.AZ " -W : Print the WORD counts\r\n"
|
||||
MSG.ERR .AZ "[%h]\r\n"
|
||||
MSG.LONG .AZ "%10L "
|
||||
MSG.LONG .AZ "%L "
|
||||
MSG.LONGTAB .AZ "%10L "
|
||||
MSG.TOTAL .AZ "(total)"
|
||||
*--------------------------------------
|
||||
.DUMMY
|
||||
.OR 0
|
||||
DS.START
|
||||
ArgIndex .BS 1
|
||||
|
||||
bPrintTotal .BS 1
|
||||
|
||||
fCharCount .BS 4
|
||||
fLineCount .BS 4
|
||||
fWordCount .BS 4
|
||||
|
@ -560,15 +597,11 @@ tCharCount .BS 4
|
|||
tLineCount .BS 4
|
||||
tWordCount .BS 4
|
||||
|
||||
hSrcFullPath .BS 1
|
||||
hFile .BS 1
|
||||
hMem .BS 1
|
||||
|
||||
.INB usr/src/bin/x.fileenum.g
|
||||
|
||||
DS.END
|
||||
.ED
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE USR/SRC/BIN/WC.S
|
||||
SAVE usr/src/bin/wc.s
|
||||
ASM
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
NEW
|
||||
AUTO 3,1
|
||||
|
||||
#DEFINE O_RDONLY 1
|
||||
#DEFINE O_WRONLY 2
|
||||
#DEFINE O_RDWR 3
|
||||
#DEFINE O_TRUNC 4
|
||||
#DEFINE O_APPEND 8
|
||||
#DEFINE O_TEXT 64
|
||||
#DEFINE O_CREATE 128
|
||||
|
||||
fastcall int putchar(short int);
|
||||
// int fputc ( hFILE stream , short int character );
|
||||
fastcall int puts(const char*);
|
||||
// int fputs (hFILE stream, const char * str );
|
||||
// char *fgets(hFILE stream, char * s, int n);
|
||||
short int getchar();
|
||||
fastcall short int getc(short int);
|
||||
// short int ungetc(short int c, short int );
|
||||
|
||||
short int fopen( const char*,short int,short int,int);
|
||||
int fclose(short int);
|
||||
// int fread (short int stream, void * ptr, int count );
|
||||
// int fwrite (short int stream, const void * ptr, int count );
|
||||
fastcall int fflush(short int);
|
||||
// int fseek( short int stream, long offset, short int whence );
|
||||
fastcall int feof(short int);
|
||||
fastcall long ftell(short int);
|
||||
fastcall int remove(const char*);
|
||||
int rename(const char*,const char*);
|
||||
|
||||
int printf(const char*,...);
|
||||
int fprintf(short int,const char*,...);
|
||||
int sprintf(char*,const char*,...);
|
||||
|
||||
int scanf(const char*,...);
|
||||
int fscanf(short int,const char*,...);
|
||||
int sscanf(const char*,const char*,...);
|
||||
|
||||
MAN
|
||||
TEXT include/stdio.h
|
|
@ -0,0 +1,22 @@
|
|||
NEW
|
||||
AUTO 3,1
|
||||
|
||||
float strtof(const char*,char**);
|
||||
float atof(const char*);
|
||||
|
||||
long strtol(const char*,char**,int);
|
||||
unsigned long strtoul(const char*,char**,int);
|
||||
|
||||
fastcall long atol(const char*);
|
||||
fastcall int atoi(const char*);
|
||||
|
||||
char *realpath(const char*,char*);
|
||||
char *expand(const char*,char*);
|
||||
|
||||
int setenv(const char*,const char*);
|
||||
char *getenv(const char*, char*);
|
||||
int putenv(char*);
|
||||
int unsetenv(const char*);
|
||||
|
||||
MAN
|
||||
TEXT include/stdlib.h
|
|
@ -0,0 +1,13 @@
|
|||
NEW
|
||||
AUTO 3,1
|
||||
|
||||
fastcall int strlen(char*);
|
||||
// char* strcat(char*,const char*);
|
||||
// char* strcpy(char*,const char*);
|
||||
fastcall char* strdup (char*);
|
||||
fastcall char* strupr (char*);
|
||||
fastcall char* strlwr (char*);
|
||||
// int strcmp(const char *s1, const char *s2);
|
||||
// int strcasecmp(const char *s1, const char *s2);
|
||||
MAN
|
||||
TEXT include/string.h
|
|
@ -188,10 +188,8 @@ CS.RUN.EXEC >PUSHEA.G Username
|
|||
stz ZPNewSID
|
||||
|
||||
.8 ldx ZPNewSession
|
||||
lda S.Table.hSID-1,x
|
||||
stz S.Table.hSID-1,x
|
||||
stz S.Table.hFILE-1,x
|
||||
>SYSCALL FreeMem
|
||||
|
||||
ldy #S.PS.hSession
|
||||
lda ZPOldSession
|
||||
|
|
|
@ -191,6 +191,6 @@ K.ArgVDup >STYA ZPPtr1
|
|||
.9 rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE USR/SRC/SYS/KERNEL.S.ARG
|
||||
LOAD USR/SRC/SYS/KERNEL.S
|
||||
SAVE usr/src/sys/kernel.s.arg
|
||||
LOAD usr/src/sys/kernel.s
|
||||
ASM
|
||||
|
|
|
@ -24,7 +24,16 @@ K.GetPWUID
|
|||
K.GetGRGID >PULLW FORPNT
|
||||
>PULLB ZPPtr1+1 UID/GID
|
||||
|
||||
jmp K.SYSCALL.JMPX
|
||||
*/--------------------------------------
|
||||
* # CloseSession
|
||||
* ## C
|
||||
* `int closesession(short int hSID);`
|
||||
* ## ASM
|
||||
* `>PUSHB hSID`
|
||||
* `>SYSCALL CloseSession`
|
||||
* ## RETURN VALUE
|
||||
*\--------------------------------------
|
||||
K.CloseSession jmp K.SYSCALL.JMPX
|
||||
*/--------------------------------------
|
||||
* # OpenSession
|
||||
* ## C
|
||||
|
@ -149,17 +158,6 @@ PWD.Flush >STYA PWD.FileSize
|
|||
|
||||
.8 lda #$ff
|
||||
jmp K.freemem SELF MODIFIED
|
||||
*/--------------------------------------
|
||||
* # CloseSession
|
||||
* ## C
|
||||
* `int closesession(short int hSID);`
|
||||
* ## ASM
|
||||
* `>PUSHB hSID`
|
||||
* `>SYSCALL CloseSession`
|
||||
* ## RETURN VALUE
|
||||
*\--------------------------------------
|
||||
K.CloseSession >PULLA
|
||||
jmp K.SYSCALL.JMPX
|
||||
*--------------------------------------
|
||||
PWD.ETCPASSWD .AZ "${ROOT}etc/passwd"
|
||||
PWD.hUsrDB .BS 1
|
||||
|
|
|
@ -199,7 +199,7 @@ PWDX.PutPW.1 jsr K.GetmemPtr
|
|||
jsr PWD.AppendRecord
|
||||
|
||||
lda #0
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
|
||||
clc
|
||||
rts
|
||||
|
@ -295,15 +295,15 @@ PWDX.OpenSession
|
|||
lda TXTPTR+1
|
||||
bne .3
|
||||
|
||||
.1 >LDYAI PWDX.ROOT.Size
|
||||
.1 >LDYAI PWDX.ROOTSESSION.Size
|
||||
jsr K.GetMem
|
||||
bcs .9
|
||||
|
||||
>STYA ZPPtr1
|
||||
|
||||
ldy #PWDX.ROOT.Size-1
|
||||
ldy #PWDX.ROOTSESSION.Size-1
|
||||
|
||||
.2 lda PWDX.ROOT,y
|
||||
.2 lda PWDX.ROOTSESSION,y
|
||||
sta (ZPPtr1),y
|
||||
dey
|
||||
bpl .2
|
||||
|
@ -311,7 +311,7 @@ PWDX.OpenSession
|
|||
txa
|
||||
clc
|
||||
rts
|
||||
|
||||
*--------------------------------------
|
||||
.3 jsr PWD.FindRecord
|
||||
bcs .9
|
||||
|
||||
|
@ -334,26 +334,22 @@ PWDX.OpenSession
|
|||
dey
|
||||
bpl .5
|
||||
|
||||
>LDYAI 256 TODO: compute S.SESSION size
|
||||
jsr PWDX.GetSessionLen
|
||||
|
||||
jsr K.Getmem
|
||||
bcs .9
|
||||
|
||||
>STYA ZPPtr2
|
||||
stx .8+1
|
||||
phx
|
||||
|
||||
jsr PWD.Record2Session
|
||||
|
||||
.8 lda #$ff SELF MODIFIED
|
||||
jsr PWDX.Record2Session
|
||||
|
||||
pla
|
||||
clc
|
||||
rts
|
||||
|
||||
sec
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
PWDX.CloseSession
|
||||
sec
|
||||
rts
|
||||
jmp K.Freemem
|
||||
*--------------------------------------
|
||||
* PRIVATE
|
||||
*--------------------------------------
|
||||
|
@ -456,74 +452,7 @@ PWD.FindRecord lda PWD.hUsrDB
|
|||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
* USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL\CR
|
||||
*--------------------------------------
|
||||
PWD.Record2Session
|
||||
ldy #0
|
||||
|
||||
jsr PWD.NextString skip USERNAME
|
||||
jsr PWD.NextString skip PASSWORD
|
||||
jsr PWD.GetByte get UID
|
||||
sta ZPPtr1
|
||||
|
||||
iny
|
||||
|
||||
jsr PWD.GetByte get GID
|
||||
sta ZPPtr1+1
|
||||
|
||||
iny
|
||||
|
||||
lda #0
|
||||
ldx ZPPtr1
|
||||
bne .1
|
||||
|
||||
ora #S.SESSION.P.ROOT
|
||||
|
||||
.1 ldx ZPPtr1+1
|
||||
bne .2
|
||||
|
||||
ora #S.SESSION.P.SYSADMIN
|
||||
|
||||
.2 jsr SHARED.PutCharPtr2
|
||||
|
||||
lda ZPPtr1
|
||||
jsr SHARED.PutCharPtr2 UID
|
||||
|
||||
lda ZPPtr1+1
|
||||
jsr SHARED.PutCharPtr2 GID
|
||||
|
||||
phy
|
||||
|
||||
ldy #$ff
|
||||
|
||||
.3 iny
|
||||
lda (ZPPtr3),y
|
||||
cmp #':'
|
||||
beq .4
|
||||
|
||||
jsr SHARED.PutCharPtr2
|
||||
bra .3
|
||||
|
||||
.4 lda #0
|
||||
jsr SHARED.PutCharPtr2
|
||||
|
||||
ply
|
||||
|
||||
.5 lda (ZPPtr3),y
|
||||
cmp #C.CR
|
||||
beq .8
|
||||
|
||||
cmp #':'
|
||||
bne .6
|
||||
|
||||
lda #0
|
||||
|
||||
.6 jsr SHARED.PutCharPtr2
|
||||
iny
|
||||
bra .5
|
||||
|
||||
.8 lda #0
|
||||
jmp SHARED.PutCharPtr2
|
||||
* Record : USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL\CR
|
||||
*--------------------------------------
|
||||
PWD.Record2PW ldy #0
|
||||
|
||||
|
@ -632,6 +561,100 @@ PWD.Record2GR ldy #0
|
|||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
* Record : USERNAME:PASSWORD:UID:GID:GECOS:HOME:SHELL\CR
|
||||
*--------------------------------------
|
||||
PWDX.GetSessionLen
|
||||
ldy #0
|
||||
|
||||
jsr PWD.NextString USERNAME
|
||||
tya
|
||||
clc
|
||||
adc #S.SESSION.NAME
|
||||
tax
|
||||
|
||||
jsr PWD.NextString skip PASSWORD
|
||||
jsr PWD.NextString skip UID
|
||||
jsr PWD.NextString skip GID
|
||||
|
||||
.1 inx
|
||||
iny
|
||||
lda (ZPPtr3),y
|
||||
beq .8
|
||||
|
||||
eor #C.CR
|
||||
bne .1
|
||||
|
||||
.8 phx A = 0
|
||||
ply
|
||||
rts
|
||||
*--------------------------------------
|
||||
PWDX.Record2Session
|
||||
ldy #0
|
||||
|
||||
jsr PWD.NextString skip USERNAME
|
||||
jsr PWD.NextString skip PASSWORD
|
||||
jsr PWD.GetByte get UID
|
||||
sta ZPPtr1
|
||||
|
||||
iny
|
||||
|
||||
jsr PWD.GetByte get GID
|
||||
sta ZPPtr1+1
|
||||
|
||||
iny
|
||||
|
||||
lda #0
|
||||
ldx ZPPtr1
|
||||
bne .1
|
||||
|
||||
ora #S.SESSION.P.ROOT
|
||||
|
||||
.1 ldx ZPPtr1+1
|
||||
bne .2
|
||||
|
||||
ora #S.SESSION.P.SYSADMIN
|
||||
|
||||
.2 jsr SHARED.PutCharPtr2
|
||||
|
||||
lda ZPPtr1
|
||||
jsr SHARED.PutCharPtr2 UID
|
||||
|
||||
lda ZPPtr1+1
|
||||
jsr SHARED.PutCharPtr2 GID
|
||||
|
||||
phy
|
||||
|
||||
ldy #$ff
|
||||
|
||||
.3 iny
|
||||
lda (ZPPtr3),y
|
||||
cmp #':'
|
||||
beq .4
|
||||
|
||||
jsr SHARED.PutCharPtr2
|
||||
bra .3
|
||||
|
||||
.4 lda #0
|
||||
jsr SHARED.PutCharPtr2
|
||||
|
||||
ply
|
||||
|
||||
.5 lda (ZPPtr3),y
|
||||
cmp #C.CR
|
||||
beq .8
|
||||
|
||||
cmp #':'
|
||||
bne .6
|
||||
|
||||
lda #0
|
||||
|
||||
.6 jsr SHARED.PutCharPtr2
|
||||
iny
|
||||
bra .5
|
||||
|
||||
.8 lda #0
|
||||
jmp SHARED.PutCharPtr2
|
||||
*--------------------------------------
|
||||
PWD.NextString lda (ZPPtr3),y
|
||||
beq .8
|
||||
|
||||
|
@ -708,44 +731,44 @@ PWD.GetRecordLen
|
|||
|
||||
jsr PWD.StoreString
|
||||
lda #':'
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
ldy #S.PW.PASSWD
|
||||
|
||||
jsr PWD.StoreString
|
||||
|
||||
lda #':'
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
|
||||
ldy #S.PW.UID
|
||||
jsr SHARED.TXTPTR.GetY
|
||||
jsr PWD.StoreByte
|
||||
jsr PWDX.StoreByte
|
||||
|
||||
lda #':'
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
|
||||
ldy #S.PW.GID
|
||||
jsr SHARED.TXTPTR.GetY
|
||||
jsr PWD.StoreByte
|
||||
jsr PWDX.StoreByte
|
||||
lda #':'
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
|
||||
ldy #S.PW.GECOS
|
||||
|
||||
jsr PWD.StoreString
|
||||
lda #':'
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
|
||||
ldy #S.PW.DIR
|
||||
|
||||
jsr PWD.StoreString
|
||||
lda #':'
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
|
||||
ldy #S.PW.SHELL
|
||||
|
||||
jsr PWD.StoreString
|
||||
lda #C.CR
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
|
||||
txa
|
||||
PWD.GetRecordLen.RTS
|
||||
|
@ -753,11 +776,11 @@ PWD.GetRecordLen.RTS
|
|||
*--------------------------------------
|
||||
PWD.StoreString jsr SHARED.TXTPTR.GetY
|
||||
beq PWD.GetRecordLen.RTS
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
iny
|
||||
bra PWD.StoreString
|
||||
*--------------------------------------
|
||||
PWD.StoreByte php
|
||||
PWDX.StoreByte php
|
||||
phx
|
||||
jsr MATH32.A2STR10NP
|
||||
plx
|
||||
|
@ -768,10 +791,10 @@ PWD.StoreByte php
|
|||
.1 lda A2osX.NumStrBuf,y
|
||||
beq PWD.GetRecordLen.RTS
|
||||
iny
|
||||
jsr PWD.StoreChar
|
||||
jsr PWDX.StoreChar
|
||||
bra .1
|
||||
*--------------------------------------
|
||||
PWD.StoreChar inx
|
||||
PWDX.StoreChar inx
|
||||
bcc .9 Dry run, no store
|
||||
sta (ZPPtr3)
|
||||
inc ZPPtr3
|
||||
|
@ -779,14 +802,15 @@ PWD.StoreChar inx
|
|||
inc ZPPtr3+1
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
PWDX.ROOT .DA #S.SESSION.P.ROOT
|
||||
PWDX.ROOTSESSION
|
||||
.DA #S.SESSION.P.ROOT
|
||||
.DA #0 UID
|
||||
.DA #0 GID
|
||||
.AZ "root" NAME
|
||||
.AZ "Root User" GECOS
|
||||
.AZ "${ROOT}root/" DIR
|
||||
.AZ "${ROOT}bin/sh" SHELL
|
||||
PWDX.ROOT.Size .EQ *-PWDX.ROOT
|
||||
PWDX.ROOTSESSION.Size .EQ *-PWDX.ROOTSESSION
|
||||
*--------------------------------------
|
||||
PWDX.GROUP .AS "root:0"
|
||||
.DA #C.CR
|
||||
|
|
|
@ -280,7 +280,7 @@ K.FGetS jsr PFT.CheckNodeA
|
|||
* # getchar (BLOCKING)
|
||||
* Get char from StdIn
|
||||
* ## C
|
||||
* `int getchar ();`
|
||||
* `short int getchar ( );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>SYSCALL getchar`
|
||||
|
@ -294,7 +294,7 @@ K.GetChar ldy #S.PS.hStdIn
|
|||
* # getc (BLOCKING)
|
||||
* Get char from Node
|
||||
* ## C
|
||||
* `int getc ( hFILE stream );`
|
||||
* `short int getc ( short int stream );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `lda stream`
|
||||
|
@ -330,7 +330,7 @@ STDIO.Get.1 lda #0
|
|||
* # ungetc
|
||||
* push byte back into input stream
|
||||
* ## C
|
||||
* `int ungetc(short int c, hFILE stream);
|
||||
* `short int ungetc(short int c, short int stream);`
|
||||
* ## ASM
|
||||
* `>PUSHB c`
|
||||
* `>PUSHB stream`
|
||||
|
@ -395,7 +395,7 @@ K.FOpen jsr PFT.CheckPath4
|
|||
* # FClose
|
||||
* Close a file
|
||||
* ## C
|
||||
* int fclose ( hFILE stream );
|
||||
* `int fclose ( short int stream );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `lda stream`
|
||||
|
@ -422,7 +422,7 @@ K.FClose jsr PFT.CheckNodeA
|
|||
* # FRead (BLOCKING)
|
||||
* Read bytes from file
|
||||
* ## C
|
||||
* int fread (hFILE stream, void * ptr, int count );
|
||||
* `int fread (short int stream, void * ptr, int count );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHWI count`
|
||||
|
@ -443,7 +443,7 @@ K.FClose.RTS rts
|
|||
* # FWrite (BLOCKING)
|
||||
* Write bytes to file
|
||||
* ## C
|
||||
* `int fwrite (hFILE stream, const void * ptr, int count );`
|
||||
* `int fwrite ( short int stream, const void * ptr, int count );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHWI count`
|
||||
|
@ -475,7 +475,7 @@ K.FWrite.RET4 >RET 4
|
|||
*/--------------------------------------
|
||||
* # FFlush
|
||||
* ## C
|
||||
* int fflush(hFILE stream);
|
||||
* `int fflush( short int stream );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `lda stream`
|
||||
|
@ -496,7 +496,7 @@ STDIO.IOERR lda #MLI.E.IO
|
|||
* # FSeek
|
||||
* Set the file-position indicator for hFILE
|
||||
* ## C
|
||||
* `int fseek(hFILE stream, long offset, short int whence);`
|
||||
* `int fseek( short int stream, long offset, short int whence );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHBI whence`
|
||||
|
@ -566,7 +566,7 @@ K.FSeek.RTS rts
|
|||
* # FEOF
|
||||
* Test the end-of-file indicator for hFILE
|
||||
* ## C
|
||||
* `int feof(hFILE stream);`
|
||||
* `int feof( short int stream );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `lda stream`
|
||||
|
@ -595,7 +595,7 @@ IO.EOF lda (pFD)
|
|||
* # FTell
|
||||
* Return the current value of the file-position indicator
|
||||
* ## C
|
||||
* `long ftell(hFILE stream);`
|
||||
* `long ftell( short int stream );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `lda stream`
|
||||
|
@ -623,7 +623,7 @@ K.FTell jsr PFT.CheckNodeA
|
|||
* # Remove
|
||||
* Remove a file or directory
|
||||
* ## C
|
||||
* int remove(const char *pathname);
|
||||
* `int remove ( const char *pathname );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>LDYA pathname`
|
||||
|
@ -639,7 +639,7 @@ K.Remove jsr PFT.CheckPathYA
|
|||
* # Rename
|
||||
* Rename a file
|
||||
* ## C
|
||||
* `int rename(const char *oldpath, const char *newpath);`
|
||||
* `int rename ( const char * oldpath, const char * newpath );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHW oldpath`
|
||||
|
|
|
@ -414,8 +414,8 @@ PrintF.PutC.RTS rts
|
|||
* # SScanF
|
||||
* Read formatted data from string
|
||||
* ## C
|
||||
* `int scanf(const char *format, ...);`
|
||||
* `int fscanf(short int stream, const char *format, ...);`
|
||||
* `int scanf( const char *format, ... );`
|
||||
* `int fscanf( short int stream, const char *format, ... );`
|
||||
* `int sscanf ( const char *s, const char *format, ... );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
|
|
|
@ -4,7 +4,7 @@ NEW
|
|||
* # StrToF
|
||||
* Convert String to 40 bits Float
|
||||
* ## C
|
||||
* `float strtof (const char* str, char** endptr);`
|
||||
* `float strtof (const char* str, char** endptr );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHW str`
|
||||
|
@ -27,7 +27,7 @@ K.StrToF >PULLW ZPPtr1
|
|||
* # AToF
|
||||
* Convert String to 40 bits Float
|
||||
* ## C
|
||||
* `float atof (const char* str);`
|
||||
* `float atof ( const char* str );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>LDYA str`
|
||||
|
|
|
@ -74,8 +74,10 @@ K.StrCpy clc
|
|||
*/--------------------------------------
|
||||
* # StrDup
|
||||
* Create a new copy of this C-String
|
||||
* ## C
|
||||
* `char * strdup ( char * str);`
|
||||
* ## ASM
|
||||
* Y,A = Ptr to source C-String
|
||||
* ## RETURN VALUE
|
||||
* CC : success
|
||||
* Y,A = PTR to String
|
||||
* X = hMem (C-String)
|
||||
|
|
Loading…
Reference in New Issue