scc

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

commit 8bfbd408ed2835a39abe06c5ec47683d81c61419
parent 24dd38d4aa27c14c412633fef7a6a69f855559a7
Author: Antonio Niño Díaz <antonio_nd@outlook.com>
Date:   Sat, 26 May 2018 01:01:59 +0100

Fix syntax of jumps

'JP [HL]' and similar imply that the contents pointed by [HL] are read,
and that is the address where the CPU jumps to. This is not the case.
That syntax would mean that a byte is loaded from the address pointed by
HL, and a byte is not a valid address.

The actual behaviour is to move the value of HL to the PC, which means
that there is no indirection, and that the syntax should be 'JP HL'.

The same applies to 'JP [IX]' and 'JP [IY]'.

Diffstat:
Mas/target/x80/x80.dat | 6+++---
Mtests/as/execute/z80.s | 6+++---
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/as/target/x80/x80.dat b/as/target/x80/x80.dat @@ -358,9 +358,9 @@ JP imm16 3 0xc3 jp Z80,R800,GB80 JP cc,imm16 3 0xc2 jp Z80,R800,GB80 JR imm16 2 0x18 jr Z80,R800,GB80 JR ss,imm16 2 0x00 jr Z80,R800,GB80 -JP (HL) 1 0xe9 jp Z80,R800,GB80 -JP (IX) 2 0xdd,0xe9 jp Z80,R800 -JP (IY) 2 0xfd,0xe9 jp Z80,R800 +JP HL 1 0xe9 noargs Z80,R800,GB80 +JP IX 2 0xdd,0xe9 noargs Z80,R800 +JP IY 2 0xfd,0xe9 noargs Z80,R800 DJNZ imm16 2 0x10 jr Z80,R800 # Call and return group diff --git a/tests/as/execute/z80.s b/tests/as/execute/z80.s @@ -757,7 +757,7 @@ L6: JR C,$L6 / 38 02 POP IX / DD E1 EX (SP),IX / DD E3 PUSH IX / DD E5 - JP (IX) / DD E9 + JP IX / DD E9 LD SP,IX / DD F9 SBC A,$64 / DE 40 RST $24 / DF @@ -770,7 +770,7 @@ L6: JR C,$L6 / 38 02 AND A,$16 / E6 10 RST $32 / E7 RET PE / E8 - JP (HL) / E9 + JP HL / E9 JP PE,$16384 / EA 00 40 EX DE,HL / EB CALL PE,$16384 / EC 00 40 @@ -1130,7 +1130,7 @@ L6: JR C,$L6 / 38 02 POP IY / FD E1 EX (SP),IY / FD E3 PUSH IY / FD E5 - JP (IY) / FD E9 + JP IY / FD E9 LD SP,IY / FD F9 CP A,$32 / FE 20 RST $56 / FF