mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
301 lines
4.7 KiB
Plaintext
301 lines
4.7 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* In: A = current CHAR
|
||
* Out: CC, int16 on stack or pSTR in stack
|
||
*--------------------------------------
|
||
EXP.Eval stz EXP.TYPE
|
||
|
||
EXP.Eval.R lda EXP.AOPS
|
||
pha
|
||
|
||
lda #$FF
|
||
>PUSHA Previous OP = none
|
||
*--------------------------------------
|
||
.10 jsr CORE.GetCharNB
|
||
bcs .39
|
||
|
||
.11 cmp #'('
|
||
bne .12
|
||
|
||
jsr CORE.GetNextCharNB skip (
|
||
bcs .39
|
||
|
||
jsr EXP.Eval.R
|
||
bcs .39
|
||
|
||
jsr CORE.GetCharNB
|
||
bcs .39
|
||
|
||
cmp #')'
|
||
sec
|
||
bne .39
|
||
|
||
jsr CORE.GetNextCharNB skip )
|
||
bra .41
|
||
|
||
.12 cmp #'"'
|
||
bne .20
|
||
|
||
jsr EXP.CreateStrConst
|
||
bcs .37
|
||
|
||
bra .40
|
||
*--------------------------------------
|
||
.20 jsr CORE.IsLetter
|
||
bcs .30 No, go check for number...
|
||
|
||
>LDYA L.ACOS.KW Yes, KW, FN or VAR ?
|
||
jsr CORE.Lookup
|
||
bcc .80 KW, end of exp
|
||
|
||
>LDYA L.ACOS.FN
|
||
jsr CORE.LookupSkip
|
||
bcs .21
|
||
|
||
jsr EXP.FNjmpX
|
||
|
||
bcs .99
|
||
bra .40
|
||
|
||
.21 jsr EXP.VARLookup
|
||
bcs .37
|
||
|
||
ldy EXP.ADDR
|
||
ldx EXP.ADDR+1
|
||
jsr CODE.LDYXI
|
||
|
||
ldx EXP.TYPE
|
||
bne .22
|
||
|
||
ldx #RT.IntGet.ID
|
||
bra .23
|
||
|
||
.22 ldx #RT.StrGet.ID
|
||
|
||
.23 jsr CODE.JSRRT
|
||
bra .40
|
||
*--------------------------------------
|
||
.30 jsr CORE.IsDigit10
|
||
.39 bcs .90
|
||
|
||
jsr EXP.Int16
|
||
.37 bcs .99
|
||
*--------------------------------------
|
||
.40 jsr CORE.GetCharNB
|
||
.41 bcs .80
|
||
|
||
.50 jsr CORE.IsEndExp
|
||
bcs .80
|
||
|
||
jsr CORE.IsKW
|
||
bcc .80
|
||
|
||
jsr CORE.LookupOPS
|
||
bcs .90
|
||
|
||
stx EXP.AOPS
|
||
|
||
lda (pStack) get op context
|
||
bmi .60 no prev op, go get arg2
|
||
|
||
cmp EXP.AOPS we have arg1 A=op1 arg2 X=op2
|
||
bcc .60
|
||
|
||
inc pStack prev op has precedence
|
||
|
||
tay
|
||
jsr EXP.ComputeY go compute (arg1 op1 arg2)
|
||
bcs .90
|
||
|
||
.60 lda EXP.AOPS we must compute arg2 op2 arg3 before
|
||
>PUSHA
|
||
|
||
jsr CORE.GetCharNB
|
||
bcs .90
|
||
jmp .11
|
||
*--------------------------------------
|
||
.80 >PULLA
|
||
tay
|
||
bmi .88 nothing to do
|
||
|
||
jsr EXP.ComputeY go compute (arg1 op1 arg2)
|
||
bcc .80
|
||
|
||
.90 lda #E.ESYN
|
||
|
||
.99 tay Save Err code
|
||
|
||
.98 >PULLA
|
||
tax
|
||
bpl .98
|
||
|
||
sec
|
||
.HS 90 BCC
|
||
.88 clc
|
||
|
||
pla
|
||
sta EXP.AOPS
|
||
|
||
tya
|
||
|
||
rts
|
||
*--------------------------------------
|
||
EXP.FNjmpX jmp (J.ACOS.FN,x)
|
||
*--------------------------------------
|
||
EXP.CreateStrConst
|
||
lda #'$'
|
||
sta EXP.TYPE
|
||
|
||
ldy #0
|
||
|
||
.1 jsr CORE.GetNextChar
|
||
bcs .91
|
||
|
||
cmp #'"'
|
||
beq .2
|
||
|
||
sta (ZPConstBufPtr),y
|
||
iny
|
||
bne .1
|
||
|
||
.2 lda #0
|
||
sta (ZPConstBufPtr),y
|
||
|
||
phy
|
||
ldy ZPConstBufPtr
|
||
ldx ZPConstBufPtr+1
|
||
jsr CODE.PUSHYXI
|
||
|
||
pla
|
||
sec for \0
|
||
adc ZPConstBufPtr
|
||
sta ZPConstBufPtr
|
||
bcc .3
|
||
|
||
inc ZPConstBufPtr+1
|
||
|
||
.3 jsr CORE.GetNextCharNB skip "
|
||
|
||
clc
|
||
rts
|
||
|
||
.91 lda #E.ESYN
|
||
* sec
|
||
rts
|
||
*--------------------------------------
|
||
EXP.Int16 >PUSHW ZPInputBufPtr
|
||
>PUSHWI ZPInputBufPtr
|
||
>PUSHBI 10
|
||
>SYSCALL StrToL
|
||
bcs .9
|
||
|
||
jsr CODE.PUSHINT16
|
||
|
||
>POP 4
|
||
|
||
clc
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
EXP.VARLookup >LDA.G hVars
|
||
|
||
>PUSHA
|
||
>PUSHA for SListGetData/SListAddData
|
||
|
||
>PUSHW ZPInputBufPtr
|
||
>SYSCALL SListLookup
|
||
bcs .3
|
||
|
||
>PUSHYA KeyID
|
||
|
||
txa
|
||
jsr CORE.SkipA
|
||
|
||
.1 >PUSHWI EXP.ADDR
|
||
>PUSHWI 3 3 bytes : ADDR + TYPE
|
||
>PUSHWZ From Start
|
||
>SYSCALL SListGetData
|
||
bcs .99
|
||
|
||
jsr CORE.GetVarType
|
||
|
||
cpx EXP.TYPE
|
||
bne .90
|
||
|
||
clc
|
||
rts
|
||
|
||
.90 lda #E.TMISMATCH
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
.3 jsr CORE.NewVarKey
|
||
bcs .9
|
||
|
||
>PUSHYA SID
|
||
|
||
jsr CORE.GetVarType
|
||
stx EXP.TYPE
|
||
|
||
beq .4
|
||
|
||
jsr CORE.GetStr
|
||
bra .5
|
||
|
||
.4 jsr CORE.GetWord
|
||
.5 >STYA EXP.ADDR
|
||
|
||
>PUSHWI EXP.ADDR
|
||
>PUSHWI 3 3 bytes : ADDR + TYPE
|
||
>SYSCALL SListAddData
|
||
|
||
rts
|
||
|
||
.9 inc pStack discard extra hVars
|
||
rts
|
||
*--------------------------------------
|
||
EXP.ComputeY lda EXP.TYPE
|
||
|
||
bne .1
|
||
|
||
ldx ACOS.OPS2FPU,y
|
||
jsr CODE.FPUCALL
|
||
clc
|
||
rts
|
||
|
||
.1 stz EXP.TYPE at the end ....TRUE/FALSE is int
|
||
|
||
cpy #3 +
|
||
bne .2
|
||
|
||
ldx #SYS.StrCat
|
||
clc
|
||
jmp CODE.SYSCALL
|
||
|
||
.2 cpy #11 <>
|
||
bne .3
|
||
|
||
ldx #SYS.StrCmp
|
||
clc
|
||
jmp CODE.SYSCALL
|
||
|
||
.3 cpy #13 =
|
||
bne .9
|
||
|
||
ldx #SYS.StrCmp
|
||
jsr CODE.SYSCALL
|
||
|
||
ldx #RT.NOT.ID
|
||
clc
|
||
jmp CODE.JSRRT
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/acos.s.exp
|
||
LOAD usr/src/bin/acos.s
|
||
ASM
|