Chuck(G)
25k Member
The right way to do this would be to use a union:
On the portability issue, you may run into problems if you try to run your emulator on a big endian CPU, such as a 68000, since the ordering of high- and low-order bytes in a word is the reverse of the x86 family.
Code:
union _bytewordregs_
{
uint16_t wordregs[8];
uint8_t byteregs[16];
} regs;
regs.wordregs[0] =1; // assign value of 1 to a word register
regs.byteregs[2] = 2; // assign value of 2 to a byte register
On the portability issue, you may run into problems if you try to run your emulator on a big endian CPU, such as a 68000, since the ordering of high- and low-order bytes in a word is the reverse of the x86 family.