Originally Posted by
rcgldr
For the loop, this may be a bit quicker:
while(++counter <= (MAX_COUNT+1);
If MAX_COUNT+1 is zero, then the loop would need to be:
while(++counter);
or
while(++counter != 0);
old compiler, Visual C/C++ 4.0:
Code:
int main(void)
{
unsigned counter = 0;
while(counter <= 0xffffffffUL)
counter++;
return(0);
}
Code:
_main PROC NEAR
xor eax, eax
$L78:
inc eax
cmp eax, -1
jbe SHORT $L78
xor eax, eax
ret 0
_main ENDP
Code:
int main(void)
{
unsigned counter = 0;
while(counter++ <= 0xffffffffUL);
return(0);
}
Code:
_main PROC NEAR
xor eax, eax
$L78:
mov ecx, eax
inc eax
cmp ecx, -1
jbe SHORT $L78
xor eax, eax
ret 0
_main ENDP
Code:
int main(void)
{
unsigned counter = 0;
while(++counter != 0UL);
return(0);
}
Code:
_main PROC NEAR
xor eax, eax
$L78:
inc eax
jne SHORT $L78
xor eax, eax
ret 0
_main ENDP
Visual Studio 2005 (counter is ignored):
Code:
_main PROC NEAR
xor eax, eax
ret 0