expression evaluation optimizations
This commit is contained in:
1 parent
8aa3aed586
commit
42e4402afa
2 files changed
+22
-35
No files matched your search
@@ -34,7 +34,7 @@ FRMEVL:
|
|||||||
|
|
||||||
// XXX we also need TEMMPPT, LASTPT and TEMPST
|
// XXX we also need TEMMPPT, LASTPT and TEMPST
|
||||||
|
|
||||||
// Put the sentinel to the stack
|
// Push the sentinel to the stack
|
||||||
|
|
||||||
lda #$00
|
lda #$00
|
||||||
pha
|
pha
|
||||||
@@ -123,7 +123,7 @@ FRMEVL_fetch_string:
|
|||||||
FRMEVL_got_value:
|
FRMEVL_got_value:
|
||||||
|
|
||||||
jsr end_of_statement_check
|
jsr end_of_statement_check
|
||||||
bcs FRMEVL_calculate
|
bcs FRMEVL_continue // calculate the stack if expression ended
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
@@ -133,48 +133,24 @@ FRMEVL_fetch_operator:
|
|||||||
// there is an operator waiting to be served
|
// there is an operator waiting to be served
|
||||||
|
|
||||||
jsr fetch_operator
|
jsr fetch_operator
|
||||||
bcs FRMEVL_calculate // branch if operator not recognized
|
bcs FRMEVL_continue // if operator not recognized, calculate what we have
|
||||||
|
// on stack and quit
|
||||||
|
|
||||||
// We have a two-argument operator - check if there is enough stack space
|
// XXX check the priorities - possibly execute the current stack first
|
||||||
// XXX this can probably be checked later
|
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
FRMEVL_push_value_operator:
|
||||||
|
|
||||||
|
// Ccheck if there is enough stack space
|
||||||
tsx
|
tsx
|
||||||
cpx #$40 // XXX is this a safe threshold?
|
cpx #$40 // XXX is this a safe threshold?
|
||||||
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
||||||
|
|
||||||
// XXX check the priorities - either push to stack, or execute it immediately
|
|
||||||
|
|
||||||
bcs FRMEVL_push_value_operator // branch always
|
|
||||||
|
|
||||||
FRMEVL_calculate: // this is the exit point for the operators
|
|
||||||
|
|
||||||
// Now, we have to calculate all the operations; at this point we
|
|
||||||
// should have a value in FAC1 and (possibly) operator on the top of the stack
|
|
||||||
|
|
||||||
pla
|
|
||||||
beq FRMEVL_done // branch if sentinel
|
|
||||||
|
|
||||||
// Priority does not matter at this point - just jump to the operator
|
|
||||||
|
|
||||||
// FALLTROUGH
|
|
||||||
|
|
||||||
FRMEVL_done:
|
|
||||||
|
|
||||||
rts
|
|
||||||
|
|
||||||
FRMEVL_push_value_operator:
|
|
||||||
|
|
||||||
// Move the operator ID in .Y
|
// Move the operator ID in .Y
|
||||||
|
|
||||||
tay
|
tay
|
||||||
|
|
||||||
// Push the return address
|
|
||||||
|
|
||||||
lda #>(FRMEVL_calculate - 1)
|
|
||||||
pha
|
|
||||||
lda #<(FRMEVL_calculate - 1)
|
|
||||||
pha
|
|
||||||
|
|
||||||
// Push the value from FAC1
|
// Push the value from FAC1
|
||||||
|
|
||||||
ldx VALTYP
|
ldx VALTYP
|
||||||
@@ -199,6 +175,8 @@ FRMEVL_push_string:
|
|||||||
txa
|
txa
|
||||||
pha
|
pha
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
FRMEVL_push_operator_address:
|
FRMEVL_push_operator_address:
|
||||||
|
|
||||||
// Push the operator address to stack, in a form
|
// Push the operator address to stack, in a form
|
||||||
@@ -219,3 +197,12 @@ FRMEVL_push_operator_address:
|
|||||||
// Continue
|
// Continue
|
||||||
|
|
||||||
jmp FRMEVL_loop
|
jmp FRMEVL_loop
|
||||||
|
|
||||||
|
|
||||||
|
FRMEVL_continue: // this is the exit point for the operators
|
||||||
|
|
||||||
|
// Now, we have to calculate all the operations; at this point we
|
||||||
|
// should have a value in FAC1 and (possibly) operator on the top of the stack
|
||||||
|
|
||||||
|
pla // priority does not matter here, get rid of it
|
||||||
|
rts // this either jumps to operator, or quits FRMEVL
|
||||||
@@ -39,4 +39,4 @@ oper_add_strings:
|
|||||||
|
|
||||||
// XXX merge strings here
|
// XXX merge strings here
|
||||||
|
|
||||||
rts
|
jmp FRMEVL_continue
|
||||||
Reference in new issue
Block a user