|
|
View previous topic :: View next topic |
Author |
Message |
JR Guest
|
#ROM directive; string problem; compiler bug? |
Posted: Mon Sep 28, 2009 4:34 am |
|
|
I want to use the #ROM directive to insert string data into the code space, but the compiler seems to get it wrong!
For example if I put :-
Code: | #define ROMDATA 0xe00
#ROM ROMDATA={"900-DV-6050-000 HAMSTEr\n"}
#ROM ROMDATA+25={"(C) GAI-Tronics"}
#ROM ROMDATA+0x29={__DATE__}
#ROM ROMDATA+0x33={__TIME__} |
in the source file.
This produces :-
ROM data:
000E00: 0039 0030 0030 002D 0044 0056 002D 0036
000E08: 0030 0035 0030 002D 0030 0030 0030 0020
000E10: 0048 0041 004D 0053 0054 0045 0072 000A
000E18: 0000 0028 0043 0029 0020 0047 0041 0049
000E20: 002D 0054 0072 006F 006E 0069 0063 0073
000E28: 0000 0031 0036 002D 0053 0065 0070 002D
000E30: 0030 0039 0000 0031 0035 003A 0033 0035
000E38: 003A 0034 0032 0000
in the list file, which is correct.
But looking in the ".sta" file at the segment location, I see
Segment Used Free
----------- ---- ----
00000-00003 4 0
00004-000FF 252 0
00100-007FF 1116 676
00800-00DFF 842 694
00E00-00E0B 12 0
00E0C-00E18 0 13
00E19-00E20 8 0
00E21-00E28 0 8
00E29-00E2D 5 0
00E2E-00E32 0 5
00E33-00E36 4 0
00E37-00EFF 0 201
The compiler seems to have mis-calculated the lengths of the the strings, leaving 'gaps' of unused code space.
This is OK at this location, but if I put string data at the bottom of the code space, where I want it, the compiler (being efficient) fills in these 'spaces' with code fragments, giving me an ususable code image.
If the ROM data is individual bytes (hex data or ASCII characters) there isn't a problem, but the predefined "__DATE__" variable is always a string, so I can't get round the problem that way.
Has anyone else experienced this problem?
Is it really a compiler bug? |
|
|
Ttelmah Guest
|
|
Posted: Mon Sep 28, 2009 7:13 am |
|
|
Remember ROM addresses, are _word_ addresses.
On a PIC18, you can fit two string characters in each word.
As far as the compiler is concerned, you are writing a 16byte string into 16bit wordspace, so only 13 words need to be reserved. You are electing though to write the data to alternate bytes, which the compiler does not understand....
You need to either add the int8 keyword to your ROM statement. So:
#ROM int8 ROMDATA={"900-DV-6050-000 HAMSTEr\n"}
Which will then put the data sequentially into the _bytes_ of the ROM, or store the individual characters, not a string.
Best Wishes |
|
|
JR Guest
|
|
Posted: Wed Sep 30, 2009 1:47 am |
|
|
Oops, I forgot to mention, it's for a 16F884 (using V4.093 compiler).
That gives me 14 bit data so the compiler shouldn't/can't pack 2 characters per word -
and it doesn't; the hex data shows that the compiler actually generates the strings correcly, it just gets the length wrong when it's linking all the code together.
As it happens I'd already tried declaring the data as int8, and as int16 - it makes no difference |
|
|
Ttelmah Guest
|
|
Posted: Wed Sep 30, 2009 2:22 am |
|
|
It is a bug, and I'd report it to CCS.
With a PIC16, you can use the 'char' option to pack two 7bit characters into each 14bit word, but given this is not the default, I'd have expected the compiler to have correctly handled the sizing...
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|