As a fairly new student in C I am having diffictly with arrays. I have a string of numbers that I am tring to split up into smaller strings to convert them to integers. I have made the code as basic as possible but still get the errors.
#include <stdio.h> #include <stdlib.h> #include <reg52.h> xdata char Temperatures1[9]; xdata char Temperatures2[12]; xdata char Temperatures3[9]; void main(void) { char a[36] = "<<123456789012345678901234567890>>"; int s; SCON = 0x52; TMOD = 0x20; TCON = 0x69; TH1 = 0xF5; for(s=0; s < 9; s++) { Temperatures1[s] = a[s+2]; } for(s=0; s < 12; s++) { Temperatures2[s] = a[s+11]; } for(s=0; s < 9; s++) { Temperatures3[s] = a[s+23]; } printf("Temperatures1: %s\n", Temperatures1); printf("Temperatures2: %s\n", Temperatures2); printf("Temperatures3: %s\n", Temperatures3); }
So what is the point of the 'BL51 Locate' tab, and the address-space fields in the 'Target' tab? The point of the locate tab is to specify the addresses and/or order of segments in the different memory areas. For example, you may prefer that segments use DATA or IDATA in a certain order. The point of the address-space fields in the target tab are to tell the linker what areas of memory it can use for your program code and your variables. Not every program's CODE and XDATA start at 0x0000. Jon
Can we create our own segments in C51/L51? In GCC and Diab DCC we can create a segment and then tell the compiler to place certain objects in these segments. These segments are unknown to the default C run-time and thus are left alone, e.g. not cleared and not initialized with compile time values. For example, for NVRAM I'd place all my NVRAM objects in a segment called .nvRam and create in a linker control file. Then, at the definition of my NVRAM objects I'd just indicate that the compiler should put these objects in the .nvRam segment. Hmm... maybe _at_ would take care of this just fine. Same net affect I guess. Regards, - Mark