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.
actually this is in reference to the thread that i have already created about declaring two dimensional arrays I have configured the the model to Xdata and the change that i have made is only of declaring a character array of a size more than 100 Yes i am going to use it to store strings but that is later isnt it .There is a problem in the declaration itself
It really would be better to continue with the already existing thread. Still, we are here now... xdata is not a memory model. Do you mean that you are using the large memory model? The fact that you get problems as the array gets bigger rather hints that variables are not being stored where you think they should be. You can use the simulator Memory Window to check. You can put strings in a two dimensional array. However, it is generally better to form an array of pointers to strings. The difference is a subtle one and may result in some confusion. Can you post some of your code - let us see that array definition and how you are accessing it.
3 #include<stdio.h> #include<conio.h> void main() { char xdata id[100][20];/*this code is producing a problem*/ char id1[50]; struct { emp[10]; nm[20]; }str[10]; //also dose not work why?? } }
OK, let's take this one step at a time. What is the problem that is being produced?
#include<conio.h> Do you really have that line in your code?
sir i am to mailing to you a part of the code along with the flash memory contents below it please ponder over it and do tell us why this code doesnt seem to work tis matter is urgent thanking you in anticipation yours sincerely Maheshwari bhosale source code #include<insignia.h> #include<card.h> #include <REG52.h> //char y[10],x,z[100][100],j; void main(void) { void temp(int); int key[52]; int Data=0,n,i,j=0,m,verFlag=0,flag1,k,z,l,pin,f=0; char id[10]; // char nm[20][20]; char xdata id1[100][20] = {0};/*this code poses a problem*/ // char nm[5][5]; #ifndef MONITOR51 SCON = 0x52; TMOD |= 0x22; TH1 = 0xfa; TL1 = 0Xfa; ////////for 9600 Baud//////// TR1 = 1; TI = 1; // PCON |= 0xf0; RI = 1; #endif start: for(i=0;i<51;i++) {key[i]=0;} for(n=0;n<5;n++) { id[n]=0; } i=0; clear(); init1(); iprint("Welcome to"); init2(); iprint("Insignia Tech. "); init2(); // iprint (*y[i]); putchar('t'); start1: while(1) { if(Data0==0 || Data1==0) goto jump; P2=0xf0; k=P2; P2=0x0f; l=P2; P0=0xff; flag1=((k==112|k==176)|(k==208)|(k==224)); n=4; jump: if(j>=51) { putchar('t'); // strcpy(m,convert(key)); j=0; printf("key %d",m); } else if(flag1) { BUZZ=0; min_delay(); BUZZ=1; The contents of the flash memory are as follows: 0000 02153D57656C636F6D6520746F00496E ..=Welcome to.In 0010 7369676E696120546563682E20006B65 signia Tech. .ke 0020 79202564002020202020202020202020 y %d. 0030 20202020002000656E74657220202020 . .enter 0040 20202020202000656D706C6F79656520 .employee 0050 49442020202000000000000000000000 ID .......... 0060 00000000000000000000000000000000 ................ 0820 00000000000000E4900068F0A3F09000 ..........h..... 0830 6EF0A3F0900072F0A3F090007CF0A3F0 n.....r.....|... 0840 78887C007D017BFF7A0079577E077FD0 x.|.}.{.z.yW~... 0850 A17C037DE812135F7C277D1012135FEF .|.}..._|'}..._. 0BA0 2BFFEE3A90007AF0A3EFF07F45121512 +..:..z.....E... 0BB0 7F6512146D121450E490007CF0A3F080 .e..m..P...|.... 0BC0 0312145090007CE07004A3E064017003 ...P..|.p...d.p. 0BD0 0209CA2212151290006BE0247EF582E4 ...".....k.$~... 0BE0 3400F5832212151290006BE0247EF582 4...".....k.$~.. C0E0C4B201C0F0120C69D0F0D5F0EB02 .........i...... 0E90 0CBA1211150D57530DD1580D284C0D24 ......WS..X.(L.$ 0EA0 420DD54F0DDD440DDD490D3D430DE355 B..O..D..I.=C..U 0EB0 0DC7460DC7450DC7470F83500D2C2D0D ..F..E..G..P.,-. 0EC0 302E0D532B0D34230D51200F6C2A0CEC 0..S+.4#.Q .l*.. 0ED0 4800000D4B3F3F3F00790AA2D5200314 H...K???.y... .. 0EE0 300509B910020404B9080104A2D52006 0............. . 0EF0 C282121521D28222E0F590D2B2C2B3D2 ....!.."........ 1390 B4C2B42275A0F0AFA07E0075A00FADA0 ..."u....~.u.... 13A0 22E0FF3395E0FE7C000210C5900897EE "..3...|........ 13B0 F0A3EFF0E4FFFEA3F0A3F0E490089BF0 ................ 13C0 A3F0D390089CE0949690089BE0648094 .............d.. 13D0 80501312136F121549900897E0B506E2 .P...o..I....... 13E0 A3E0B507DD2290089912136FD390089A .....".....o.... 13F0 E094FF900899E06480948140BE229008 .......d...@.".. 1400 5812110CE490085BF0A3F09008581211 X......[.....X.. 1410 031214D990085BE0FCA3E0FDC39FEE64 ......[........d 1420 80F8EC648098501C9008581211038D82 ...d..P...X..... 1430 8C83121098FF12151212149490085B12 ..............[. 1440 136F80C722D21510 F6D8FD758121020827121394EF2DFFEE ...u.!..'....-.. 1550 33FE227FC07E001214AC227F017E0012 3."..~...."..~.. 1560 14AC22FFFFFFFFFFFFFFFFFFFFFFFFFF ..".............
well that code was done firstin c and then transferd on to keil
Please post code etc using <pre> and </pre>. None of your code seems to operate on Id1. So, what is your program doing that you are not expecting?
the code dose not exicute instead the LCD on port one is bank and leds on port 0 go on and off
Does it work with a smaller array size? If so, how large is the maximum array size?
Yes it works with a arr of [20][20] but any greater it dose not work
which chip ? which external RAM ? Erik
Why do you think it doesn't work? Hint: RAM comes in finite amounts.
RAM comes in finite amounts Erik will never make a PC programmer out of you as long as you insist on thinking like that. A gigabyte here, a gigabyte there, pretty soon you're talking about real memory.
After looking at the hex file, I found the problem! I lost interest in looking at the hex file! Seriously though, your micro has 2048 bytes of xram so your array cannot be much bigger than your 100 * 20. Firstly, where has the linker put your array? What memory model have you selected? Tiny? - that's definitely not going to work. Read up on the linker output, it tells you many things. Secondly, does the 89c51rd2 need a bit set to enable the xram? I know aduc834 does and a 89c668 does. Read the datasheet on your device. Putting the hex file on the forum was a waste of time! If you'd put the linker listing, that would have been much more helpful.