constant string changed

Phung Nguyen nhphung@gmail.com
Wed Oct 6 14:59:00 GMT 2010


Dear all,

When porting GCC on xc16x, I met a problem with a constant string. The
following is the C code:
#include "stdio.h"

int main () {
	
	printf ("c\n");
}
And the following is the generated assembly:
	.xc16x

	.section .rodata

.LC0:
	.ascii "c\0"
	.section .text
	.align 1
	.global _main
_main:
	 mov  [-r0],r1
	 mov  r1,r0
	
	mov r8,#SOF:.LC0
	calla cc_UC,_puts
	 mov  r1,[r0+]
ret

where there is no '\n' in the constant string .LC0 any more. However,
when I change the string into "%c\n" (with a character passed), the
constant string .LC0 becomes .ascii "c\12\0"

Is there any idea about this kind of problem? Where did I got the mistake?

Best regards,
Phung



More information about the Gcc mailing list