summaryrefslogtreecommitdiff
path: root/asmmon.h
diff options
context:
space:
mode:
Diffstat (limited to 'asmmon.h')
-rw-r--r--asmmon.h48
1 files changed, 43 insertions, 5 deletions
diff --git a/asmmon.h b/asmmon.h
index de1f732..e98afff 100644
--- a/asmmon.h
+++ b/asmmon.h
@@ -9,6 +9,7 @@ typedef struct ln line;
typedef struct sym symbol;
typedef struct fix fixup;
typedef struct inst instruction;
+typedef struct expr expr;
struct tok {
@@ -27,6 +28,7 @@ struct tok {
/* Token value(s). */
union {
+ expr *expr;
symbol *sym;
char *str;
uint8_t byte ;
@@ -74,6 +76,19 @@ struct inst {
uint8_t op; /* Base value used to get the actual opcode. */
};
+struct expr {
+ int type; /* Expression type. */
+
+ expr *left; /* Left side of expression. */
+ expr *right; /* Right side of expression. */
+
+ /* Expression value. */
+ union {
+ uint64_t val;
+ symbol *sym;
+ } value;
+};
+
extern char lexeme[];
extern char *string[];
@@ -89,7 +104,6 @@ extern symbol *locals;
extern symbol *last_loc;
extern fixup *fixups;
extern fixup *last_fix;
-extern tmp_symtab *tmp_sym_table;
extern uint8_t lex_type;
@@ -173,7 +187,7 @@ enum pre_token {
PTOK_OTHER
};
-enum expr {
+enum expression {
EXPR_PLUS,
EXPR_MINUS,
EXPR_LOW,
@@ -182,6 +196,12 @@ enum expr {
EXPR_LSHFT,
EXPR_RSHFT,
EXPR_MUL,
+ EXPR_HEX,
+ EXPR_DEC,
+ EXPR_BIN,
+ EXPR_CHAR,
+ EXPR_SYM,
+ EXPR_REG,
EXPR_NONE
};
@@ -690,6 +710,25 @@ static const char *set_cc[8] = {
"VC"
};
+static const char *reg_name[16] = {
+ [REG_A ] = "A",
+ [REG_B ] = "B",
+ [REG_X ] = "X",
+ [REG_Y ] = "Y",
+ [REG_E ] = "E",
+ [REG_C ] = "C",
+ [REG_D ] = "D",
+ [REG_S ] = "S",
+ [REG_F ] = "F",
+ [REG_SP ] = "SP",
+ [REG_BP ] = "BP",
+ [REG_R11] = "R11",
+ [REG_R12] = "R12",
+ [REG_R13] = "R13",
+ [REG_R14] = "R14",
+ [REG_R15] = "R15"
+};
+
static const char *instdesc[OPNUM] = {
[ADC] = "ADd accumulator, with operand, Carry if needed.",
[AND] = "Bitwise AND accumulator, with operand.",
@@ -805,11 +844,10 @@ extern uint8_t isfixup;
extern line *find_line(uint32_t ln, uint8_t dbg);
extern uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg);
-
-extern uint64_t get_val(token *t, uint64_t addr, uint8_t size, uint8_t end_expr, uint8_t stop_comma, uint8_t dbg);
+extern uint64_t get_val(expr *tree, uint64_t addr, uint8_t size, int depth, uint8_t dbg);
extern token *skip_expr(token *t, uint8_t end_expr, uint8_t stop_comma, uint8_t dbg);
extern uint64_t parse_tokens(token *tm, line **l, bytecount *bc, uint8_t isasm, uint64_t address, uint8_t dbg);
-extern token *make_token(uint8_t id, uint8_t type, uint8_t space, uint8_t tab, uint64_t value, char *str, symbol *s);
+extern token *make_token(uint8_t id, uint8_t type, uint8_t space, uint8_t tab, uint64_t value, char *str, symbol *s, expr *e);
extern void assemble(line *ln, bytecount *bc, uint8_t dbg);
extern void fix_symtree(line *l);
extern void cleanup();