This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Reading memory address

I have following code to read the variable address by using huge pointer.

unsigned int Regular_Shutdown;

unsigned int huge *const Array[1] = {(unsigned char huge)&Regular_Shutdown};

unsigned int huge* ReadAdd;
Read_Address
{
 ReadAdd = Array[1];
 Store_Off = ReadAdd;
 Store_Seg = (((unsigned long)ReadAdd >>16) & 0xffff);
};

This method shows me address as Store_Off= B602h, Store_Seg=B602h which is wrong address. now if I use following method

unsigned int Regular_Shutdown;
Read_Address
{
 ReadAdd = (unsigned int huge*)&Regular_Shutdown;
 Store_Off = ReadAdd;
 Store_Seg = (((unsigned long)ReadAdd >>16) & 0xffff);

};

This method shows me address as Store_Off= F602h,Store_Seg=000h which is correct address. Can any body explain me why it happens like this?

0