scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 5617bd05cbe804de5fcd9caed04088ca219becf5
parent d5491b4cf13745104b520ca6ea4a7865bcaa473b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 27 Dec 2017 15:32:22 +0000

[as-z80] Add IM instructions

Diffstat:
Mas/target/x80/ins.c | 12++++++++++--
Mas/target/x80/x80.dat | 2+-
Mas/target/z80/test.s | 11+++--------
3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/as/target/x80/ins.c b/as/target/x80/ins.c @@ -381,8 +381,16 @@ idx(Op *op, Node **args) void im(Op *op, Node **args) { - /* TODO */ - abort(); + unsigned val = args[0]->sym->value; + unsigned char buf[4]; + int n = op->size; + + if (val > 0) + ++val; + + memcpy(buf, op->bytes, n); + buf[n-1] |= val << 3; + emit(buf, n); } void diff --git a/as/target/x80/x80.dat b/as/target/x80/x80.dat @@ -209,7 +209,7 @@ NOP none 1 0x00 noargs Z80,R800,GB80 HALT none 1 0x76 noargs Z80,R800,GB80 DI none 1 0xf3 noargs Z80,R800,GB80 EI none 1 0xfb noargs Z80,R800,GB80 -IM imm8 2 0xed im Z80,R800 +IM imm8 2 0xed,0x46 im Z80,R800 # Exchange, block transfer and search groups EX DE,HL 1 0xeb noargs Z80,R800 diff --git a/as/target/z80/test.s b/as/target/z80/test.s @@ -780,47 +780,42 @@ LD (32768),%BC / ED 43 00 80 NEG / ED 44 RETN / ED 45 -/ED46 IM 0 + IM 0 / ED 46 LD %I,%A / ED 47 /ED48 IN C, (C) /ED49 OUT (C), C ADC %HL,%BC / ED 4A LD %BC,(16384) / ED 4B 00 40 RETI / ED 4D -/ED4E IM 0/1* LD %R,%A / ED 4F /ED50 IN D, (C) /ED51 OUT (C), D SBC %HL,%DE / ED 52 LD (32768),%DE / ED 53 00 80 -/ED56 IM 1 + IM 1 / ED 56 LD %A,%I / ED 57 /ED58 IN E, (C) /ED59 OUT (C), E ADC %HL,%DE / ED 5A LD %DE,(16384) / ED 5B 00 40 -/ED5E IM 2 + IM 2 / ED 5E LD %A,%R / ED 5F /ED60 IN H, (C) /ED61 OUT (C), H SBC %HL,%HL / ED 62 -/ED66 IM 0* RRD / ED 67 /ED68 IN L, (C) /ED69 OUT (C), L ADC %HL,%HL / ED 6A -/ED6E IM 0/1* RLD / ED 6F /ED70 IN (C)* / IN F, (C)* /ED71 OUT (C), 0* SBC %HL,%SP / ED 72 LD (16384),%SP / ED 73 00 40 -/ED76 IM 1* /ED78 IN A, (C) /ED79 OUT (C), A ADC %HL,%SP / ED 7A LD %SP,(32768) / ED 7B 00 80 -/ED7E IM 2* LDI / ED A0 CPI / ED A1 INI / ED A2