diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2017-01-18 19:20:20 -0600 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2017-01-18 19:20:20 -0600 |
commit | 1e0d0202e614f398f491624c84ae9a8309fa2f96 (patch) | |
tree | 1000df0a8eb39453ac48a14809dd250230f67e6c /nqasm.c | |
parent | 2e0de3cc53d031ac2fa48eddc9a472b0e4c34a45 (diff) |
nqasm: allow "." to refer to current pc in immediate operand
Diffstat (limited to 'nqasm.c')
-rw-r--r-- | nqasm.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -56,12 +56,12 @@ void add_instruction(const struct instruction *inst) addr += 2; } -static long eval_argument(const struct argument *arg) +static long eval_argument(const struct argument *arg, uint16_t pc) { struct label *l; switch (arg->type) { - case ARG_INTEGER: - return arg->value; + case ARG_INTEGER: return arg->value; + case ARG_PC: return pc; case ARG_LABEL: l = vector_search(&labels->v, &(struct label) { .name = arg->label }, cmp_label); @@ -82,7 +82,7 @@ static void assemble_instruction(const struct instruction *inst, uint16_t pc) const struct operand *ops = mnem->operands; const struct argument *args = inst->args.args; for (int i = 0; i < 3 && ops[i].type; i++) { - long value = eval_argument(args + i); + long value = eval_argument(args + i, pc); switch (ops[i].type) { case REG: |