I'm writing a chip-8 interpreter. I have my mock hardware, instruction execution, UI, etc.. all good to go, so I started actually loading and executing real chip8 programs.
In the zip archive I found on the web there are several games in there that seem to have illegal jump calls.
From CowGod's specification it says:
All instructions are 2 bytes long and are stored most-significant-byte first. In memory, the first byte of each instruction should be located at an even addresses. If a program includes sprite data, it should be padded so any instructions following it will be properly situated in RAM.
This seems very insistent that it's impossible to have an instruction that executes from an odd memory address, and therefore I coded my interpreter to fail is we end up trying to go to an odd memory address (mostly because I assume that I"m reading something wrong if this occurred).
However two of the games in my pack (INVADERS
, and BLITZ
) seem to immediately start with a jump call (they signed the roms with their names in ascii so the first instruction is a call to jump after the signature.
The former starts with 0x12 0x25
and the second starts with 0x12 0x17
. Both of these point to jump calls to odd addresses (0x225 and 0x217 respectively) which then fail in my emulator. Looking at those addresses they are pointing to they look like they contain valid instructions (byte 25 in the former contains 0x6000 (LD V0, 00
) and byte 17 in the latter points to 0xA341 (LD I, 341
).
Am I just interpreting the specifications too strictly and it's expected that real applications won't be padded and can be run on odd addresses?