I'm trying to write a function that takes a 32bit address and a data to store at this address.
I'm watning to take the 32 bit memory address eg 0x12345678 and split it
into 4 x 2 bytes
12, 34, 56, 78
then each of the 4 entries is at most a 256 entry array.eg
FF, FF, FF, FF
So in this example, 0x12 points to 0x34 in the second array, which
points to 0x56 in the third array, which finally points to 0x78 in the
This last array holds the actual data.
After successfully doing 0x12345678, say I might get a read for
0x1234AABB. So, the first and second pointers already exist, but I then have to create and write to dynamically created arrays.
The arrays need to have all entries set to NULL so that i know whether to follow the pointers to overwrite a previously entered value or create new arrays and pointers.
It all looks good and simple in the pseudo code I've written up but I'm having trouble coding it.
I'm currently trying to deal with the first entry case, ie all array elements are NULL, but I'm getting confused with the pointers and creation of new arrays.
void cpu::store(unsigned int mem_add,unsigned int mem_val)
int first = (mem_address&4278190080)>>24;
int second = (mem_address&16711680)>>16;
int third = (mem_address&65280)>>8;
int fourth= (mem_address&255);
int** A2=new int*;
int** A3=new int*;
unsigned int* A4=new unsigned int;
A1 has been declared as
int* A1 ;
Any tips on where I'm going wrong?