scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit de7c12f6f60a817c25ddff8488f55ed496987155
parent b075adfa058f48a924c14412c6695d35be1b968f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 27 Sep 2017 22:21:16 +0200

[as] Add basic AIMM argument matching in z80

This matching is ignoring the size of the immediate at this moment.

Diffstat:
Mas/expr.c | 1+
Mas/target/z80/proc.c | 18++++++++++--------
2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/as/expr.c b/as/expr.c @@ -350,6 +350,7 @@ primary(void) basic_atom: np = node(yytoken, NULL, NULL); np->sym = yylval.sym; + np->addr = addr; next(); break; default: diff --git a/as/target/z80/proc.c b/as/target/z80/proc.c @@ -53,23 +53,25 @@ iarch(void) int match(Op *op, Node **args) { - char *p; - int a, olda; + unsigned char *p; + int arg; + Node *np; if (!op->args) return args == NULL; - for (p = op->args; *p; ++p) { - if (*p != AREP) - a = *p; - else + for (p = op->args; (arg = *p) && *args; ++p) { + if (arg & AREP) --p; - - switch (a) { + switch (arg & ~AREP) { case AIMM8: case AIMM16: case AIMM32: case AIMM64: + np = *args++; + if (np->addr != AIMM) + return 0; + break; default: abort(); }