A2osX/BIN/SHELL.S.EXP.txt

280 lines
4.4 KiB
Plaintext
Raw Normal View History

2019-02-01 16:32:29 +00:00
NEW
PREFIX
AUTO 4,1
.LIST OFF
*--------------------------------------
EXP.EVAL ldx #1
jsr CORE.GetArgX
beq .9
>PUSHYA
>LDYA L.EXP.BEGIN
jsr Lookup
bcs .9
cpx #4 [ or ![
bcs .9
dex
dex 1 or $ff
txa
and #$80 true or false
>ORA.G CORE.Test
sta (pData),y
ldx #2
jsr CORE.GetArgX
beq .9
>PUSHYA
>LDYA L.EXP.OP.UNARY -d -e -f ?
jsr Lookup
bcs .1
txa
>STA.G CORE.Operator
jsr EXP.EVAL.UNARY
bcs .9
>EOR.G CORE.Test
sta (pData),y
ldx #4 go check ]
bra .8
.9 lda #E.ESYN
sec
.99 rts
.1 ldx #3
jsr CORE.GetArgX
beq .9
>PUSHYA
>LDYA L.EXP.OP.BINARY -eq -ne .... ?
jsr Lookup
bcs .9
txa
>STA.G CORE.Operator
jsr EXP.EVAL.BINARY
bcs .9
>EOR.G CORE.Test
sta (pData),y
ldx #5 go check ]
.8 jsr CORE.GetArgX
beq .9
>STYA ZPPTR1
lda (ZPPTR1)
cmp #']'
bne .9
ldy #1
lda (ZPPTR1),y
bne .9
clc
rts
*--------------------------------------
EXP.EVAL.UNARY ldx #3
jsr CORE.GetArgX
bcs .9 we need one arg
>LDA.G CORE.Operator
tax
jmp (J.EXP.OP.UNARY,x)
.9 lda #E.ESYN
sec
rts
EXP.OP.UNARY.D jsr EXP.OP.UNARY.DEF.7
bcs EXP.OP.UNARY.DEF.9
>LDA.G StatBuf+S.STAT.P.TYPE
cmp #S.FI.T.DIR
bne EXP.OP.UNARY.DEF.9
bra EXP.OP.UNARY.DEF.8
EXP.OP.UNARY.E jsr EXP.OP.UNARY.DEF.7
bcs EXP.OP.UNARY.DEF.9
bra EXP.OP.UNARY.DEF.8 DIR or FILE exist
EXP.OP.UNARY.F jsr EXP.OP.UNARY.DEF.7
bcs EXP.OP.UNARY.DEF.9
>LDA.G StatBuf+S.STAT.P.TYPE
cmp #S.FI.T.DIR
beq EXP.OP.UNARY.DEF.9
bra EXP.OP.UNARY.DEF.8
EXP.OP.UNARY.DEF.7
>PUSHEA.G StatBuf
ldx #3
jsr CORE.GetArgX
>SYSCALL STAT
rts
EXP.OP.UNARY.DEF.8
lda #$80 true
clc
rts
EXP.OP.UNARY.DEF.9
lda #0 false
clc
rts
*--------------------------------------
EXP.EVAL.BINARY ldx #2
jsr CORE.GetArgX
bcs .9
ldx #4
jsr CORE.GetArgX
bcs .9
>LDA.G CORE.Operator
beq .1 =
cmp #2 !=
bne EXP.EVAL.BINARY.NUM
lda #$80
>STA.G CORE.Operator
.1 ldx #2
jsr CORE.GetArgX
>PUSHYA
ldx #4
jsr CORE.GetArgX
>SYSCALL strcmp
ror CS if !=
and #$80
eor #$80
>EOR.G CORE.Operator
clc
rts
.9 lda #E.ESYN
sec
rts
*--------------------------------------
EXP.EVAL.BINARY.NUM
ldx #2
jsr CORE.GetArgX
bcs .9
>SYSCALL AToL
bcs .9
>PULLL.G M32.ACC
ldx #4
jsr CORE.GetArgX
bcs .9
>SYSCALL AToL
bcs .9
>PULLL.G M32.ARG
jsr M32.Cmp
pha
>LDA.G CORE.Operator
lsr
tax
pla
and EXP.OP.BINARY.BITS,x
beq .80
lda #$80 true
clc
rts
.80 lda #0 false
clc
rts
.9 lda #E.ESYN
sec
rts
*--------------------------------------
EXP.GET >LDA.G CORE.ArgIndex
inc
tax
jsr CORE.GetArgX
bcc .1
>LDA.G CORE.ArgIndex no op, return text value
tax
jsr CORE.GetArgX
rts
.1 >LDA.G CORE.ArgIndex
tax
jsr CORE.GetArgX
>SYSCALL AToL
bcs .99
>PULLL.G M32.ACC
jsr EXP.GetNext
.2 >PUSHYA
>LDYA L.EXP.OP.MATH + - .... ?
jsr Lookup
bcs .9
txa
>STA.G CORE.Operator
jsr M32.ACC2ARG
jsr EXP.GetNext get next argument in ACC
.99 bcs .9
>SYSCALL AToL
bcs .9
>PULLL.G M32.ACC
jsr EXP.GET.OP
bcs .9
jsr EXP.GetNext another op ?
bcc .2
.8 >PUSHL.G M32.ACC
>PUSHBI 4
>PUSHW L.M32.Printf
>LEA.G M32.BUF
>SYSCALL sprintf
bcs .9
>LEA.G M32.Buf
rts
.9 lda #E.BADEXP
rts
EXP.GET.OP >LDA.G CORE.Operator
tax
jmp (J.EXP.OP.MATH,x)
*--------------------------------------
EXP.GetNext >INC.G CORE.ArgIndex
tax
jsr CORE.GetArgX
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SHELL.S.EXP
LOAD USR/SRC/BIN/SHELL.S
ASM