meganesu / generate-gb-opcodes

A helper project to dynamically generate the opcodes for each Game Boy CPU instruction mnemonic
https://meganesu.github.io/generate-gb-opcodes/
42 stars 9 forks source link

Misleading opcode mnemonic: 0xE9 JP,(HL) #26

Closed chrisguiney closed 3 years ago

chrisguiney commented 4 years ago

Hi there, thanks for making this project! It's been really handy while I'm trying to implement my own emulator!

One thing that's tripped me up a bit was the 0xE9 instruction, which is listed as JP,(HL). In every other case, the notation (HL) implies that the address in register HL should be dereferenced. However, for 0xE9, that is not the case.

The description is correct, that it should be the "contents of register HL", and not "the contents of memory specified by register HL" that is loaded into the program counter.

The pasterizer table also lists it as JP (HL), but the Gameboy Complete Technical Reference pdf agrees that this notation is misleading, having a note stating:

In some documentation this instruction is written as JP [HL]. This is very misleading, since brackets are usually used to indicate a memory read, and this instruction simply copies the value of HL to PC.

I'm not a javascript person, but I'd be happy to take a little bit to contribute the change, if it's something you'd be interested in incorporating.

I believe the change would mostly be just an adjustment to the string mnemonic here: https://github.com/meganesu/generate-gb-opcodes/blob/master/src/generators/jump/JP_memory_at_HL.js#L8

I'm not sure if you'd want the file name changed as well, JP_memory_at_HL.js also sounds like it implies the dereference of register HL

meganesu commented 4 years ago

Hey there, thanks for reaching out. (And for using this to build your own emulator - so cool!)

Great catch! I think you're right, the change should just be updating that string and the filename. If you're up for making that change, feel free to open up a PR and then tag me on it, and I'll take a look and get it merged in.

Thanks again!

meganesu commented 3 years ago

Just made the fix for this. Thanks again for pointing it out!