hello, I have just started using Keil-c51 Eval version 7.50 with uVision for 8051 comptible device.I wanted to use 71M6513 from TDK.But unable to find it from Device Database i have selected closest match 73S11xx . My simple piece of code lookes like: #include <stdio.h> #include <string.h> #include <ctype.h> #include <Reg51.h> void foo() { unsigned char xdata x[10]; unsigned int xdata y[10]; unsigned char xdata z[10]; unsigned char xdata k[10]; unsigned long xdata d; x[3]=0x07; y[3]=0x0302; d=&y[3]; z[3]=0x09; k[3]=0x10; } void main() { foo(); printf("hello"); } I have configured XDATA start as 0x0000 and size as 0x1000...as the XDATA size for the particular device is 4kBytes. Now this program compiles OK. When go for step by step Debugging with uVision...and check the local variables there are two doubts come into my mind .They are: a) for the line d=&y[3] in source code above the result is d=X:0x00010010 ,why the adress of a xdata variable is crossing its maximum limit(max possible limit 64K also) ? b) When Xdata variable can adress upto 64Kbytes i.e 0xFFFF then why Xdata variable e.g x[10] in above source code shows starting address of X:0x00000000 i.e 4bytes why not X:0x0000 2bytes as i feel.?? I will be thankful if any one can pls take some time and clarify me on above two Qs. Thanks in advance, Arup
First, you need to read the uVision Getting Started guide, and work through the example projects in it. This will give you a proper introductions to the tools, how they work, and how to use them - rather than just jumping-in blindly at the deep-end! There's little point trying to discuss the finer details before you've done the basic groundwork!
Dear Mr Neil, Thanks for your expert comment.i know how to walk....And i am not running too.If you look at my questions....you would have probably noticed that i have not jumped into deep.And i have started studying the Keil-c51 with uVision user manual.Probably i missed something.I think there is no harm to discuss an issue if you don't understand properly.....this thing happen while YOU HAVE LEARNED WALKING too. I have started merely with data types.I know XDATA range is 0x0000-0xFFFF for 8051 Architecture.I have defined an array x[10] of int type in xdata region .While in debug mode "under Watch and Call Stack window in uVision" i find the array start at address X:0x000000 i.e 24 byte ? why not X:0x0000 i.e 16 byte .That's i want to ask?I have seen the .m51.there it was ok.Why it is in 24byte format in "watch and call stack window" And in the other qs, i have assigned the address of a int type variable to a long type variable.But when i see the adress value at watch window it is 65552? why did it cross FF i.e 65535.......what i am asking is basic only.....pls give atleast a hints where i gone wrong?? thnks.
"X:0x000000 i.e 24 byte ? why not X:0x0000 i.e 16 byte" (I assume you mean "bits", not "bytes") See Dan's previous comment about Generic Pointers. Also, remember that the Keil tools support various means to expand the 8051's address range - the display format has to accomodate that, whether you happen to be using it or not. "i have assigned the address of a int type variable to a long type variable.But when i see the adress value at watch window it is 65552? why did it cross FF i.e 65535......" Again, look up Generic Pointers. And, as Dan also said, you should not be at all surprised to find that assigning a pointer value to a non-pointer variable gives you unexpected results! (this is not Keil-specific; it is a dodgy practice in any implementation!) Why are you assigning a pointer value to a non-pointer variable, anyhow?
Thanks Mr. Neil for your answer. sorry, i should have mentioned "bits" not "byte" Yes i understood now that uVision simulates upto 16Mbytes of memory. so whether i am using or not it has kept option for that much space so i am seeing 0x00000000 instead of 0x0000. And regarding other question ...i had feeling that any variable can take address value of other variable with "&" operator.It doesn't need to be a pointer type...ok now on i will change the variable to pointer type if it needs to keep address of other variable. thanks, arup