mirror of
https://github.com/ksherlock/x65.git
synced 2025-02-26 00:29:28 +00:00
Error fixes
-Declaring an enum is apparently not proper c++, Visual Studio did not complain.. Moved the whole EvalOperator enum up to the top of the file -If a line can't be processed, error out instead of infinite looping (freeze) -Kick Assembler syntax for using a macro was broken with recent changes to support Merlin syntax, colon prefix for using macros is now only allowed if not specifying -merlin.
This commit is contained in:
parent
feb79990ee
commit
db6f6887e5
56
asm6502.cpp
56
asm6502.cpp
@ -115,6 +115,7 @@ enum StatusCode {
|
|||||||
ERROR_REPT_MISSING_SCOPE,
|
ERROR_REPT_MISSING_SCOPE,
|
||||||
ERROR_LINKER_MUST_BE_IN_FIXED_ADDRESS_SECTION,
|
ERROR_LINKER_MUST_BE_IN_FIXED_ADDRESS_SECTION,
|
||||||
ERROR_LINKER_CANT_LINK_TO_DUMMY_SECTION,
|
ERROR_LINKER_CANT_LINK_TO_DUMMY_SECTION,
|
||||||
|
ERROR_UNABLE_TO_PROCESS,
|
||||||
|
|
||||||
STATUSCODE_COUNT
|
STATUSCODE_COUNT
|
||||||
};
|
};
|
||||||
@ -169,6 +170,7 @@ const char *aStatusStrings[STATUSCODE_COUNT] = {
|
|||||||
"rept is missing a scope ('{ ... }')",
|
"rept is missing a scope ('{ ... }')",
|
||||||
"Link can only be used in a fixed address section",
|
"Link can only be used in a fixed address section",
|
||||||
"Link can not be used in dummy sections",
|
"Link can not be used in dummy sections",
|
||||||
|
"Can not process this line",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Assembler directives
|
// Assembler directives
|
||||||
@ -215,6 +217,28 @@ enum OperationType {
|
|||||||
OT_DIRECTIVE
|
OT_DIRECTIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// These are expression tokens in order of precedence (last is highest precedence)
|
||||||
|
enum EvalOperator {
|
||||||
|
EVOP_NONE,
|
||||||
|
EVOP_VAL='a', // a, value => read from value queue
|
||||||
|
EVOP_LPR, // b, left parenthesis
|
||||||
|
EVOP_RPR, // c, right parenthesis
|
||||||
|
EVOP_ADD, // d, +
|
||||||
|
EVOP_SUB, // e, -
|
||||||
|
EVOP_MUL, // f, * (note: if not preceded by value or right paren this is current PC)
|
||||||
|
EVOP_DIV, // g, /
|
||||||
|
EVOP_AND, // h, &
|
||||||
|
EVOP_OR, // i, |
|
||||||
|
EVOP_EOR, // j, ^
|
||||||
|
EVOP_SHL, // k, <<
|
||||||
|
EVOP_SHR, // l, >>
|
||||||
|
EVOP_LOB, // m, low byte of 16 bit value
|
||||||
|
EVOP_HIB, // n, high byte of 16 bit value
|
||||||
|
EVOP_STP, // o, Unexpected input, should stop and evaluate what we have
|
||||||
|
EVOP_NRY, // p, Not ready yet
|
||||||
|
EVOP_ERR, // q, Error
|
||||||
|
};
|
||||||
|
|
||||||
// Opcode encoding
|
// Opcode encoding
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int op_hash;
|
unsigned int op_hash;
|
||||||
@ -247,8 +271,6 @@ enum AddressingMode {
|
|||||||
AM_INVALID, // 11
|
AM_INVALID, // 11
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EvalOperator;
|
|
||||||
|
|
||||||
// How instruction argument is encoded
|
// How instruction argument is encoded
|
||||||
enum CODE_ARG {
|
enum CODE_ARG {
|
||||||
CA_NONE, // single byte instruction
|
CA_NONE, // single byte instruction
|
||||||
@ -316,7 +338,7 @@ unsigned char CC10Mask[] = { 0xaa, 0xaa, 0xaa, 0xaa, 0x2a, 0xae, 0xaa, 0xaa };
|
|||||||
// hardtexted strings
|
// hardtexted strings
|
||||||
static const strref c_comment("//");
|
static const strref c_comment("//");
|
||||||
static const strref word_char_range("!0-9a-zA-Z_@$!#");
|
static const strref word_char_range("!0-9a-zA-Z_@$!#");
|
||||||
static const strref label_end_char_range("!0-9a-zA-Z_@$!.:");
|
static const strref label_end_char_range("!0-9a-zA-Z_@$!.");
|
||||||
static const strref label_end_char_range_merlin("!0-9a-zA-Z_@$!]:?");
|
static const strref label_end_char_range_merlin("!0-9a-zA-Z_@$!]:?");
|
||||||
static const strref filename_end_char_range("!0-9a-zA-Z_!@#$%&()\\-");
|
static const strref filename_end_char_range("!0-9a-zA-Z_!@#$%&()\\-");
|
||||||
static const strref keyword_equ("equ");
|
static const strref keyword_equ("equ");
|
||||||
@ -1339,28 +1361,6 @@ StatusCode Asm::EvalStruct(strref name, int &value)
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
// These are expression tokens in order of precedence (last is highest precedence)
|
|
||||||
enum EvalOperator {
|
|
||||||
EVOP_NONE,
|
|
||||||
EVOP_VAL='a', // a, value => read from value queue
|
|
||||||
EVOP_LPR, // b, left parenthesis
|
|
||||||
EVOP_RPR, // c, right parenthesis
|
|
||||||
EVOP_ADD, // d, +
|
|
||||||
EVOP_SUB, // e, -
|
|
||||||
EVOP_MUL, // f, * (note: if not preceded by value or right paren this is current PC)
|
|
||||||
EVOP_DIV, // g, /
|
|
||||||
EVOP_AND, // h, &
|
|
||||||
EVOP_OR, // i, |
|
|
||||||
EVOP_EOR, // j, ^
|
|
||||||
EVOP_SHL, // k, <<
|
|
||||||
EVOP_SHR, // l, >>
|
|
||||||
EVOP_LOB, // m, low byte of 16 bit value
|
|
||||||
EVOP_HIB, // n, high byte of 16 bit value
|
|
||||||
EVOP_STP, // o, Unexpected input, should stop and evaluate what we have
|
|
||||||
EVOP_NRY, // p, Not ready yet
|
|
||||||
EVOP_ERR, // q, Error
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get a single token from a merlin expression
|
// Get a single token from a merlin expression
|
||||||
EvalOperator Asm::RPNToken_Merlin(strref &expression, int pc, int scope_pc, int scope_end_pc, EvalOperator prev_op, short §ion, int &value)
|
EvalOperator Asm::RPNToken_Merlin(strref &expression, int pc, int scope_pc, int scope_end_pc, EvalOperator prev_op, short §ion, int &value)
|
||||||
{
|
{
|
||||||
@ -1507,7 +1507,6 @@ StatusCode Asm::EvalExpression(strref expression, int pc, int scope_pc, int scop
|
|||||||
short section_val[MAX_EVAL_VALUES]; // each value can be assigned to one section, or -1 if fixed
|
short section_val[MAX_EVAL_VALUES]; // each value can be assigned to one section, or -1 if fixed
|
||||||
short num_sections = 0; // number of sections in section_ids (normally 0 or 1, can be up to MAX_EVAL_SECTIONS)
|
short num_sections = 0; // number of sections in section_ids (normally 0 or 1, can be up to MAX_EVAL_SECTIONS)
|
||||||
values[0] = 0; // Initialize RPN if no expression
|
values[0] = 0; // Initialize RPN if no expression
|
||||||
StatusCode status = STATUS_OK;
|
|
||||||
{
|
{
|
||||||
int sp = 0;
|
int sp = 0;
|
||||||
char op_stack[MAX_EVAL_OPER];
|
char op_stack[MAX_EVAL_OPER];
|
||||||
@ -3127,6 +3126,8 @@ StatusCode Asm::BuildLine(OP_ID *pInstr, int numInstructions, strref line)
|
|||||||
line = line.before_or_full(';'); // clip any line comments
|
line = line.before_or_full(';'); // clip any line comments
|
||||||
line = line.before_or_full(c_comment);
|
line = line.before_or_full(c_comment);
|
||||||
line.clip_trailing_whitespace();
|
line.clip_trailing_whitespace();
|
||||||
|
if (line[0]==':' && syntax!=SYNTAX_MERLIN) // Kick Assembler macro prefix (incompatible with merlin)
|
||||||
|
++line;
|
||||||
strref line_nocom = line;
|
strref line_nocom = line;
|
||||||
strref operation = line.split_range(syntax==SYNTAX_MERLIN ? label_end_char_range_merlin : label_end_char_range);
|
strref operation = line.split_range(syntax==SYNTAX_MERLIN ? label_end_char_range_merlin : label_end_char_range);
|
||||||
char char1 = operation[0]; // first char of first word
|
char char1 = operation[0]; // first char of first word
|
||||||
@ -3251,6 +3252,9 @@ StatusCode Asm::BuildLine(OP_ID *pInstr, int numInstructions, strref line)
|
|||||||
error = ERROR_UNTERMINATED_CONDITION;
|
error = ERROR_UNTERMINATED_CONDITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (line.same_str_case(line_start))
|
||||||
|
error = ERROR_UNABLE_TO_PROCESS;
|
||||||
|
|
||||||
if (error > STATUS_NOT_READY)
|
if (error > STATUS_NOT_READY)
|
||||||
PrintError(line_start, error);
|
PrintError(line_start, error);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user