shithub: scc

Download patch

ref: 8fe3cb063acd20ad53b0da4e27418050ed8a7125
parent: d82cd3b9dba1335ff981f2816672501babf55e11
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Dec 16 03:14:27 EST 2017

[as] Add optional parameter to .section

This parameter is used to add attributes to the section.

--- a/as/as.h
+++ b/as/as.h
@@ -41,7 +41,8 @@
 	AREG_OFF,
 	ASYM,
 	AMAX,
-	AREP = 128
+	AOPT = 64,
+	AREP = 128,
 };
 
 enum tokens {
--- a/as/target/gen.awk
+++ b/as/target/gen.awk
@@ -89,6 +89,8 @@
 			out = out "AREG_HL"
 		} else if (match(a, /^sym/)) {
 			out = out "ASYM"
+		} else if (match(a, /^string/)) {
+			out = out "ASTR"
 		} else {
 			print "wrong arg", a > "/dev/stderr"
 			exit 1
@@ -96,6 +98,8 @@
 		a = substr(a, RLENGTH+1)
 		if (a ~ /^\+$/) {
 			return out "|AREP"
+		} else if (a ~ /^\?$/) {
+			return out "|AOPT"
 		} else if (a != "") {
 			print "wrong arg", a > "/dev/stderr"
 			exit 1
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -1,6 +1,6 @@
 # Tab 16, tabs 16, :set ts=16
 # op	args	size	bytes	format	cpu
-.SECTION	sym	0	none	section	Z80,R800,GB80
+.SECTION	sym,string?	0	none	section	Z80,R800,GB80
 .TEXT	none	0	none	text	Z80,R800,GB80
 .DATA	none	0	none	data	Z80,R800,GB80
 .BSS	none	0	none	bss	Z80,R800,GB80
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -61,11 +61,13 @@
 	if (!op->args)
 		return args == NULL;
 
-	for (p = op->args; (arg = *p) && *args; ++p) {
+	for (p = op->args; arg = *p; ++p) {
 		if (arg & AREP)
 			--p;
-		np = *args++;
-		switch (arg & ~AREP) {
+		if ((np = *args++) == NULL)
+			return (arg & (AREP|AOPT)) != 0;
+
+		switch (arg & ~(AREP|AOPT)) {
 		case AINDER_HL:
 			if (np->addr != AINDIR)
 				return 0;
@@ -113,10 +115,14 @@
 			if (np->addr != AIMM || np->op != IDEN)
 				return 0;
 			break;
+		case ASTR:
+			if (np->addr != ASTR)
+				return 0;
+			break;
 		default:
 			abort();
 		}
 	}
 
-	return (!arg || arg & AREP) && !*args;
+	return *args == NULL;
 }