I'm attempting to write a Gameboy emulator in C, and am currently in the process of deciding how to implement the following behavior:
- Two 8-bit registers can be combined and treated as a single 16-bit register
- changing the value of one of the 8-bit registers in the pairing should change the value of the combined register
For example, registers A and F, which are 8-bit registers, can be used jointly as the 16-bit register AF. However when the contents of registers A and F change, these changes should be reflected in subsequent referrals to register AF.
If I implement register AF as a uint16_t*
, can I store the contents of registers A and F as uint8_t*
's pointing to the first and second byte of register AF respectively? If not, any other suggestions would be appreciated :)
EDIT: Just to clarify, this is a very similar architecture to the Z80