Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/12/03 11:05
Read: times


 
#50546 - RE: OVERLAY in KEil C
Responding to: ???'s previous message
"Which is the best ?

a) access via poiner
Char = *Ptr;
b) access like string
Char = Buffer[BuffCounter];


Note that this has nothing to do with your subject line, "Overlay in Keil C". It's best to only ask one question in a post - otherwise the answers to the different questions will get very muddled!

Anyway,

As far as the 'C' programming language is concerned, they're entirely equivalent!

For the specific 8051 implementation, there is no simple answer - it depends too much on precisely what you're trying to do, and how you write your code!
eg careful use of DATA, IDADTA, PDATA, XDATA locations for your variables can make far more difference than the pointer/index choice.

If you're in a loop, you generally need to maintain both the pointer and a loop counter; whereas the array can use the loop counter directly as the index. The the difference is likely to be marginal.
If you really need to know, you will just have to try it and examine the generated assembler.

BTW: With loop counters, counting down to zero can be advantageous, as it can allow the compiler to use the DJNZ instruction.


List of 4 messages in thread
TopicAuthorDate
OVERLAY in KEil C            01/01/70 00:00      
   RE: OVERLAY in KEil C            01/01/70 00:00      
   RE: OVERLAY in KEil C            01/01/70 00:00      
      RE: Array vs Pointer            01/01/70 00:00      

Back to Subject List