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

question on memory models

Hi

I have following test code:


#include "C8051F300.h"

void print(char code *inData){
         inData = inData;
}

static void printVersion(void){
        char code s[]  = "This is a test.";
        print(s);

}

void main (void){
printVersion();

}

If I use the memory model "Small: variables in data" this little piece of code works just fine. If I change the memory model to "Large: variables in xdata" it does not work. In printVersion() 's' points exactly on the 'T' in the CODE memory but if I call "print()" the pointer inData is pointing somewhere else in the CODE memory space. Why is that?

Hans

Parents
  • In printVersion() 's' points exactly on the 'T' in the CODE memory but if I call "print()" the pointer inData is pointing somewhere else in the CODE memory space. Why is that?

    Probably the compiler hasn't generated any code for inData. If you want to force it to do so declare inData as volatile.

Reply
  • In printVersion() 's' points exactly on the 'T' in the CODE memory but if I call "print()" the pointer inData is pointing somewhere else in the CODE memory space. Why is that?

    Probably the compiler hasn't generated any code for inData. If you want to force it to do so declare inData as volatile.

Children
No data