scc

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

commit c8f7dc5a930f840f547f04f1f24b354b805ae74b
parent 6c5b9c972895b084424711dc3e0eab4b34c23fcc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 19 Dec 2017 09:45:59 +0000

[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.

Diffstat:
Mas/target/x80/ins.c | 16+++++++++++-----
Mas/target/x80/x80.dat | 18+++++++++---------
2 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/as/target/x80/ins.c b/as/target/x80/ins.c @@ -275,20 +275,26 @@ r8_xx(Op *op, Node **args) } 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 r16_imm16(Op *op, Node **args) { Node *par1, *par2; diff --git a/as/target/x80/x80.dat b/as/target/x80/x80.dat @@ -98,10 +98,10 @@ LD SP,HL 1 0xf9 noargs Z80,R800,GB80 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 (IX+n) 3 0xdd,0x35 idx Z80,R800 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