ref: f6033a17f5c0fd728a0131642dc65d2bf0c4da2d
parent: a8c12d5af237508f34662b5748cb672f5b75da53
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Dec 18 03:28:00 EST 2017
[as-z80] Add missed exchange instructions
--- a/as/target/gen.awk
+++ b/as/target/gen.awk
@@ -95,8 +95,6 @@
out = out "AREG_RCLASS"
} else if (match(a, /^R/)) {
out = out "AREG_R"
- } else if (match(a, /^A/)) {
- out = out "AREG_A"
} else if (match(a, /^\(DE\)/)) {
out = out "AINDER_DE"
} else if (match(a, /^\(BC\)/)) {
@@ -103,14 +101,24 @@
out = out "AINDER_BC"
} else if (match(a, /^\(HL\)/)) {
out = out "AINDER_HL"
+ } else if (match(a, /^\(SP\)/)) {
+ out = out "AINDER_SP"
} else if (match(a, /^SP/)) {
out = out "AREG_SP"
} else if (match(a, /^HL/)) {
out = out "AREG_HL"
+ } else if (match(a, /^DE/)) {
+ out = out "AREG_DE"
} else if (match(a, /^IX/)) {
out = out "AREG_IX"
} else if (match(a, /^IY/)) {
out = out "AREG_IY"
+ } else if (match(a, /^AF'/)) {
+ out = out "AREG_AF_"
+ } else if (match(a, /^AF/)) {
+ out = out "AREG_AF"
+ } else if (match(a, /^A/)) {
+ out = out "AREG_A"
} else if (match(a, /^\(n\)/)) {
out = out "ADIRECT"
} else if (match(a, /^I/)) {
--- a/as/target/x80/proc.h
+++ b/as/target/x80/proc.h
@@ -43,6 +43,7 @@
AINDER_HL, /* (HL) */
AINDER_DE, /* (DE) */
AINDER_BC, /* (BC) */
+ AINDER_SP, /* (SP) */
};
extern int rclass(int reg);
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -224,11 +224,18 @@
IM imm8 2 0xed im Z80,R800
# Exchange, block transfer and search groups
+EX DE,HL 1 0xeb noargs Z80,R800
+EX AF,AF' 1 0x08 noargs Z80,R800
EXX none 1 0xd9 noargs Z80,R800
+EX (SP),HL 1 0xe3 noargs Z80,R800
+EX (SP),IX 2 0xdd,0xe3 noargs Z80,R800
+EX (SP),IY 2 0xfd,0xe3 noargs Z80,R800
+
LDI none 2 0xed,0xa0 noargs Z80,R800
LDIR none 2 0xed,0xb0 noargs Z80,R800
LDD none 2 0xed,0xa8 noargs Z80,R800
LDDR none 2 0xed,0xb8 noargs Z80,R800
+
CPI none 2 0xed,0xa1 noargs Z80,R800
CPIR none 2 0xed,0xb1 noargs Z80,R800
CPD none 2 0xed,0xa9 noargs Z80,R800
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -71,16 +71,28 @@
arg &= ~(AREP|AOPT);
switch (arg) {
case AINDER_HL:
+ arg = AREG_HL;
+ goto indirect;
+ case AINDER_DE:
+ arg = AREG_DE;
+ goto indirect;
+ case AINDER_BC:
+ arg = AREG_BC;
+ goto indirect;
+ case AINDER_SP:
+ arg = AREG_SP;
+ indirect:
if (np->addr != AINDIR)
return 0;
- if (np->left->sym->argtype != AREG_HL)
- return 0;
- break;
+ np = np->left;
case AREG_A:
case AREG_HL:
+ case AREG_DE:
case AREG_IY:
case AREG_IX:
case AREG_SP:
+ case AREG_AF:
+ case AREG_AF_:
if (np->addr != AREG || np->sym->argtype != arg)
return 0;
break;