gbdev / gb-opcodes

https://gbdev.io/gb-opcodes/optables/
Creative Commons Zero v1.0 Universal
24 stars 10 forks source link

0xE9 should be JP (HL) not JP HL #17

Closed pomann closed 3 years ago

pomann commented 3 years ago

Based on z80 documentation and many other sites like https://clrhome.org/table/ and http://imrannazar.com/GameBoy-Z80-Opcode-Map the instruction 0xE9 should be JP (HL), the immediate var should therefore be set to false for this instruction

Rangi42 commented 3 years ago

This conflicts with issue #1: the modern rgbasm syntax is jp hl. ([hl] implies dereferencing its contents, which is not the case.)

pomann commented 3 years ago

(HL) or [HL] isn't the point of this issue. 0xE9 shouldn't jump to the location stored in register HL, it should jump to the location pointed by the memory at HL

Rangi42 commented 3 years ago

That is not the case: ld hl, Function / jp hl will jump to Function. And regardless, the current rgbasm syntax for it is jp hl, so according to #1 that should be used.

basxto commented 3 years ago

0xE9 shouldn't jump to the location stored in register HL, it should jump to the location pointed by the memory at HL

Take a closer look at https://clrhome.org/table/, that's not even the case on z80:

Loads the value of hl into pc

Though somebody argued that jp hl would mean jumping to the register.

ISSOtm commented 3 years ago
ASM mnemonic Pseudo-C
ld hl, 0 hl = 0;
ld [hl], 0 *hl = 0;
ld a, c a = c;
ld a, [hl] a = *hl;
ld pc, $1234
(jp $1234)
pc = 0x1234;
jp hl pc = hl;
jp [hl] pc = *hl;

@max-m actually originally implemented this instruction as pc = *hl in his emulator, and I believe that fixing this was one of the reasons why he begun this project in the first place.

It's pretty widely agreed upon that jp hl is more consistent; thus, closing.