CW4.6: 9S12XDP512: Assembly SECTION/SEGMENT problems

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

CW4.6: 9S12XDP512: Assembly SECTION/SEGMENT problems

跳至解决方案
2,314 次查看
paulcsf
Contributor II
We are in the process of converting our existing assembly to C. The first step we are trying is to get the existing files to build in Codewarrior. We have several tables of constant data that is placed in flash.

Using Codewarrior, it appears to just ignore the data. The data is in separate files, included into the assembly. Adding SEGMENTS to the linker command file, and trying to use them as SECTIONS in the code isn't working. The tables are present in the listing file, are present in the *.dbg file, but are missing from the *.s19.

Interestingly and irritatingly, the linker doesn't give an error or warning when code/data is assigned to a missing section. However, it typically just puts the code/data into DEFAULT_ROM, which it isn't in this case. I have checked the syntax, the names, everything I can think of with no luck. I have tried changing the names, even shortened them in case there was some length restriction.

Here is an excerpt of the linker command file:

SEGMENTS       PAGE_FA       = READ_ONLY   0x7E8000 TO 0x7EBFFF;       PAGE_FB       = READ_ONLY   0x7EC000 TO 0x7EFFFF;       PAGE_FC       = READ_ONLY   0x7F0000 TO 0x7F3FFF; /*    PAGE_FD       = READ_ONLY   0xFD8000 TO 0xFDBFFF; intentionally not defined: =ROM_4000 */      PG_FE         = READ_ONLY   0x7F8000 TO 0x7F86FF;       PG_FE_A       = READ_ONLY   0x7F8700 TO 0x7F8DFF;       PG_FE_B       = READ_ONLY   0x7F8E00 TO 0x7F94FF;       PG_FE_C       = READ_ONLY   0x7F9500 TO 0x7F9BFF;       PG_FE_D       = READ_ONLY   0x7F9C00 TO 0x7FA2FF;       PG_FE_E       = READ_ONLY   0x7FA300 TO 0x7FA9FF;       PG_FE_F       = READ_ONLY   0x7FAA00 TO 0x7FBFFF; /*    PAGE_FF       = READ_ONLY   0xFF8000 TO 0xFFBFFF; intentionally not defined: =ROM_C000 */ENDPLACEMENT     FPAGE_FE      INTO    PG_FE;    FPAGE_FEA     INTO    PG_FE_A;    FPAGE_FEB     INTO    PG_FE_B;    FPAGE_FEC     INTO    PG_FE_C;    FPAGE_FED     INTO    PG_FE_D;    FPAGE_FEE     INTO    PG_FE_E;    FPAGE_FEF     INTO    PG_FE_F;    DEFAULT_ROM   INTO    PAGE_FC, PAGE_FB, PAGE_FA, PAGE_F9,                          PAGE_F7, PAGE_F6, PAGE_F5, PAGE_F4, PAGE_F3, PAGE_F2, PAGE_F1, PAGE_F0,                           PAGE_EF, PAGE_EE, PAGE_ED, PAGE_EC, PAGE_EB, PAGE_EA, PAGE_E9, PAGE_E8, END

And here is an excerpt of the assembly code:
FPAGE_FE: SECTION  INCLUDE "Table1.ASM"FPAGE_FEA: SECTION  INCLUDE "Table2.ASM"FPAGE_FEB: SECTION  INCLUDE "Table3.ASM"...

 And finally an excerpt of the table1.asm:
DC.B  $B0,$BA,$98,$A8,$B4,$A7,$B5,$89DC.B  $B1,$BA,$98,$A8,$B4,$A7,$B5,$89DC.B  $B2,$BA,$98,$A8,$B4,$A7,$B5,$89....

 This all shows up in the listing file, and in the *.dbg file. No errors or warnings are thrown, but the data doesn't get included in the *.s19 file.

Thanks for any help. Paul.





Message Edited by paulcsf on 2008-09-09 04:44 AM
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
791 次查看
paulcsf
Contributor II
Thank you Daniel.

We use the data by pointers, so it's just a table. I tried adding labels to the tables, but that doesn't work unless it's referenced outside that section.

I ended up using the ENTRIES field, it worked great.
ENTRIES   file.asm.o:* END

 Thanks again, Paul.

在原帖中查看解决方案

0 项奖励
回复
4 回复数
791 次查看
CompilerGuru
NXP Employee
NXP Employee
Hi Paul,

the linker is only allocating referenced objects, so if nothing is using your tables, they do not get linked.
So usually there is something which uses the tables, if not (version strings, ...) it can be explicitly
referenced in a prm ENTRIES block.
There is also a syntax to link everything in an object file (not sure by heart, something like ENTRIES objectFile.obj:* END, check the manual), but normally I would just list labels (exported with XDEF) in an ENTRIES block.

Check also the map file, I think it lists non used objects, which don't get linked. Adding a label at the start of the section
just after the SECTION directive may help giving more descriptive names.

Daniel

0 项奖励
回复
792 次查看
paulcsf
Contributor II
Thank you Daniel.

We use the data by pointers, so it's just a table. I tried adding labels to the tables, but that doesn't work unless it's referenced outside that section.

I ended up using the ENTRIES field, it worked great.
ENTRIES   file.asm.o:* END

 Thanks again, Paul.

0 项奖励
回复
791 次查看
CompilerGuru
NXP Employee
NXP Employee
Good that you have it working :smileyhappy:

How do you initialize those pointers?
I would expect that initial pointer assignment to be the reference which causes the tables to be linked.

Daniel
0 项奖励
回复
791 次查看
paulcsf
Contributor II
The original code used "constants".

So we had tables defined as: (file includes removed, ~ listing)
    ORG    $8000Table1:    bla bla (length $10)Table2:    bla bla (length $10)...TableN:    bla bla (length $10)

 
Then we used it like so:
    LDAA    TableNumUsed    LDAB    $10              ;table length    MUL    ADDD    $8000            ;table base address (assuming PPAGE set)    TFR     D,X    LDAB    TableIndexUsed    LDAA    B,X              ;get actual table entry

 
So, the coder new where the tables were and how to use them, but the compiler/linker couldn't make that association.

Paul
0 项奖励
回复