scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 4b9e2faf7b3ccd6268c11a8844e1ef2798278b57
parent 4ab6f49ca80e367e4b226591468781b95579ec17
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 16 Dec 2017 08:14:27 +0100

[as] Add optional parameter to .section

This parameter is used to add attributes to the section.

Diffstat:
Mas/as.h | 3++-
Mas/target/gen.awk | 4++++
Mas/target/x80/x80.dat | 2+-
Mas/target/z80/proc.c | 14++++++++++----
4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/as/as.h b/as/as.h @@ -41,7 +41,8 @@ enum common_args { AREG_OFF, ASYM, AMAX, - AREP = 128 + AOPT = 64, + AREP = 128, }; enum tokens { diff --git a/as/target/gen.awk b/as/target/gen.awk @@ -89,6 +89,8 @@ function str2args(s, args, i, out, n) 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 @@ function str2args(s, args, i, out, n) 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 diff --git 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 diff --git a/as/target/z80/proc.c b/as/target/z80/proc.c @@ -61,11 +61,13 @@ match(Op *op, Node **args) 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 @@ match(Op *op, Node **args) 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; }