mirror of
https://github.com/A2osX/A2osX.git
synced 2024-12-01 14:50:10 +00:00
271 lines
4.3 KiB
Plaintext
271 lines
4.3 KiB
Plaintext
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
|
||
|
||
ldy #0 Any var type
|
||
lda #0
|
||
jsr CSH.ExpEval
|
||
bcs .99
|
||
|
||
jsr CSH.IsValue0 result in X
|
||
|
||
jsr CSH.GetCharNB
|
||
bcs .99
|
||
|
||
cmp #')'
|
||
bne .9
|
||
|
||
jsr CSH.GetNextCharNB skip ')'
|
||
bcs .9
|
||
|
||
cmp #'{'
|
||
bne .9
|
||
|
||
jsr CSH.GetNextCharNB Skip '{'
|
||
bcs .9
|
||
|
||
txa
|
||
beq .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
|
||
|
||
.99 rts
|
||
|
||
.6 jsr CSH.SkipBlock
|
||
|
||
bcc .99
|
||
|
||
.9 lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CSH.IF.END clc
|
||
rts
|
||
*--------------------------------------
|
||
CSH.WHILE.END jsr CSH.Pop
|
||
sta ZPInputBufPtr
|
||
jsr CSH.Pop
|
||
sta ZPInputBufPtr+1
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CSH.ELSE
|
||
*--------------------------------------
|
||
CSH.DO
|
||
CSH.FOR
|
||
CSH.SWITCH
|
||
CSH.CASE
|
||
CSH.BREAK
|
||
CSH.CONTINUE
|
||
CSH.SIZEOF
|
||
*--------------------------------------
|
||
CSH.TYPEDEF lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CSH.STRUCT >ENTER 4
|
||
|
||
jsr CSH.GetCharNB
|
||
bcs .99
|
||
|
||
>LDA.G CSH.hTags
|
||
jsr CSH.NewKey
|
||
bcs .99
|
||
|
||
sta (pStack) Y,A = KeyID
|
||
tya
|
||
ldy #1
|
||
sta (pStack),y
|
||
|
||
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
|
||
*--------------------------------------
|
||
* Type Declaration keywords
|
||
*--------------------------------------
|
||
CSH.CONST ldy #1
|
||
|
||
lda (pStack),y
|
||
ora #CSH.Q.CONST
|
||
sta (pStack),y
|
||
|
||
jsr CSH.CheckSpace
|
||
bcs .9
|
||
|
||
>LDYA L.CSH.TMODS2
|
||
jsr CSH.LookupID
|
||
bcs .9
|
||
|
||
jmp (J.CSH.TMODS2,x)
|
||
|
||
.9 lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CSH.SIGNED sec
|
||
.HS 90 BCC
|
||
*--------------------------------------
|
||
CSH.UNSIGNED clc
|
||
php
|
||
|
||
jsr CSH.CheckSpace
|
||
bcs .9
|
||
|
||
>LDYA L.CSH.TYPES
|
||
jsr CSH.LookupID
|
||
|
||
bcs .9
|
||
|
||
cpx #CSH.T.UCHAR
|
||
bcc .9 void
|
||
|
||
cpx #CSH.T.SLONG+1 only char int long allowed
|
||
bcs .9
|
||
|
||
plp
|
||
bcs .8
|
||
|
||
jmp (J.CSH.UTYPES-2,x)
|
||
|
||
.8 jmp (J.CSH.STYPES-2,x)
|
||
|
||
.9 plp
|
||
|
||
lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CSH.SHORT jsr CSH.CheckSpace
|
||
bcs .9
|
||
|
||
>LDYA L.CSH.TYPES
|
||
jsr CSH.LookupID
|
||
|
||
bcs CSH.UCHAR
|
||
|
||
cpx #4 only int allowed
|
||
beq CSH.SCHAR
|
||
|
||
.9 lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CSH.VOID lda #CSH.T.VOID
|
||
bra CSH.TYPE
|
||
|
||
CSH.CHAR
|
||
CSH.UCHAR lda #CSH.T.UCHAR
|
||
bra CSH.TYPE
|
||
|
||
CSH.SCHAR lda #CSH.T.SCHAR
|
||
bra CSH.TYPE
|
||
|
||
CSH.UINT lda #CSH.T.UINT
|
||
bra CSH.TYPE
|
||
|
||
CSH.INT
|
||
CSH.SINT lda #CSH.T.SINT
|
||
bra CSH.TYPE
|
||
|
||
CSH.ULONG lda #CSH.T.ULONG
|
||
bra CSH.TYPE
|
||
|
||
CSH.LONG
|
||
CSH.SLONG lda #CSH.T.SLONG
|
||
bra CSH.TYPE
|
||
|
||
CSH.FLOAT lda #CSH.T.FLOAT
|
||
|
||
CSH.TYPE sta (pStack)
|
||
|
||
jsr CSH.GetCharNB
|
||
bcs .9
|
||
|
||
ldy #1
|
||
|
||
.1 cmp #'*'
|
||
bne .10
|
||
|
||
lda (pStack),y
|
||
clc
|
||
adc #CSH.Q.POINTER
|
||
bcs .9 more than ***
|
||
|
||
sta (pStack),y
|
||
|
||
jsr CSH.GetNextCharNB
|
||
bcc .1
|
||
|
||
.9 lda #E.CSYN
|
||
sec
|
||
.99 rts
|
||
|
||
.10 jsr CSH.IsLetter
|
||
bcs .8
|
||
|
||
>LDYA L.CSH.FTYPES
|
||
jsr CSH.LookupID
|
||
bcs .8 next char is an identifier
|
||
|
||
sec
|
||
ror bFastCall
|
||
|
||
ldy #1
|
||
lda (pStack),y
|
||
ora #CSH.Q.FUNC
|
||
sta (pStack),y
|
||
|
||
jsr CSH.GetNextCharNB
|
||
bcs .9 next char is an identifier, ",", "(",")"
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/csh.s.kw
|
||
LOAD usr/src/bin/csh.s
|
||
ASM
|