shithub: scc

Download patch

ref: e389dc2387eb8f243a3361263f5ac1d85e95b7ec
parent: 10e4cba238d4a3003646328e3994bd17db2ef245
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Sep 9 03:02:18 EDT 2017

[as] Use a common regex language

* means 0 or more, but + 1 or more

--- a/as/common.dat
+++ b/as/common.dat
@@ -1,6 +1,6 @@
 # Tab 16, tabs 16, :set ts=16
 # op	args	size	bytes	format
-DB	imm8*	0	none	defb
-DW	imm16*	0	none	defw
-DD	imm32*	0	none	defd
-DQ	imm64*	0	none	defq
+DB	imm8+	0	none	defb
+DW	imm16+	0	none	defw
+DD	imm32+	0	none	defd
+DQ	imm64+	0	none	defq
--- a/as/target/x86/gen.awk
+++ b/as/target/x86/gen.awk
@@ -51,22 +51,28 @@
 {
 	split(s, args, /,/)
 	for (i in args) {
-		if (args[i] == "none")
+		a = args[i]
+		if (a == "none") {
 			break
-		else if (args[i] ~ /imm8/)
+		} else if (match(a, /^imm8/)) {
 			out = "AIMM8"
-		else if (args[i] ~ /imm16/)
+		} else if (match(a, /^imm16/)) {
 			out = "AIMM16"
-		else if (args[i] ~ /imm32/)
+		} else if (match(a, /^imm32/)) {
 			out = "AIMM32"
-		else if (args[i] ~ /imm64/)
+		} else if (match(a, /^imm64/)) {
 			out = "AIMM64"
-		else {
-			print "wrong arg", args[i]
+		} else {
+			print "wrong arg", a
 			exit 1
 		}
-		if (args[i] ~ /\*$/)
+		a = substr(a, RLENGTH+1)
+		if (a ~ /^\+$/) {
 			return out "|AREP"
+		} else {
+			print "wrong arg", a
+			exit 1
+		}
 		out = out ","
 	}
 	out = out "0"