Hi Folks, I do have some trouble with huge memory model and xhuge structures. I wonder, how is it with structures of type xhuge, which constists of a lot of sub- structure types: struct big { char amem[65000]; char bmem[65000]; char cmem[65000]; } xhuge st; I do have functions get passed pointers to the substructures like this: void dothat(char * pcStr) {} I call the function like this: dothat(&st.amem[8]); Because of some strange errors in my system I wonder whether I should call the function with this cast: dothat((char*)&st.amem[8]); do get the xhuge type of struct st out of the way. In common: how is it with assignments of a variable of type xhuge to one of type huge? I do this often in my code and the compiler gives no warning when doing that. A little bit confused. Mike
Hi Folks, the Situation is like this: Keil doc says about huge pointers: 32-bit pointer; 16-bit address calculation supports objects of up to 64 KB. huge is the optimum memory type on the C167/C165 CPU for accessing the 16MB address space. Thats half of the truth. "16-bit address calculation" means: Only the 16 least significant bits of the pointer are calculated. So the pointer can only be used with objects up to 64 KB size when the object was placed by the linker to the start of a 64 KB segment. Objects, which are manualy placed at fixed adresses, for instance in a 1 MB external flash, can be at a boundary between two 64 KB segments. So the access to the end of the structure does access in reality to the begin of the first segment. Keep in mind: huge pointer objects must not cross a 64 KB segment border. Mike
I think this describes it correct: http://www.keil.com/support/man/docs/c166/c166_le_huge.htm
32-bit pointer; 16-bit address calculation supports objects of up to 64 KB. Well, the struct in your examples is 195000 bytes large, which is clearly larger than 64KiB, and thus makes it rather less than surprising that this doesn't work. If there's any valid complaint here, it's that the compiler seems to not have complained immediately when it saw that struct definition.
32-bit pointer; 16-bit address calculation supports objects of up to 64 KB. correction (as far as i know from the '51) supports objects within a 64 KB page. there is no "page rollover" Erik