ref: 67edfb04d803788d5d55242ec0ca813048d78266
parent: 38c7bd73ee1a5c394045ed17eea8661c4f8a6302
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Dec 27 10:53:24 EST 2017
[as-z80] Add idx() implementation
--- a/as/target/x80/ins.c
+++ b/as/target/x80/ins.c
@@ -374,8 +374,14 @@
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
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -151,6 +151,8 @@
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)