Discussion in "8051 Discussion Forum" started by    scorcho    Oct 9, 2007.
Tue Oct 09 2007, 12:56 AM

I'm wondering what the difference is when I declare a variable with one of the modifiers, eg

1. BYTE xdata temp;
2. BYTE idata temp;
3. BYTE data temp;
4. BYTE temp;

I notice that some data types aren't allowed to be placed in xdata, for example BOOL. I get an error telling me it's in a different/illegal memory space.

I also notice that there are code size differences. When I put variables in xdata/idata(1/2), my code seems to be larger by a few bytes than if I were to put them in data or not specify them(3/4). I'm wondering if there are any functional differences. I'm trying to keep my code as small as possible now so should I not put anything in xdata/idata? What are the guidelines?

btw I'm programming in C and using Keil uVision2 as my IDE.

Tue Oct 09 2007, 07:08 AM
Xdata doesn't allow BOOL the reason is external RAM is byte oriented and is not accessible bit wise.

Regarding the reason of increase in code space when u put variables in xdata/idata is that when you declare a variable and initialize it... the whole initialization code as well as creating a data space for that variable is generated as a code.
Like if you declare something like...
BYTE idata a[10] = "test";
when you compile this, the compiler generate a code which includes the code for creating a variable of 10 bytes in idata and then initialize it with string "test" So this increase your code.. there is actually nothing can be done regarding this..
The only optimization tip i can give you is.. if you have constant strings, which are not going to change throughout the program then its better to store them in the code space instead of idata/xdata.. e.g.

BYTE code string[]="Welcome to Rickey's World";

this will take no space in RAM and will save the initialization part and ultimately the code space..
Tue Oct 09 2007, 01:39 PM
u can also refer c51.pdf for more ... of the topic...

Get Social


Powered by e107 Forum System


Tue May 19 2020, 06:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 03:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 09:39 AM
Sir kindly send the code file i2c for 8051
Fri Mar 13 2020, 06:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 08:55 AM
how can get hadwere of this project
Sat Mar 07 2020, 12:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 11:58 AM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 05:12 AM
Pearl Olin
Wed Jan 22 2020, 01:16 PM
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 02:08 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me



Thu May 21 2020, 08:44 AM
Wed May 20 2020, 09:28 PM
Wed May 20 2020, 03:05 PM
Wed May 20 2020, 07:52 AM
Wed May 20 2020, 03:15 AM
Tue May 19 2020, 06:08 PM
Tue May 19 2020, 02:22 PM
Mon May 18 2020, 09:50 PM


Guests: 78, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 01:37 AM

Members: 38211
Newest member: Davidthils
Forum Activity
xrxx Avatar
Posted By xrxx
Thu Apr 30 2020, 06:59 AM
BCD MULTIPLICATIONAssume that you have to 2 BCD nu...
liqian Avatar
Posted By liqian
Tue Apr 28 2020, 05:26 AM
I happened to see your post and I got many useful ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Apr 28 2020, 04:21 AM
The code is hard to read.Please zip it and attach ...
rogermado Avatar
Posted By rogermado
Sun Apr 26 2020, 01:53 AM
@ExperimenterUK, thanks for your reply. You'll fin...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Apr 25 2020, 05:42 PM
Some simulators handle displays better than others...
rogermado Avatar
Posted By rogermado
Sat Apr 25 2020, 03:59 PM
Hello everyone, sorry in advance if i'm not in the...
PHANTOM28 Avatar
Posted By PHANTOM28
Fri Feb 28 2020, 10:25 AM
Hi.I hope you all can help me. I am relatively ne...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 21 2020, 05:05 PM
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Feb 21 2020, 04:45 AM
Yes you can do that.1. Create a channel @Thingspea...
ananyagupta Avatar
Posted By ananyagupta
Thu Feb 20 2020, 03:58 AM
With regards to the particular characters sent to ...