ref: 5fb3dda9da04112b9d166df06c46ab0288a9bade
parent: 23d465219fc21eae98468d5a5bcd82395934230a
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Sep 30 06:19:17 EDT 2017
[as-z80] Add imm8 and r8 instruction formats
--- a/as/target/gen.awk
+++ b/as/target/gen.awk
@@ -81,6 +81,8 @@
out = out "AREG_QCLASS"
} else if (match(a, /^reg_r/)) {
out = out "AREG_RCLASS"
+ } else if (match(a, /^regA/)) {
+ out = out "AREG_A"
} else {
print "wrong arg", a
exit 1
--- a/as/target/x80/ins.c
+++ b/as/target/x80/ins.c
@@ -94,6 +94,20 @@
}
void
+imm8(Op *op, Node **args)
+{
+ Node *par1, *par2;
+ unsigned char buf[3];
+ int n = op->size;
+
+ par2 = args[1];
+
+ memcpy(buf, op->bytes, n-1);
+ buf[n-1] = par2->sym->value;
+ emit(cursec, buf, n);
+}
+
+void
r8_r8(Op *op, Node **args)
{
Node *par1, *par2;
@@ -105,5 +119,19 @@
memcpy(buf, op->bytes, n);
buf[n-1] |= reg2int(par1->sym->argtype) << 3 |
reg2int(par2->sym->argtype);
+ emit(cursec, buf, n);
+}
+
+void
+r8(Op *op, Node **args)
+{
+ Node *par1, *par2;
+ unsigned char buf[3];
+ int n = op->size;
+
+ par1 = args[0];
+ par2 = args[1];
+ memcpy(buf, op->bytes, n);
+ buf[n-1] |= reg2int(par2->sym->argtype);
emit(cursec, buf, n);
}
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -62,3 +62,8 @@
LD reg_r,reg_r 1 0x40 r8_r8 Z80,R800,GB80
LD reg_p,reg_p 2 0xdd,0x40 r8_r8 Z80,R800
LD reg_q,reg_q 2 0xfd,0x40 r8_r8 Z80,R800
+
+ADD regA,reg_r 1 0x80 r8 Z80,R800,GB80
+ADD regA,reg_p 2 0xdd,0x80 r8 Z80,R800
+ADD regA,reg_q 2 0xfd,0x80 r8 Z80,R800
+ADD regA,imm8 2 0xc6 imm8 Z80,R800
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -65,6 +65,10 @@
--p;
np = *args++;
switch (arg & ~AREP) {
+ case AREG_A:
+ if (np->op != AREG || np->sym->argtype != AREG_A)
+ return 0;
+ break;
case AREG_RCLASS:
if (np->op != AREG)
return 0;