scc

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

commit 38df2f7d8bbde9f7d5083da7f22734e3c4836f27
parent 5fb67b526f1697729473a560d383d7ef1cdae75e
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 27 Dec 2017 15:53:24 +0000

[as-z80] Add idx() implementation

Diffstat:
Mas/target/x80/ins.c | 10++++++++--
Mas/target/z80/proc.c | 2++
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/as/target/x80/ins.c b/as/target/x80/ins.c @@ -374,8 +374,14 @@ r16_dir(Op *op, Node **args) void idx(Op *op, Node **args) { - /* TODO */ - abort(); + Node *imm; + unsigned char buf[4]; + int n = op->size; + + imm = args[0]->left->right; + memcpy(buf, op->bytes, n); + buf[n-1] = imm->sym->value; + emit(buf, n); } void diff --git a/as/target/z80/proc.c b/as/target/z80/proc.c @@ -151,6 +151,8 @@ match(Op *op, Node **args) return 0; if (np->left->left->sym->argtype != arg) return 0; + if (toobig(np, arg)) + error("overflow in index"); break; case ARST: if (np->addr != AIMM)