asm: implement $-prefixed label references for branch instructions

This commit is contained in:
2025-05-12 15:49:27 +01:00
parent 497ba65440
commit c1ba6e78bc
3 changed files with 67 additions and 4 deletions

View File

@@ -487,7 +487,7 @@ static enum ivy_status parse_ident(
state->s_prev_component = INSTR_OPERAND;
if (x == REG_INDEX_INVALID) {
return push_label_arg(state, tok, x);
return IVY_ERR_BAD_SYNTAX;
} else {
return push_reg_arg(state, tok, x);
}
@@ -510,6 +510,28 @@ static enum ivy_status parse_ident(
return IVY_ERR_BAD_SYNTAX;
}
static enum ivy_status parse_label_ref(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
struct block_parser_state *state
= (struct block_parser_state *)asm_parser_get_state(ctx);
unsigned long long x = 0;
switch (state->s_prev_component) {
case INSTR_OPCODE:
case INSTR_OPERAND_SEPARATOR:
state->s_prev_component = INSTR_OPERAND;
return push_label_arg(state, tok, x);
default:
return IVY_ERR_BAD_SYNTAX;
}
/* not sure what this is but we aren't expecting it. */
return IVY_ERR_BAD_SYNTAX;
}
static enum ivy_status parse_dot(
struct ivy_asm_parser *ctx, struct ivy_asm_token *tok)
{
@@ -633,6 +655,7 @@ struct parser_state_type block_parser_state_type = {
.n_token_parsers = {
TOK_PARSER(IDENT, parse_ident),
TOK_PARSER(LABEL, parse_label),
TOK_PARSER(LABEL_REF, parse_label_ref),
TOK_PARSER(INT, parse_int),
TOK_PARSER(LINEFEED, parse_linefeed),
},