shithub: scc

Download patch

ref: 461cca7fa3f4225b2aa9bbba5c4690cd90fa7513
parent: 1e1f75a7e9d7df35f4999c0ad3913ed61a92678b
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Sep 29 17:47:09 EDT 2017

[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.

--- a/as/target/gen.awk
+++ b/as/target/gen.awk
@@ -60,11 +60,12 @@
 		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"
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -63,6 +63,7 @@
 	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 @@
 		case AIMM16:
 		case AIMM32:
 		case AIMM64:
-			np = *args++;
 			if (np->addr != AIMM)
 				return 0;
 			if (toobig(np, arg))