mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-22 16:31:07 +00:00
282 lines
4.3 KiB
Plaintext
282 lines
4.3 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
|
||
bcc .22
|
||
|
||
|
||
.22 ldx EXP.TYPE
|
||
bne .23
|
||
|
||
jsr CODE.INTGET
|
||
|
||
bra .40
|
||
|
||
.23 jsr CODE.STRGET
|
||
|
||
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
|
||
ldx ACOS.OPS2FPU,y
|
||
jsr CODE.FPUCALL go compute (arg1 op1 arg2)
|
||
|
||
.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
|
||
|
||
ldx ACOS.OPS2FPU,y
|
||
jsr CODE.FPUCALL
|
||
bra .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
|
||
>LDYA ZPConstBufPtr
|
||
jsr CODE.PUSHIYA
|
||
|
||
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 .39
|
||
|
||
phy
|
||
pha KeyID
|
||
|
||
jsr CORE.GetVarType
|
||
stx EXP.TYPE
|
||
|
||
beq .11
|
||
|
||
lda STRID
|
||
sta EXP.ADDR
|
||
|
||
lda STRID+1
|
||
sta EXP.ADDR+1
|
||
|
||
inc STRID
|
||
bne .10
|
||
|
||
inc STRID+1
|
||
bra .10
|
||
|
||
.11 lda ZPDataBufPtr
|
||
sta EXP.ADDR
|
||
|
||
clc
|
||
adc #2 Word
|
||
sta ZPDataBufPtr
|
||
|
||
lda ZPDataBufPtr+1
|
||
sta EXP.ADDR+1
|
||
adc #0
|
||
sta ZPDataBufPtr+1
|
||
|
||
.10 pla
|
||
>PUSHA
|
||
pla
|
||
>PUSHA
|
||
>PUSHWI EXP.ADDR
|
||
>PUSHWI 3 3 bytes : ADDR + TYPE
|
||
>SYSCALL SListAddData
|
||
rts
|
||
|
||
.39 inc pStack
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE usr/src/bin/acos.s.exp
|
||
LOAD usr/src/bin/acos.s
|
||
ASM
|