Just a little something that has been bothering me.

Dave ccastdf at prism.gatech.EDU
Thu Dec 13 04:38:38 AEST 1990


bright at nazgul.UUCP (Walter Bright) writes:

>In article <1990Dec08.222943.1581 at cs.widener.edu> sven at cs.widener.edu (Sven Heinicke) writes:
>-What is quicker?
>-	int a = 0,i = 0;
>-or
>-	int a,i;
>-	i = a = 0;
>-and why?


Well, int a=0,i=0 generates the following lines of assembly:

_main:
	jmp	.L22
.L21:
	movl	$0,-4(%ebp)
	movl	$0,-8(%ebp)

and int a,i; i=a=0; generates these lines:

_main:
	jmp	.L22
.L21:
	movl	$0,-4(%ebp)
	movl	$0,%eax
	movl	%eax,-8(%ebp)



Therefore, on a 386 Sequent with no optimization, the first is more effieient.


Dave
-- 
David Frascone 
Georgia Institute of Technology,
Atlanta Georgia, 30332
Office of Computing Services--User Assistant



More information about the Comp.lang.c mailing list