From 633e6598859fc5104bb28d5cccac845cb5d5198e Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Wed, 18 Jan 2017 20:12:49 -0600 Subject: nqasm: support binary arithmetic operators in immediate operands --- nqasm.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'nqasm.c') diff --git a/nqasm.c b/nqasm.c index 49b4ec6..e915bd7 100644 --- a/nqasm.c +++ b/nqasm.c @@ -78,6 +78,11 @@ static long eval_argument(const struct argument *arg, uint16_t pc) case ARG_UNARY_NOT: return !eval_argument(arg->children[0], pc); case ARG_UNARY_INV: return ~eval_argument(arg->children[0], pc); + case ARG_ADD: return eval_argument(arg->children[0], pc) + eval_argument(arg->children[1], pc); + case ARG_SUB: return eval_argument(arg->children[0], pc) - eval_argument(arg->children[1], pc); + case ARG_MUL: return eval_argument(arg->children[0], pc) * eval_argument(arg->children[1], pc); + case ARG_DIV: return eval_argument(arg->children[0], pc) / eval_argument(arg->children[1], pc); + case ARG_LABEL: l = vector_search(&labels->v, &(struct label) { .name = arg->label }, cmp_label); if (l) return l->addr; -- cgit v1.2.3