Sep 21
For Thu (nothing to turn in) :
Start reading chap3,
at least sections 3.1 - 3.4, pgs 153 - 174.
Explore gcc options discussed below.
x86 backround :
How to : run through attached gcc_notes.txt.
$ gcc -O -m32 -S sum_example.c # creates .s "source file"
$ gcc -O -m32 -c sum_example.c # creates .o "object file"
$ gobjdump -d sum_example.o > sum_example.dump
// pg 17 of 05-machine-basics.pdf
int sum(int x, int y){
int t = x + y;
return t;
}
And here's sum_example.s
.text
.globl _sum
_sum:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
movl 12(%ebp), %eax
addl 8(%ebp), %eax
movl %eax, -12(%ebp)
movl -12(%ebp), %eax
leave
ret
.subsections_via_symbols
And the disassembled dump
sum_example.o: file format mach-o-i386
Disassembly of section .text:
00000000 <_sum>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 8b 45 0c mov 0xc(%ebp),%eax
6: 03 45 08 add 0x8(%ebp),%eax
9: c9 leave
a: c3 ret