All,
I have the following code fragment:
unsigned int test0;
unsigned int test1;
if( 0 == test0 )
{
test0 = 1;
}
if( !test1 )
{
test1 = 1
}
The list output shows the following:
0000 E5*00 113 mov a,_test0
0002 70 04 114 jnz 00109$
0004 E5*01 115 mov a,(_test0 + 1)
0006 60 02 116 jz 00110$
0008 117 00109$:
0008 80 06 118 sjmp 00102$
000A 119 00110$:
120 ; test51.c:8: test0 = 1;
000A 75*00 01 121 mov _test0,#0x01
000D E4 122 clr a
000E F5*01 123 mov (_test0 + 1),a
0010 124 00102$:
125 ; test51.c:11: if( !test1 )
0010 E5*02 126 mov a,_test1
0012 45*03 127 orl a,(_test1 + 1)
128 ; test51.c:13: test1 = 0;
0014 70 04 129 jnz 00105$
0016 F5*02 130 mov _test1,a
0018 F5*03 131 mov (_test1 + 1),a
My question is why is the first 'if' statement not optimized to be the
same as the 2nd if statement. This is using an extra 4-code space bytes.
Lets not have any code stylistic comments I personally think the 1st if
statement is clearer and that is what the companies coding standard
mandates.
I currently don't need the missing 4-bytes of code space and will only
note this in the delivery notes.
Regards,
Rod Boyce
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user