gbdev / pandocs

The single, most comprehensive Game Boy technical reference.
https://gbdev.io/pandocs/
Creative Commons Zero v1.0 Universal
614 stars 92 forks source link

CPU Instruction Set Encodings #456

Closed Kenjugs closed 9 months ago

Kenjugs commented 1 year ago

Currently, it seems that many of the instructions are "generalized" to avoid the need to write individual instructions for each register. However, there are some encodings for instructions that just say "xx", which doesn't really help with decoding those instructions or even specifying what valid values would be for that specific instruction.

For example, the ld r, nn instruction says the encoding is xx nn. But valid values for "xx" in this case are 0x06, 0x16, 0x26, 0x0E, 0x1E, 0x2E, and 0x3E, which aren't really mentioned outside of the opcodes table which is buried in the References section.

I'm not sure what the best style for expanding on this would be, but as it is, the Encoding column seems to not be very useful unless it has the entire encoding already. Maybe a link to the opcodes table might be better served at the top of this page?

ISSOtm commented 1 year ago

IMO, the page should be removed entirely, since its information is already present in gbz80(7) and optables, with more adapted presentations to their respective use cases, while Pan Docs' pages are neither here nor there.

avivace commented 1 year ago

IMO, the page should be removed entirely, since its information is already present in gbz80(7) and optables, with more adapted presentations to their respective use cases, while Pan Docs' pages are neither here nor there.

I agree, maybe we could have Pan Docs "import" the table from the optables repository? But I'm not super sure about the layout..

ISSOtm commented 1 year ago

Alternatively, the "CPU core" section of gb-ctr looks really good.

iximeow commented 1 year ago

fwiw the optables reference seems the most dense - it certainly has all the information i've been looking for from the CPU Instruction Set page except that i've found it very helpful that the page in Pan Docs generalizes over trivial variants (no duplicate rows for ld b, b, ld b, c, ld b, d, ... when they're all Basically The Same).

so +1 for prominently linking to optables, but it's nice to have something more concise

ISSOtm commented 1 year ago

Reworking this into some kind of "instruction decoding" page would be more useful, then.

54UL commented 1 year ago

Dealing with the encoding column in the instruction set table is proving tough. Switching to a binary representation, plus adding a base opcode column like in technical guides, would really help. For the encoding column:

Suggested Format:

ld r, r'
__________
encoding: 0b01xxxyyy
base opcode: 0x40 (hex)

This change makes it easier to understand and matches common technical documentation style.

ISSOtm commented 1 year ago

That sounds like a good idea, though then I'd like to use the tables introduced by #334. (Any help reviewing that PR so it gets merged, and this gets worked on faster, would be immensely appreciated. :pray:)

ISSOtm commented 11 months ago

Screenshot of a render of PR #511

Here is a render of #511; please let me know what you think of it?