Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Storing a string from code memory to IDATA memory in C (8051)

Status
Not open for further replies.

adrianvon

Member
I have the following code of line which stores the string TesT in the code memory of the 8051 micro-controller.

char code *text_to_compare ="TesT";

How can I store the same string in the IDATA memory starting from 92Hex?

Any kind of help would be highly appreciated.
Thanks in advance.
 
Which compiler??? SDCC uses the __at to specify an absolute address.. However!! char *text_to_compare = "Test"; will store the string in IDATA..

Some compilers use @ to absolute address....#

I don't think using a pointer will work..

char _at (0x92) text_to_compare[] = {"Test"};
char *pointer_to_text = &text_to_compare[0];

Now pointer_to_text is what you need....
 
Thanks for the reply. The thing is that i need it to start from 92hex. char _at (0x92) text_to_compare[] = {"Test"}; did not work. I am using the C51 compiler.
 
C51 documentation said:
struct link {
struct link idata *next;
char code *test;
};

struct link idata list _at_ 0x40; /* list at idata 0x40 */
char xdata text[256] _at_ 0xE000; /* array at xdata 0xE000 */
int xdata i1 _at_ 0x8000; /* int at xdata 0x8000 */
char far ftext[256] _at_ 0x02E000; /* array at xdata 0x03E000 */

void main ( void ) {
link.next = (void *) 0;
i1 = 0x1234;
text [0] = 'a';
ftext[0] = 'f';
}

The syntax is slightly different for c51... The documentation is very good
https://www.keil.com/support/man/docs/c51/c51_intro.htm
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top