diff options
author | Bobby Bingham <koorogi@koorogi.info> | 2017-01-18 20:12:49 -0600 |
---|---|---|
committer | Bobby Bingham <koorogi@koorogi.info> | 2017-01-18 20:21:17 -0600 |
commit | 633e6598859fc5104bb28d5cccac845cb5d5198e (patch) | |
tree | 575e9343507673d3f515993ee636e602c3d33182 /nqasm.c | |
parent | 6c6b91f9a6bc5ae203e99ac7abb3a70215488a6f (diff) |
nqasm: support binary arithmetic operators in immediate operands
Diffstat (limited to 'nqasm.c')
-rw-r--r-- | nqasm.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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; |