added list of operators and priorities
This commit is contained in:
1 parent
855d8c43d5
commit
d7a8649432
18 files changed
+232
-11
No files matched your search
@@ -47,8 +47,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#if !HAS_OPCODES_65C02
|
|
||||||
|
|
||||||
.macro put_jumptable_lo(list)
|
.macro put_jumptable_lo(list)
|
||||||
{
|
{
|
||||||
.for (var i = 0; i < list.size(); i++)
|
.for (var i = 0; i < list.size(); i++)
|
||||||
@@ -65,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // HAS_OPCODES_65C02
|
#if HAS_OPCODES_65C02
|
||||||
|
|
||||||
.macro put_jumptable(list)
|
.macro put_jumptable(list)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,15 @@
|
|||||||
|
|
||||||
FRMEVL:
|
FRMEVL:
|
||||||
|
|
||||||
|
// XXX we neeed FRETOP for string concatenation
|
||||||
|
|
||||||
|
// lda VARTAB+0
|
||||||
|
// sta FRETOP+0
|
||||||
|
// lda VARTAB+1
|
||||||
|
// sta FRETOP+1
|
||||||
|
|
||||||
|
// XXX we also need TEMMPPT, LASTPT and TEMPST
|
||||||
|
|
||||||
// Put the sentinel to the stack
|
// Put the sentinel to the stack
|
||||||
|
|
||||||
lda #$00
|
lda #$00
|
||||||
@@ -50,7 +59,7 @@ FRMEVL_loop:
|
|||||||
bcc FRMEVL_fetch_float
|
bcc FRMEVL_fetch_float
|
||||||
|
|
||||||
// Search for a value or unary operator, starting from the most probable
|
// Search for a value or unary operator, starting from the most probable
|
||||||
// XXX check for BASIC functions here, too
|
// XXX check all other operators
|
||||||
|
|
||||||
cmp #$AB // check for unary minus
|
cmp #$AB // check for unary minus
|
||||||
beq_16 do_NOT_IMPLEMENTED_error // XXX
|
beq_16 do_NOT_IMPLEMENTED_error // XXX
|
||||||
@@ -129,7 +138,7 @@ FRMEVL_fetch_operator:
|
|||||||
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
bcc_16 do_FORMULA_TOO_COMPLEX_error
|
||||||
|
|
||||||
// Now look for an operator
|
// Now look for an operator
|
||||||
// XXX for now only plus operator is implemented
|
// XXX for now only addition operator is implemented
|
||||||
|
|
||||||
jsr fetch_character
|
jsr fetch_character
|
||||||
cmp #$AA // check for a plus operator
|
cmp #$AA // check for a plus operator
|
||||||
@@ -197,9 +206,9 @@ FRMEVL_push_operator_address:
|
|||||||
|
|
||||||
// XXX add support for other operators
|
// XXX add support for other operators
|
||||||
|
|
||||||
lda #>(oper_plus - 1)
|
lda #>(oper_add - 1)
|
||||||
pha
|
pha
|
||||||
lda #<(oper_plus - 1)
|
lda #<(oper_add - 1)
|
||||||
pha
|
pha
|
||||||
|
|
||||||
// Push operator priority
|
// Push operator priority
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
// #LAYOUT# * * #IGNORE
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
oper_plus:
|
oper_add:
|
||||||
|
|
||||||
// This operator can be used either with two strings, or with two floats
|
// This operator can be used either with two strings, or with two floats
|
||||||
// First check whether arguments match and then choose the variant
|
// First check whether arguments match and then choose the variant
|
||||||
@@ -13,17 +13,17 @@ oper_plus:
|
|||||||
bne_16 do_TYPE_MISMATCH_error
|
bne_16 do_TYPE_MISMATCH_error
|
||||||
|
|
||||||
lda VALTYP
|
lda VALTYP
|
||||||
bmi oper_plus_strings
|
bmi oper_add_strings
|
||||||
|
|
||||||
// FALLTROUGH
|
// FALLTROUGH
|
||||||
|
|
||||||
oper_plus_floats:
|
oper_add_floats:
|
||||||
|
|
||||||
// XXX implement this
|
// XXX implement this
|
||||||
|
|
||||||
jmp do_NOT_IMPLEMENTED_error
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
|
|
||||||
oper_plus_strings:
|
oper_add_strings:
|
||||||
|
|
||||||
// Pull string length
|
// Pull string length
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_and:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_cmp_eq:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_cmp_gt:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_cmp_gteq:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_cmp_lt:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_cmp_lteq:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_cmp_neq:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_div:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_mul:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_or:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_pow:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_sub:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_unary_minus:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
|
||||||
|
oper_unary_not:
|
||||||
|
|
||||||
|
// XXX provide implementation
|
||||||
|
|
||||||
|
jmp do_NOT_IMPLEMENTED_error
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// #LAYOUT# STD * #TAKE
|
||||||
|
// #LAYOUT# * BASIC_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
//
|
||||||
|
// Jumptable and priority list for all BASIC operators
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
.const operator_list = List().add(
|
||||||
|
|
||||||
|
// Tokens XXX
|
||||||
|
|
||||||
|
oper_add,
|
||||||
|
oper_sub,
|
||||||
|
oper_mul,
|
||||||
|
oper_div,
|
||||||
|
|
||||||
|
// Tokens XXX
|
||||||
|
|
||||||
|
oper_and,
|
||||||
|
oper_or,
|
||||||
|
|
||||||
|
// Tokens XXX
|
||||||
|
|
||||||
|
oper_cmp_gt,
|
||||||
|
oper_cmp_eq,
|
||||||
|
oper_cmp_lt,
|
||||||
|
|
||||||
|
// Combined two tokens
|
||||||
|
|
||||||
|
oper_cmp_gteq,
|
||||||
|
oper_cmp_lteq,
|
||||||
|
oper_cmp_neq,
|
||||||
|
|
||||||
|
// Not a token
|
||||||
|
|
||||||
|
oper_pow,
|
||||||
|
|
||||||
|
// Unary
|
||||||
|
|
||||||
|
oper_unary_minus,
|
||||||
|
oper_unary_not
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
operator_priorities: // higher number = higher priority
|
||||||
|
|
||||||
|
.byte $05 // oper_add
|
||||||
|
.byte $05 // oper_sub
|
||||||
|
.byte $06 // oper_mul
|
||||||
|
.byte $06 // oper_div
|
||||||
|
.byte $02 // oper_and
|
||||||
|
.byte $01 // oper_or
|
||||||
|
.byte $04 // oper_cmp_gt
|
||||||
|
.byte $04 // oper_cmp_eq
|
||||||
|
.byte $04 // oper_cmp_lt
|
||||||
|
.byte $04 // oper_cmp_gteq
|
||||||
|
.byte $04 // oper_cmp_lteq
|
||||||
|
.byte $04 // oper_cmp_neq
|
||||||
|
.byte $08 // oper_pow
|
||||||
|
.byte $07 // oper_unary_minus
|
||||||
|
.byte $03 // oper_unary_not
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
operator_jumptable_lo:
|
||||||
|
|
||||||
|
put_jumptable_lo(operator_list)
|
||||||
|
|
||||||
|
|
||||||
|
operator_jumptable_hi:
|
||||||
|
|
||||||
|
put_jumptable_hi(operator_list)
|
||||||
Reference in new issue
Block a user