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.
I am using the Dallas 80C400 processor in contiguous mode (16mb memory space). PK51 development kit. My compiler is 7.50
In a most simplistic form, I am doing this:
#pragma string(far) typedef struct { unsigned char *help_txt[15]; } helpsystem; helpsystem const far help_table_E[] = { // 0x20 {"x","y","c","t","","","","","","","","","","",""}, // 0x21 {"","","","","","","","","","","","","","",""}, // 0x22 {"","","","","","","","","","","","","","",""}, };
I am finding that when compiled, and loaded, that the structure itself AND the strings are being allocated the same memory addresses. If I remove the "string(far)" and allow the strings to go to the code segment, then the structure, which is still is far memory, now points correctly to the strings, at their addresses in the code segment. The only problem is I have a ton of strings, way more than 64k worth, so they will not all fit in the code segment. The actual size of "help_table_E" is a lot larger than shown in the example, and there are four other tables like it, each with several hundred structure records, pointing to hundreds of different 15 line strings. I need the strings located in far memory. Somehow the compiler is running independent program counters, one for where the structure goes, and one for where the strings go, and this is causing the problem.
I know this is a little hard to explain, and I wish I could show you the actual results that I see using my in circuit emulator, but I'm hoping somebody knows what I'm talking about here and can tell me why the structure and the strings want to use the same memory locations when string(far) is used.
I tried numerous combinations and it changed nothing. It's hard to explain with seeing the actual numbers on the emulator, but let me see if I can explain it again. Let's take this simple fragment:
helpsystem const far help_table_E[] = { {"x","y","c","t","","","","","","","","","","",""}, };
The structure contains 1 record. That record has 15 pointers to 15 different strings. In this example 4 unique strings (x, y, c, and z) and the rest are NULLs.
When compiled and loaded into the target memory, for example, the structure is at 0xC5D900 and consists of 15 3 byte pointers. The pointer to the first string (the "x") is also 0xC5D900. Both the string and the pointer to the string can't be at the same place! The pointer to the second string is 0xC5D902, and so on.
If you take out the string(far) pragma, then the structure is still at 0xC5D900, but the pointer to the "x" is now 0x87500, which is the "code" segment on my map (0x80000 - 0x8FFFF).
I hope I've been able to explain this better
Now, before this goes any further, I just installed my updated PK51 kit (finally got my serial number this morning), which has the version 8 compiler. The problem is now GONE. When string(far) used, the structure (of pointers) and the physical strings are now in different spots (not on top of each other), both in far const memory and all is working and happy (as far as I can tell). There definitely is something wrong with the 7.50 compiler.