From 1e0d0202e614f398f491624c84ae9a8309fa2f96 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Wed, 18 Jan 2017 19:20:20 -0600 Subject: nqasm: allow "." to refer to current pc in immediate operand --- nqasm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nqasm.c') diff --git a/nqasm.c b/nqasm.c index 0b0bbd8..ee3010a 100644 --- a/nqasm.c +++ b/nqasm.c @@ -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: -- cgit v1.2.3