6. Code Example
-
From the book, Chapter 18 pages 9-10:
int array[1000]; // 1000 = 0x3e8 ... for (i = 0; i < 1000; i++) array[i] = 0; gcc -o array array.c -Wall -O objdump -d array 1024 movl $0x0,(%edi,%eax,4) 1028 incl %eax 1032 cmpl $0x03e8,%eax 1036 jne 0x1024
- Compare using gcc-8.2.0 on Linux x86_64:
int main(void) { int array[1000]; for( int i = 0; i < 1000; ++i) array[i] = 0; return array[10]; } gcc -m32 -S array.c array.s: ... movl $0, -4(%ebp) jmp .L2 .L3: movl -4(%ebp), %eax movl $0, -4004(%ebp,%eax,4) addl $1, -4(%ebp) .L2: cmpl $999, -4(%ebp) jle .L3 ...