summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/oasm/parse.c')
-rw-r--r--usr.bin/oasm/parse.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.bin/oasm/parse.c b/usr.bin/oasm/parse.c
index 9a4dd0e..113671f 100644
--- a/usr.bin/oasm/parse.c
+++ b/usr.bin/oasm/parse.c
@@ -43,11 +43,14 @@ static const char *tokstr[] = {
[ TT_MUL ] = "mul",
[ TT_DIV ] = "div",
[ TT_HLT ] = "hlt",
+ [ TT_BR ] = "br",
[ TT_COMMA ] = ",",
[ TT_INC ] = "inc",
[ TT_DEC ] = "dec",
[ TT_MOV ] = "mov",
[ TT_IMM ] = "<imm>",
+ [ TT_LABEL] = "<label>",
+
/* X<n> registers */
[ TT_X0 ] = "x0",
@@ -112,6 +115,7 @@ parse_reg(struct oasm_state *state, struct oasm_token *tok)
case TT_SUB:
case TT_MUL:
case TT_DIV:
+ case TT_BR:
state->last = tok->type;
break;
default:
@@ -144,6 +148,13 @@ parse_tok(struct oasm_state *state, struct oasm_token *tok)
int error;
switch (tok->type) {
+ case TT_BR:
+ state->last = tok->type;
+ emit_osmx64(&emit_state, tok);
+ break;
+ case TT_LABEL:
+ state->last = tok->type;
+ break;
case TT_HLT:
state->last = tok->type;
emit_osmx64(&emit_state, tok);
@@ -176,7 +187,7 @@ parse_tok(struct oasm_state *state, struct oasm_token *tok)
case TT_IMM:
p = tokstr[state->last];
if (!tok_is_xreg(state->last)) {
- printf("expected X<n> but got %s\n", p);
+ oasm_err("expected X<n> but got %s\n", p);
return -1;
}
emit_osmx64(&emit_state, tok);