scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit ac1ee6278edd378b64554a16eeeadb8923f2bd72
parent 8d3968bf9dfc2e322b7fd940628821c27ecfc87f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 29 Sep 2017 21:47:09 +0200

[as] Fix order of evaluation of arguments in as description

using an incremental for makes easier to know the order of
the indexes in the list of arguments.

Diffstat:
as/target/gen.awk | 7++++---
as/target/z80/proc.c | 2+-
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/as/target/gen.awk b/as/target/gen.awk @@ -60,11 +60,12 @@ END { print "};" } -function str2args(s, args, i, out) +function str2args(s, args, i, out, n) { - if (split(s, args, /,/) == 0 || args[1] == "none") + n = split(s, args, /,/) + if (n == 0 || args[1] == "none") return "" - for (i in args) { + for (i = 1; i <= n; i++) { a = args[i] if (match(a, /^imm8/)) { out = out "AIMM8" diff --git a/as/target/z80/proc.c b/as/target/z80/proc.c @@ -63,6 +63,7 @@ match(Op *op, Node **args) for (p = op->args; (arg = *p) && *args; ++p) { if (arg & AREP) --p; + np = *args++; switch (arg & ~AREP) { case AREG_8: if (np->op != AREG) @@ -74,7 +75,6 @@ match(Op *op, Node **args) case AIMM16: case AIMM32: case AIMM64: - np = *args++; if (np->addr != AIMM) return 0; if (toobig(np, arg))