We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I have the following line of code which I need to store in the IDATA memory starting from 92H.
char code *text_to_compare = "Tesing";
How can I achieve this please?
Thanks for the reply. I need to move the character array starting from 92H.
Can you create a pointer and then assign the address of the pointer the memory location 92H.
Then just assign the character data one character at a time.
char * ptr;
ptr = 0x92;
*ptr = 'h'; ptr++;
*ptr = 'e'; ptr++;
*ptr = 'l'; ptr++;
*ptr = '0'; ptr++;
I think this should work.
Again, why this fixation with the absolute address?
Really, that's not the way to be thinking in 'C'!
www.catb.org/.../smart-questions.html
You would have to make sure that it's a specific IDATA pointer
http://www.keil.com/support/man/docs/c51/c51_le_memtypes.htm
http://www.keil.com/support/man/docs/c51/c51_le_ptrs.htm
But before an idata char pointer is used to write data into IDATA RAM, you need to make sure that you "own" that address range within the IDATA RAM.
So it's best to stop thinking about absolute addresses and just have the compiler create a variable (potentially initialized) of type character array within IDATA. And the Keil manuals clearly indicates how to create a variable within IDATA or any other memory region. Then a pointer of type "pointing to IDATA" (note the difference from a pointer stored in IDATA) can access this character array.
While the IDATA memory region is specific to the 8051 processor architecture, there is a lot of similarity with pointers and the "const" keyword. You can have a pointer to const data. I.e. you can't modify the data through the pointer. Or you can have a const pointer, i.e. you can't change the value of the pointer. And similarly, you can have a pointer to IDATA. Or you can have a pointer stored in IDATA.
So in the end, there are two separate things to read up on. One is the C language standard related to additional attributes for pointer types. And one is the Keil manual related to all the C51-specific keywords for specifying size of pointer or memory region.
It is very hard (impossible?) to work efficiently with the 8051 architecture without having read up on these concepts.
And you can have a pointer which is both stored in and points to IDATA.
Just like you can also have a const pointer to const data.