[cc65] Why does sizeof(string) generates data?

From: Stefan <vorsichtphysiker1gmx.net>
Date: 2013-01-25 20:21:52
Is there a reason why this code needs data in the executable?

#define STRING "test1234"

static char len = sizeof(STRING);	
void main(void)
{

}

translates into (cc65)

000000r 1               _len:
000000r 1  09           	.byte	$09
000001r 1               
000001r 1               .segment	"RODATA"
000000r 1               
000000r 1               L0002:
000000r 1  54 45 53 54  	.byte	$54,$45,$53,$54,$31,$32,$33,$34,$00
000004r 1  31 32 33 34  
000008r 1  00           
000009r 1               
000009r 1               ; ---------------------------------------------------------------
000009r 1               ; void __near__ main (void)
000009r 1               ; ---------------------------------------------------------------
000009r 1               
000009r 1               .segment	"CODE"
000000r 1               
000000r 1               .proc	_main: near
000000r 1               
000000r 1               .segment	"CODE"
000000r 1               
000000r 1  60           	rts
000001r 1               
000001r 1               .endproc
000001r 1               
000001r 1       

while gcc translates it into:

	.file	"stringmacrotest.c"
	.data
_len:
	.byte	9
	.def	___main;	.scl	2;	.type	32;	.endef
	.text
	.globl	_main
	.def	_main;	.scl	2;	.type	32;	.endef
_main:
LFB0:
	.cfi_startproc
	pushl	%ebp
	.cfi_def_cfa_offset 8
	.cfi_offset 5, -8
	movl	%esp, %ebp
	.cfi_def_cfa_register 5
	andl	$-16, %esp
	call	___main
	leave
	.cfi_restore 5
	.cfi_def_cfa 4, 4
	ret
	.cfi_endproc
LFE0:

where there is no sign of string data in the end file.
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Jan 25 20:22:01 2013

This archive was generated by hypermail 2.1.8 : 2013-01-25 20:22:05 CET