Computer
Systems

Fall 2010
course
navigation

Sep 21

Last C and chap 2 stuff : sep 21 homework
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 :
"Hello world" in IA32 assembler: http://asm.sourceforge.net/intro/hello.html (Dated, but the basic idea is there).
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
Start walk through the machine basics slides
http://cs.marlboro.edu/ courses/ fall2010/systems/ notes/ Sep_21
last modified Tuesday September 21 2010 1:36 am EDT

attachments [paper clip]

     name last modified size
[TXT]gcc_notes.txt Sep 21 2010 1:36 am 5.29kB