Hi all,
When inspecting code produced by gcc 4.1.1 (fedora core 6 test 2) I discover something extrange:
The C program is:
const int n = 100;
int a[n];
int main()
{
a[0] = 0;
for (int i = 1; i < n; ++i)
a[i] = a[i - 1] + 1;
}
When disassembling .text with objedump it shows:
Intel syntax:
/*
cs = 0x33, ds = 0x0, ss = 0x2b
0000000000400510 :
400510: c7 05 26 04 20 00 00 mov DWORD PTR ds:0x200426,0x0
400517: 00 00 00
40051a: 31 d2 xor edx,edx
40051c: 0f 1f 40 00 nop DWORD PTR [rax]
400520: 8b 04 95 40 09 60 00 mov eax,DWORD PTR [rdx*4+0x600940]
400527: 83 c0 01 add eax,0x1
40052a: 89 04 95 44 09 60 00 mov DWORD PTR [rdx*4+0x600944],eax
400531: 48 83 c2 01 add rdx,0x1
400535: 48 83 fa 63 cmp rdx,0x63
400539: 75 e5 jne 400520
40053b: 31 c0 xor eax,eax
40053d: c3 ret
40053e: 90 nop
0000000000600940 :
...
*/
AT&T syntax:
/*
0000000000400510 :
400510: c7 05 26 04 20 00 00 movl $0x0,2098214(%rip) # 600940
400517: 00 00 00
40051a: 31 d2 xor %edx,%edx
40051c: 0f 1f 40 00 nopl 0x0(%rax)
400520: 8b 04 95 40 09 60 00 mov 0x600940(,%rdx,4),%eax
400527: 83 c0 01 add $0x1,%eax
40052a: 89 04 95 44 09 60 00 mov %eax,0x600944(,%rdx,4)
400531: 48 83 c2 01 add $0x1,%rdx
400535: 48 83 fa 63 cmp $0x63,%rdx
400539: 75 e5 jne 400520
40053b: 31 c0 xor %eax,%eax
40053d: c3 retq
40053e: 90 nop
0000000000600940 :
...
*/
What is the first instruction? What sintax is right? Are both instructions the same?
Any help will be welcome :)
I forgot...
it is the 64 bit version of fedora core 6 test 2 :)