summaryrefslogtreecommitdiff
path: root/nqasm.c
diff options
context:
space:
mode:
Diffstat (limited to 'nqasm.c')
-rw-r--r--nqasm.c8
1 files changed, 4 insertions, 4 deletions
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: