ref: 52e4bfb01814fc18500b2030aa2529192f3bdf60
parent: 609f926b42931b6ed5b7f778ad7af519488ac20f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Dec 19 04:45:59 EST 2017
[as-z80] Create r16_xx() and xx_r16() Sometimes we have to use in the instruction the 1st parameter but oher times we need the second. This patch adds both functions so every instruction can select the instruction format needed.
--- a/as/target/x80/ins.c
+++ b/as/target/x80/ins.c
@@ -275,17 +275,23 @@
}
void
-r16(Op *op, Node **args)
+r16_xx(Op *op, Node **args)
{
- Node *par1, *par2;
+ Node *par;
unsigned char buf[4];
int n = op->size;
- par1 = args[0];
-
+ par = args[0];
memcpy(buf, op->bytes, n);
- buf[n-1] |= reg2int(par1->sym->argtype) << 4;
+ buf[n-1] |= reg2int(par->sym->argtype) << 4;
emit(buf, n);
+}
+
+void
+xx_r16(Op *op, Node **args)
+{
+ args[0] = args[1];
+ r16_xx(op, args);
}
void
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -98,10 +98,10 @@
LD SP,IX 2 0xdd,0xf9 noargs Z80,R800
LD SP,IY 2 0xfd,0xf9 noargs Z80,R800
-PUSH qq 1 0xc5 r16 Z80,R800,GB80
+PUSH qq 1 0xc5 r16_xx Z80,R800,GB80
PUSH IX 2 0xdd,0xe5 noargs Z80,R800
PUSH IY 2 0xdd,0xe5 noargs Z80,R800
-POP qq 1 0xc1 r16 Z80,R800,GB80
+POP qq 1 0xc1 r16_xx Z80,R800,GB80
POP IX 2 0xdd,0xe1 noargs Z80,R800
POP IY 2 0xfd,0xe1 noargs Z80,R800
@@ -185,17 +185,17 @@
DEC (IY+n) 3 0xfd,0x35 idx Z80,R800
# 16 bit ALU group
-ADD HL,dd 1 0x09 r16 Z80,R800,GB80
-ADC HL,dd 2 0xed,0x4a r16 Z80,R800
-SBC HL,dd 2 0xed,0x42 r16 Z80,R800
-ADD IX,pp 2 0xdd,0x09 r16 Z80,R800
-ADD IY,rr 2 0xfd,0x09 r16 Z80,R800
+ADD HL,dd 1 0x09 xx_r16 Z80,R800,GB80
+ADC HL,dd 2 0xed,0x4a xx_r16 Z80,R800
+SBC HL,dd 2 0xed,0x42 xx_r16 Z80,R800
+ADD IX,pp 2 0xdd,0x09 xx_r16 Z80,R800
+ADD IY,rr 2 0xfd,0x09 xx_r16 Z80,R800
-INC dd 1 0x03 r16 Z80,R800,GB80
+INC dd 1 0x03 r16_xx Z80,R800,GB80
INC IX 2 0xdd,0x23 noargs Z80,R800
INC IY 2 0xfd,0x23 noargs Z80,R800
-DEC dd 1 0x0b r16 Z80,R800,GB80
+DEC dd 1 0x0b r16_xx Z80,R800,GB80
DEC IX 2 0xdd,0x2b noargs Z80,R800
DEC IY 2 0xfd,0x2b noargs Z80,R800