Greg Lopp on Wed, 19 Feb 2003 23:00:13 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] gcc, assembly, etc...


Additional mystery : 
void f_1(void) { char car[1]; car[0] = 1;}
void f_2(void) { char car[2]; car[1] = 1;}
void f_3(void) { char car[3]; car[2] = 1;}
void f_4(void) { char car[4]; car[3] = 1;}
void f_5(void) { char car[5]; car[4] = 1;}
void f_6(void) { char car[6]; car[5] = 1;}
void f_7(void) { char car[7]; car[6] = 1;}
void f_8(void) { char car[8]; car[7] = 1;}
void f_9(void) { char car[9]; car[8] = 1;}

$ gcc -O0 -S bar.c
$ grep movb bar.s
	movb $1,-1(%ebp)
	movb $1,-1(%ebp)
	movb $1,-2(%ebp)
	movb $1,-1(%ebp)
	movb $1,-4(%ebp)
	movb $1,-3(%ebp)
	movb $1,-2(%ebp)
	movb $1,-1(%ebp)
	movb $1,-4(%ebp)

There are no other differences between these functions....
f_1:
	pushl %ebp
        movl %esp,%ebp
        subl $24,%esp
        movb $1,-1(%ebp)
        leave
	ret




_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug