A2osX/BIN/ACOS.S.EXP.txt

326 lines
5.3 KiB
Plaintext
Raw Normal View History

2021-04-08 20:30:18 +00:00
NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
* In: A = current CHAR
2021-05-09 12:39:40 +00:00
* Out: CC, int16 on stack or pSTR in stack
2021-04-08 20:30:18 +00:00
*--------------------------------------
2021-04-29 11:56:34 +00:00
EXP.Eval stz EXP.TYPE
2021-08-06 17:58:04 +00:00
*--------------------------------------
EXP.Eval.R lda EXP.AOP
2021-04-10 17:17:40 +00:00
pha
2021-04-08 20:30:18 +00:00
2021-04-10 17:17:40 +00:00
lda #$FF
>PUSHA Previous OP = none
*--------------------------------------
.10 jsr CORE.GetCharNB
bcs .39
2021-06-22 18:59:02 +00:00
2021-04-10 17:17:40 +00:00
.11 cmp #'('
2021-04-16 19:17:18 +00:00
bne .12
2021-06-22 18:59:02 +00:00
2021-04-10 17:17:40 +00:00
jsr CORE.GetNextCharNB skip (
2021-04-16 19:17:18 +00:00
bcs .39
2021-06-22 18:59:02 +00:00
2021-04-29 11:56:34 +00:00
jsr EXP.Eval.R
2021-04-16 19:17:18 +00:00
bcs .39
2021-04-08 20:30:18 +00:00
2021-04-10 17:17:40 +00:00
jsr CORE.GetCharNB
2021-04-16 19:17:18 +00:00
bcs .39
2021-05-04 17:31:21 +00:00
2021-04-10 17:17:40 +00:00
cmp #')'
2021-04-29 11:56:34 +00:00
sec
bne .39
2021-05-04 17:31:21 +00:00
2021-04-10 17:17:40 +00:00
jsr CORE.GetNextCharNB skip )
bra .41
2021-06-22 18:59:02 +00:00
2021-04-16 19:17:18 +00:00
.12 cmp #'"'
bne .20
2021-06-22 18:59:02 +00:00
2021-04-29 11:56:34 +00:00
jsr EXP.CreateStrConst
2021-08-06 17:58:04 +00:00
bra .39
2021-04-08 20:30:18 +00:00
*--------------------------------------
2021-04-10 17:17:40 +00:00
.20 jsr CORE.IsLetter
2021-05-09 12:39:40 +00:00
bcs .30 No, go check for number...
2021-04-10 17:17:40 +00:00
2021-05-09 12:39:40 +00:00
>LDYA L.ACOS.KW Yes, KW, FN or VAR ?
2021-04-08 20:30:18 +00:00
jsr CORE.Lookup
2021-05-09 12:39:40 +00:00
bcc .80 KW, end of exp
2021-04-29 11:56:34 +00:00
2021-05-09 12:39:40 +00:00
>LDYA L.ACOS.FN
jsr CORE.LookupSkip
2021-08-06 17:58:04 +00:00
bcs .25
2021-04-08 20:30:18 +00:00
jsr EXP.FNjmpX
2021-08-06 17:58:04 +00:00
bra .39
2021-07-09 13:54:42 +00:00
2021-08-06 17:58:04 +00:00
.25 jsr EXP.VARLookup
bra .39
2021-04-10 17:17:40 +00:00
*--------------------------------------
2021-08-05 11:35:37 +00:00
.30 jsr EXP.Int16
2021-08-06 17:58:04 +00:00
*--------------------------------------
.39 bcs .99
2021-04-08 20:30:18 +00:00
*--------------------------------------
2021-04-10 17:17:40 +00:00
.40 jsr CORE.GetCharNB
.41 bcs .80
2021-04-08 20:30:18 +00:00
2021-04-10 17:17:40 +00:00
.50 jsr CORE.IsEndExp
bcs .80
2021-06-22 18:59:02 +00:00
2021-05-09 12:39:40 +00:00
jsr CORE.IsKW
bcc .80
2021-08-06 17:58:04 +00:00
jsr CORE.LookupLOPS
bcs .51
2021-06-22 18:59:02 +00:00
2021-08-06 17:58:04 +00:00
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
2021-04-08 20:30:18 +00:00
2021-05-09 12:39:40 +00:00
lda (pStack) get op context
bmi .60 no prev op, go get arg2
2021-06-22 18:59:02 +00:00
2021-08-06 17:58:04 +00:00
cmp EXP.AOP we have arg1 A=op1 arg2 X=op2
2021-05-09 12:39:40 +00:00
bcc .60
2021-06-22 18:59:02 +00:00
2021-08-06 17:58:04 +00:00
inc pStack prev op has precedence
2021-06-22 18:59:02 +00:00
2021-05-04 17:31:21 +00:00
tay
2021-07-09 13:54:42 +00:00
jsr EXP.ComputeY go compute (arg1 op1 arg2)
bcs .90
2021-06-22 18:59:02 +00:00
2021-08-06 17:58:04 +00:00
.60 lda EXP.AOP we must compute arg2 op2 arg3 before
2021-04-10 17:17:40 +00:00
>PUSHA
2021-04-08 20:30:18 +00:00
2021-05-09 12:39:40 +00:00
jsr CORE.GetCharNB
2021-04-10 17:17:40 +00:00
bcs .90
2021-04-16 19:17:18 +00:00
jmp .11
2021-04-10 17:17:40 +00:00
*--------------------------------------
2021-08-06 17:58:04 +00:00
.80 jsr EXP.ComputeAll go compute (arg1 op1 arg2)
bcs .99
inc pStack discard $FF
2021-04-08 20:30:18 +00:00
2021-08-06 17:58:04 +00:00
bra .88
2021-04-08 20:30:18 +00:00
2021-04-10 17:17:40 +00:00
.90 lda #E.ESYN
2021-06-22 18:59:02 +00:00
2021-04-10 17:17:40 +00:00
.99 tay Save Err code
2021-04-08 20:30:18 +00:00
2021-04-29 11:56:34 +00:00
.98 >PULLA
2021-04-10 17:17:40 +00:00
tax
2021-04-29 11:56:34 +00:00
bpl .98
2021-06-22 18:59:02 +00:00
2021-04-10 17:17:40 +00:00
sec
2021-04-08 20:30:18 +00:00
2021-08-06 17:58:04 +00:00
.88 pla
sta EXP.AOP
2021-06-22 18:59:02 +00:00
2021-04-10 17:17:40 +00:00
tya
2021-06-22 18:59:02 +00:00
2021-04-08 20:30:18 +00:00
rts
*--------------------------------------
EXP.FNjmpX jmp (J.ACOS.FN,x)
2021-04-10 17:17:40 +00:00
*--------------------------------------
2021-04-29 11:56:34 +00:00
EXP.CreateStrConst
lda #'$'
sta EXP.TYPE
2021-06-22 18:59:02 +00:00
2021-04-29 11:56:34 +00:00
ldy #0
2021-06-22 18:59:02 +00:00
2021-04-16 19:17:18 +00:00
.1 jsr CORE.GetNextChar
2021-08-05 11:35:37 +00:00
bcs .9
2021-06-22 18:59:02 +00:00
2021-04-16 19:17:18 +00:00
cmp #'"'
beq .2
2021-06-22 18:59:02 +00:00
2021-08-05 11:35:37 +00:00
sta (ZPStrBuf1),y
2021-04-16 19:17:18 +00:00
iny
bne .1
2021-08-05 11:35:37 +00:00
.9 lda #E.ESYN
* sec
.99 rts
2021-06-22 18:59:02 +00:00
2021-04-16 19:17:18 +00:00
.2 lda #0
2021-08-05 11:35:37 +00:00
sta (ZPStrBuf1),y
2021-04-16 19:17:18 +00:00
2021-08-05 11:35:37 +00:00
jsr CORE.GetNextCharNB skip "
2021-06-22 18:59:02 +00:00
2021-08-05 11:35:37 +00:00
>PUSHB hStrings
jsr CORE.GetStrID
>PUSHYA
>PUSHW ZPStrBuf1
>SYSCALL StrVSet
bcs .99
2021-04-16 19:17:18 +00:00
2021-08-05 11:35:37 +00:00
ldy STRID
ldx STRID+1
2021-04-16 19:17:18 +00:00
clc
2021-08-05 11:35:37 +00:00
jmp CODE.PUSHYXI push StrID on stack
2021-04-16 19:17:18 +00:00
*--------------------------------------
2021-08-05 11:35:37 +00:00
EXP.Int16 jsr CORE.IsDigit10
bcc .1
cmp #'-'
bne .90
.1 >PUSHW ZPInputBufPtr
2021-04-08 20:30:18 +00:00
>PUSHWI ZPInputBufPtr
>PUSHBI 10
>SYSCALL StrToL
2021-08-05 11:35:37 +00:00
bcs .99
2021-04-08 20:30:18 +00:00
2021-04-29 11:56:34 +00:00
jsr CODE.PUSHINT16
2021-06-22 18:59:02 +00:00
2021-08-05 11:35:37 +00:00
>POP 4 Discard long on stack
2021-04-08 20:30:18 +00:00
clc
2021-08-05 11:35:37 +00:00
rts
.90 lda #E.ESYN
sec
.99 rts
2021-04-08 20:30:18 +00:00
*--------------------------------------
EXP.VARLookup >LDA.G hVars
>PUSHA
2021-05-22 21:05:12 +00:00
>PUSHA for SListGetData/SListAddData
2021-04-08 20:30:18 +00:00
>PUSHW ZPInputBufPtr
>SYSCALL SListLookup
2021-05-22 21:05:12 +00:00
bcs .3
2021-04-08 20:30:18 +00:00
2021-05-22 21:05:12 +00:00
>PUSHYA KeyID
2021-04-08 20:30:18 +00:00
txa
2021-04-11 19:47:48 +00:00
jsr CORE.SkipA
2021-04-08 20:30:18 +00:00
.1 >PUSHWI EXP.ADDR
2021-04-11 19:47:48 +00:00
>PUSHWI 3 3 bytes : ADDR + TYPE
2021-04-08 20:30:18 +00:00
>PUSHWZ From Start
>SYSCALL SListGetData
2021-04-29 11:56:34 +00:00
bcs .99
2021-05-22 21:05:12 +00:00
jsr CORE.GetVarType
2021-06-22 18:59:02 +00:00
2021-05-22 21:05:12 +00:00
cpx EXP.TYPE
2021-08-06 17:58:04 +00:00
beq .7
2021-06-22 18:59:02 +00:00
2021-08-06 17:58:04 +00:00
lda #E.TMISMATCH
2021-05-22 21:05:12 +00:00
sec
.99 rts
*--------------------------------------
.3 jsr CORE.NewVarKey
2021-07-09 13:54:42 +00:00
bcs .9
2021-05-22 21:05:12 +00:00
2021-08-05 11:35:37 +00:00
>PUSHYA SID
2021-06-22 18:59:02 +00:00
2021-05-22 21:05:12 +00:00
jsr CORE.GetVarType
stx EXP.TYPE
2021-07-09 13:54:42 +00:00
beq .4
2021-06-22 18:59:02 +00:00
2021-08-05 11:35:37 +00:00
jsr CORE.GetStrID
2021-07-09 13:54:42 +00:00
bra .5
2021-06-22 18:59:02 +00:00
2021-07-09 13:54:42 +00:00
.4 jsr CORE.GetWord
.5 >STYA EXP.ADDR
2021-05-22 21:05:12 +00:00
>PUSHWI EXP.ADDR
>PUSHWI 3 3 bytes : ADDR + TYPE
>SYSCALL SListAddData
2021-08-06 17:58:04 +00:00
bcc .7
.9 inc pStack discard extra hVars
2021-05-22 21:05:12 +00:00
rts
2021-08-06 17:58:04 +00:00
*--------------------------------------
.7 ldy EXP.ADDR
ldx EXP.ADDR+1
2021-07-09 13:54:42 +00:00
2021-08-06 17:58:04 +00:00
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
2021-07-09 13:54:42 +00:00
rts
2021-08-06 17:58:04 +00:00
.8 clc
rts
2021-07-09 13:54:42 +00:00
*--------------------------------------
EXP.ComputeY lda EXP.TYPE
bne .1
2021-05-22 21:05:12 +00:00
2021-08-06 17:58:04 +00:00
ldx ACOS.AOPS2FPU,y
2021-07-09 13:54:42 +00:00
jsr CODE.FPUCALL
clc
rts
.1 cpy #3 +
2021-07-09 20:40:57 +00:00
bne .2
ldx #RT.StrAdd.ID
2021-07-09 20:40:57 +00:00
clc
jmp CODE.JSRRT
2021-07-09 20:40:57 +00:00
.2 stz EXP.TYPE at the end ....TRUE/FALSE is int
2021-08-06 17:58:04 +00:00
cpy #11 <>
2021-07-09 20:40:57 +00:00
bne .3
2021-08-06 17:58:04 +00:00
ldx #RT.StrCmp.ID
2021-07-09 20:40:57 +00:00
clc
2021-08-06 17:58:04 +00:00
jmp CODE.JSRRT
2021-07-09 20:40:57 +00:00
.3 cpy #13 =
bne .9
2021-08-06 17:58:04 +00:00
ldx #RT.StrCmp.ID
jsr CODE.JSRRT
2021-07-09 20:40:57 +00:00
ldx #RT.NOT.ID
clc
2021-08-06 17:58:04 +00:00
jmp CODE.JSRRT
2021-07-09 20:40:57 +00:00
2021-08-06 17:58:04 +00:00
.9 lda #E.TMISMATCH
sec
2021-04-08 20:30:18 +00:00
rts
*--------------------------------------
MAN
SAVE usr/src/bin/acos.s.exp
LOAD usr/src/bin/acos.s
ASM