ref: e00bb1e5ac3291539ba6df03248290496edb9814
parent: 4c09eaec1c1f81e175b6e8b6266e8a2c9aa7afaa
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Dec 17 05:10:05 EST 2017
[as-z80] Add SP 16 bit load instructions These instructions allows to load a 16 bit value in SP.
--- a/as/target/gen.awk
+++ b/as/target/gen.awk
@@ -87,6 +87,8 @@
out = out "AREG_A"
} else if (match(a, /^indir_HL/)) {
out = out "AINDER_HL"
+ } else if (match(a, /^regSP/)) {
+ out = out "AREG_SP"
} else if (match(a, /^regHL/)) {
out = out "AREG_HL"
} else if (match(a, /^regIX/)) {
--- a/as/target/x80/ins.c
+++ b/as/target/x80/ins.c
@@ -212,7 +212,7 @@
val = par2->sym->value;
buf[n-1] = val >> 8;
buf[n-2] = val;
- buf[n-3] |= reg2int(par1->sym->argtype) << 3;
+ buf[n-3] |= reg2int(par1->sym->argtype) << 4;
emit(buf, n);
}
--- a/as/target/x80/x80.dat
+++ b/as/target/x80/x80.dat
@@ -87,6 +87,7 @@
LD indir_HL,reg_r 1 0x70 xx_r8 Z80,R800,GB80
LD reg_r,indir_HL 1 0x46 r8_xx Z80,R800,GB80
+# 16 bit load group
LD reg_dd,imm16 3 0x01 r16_imm16 Z80,R800,GB80
LD regIX,imm16 4 0xdd,0x21 imm16 Z80,R800
LD regIY,imm16 4 0xfd,0x21 imm16 Z80,R800
@@ -100,6 +101,10 @@
LD dir,reg_dd 4 0xdd,0x42 r16_dir Z80,R800
LD dir,regIX 4 0xdd,0x22 dir Z80,R800
LD dir,regIY 4 0xfd,0x22 dir Z80,R800
+
+LD regSP,regHL 1 0xf9 noargs Z80,R800,GB80
+LD regSP,regIX 2 0xdd,0xf9 noargs Z80,R800
+LD regSP,regIY 2 0xfd,0xf9 noargs Z80,R800
ADD regA,reg_r 1 0x80 xx_r8 Z80,R800,GB80
ADD regA,reg_p 2 0xdd,0x80 xx_r8 Z80,R800
--- a/as/target/z80/proc.c
+++ b/as/target/z80/proc.c
@@ -80,6 +80,7 @@
case AREG_HL:
case AREG_IY:
case AREG_IX:
+ case AREG_SP:
if (np->addr != AREG || np->sym->argtype != arg)
return 0;
break;