scc

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

commit 27f97dfd312192e7b5188eb064369d44a7caad83
parent 9805cb36b570b5203ac8b76034294f4c867adc58
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 14 Dec 2017 15:27:25 +0000

[as] Add ASYM argument type

In some pseudo instructions we need an
argument of symbol type, that is different
to string (enclosed between "") or of an immediate,
which can be a symbol or a numeric value.

Diffstat:
Mas/as.h | 1+
Mas/expr.c | 6+++++-
Mas/target/gen.awk | 2++
Mas/target/z80/proc.c | 18++++++++++++------
4 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/as/as.h b/as/as.h @@ -37,6 +37,7 @@ enum common_args { AINDEX, ADIRECT, AREG_OFF, + ASYM, AMAX, AREP = 128 }; diff --git a/as/expr.c b/as/expr.c @@ -356,7 +356,11 @@ content(Node *np) case AIMM: op = ADIRECT; new_node: - return node(op, np, NULL); + np = node(op, np, NULL); + np->addr = op; + break; + default: + abort(); } return np; } diff --git a/as/target/gen.awk b/as/target/gen.awk @@ -87,6 +87,8 @@ function str2args(s, args, i, out, n) out = out "AINDER_HL" } else if (match(a, /^HL/)) { out = out "AREG_HL" + } else if (match(a, /^sym/)) { + out = out "ASYM" } else { print "wrong arg", a > "/dev/stderr" exit 1 diff --git a/as/target/z80/proc.c b/as/target/z80/proc.c @@ -66,35 +66,37 @@ match(Op *op, Node **args) np = *args++; switch (arg & ~AREP) { case AINDER_HL: - if (np->op != AINDIR) + if (np->addr != AINDIR) return 0; if (np->left->sym->argtype != AREG_HL) return 0; break; case AREG_A: - if (np->op != AREG || np->sym->argtype != AREG_A) + if (np->addr != AREG || np->sym->argtype != AREG_A) return 0; break; case AREG_RCLASS: - if (np->op != AREG) + if (np->addr != AREG) return 0; if (!rclass(np->sym->argtype)) return 0; break; case AREG_PCLASS: - if (np->op != AREG) + if (np->addr != AREG) return 0; if (!pclass(np->sym->argtype)) return 0; break; case AREG_QCLASS: - if (np->op != AREG) + if (np->addr != AREG) return 0; if (!qclass(np->sym->argtype)) return 0; break; case AREG_HL: - if (np->op != AREG && np->sym->argtype != AREG_HL) + if (np->addr != AREG) + return 0; + if (np->sym->argtype != AREG_HL) return 0; break; case AIMM8: @@ -106,6 +108,10 @@ match(Op *op, Node **args) if (toobig(np, arg)) error("overflow in immediate operand"); break; + case ASYM: + if (np->op != ASYM) + return 0; + break; default: abort(); }