A2osX/BIN/ACOS.S.EXP.txt
2021-08-06 19:58:04 +02:00

326 lines
5.3 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.AOP
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
bra .39
*--------------------------------------
.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 .25
jsr EXP.FNjmpX
bra .39
.25 jsr EXP.VARLookup
bra .39
*--------------------------------------
.30 jsr EXP.Int16
*--------------------------------------
.39 bcs .99
*--------------------------------------
.40 jsr CORE.GetCharNB
.41 bcs .80
.50 jsr CORE.IsEndExp
bcs .80
jsr CORE.IsKW
bcc .80
jsr CORE.LookupLOPS
bcs .51
phx
jsr EXP.ComputeAll compute all until $FF
plx
bcs .99
txa
lsr
adc #14
>PUSHA
jsr EXP.Eval.R
bcs .99
bra .40
.51 jsr CORE.LookupAOPS
bcs .90
stx EXP.AOP
lda (pStack) get op context
bmi .60 no prev op, go get arg2
cmp EXP.AOP 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.AOP we must compute arg2 op2 arg3 before
>PUSHA
jsr CORE.GetCharNB
bcs .90
jmp .11
*--------------------------------------
.80 jsr EXP.ComputeAll go compute (arg1 op1 arg2)
bcs .99
inc pStack discard $FF
bra .88
.90 lda #E.ESYN
.99 tay Save Err code
.98 >PULLA
tax
bpl .98
sec
.88 pla
sta EXP.AOP
tya
rts
*--------------------------------------
EXP.FNjmpX jmp (J.ACOS.FN,x)
*--------------------------------------
EXP.CreateStrConst
lda #'$'
sta EXP.TYPE
ldy #0
.1 jsr CORE.GetNextChar
bcs .9
cmp #'"'
beq .2
sta (ZPStrBuf1),y
iny
bne .1
.9 lda #E.ESYN
* sec
.99 rts
.2 lda #0
sta (ZPStrBuf1),y
jsr CORE.GetNextCharNB skip "
>PUSHB hStrings
jsr CORE.GetStrID
>PUSHYA
>PUSHW ZPStrBuf1
>SYSCALL StrVSet
bcs .99
ldy STRID
ldx STRID+1
clc
jmp CODE.PUSHYXI push StrID on stack
*--------------------------------------
EXP.Int16 jsr CORE.IsDigit10
bcc .1
cmp #'-'
bne .90
.1 >PUSHW ZPInputBufPtr
>PUSHWI ZPInputBufPtr
>PUSHBI 10
>SYSCALL StrToL
bcs .99
jsr CODE.PUSHINT16
>POP 4 Discard long on stack
clc
rts
.90 lda #E.ESYN
sec
.99 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
beq .7
lda #E.TMISMATCH
sec
.99 rts
*--------------------------------------
.3 jsr CORE.NewVarKey
bcs .9
>PUSHYA SID
jsr CORE.GetVarType
stx EXP.TYPE
beq .4
jsr CORE.GetStrID
bra .5
.4 jsr CORE.GetWord
.5 >STYA EXP.ADDR
>PUSHWI EXP.ADDR
>PUSHWI 3 3 bytes : ADDR + TYPE
>SYSCALL SListAddData
bcc .7
.9 inc pStack discard extra hVars
rts
*--------------------------------------
.7 ldy EXP.ADDR
ldx EXP.ADDR+1
lda EXP.TYPE
bne .8
jsr CODE.LDYXI
ldx #RT.IntGet.ID
clc
jmp CODE.JSRRT
.8 clc
jmp CODE.PUSHYXI
*--------------------------------------
EXP.ComputeAll lda (pStack)
bmi .8 nothing to do
inc pStack
tay
jsr EXP.ComputeY go compute (arg1 op1 arg2)
bcc EXP.ComputeAll
* sec
rts
.8 clc
rts
*--------------------------------------
EXP.ComputeY lda EXP.TYPE
bne .1
ldx ACOS.AOPS2FPU,y
jsr CODE.FPUCALL
clc
rts
.1 cpy #3 +
bne .2
ldx #RT.StrAdd.ID
clc
jmp CODE.JSRRT
.2 stz EXP.TYPE at the end ....TRUE/FALSE is int
cpy #11 <>
bne .3
ldx #RT.StrCmp.ID
clc
jmp CODE.JSRRT
.3 cpy #13 =
bne .9
ldx #RT.StrCmp.ID
jsr CODE.JSRRT
ldx #RT.NOT.ID
clc
jmp CODE.JSRRT
.9 lda #E.TMISMATCH
sec
rts
*--------------------------------------
MAN
SAVE usr/src/bin/acos.s.exp
LOAD usr/src/bin/acos.s
ASM