I'm working on a personal project, an emulator. Let's say there are two registers H and L, each one byte long. So we could write to H or L with one byte. However, some instructions require that you write two bytes to H and L, or HL. First byte goes to H, second goes to L. There are some things that are difficult to implement based on how mine is implemented.
So my idea was to have HL be a single two-byte word. However, there would still exist H and L variables, which share the same address as the first byte of HL and the second byte of HL respectively.
I could do pointers, but I really don't want to declare all my registers as pointers.
One thing I was thinking was a union, like this:
union {
BYTE H;
WORD HL;
}
But then I wouldn't know how to put L in there as a second byte.
Any ideas?