CSCI 434T
Compiler Design
Home | Schedule and Assignments | Resources
Code Generation Material
hello.ic,
hello.s
fib.ic,
fib.s
objects.ic,
objects.s
%eax register (not on stack) %eax, %ecx, %edx %ebx, %esi, %edi, %ebp, %espnasm assembler documentation; uses
Intel syntax)
| AT&T | Intel | |
| Order of operands | op a,b means b = a op b (second operand is destination) |
op a, b means a = a op b(first operand is destination) |
| Memory addressing | disp(base, offset, scale) |
[base + offset*scale + disp] |
| Size of memory operands | instruction suffixes (b,w,l) (e.g., movb, movw, movl) |
operand prefixes (e.g., byte ptr, word ptr, dword ptr) |
| Registers | %eax, %ebx, etc. |
eax, ebx, etc. |
| Constants | $4, $foo, etc |
4, foo, etc |
To assemble and link the file "
file.s", use:
gcc -g -o file.exe file.s libic.aThe library file
libic.ais a collection of .o files bundled together, containing the code for all of the library functions defined in the language specification, along with run-time support for garbage collection. The-gflag enables you to usegdbto step through your program.The IC library is also available for Intel Macs running FreeBSD:
libic.osx.a.