Bug#472867: more simplier loop (asm x86 corrected)
On Thu, Mar 27, 2008 at 12:33:58AM +0100, Cyprien LAPLACE wrote:
> /* b.c */
>
> int main()
> {
> register long foo = 0;
"signed long". Signed integer values have no overflow behaviour in C.
Use "unsigned long" if you want that.
> do {
> asm volatile("nop"::"r"(foo));
> } while(++foo);
Can be expressed as endless loop.
> return 0;
> }
> Disassembly of section .text:
>
> 0000000000000000 <main>:
> 0: 31 c0 xor %eax,%eax
> 2: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
> 8: 90 nop
> 9: 48 83 c0 01 add $0x1,%rax
> d: eb f9 jmp 8 <main+0x8>
gcc converts it into an endless loop.
Bastian
--
Killing is stupid; useless!
-- McCoy, "A Private Little War", stardate 4211.8
Reply to: