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

How to tread the different memory spaces?

Hello,

Suppose you declare an array in a certain memory space, for instance

unsigned char xdata SendBuffer[ 20 ];
.
Is it allowed to just prototype the callees with
byte *SendBuffer
and dereference it as
TempVal = *( SendBuffer + Counter );
?
Or should it be casted to the correct memory space, like
TempValue = *( (unsigned char xdata*)SendBuffer + Counter );
?
In other words, is the Keil compiler 'clever' enough to see the memory space in the called functions and do the correct memory space conversion itself?
That means, if I declare my SendBuffer in
idata
, will it also work correctly with the same prototype for the callees?

I've run the PC simulator and it seems it works fine, but I just want confirmation.

Rgds,

Geert

Parents
  • "you'll get more efficient code by using specific pointers"

    That depends upon your definition of "efficient"

    If you use Generic Pointers, the compiler will use Library calls to handle them; if you use memory-specific pointers, the compiler can put the code in-line.

    Thus, using memory-specific pointers can actually increase your code size - although execution speed should be improved.

    As I said, it all depends on what you mean by, "efficient"

Reply
  • "you'll get more efficient code by using specific pointers"

    That depends upon your definition of "efficient"

    If you use Generic Pointers, the compiler will use Library calls to handle them; if you use memory-specific pointers, the compiler can put the code in-line.

    Thus, using memory-specific pointers can actually increase your code size - although execution speed should be improved.

    As I said, it all depends on what you mean by, "efficient"

Children