Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modern 8XY6 and 8XYE not necessarily correct #13

Open
MolotovCherry opened this issue Oct 2, 2023 · 0 comments
Open

Modern 8XY6 and 8XYE not necessarily correct #13

MolotovCherry opened this issue Oct 2, 2023 · 0 comments

Comments

@MolotovCherry
Copy link

MolotovCherry commented Oct 2, 2023

It might be worth making a note in the book about instructions 8XY6 and 8XYE.

It turns out the these instruction's meaning somehow got changed with time. Since the idea about the implementation of these is so widespread these days, this leaves the emulator implementor with a dilemma, support the original way (for original ROMs), or support the new way?

Generally it's likely a good idea to support both ways, seeing as its possible one may run into older ROMs which rely on the original correct behavior.

https://web.archive.org/web/20170213223712/http://laurencescotford.co.uk/?p=266

Only the first five of these instructions were officially documented by RCA. 8XY6, 8XY7 and 8XYE are all undocumented. Unfortunately an erroneous assumption about 8XY6 and 8XYE, the two shift instructions, seems to have crept into Chip-8 lore at some point. Most recent documentation on Chip-8 suggests these instructions shift VX rather than VY. Some documents suggest that the correct format for them is 8X06 and 8X0E. However, when these instructions are run on the original Chip-8 interpreter, they will shift VY not VX! An instruction of the form 8X06 or 8X0E will not work as expected. The programmer would be expecting this to shift VX and store the result back in VX. What would actually happen is that V0 would be shifted and the result stored back in VX. This leaves the programmer of a contemporary interpreter with a bit of a dilemma. Do you make these instructions function as they would have done in the original interpreter or do you make them function in accordance with the erroneous assumption? Or do you offer both modes and a way to switch between them? This post documents the way the instructions worked in the original Chip-8 interpreter.

Edit: Also, here's a chip8 test suite. It revealed a few problems with the book's implementation, particularly this one
https://github.com/Timendus/chip8-test-suite

@MolotovCherry MolotovCherry changed the title 8XY6 adn 8XYE Modern 8XY6 and 8XYE not necessarily correct Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant