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?
unsigned int huge *const Array[1] ...
This defines an array having one element.
ReadAdd = Array[1];
This reads the second element of the array - remember that 'C' array indexes are zero based; ie, the first element has index zero!
It is writing error.Sorry In actual code it is
ReadAdd = Array[0];
Never re-type stuff manually to post it; always use copy-and-paste.
How do we know that the rest of your post doesn't also have typos - or that you've actually typed your post correctly when a typo exists in the real code!
Re-post the real code, using copy-and-paste.