As noted by Patryk on the SiLabs forum in the thread
http://www.cygnal.org/ubb/Forum10/HTML/000036.html
redundant strings get linked.
I'm filing it here so it won't get lost:
-----8<-----------------------------------------
#define STR2LEN sizeof ("F320") * 2
code const unsigned char String2Desc [STR2LEN] =
{
STR2LEN, 0x03,
'F', 0,
'3', 0,
'2', 0,
'0', 0
};
void main(void)
{
static unsigned int n=0;
/* "12345rgfgh" is linked with SDCC 2.6.0
but not with 2.5.0 */
n = sizeof("12345rgfgh");
}
----->8-----------------------------------------
-----8<-----------------------------------------
.area CONST (CODE)
__str_0:
.ascii "F320"
.db 0x00
_String2Desc:
.db #0x0A
.db #0x03
.db #0x46
.db #0x00
.db #0x33
.db #0x00
.db #0x32
.db #0x00
.db #0x30
.db #0x00
__str_1:
.ascii "12345rgfgh"
.db 0x00
----->8-----------------------------------------
Logged In: YES
user_id=568035
Originator: NO
Fixed in svn revision #4770.
Borut
Logged In: YES
user_id=1788180
Originator: NO
And worked great in SDCC up to Version 2.7.2 #4885 (Jul 16 2007). But is no longer in Version 2.7.4 #4960 (Nov 12 2007) (MINGW32).
Logged In: YES
user_id=568035
Originator: NO
I can't reproduce it with the today's snapshot build:
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.7.4 #4960 (Nov 12 2007) (MINGW32)
The resulting asm code is the same as the one produced 2007-04-27 when I fixed the bug: the __str_1 is not defined and the string "12345rgfgh" is not allocated.
Patryk, did you try it with the same C code? Can you please send me the C source and generated asm file?
Borut
Logged In: YES
user_id=1788180
Originator: NO
You're right, example is OK. Problem reveals in my sources, compile result is different with #4885 and #4960. I'll check it and let you know.
Logged In: YES
user_id=1788180
Originator: NO
My stripped down code:
#define MY_STR "abc"
static code const struct
{
unsigned char Length;
unsigned char String[sizeof(MY_STR)];
} My_str =
{
sizeof(My_str),
MY_STR
};
Result (asm):
;--------------------------------------------------------
; code
;--------------------------------------------------------
.area CSEG (CODE)
.area CSEG (CODE)
.area CONST (CODE)
FSource1$My_str$0$0 == .
_My_str:
.db #0x05
.ascii "abc"
.db 0x00
FSource1$_str_1$0$0 == .
__str_1:
.ascii "abc"
.db 0x00
.area XINIT (CODE)
.area CABS (ABS,CODE)
Logged In: YES
user_id=568035
Originator: NO
It seems that this has nothing to do with the sizeof("abc") problem, since the produced asm code is the same for the following case:
--8<---------------------
static code const struct
{
unsigned char Length;
unsigned char String[4];
} My_str =
{
5,
"abc"
};
-->8---------------------
I'm still investigating it...
Borut
Logged In: YES
user_id=568035
Originator: NO
The problem is caused by fixing the bug #983491 https://sourceforge.net/tracker/?func=detail&atid=100599&aid=983491&group_id=599,
so I reverted the fix and reopened the bug :-(
Borut