Where is a string stored

General discussion on mikroBasic PRO for 8051.
Post Reply
Author
Message
RAWWAR
Posts: 9
Joined: 21 Oct 2016 23:09

Where is a string stored

#1 Post by RAWWAR » 22 Oct 2016 10:32

Just started with mikrobasic for the 8051. I had trouble selecting the right processor.
I use the 80c552, but this one is not in the list. So I choosed several types, but the T89C51CC02 seems to work.
Not exactly the same but OK, more or less....
I choose large memory model, expecting stringvariables automatically to be stored in external memory. So says the manual.
However, with another monitor program I could not find these strings there. However, I DID find them somewhere in internal memory.
Only explicitely defining these variables to be stored in ext mem.with: "dim A as string[10] xdata",
I forced them to be stored in ext mem.
What am I doing wrong ? Why are these variables not stored in EXT mem. when selecting large model ?
Has it something to do with the processor choiche ? Or is it a bug in the compiler ? something else ?
I hope you can help me.
Regards, Rob

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: Where is a string stored

#2 Post by lana.arsic » 25 Oct 2016 11:11

Hi Rob,

Welcome to the MikroE forum.

I'm sorry, it is mistake in the documentation, you should always use
keyword xdata when you want to save data in external memory.

Best regards,
Lana

RAWWAR
Posts: 9
Joined: 21 Oct 2016 23:09

Re: Where is a string stored

#3 Post by RAWWAR » 25 Oct 2016 22:16

Hi,
using the keyword "xdata" is ofcourse the easiest solution. However, not only string variables
are NOT stored in ext. mem despite using the "large model" option, also byte, word and other variables
are not. So they all need the keyword xdata. To me, that sounds not so much like an error in the
manual, it sounds more like a bug in the compiler. The option "large model" seems not to work at all
And it is getting worse.
take this example assuming the usart has been initialized:
dim S as string [10]
S="12345678"
UART1_Write_Text(S)
This works fine. However:

dim S as string [10] xdata
S="12345678"
UART1_Write_Text(S)
This example does not work. The text IS stored in ext mem. But NOT sent to the serial link

What am I doing wrong here ?
Regards, Rob

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: Where is a string stored

#4 Post by lana.arsic » 27 Oct 2016 16:02

Hi Rob,

When you open mlk file (Ctrl + Alt + M),
can you try to uncomment node <XDATA>?

Also, you can try to access xdata memory using pointers,
please take a look at these links:

http://forum.mikroe.com/viewtopic.php?p=127309#p127309

http://forum.mikroe.com/viewtopic.php?f ... 45#p133514

Best regards,
Lana

RAWWAR
Posts: 9
Joined: 21 Oct 2016 23:09

Re: Where is a string stored

#5 Post by RAWWAR » 30 Oct 2016 19:30

Lana,
I tried your suggestion to uncomment node <xdata> in the .mlk file.
This makes no difference. I did not try to use pointers. Basically I think that,
by using "xdata" the compiler should know where to find the string: in ext mem.
So, when it does not, am I wrong when I say that this is an error in the compiler ?
Regards,
Rob

Post Reply

Return to “mikroBasic PRO for 8051 General”