Just a little something that has been bothering me.

GORDON KEEGAN c145gmk at utarlg.utarl.edu
Tue Dec 11 10:11:45 AEST 1990


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?
> 
>This type of thing has been bothering me for a long time.


	Our C compiler under VMS 5.3-1 produced the following
	assembler code for the respective C segments:

	    int a=0, i=0;
                 F8 AD 00 D0    000B		movl	#0,-8(fp)
                 F4 AD 00 D0    000F		movl	#0,-12(fp)

	and

	    int a, i;
	    i = a = 0;
                 F8 AD 00 D0    000B		movl	#0,-8(fp)
              F4 AD F8 AD D0    000F		movl	-8(fp),-12(fp)

	The second will be marginally slower, but only just...

-----------------------------------------------------------------------------
|  Gordon Keegan                    ||   Bitnet  : c145gmk at utarlg           |
|  Systems Programmer               ||   THEnet  : UTARLG::C145GMK          |
|  Academic Computing Services      ||   Internet: c145gmk at utarlg.utarl.edu |
|  University of Texas, Arlington   ||   AT&TNet : 817-273-2208             |
-----------------------------------------------------------------------------
|  Beauty does what beauty does best: it's beautiful...                     |
-----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list