The reason for this is so if you change an 8 bit register or a 16 bit register they will both update. The problem is I get warnings
cpu.c: In function ‘cpu_exec’:
cpu.c:18: warning: assignment from incompatible pointer type
cpu.c:19: warning: assignment from incompatible pointer type
cpu.c:21: warning: assignment makes pointer from integer without a cast
cpu.c:22: warning: assignment makes pointer from integer without a cast
x86Emu compiled!
Also my code is slightly wrong how can I change the 16 bit integer by char without changing its datatype
& operator doesn't return int *, so you need to cast it to char *. But why are you trying to conver one char pointer on index 4 to int pointer and then you skip continuing 3 pointers?
computertrick wrote:Hi i am quite new to C and I have an issue with it.
I am developing a x86 emulator here (snipped)
For learning purpose, I truly suggest you do a calculator instead. As a side note, you will get more help with general programming issue on forum like stackoverflow.
computertrick wrote:The reason for this is so if you change an 8 bit register or a 16 bit register they will both update.
reg_8[x] isn't pointing anywhere.
®_8[x] returns the address of a pointer to unsigned char (unsigned char **) which is assigned to reg_16[x] which is a pointer to unsigned int.