Sample code from
Lecture 5: Machine Programs
Ch 3.2 of textbook (CS:APP)

--------------------------------------------------
swap.c   -- C source for swap() function
main.c   -- C source for main() function

# 64 bit files
swap.s   -- assembly code (64 bit)
swap.o   -- object file (64 bit)
swap.txt -- disassembled object code
swap     -- executable

#32 bit files
swap32.s -- assembly code (32 bit)
swap32.o -- object file (32 bit)
swap32.txt -- disassembled object code
swap32   -- executable
--------------------------------------------------
Commands to generate these files
--------------------------------------------------
# 64 bit code

# generate swap.s (compile C to assembly code)
bluefish> gcc -O2 -S swap.c

# generate swap.o (compile C to object code)
bluefish> gcc -O2 -c swap.c

# generate swap.txt (disassemble swap.o)
bluefish> objdump -d swap.o > swap.txt

# generate swap (compile main.c and link with swap.o)
bluefish> gcc -O2 -o swap swap.o main.c

# run executable
bluefish> ./swap

--------------------------------------------------
# 32 bit code (add -m32 argument)

# generate swap32.s (compile C to assembly code)
bluefish> gcc -O2 -m32 -S -o swap32.s swap.c

# generate swap.o (compile C to object code)
bluefish> gcc -O2 -m32 -c -o swap32.o swap.c

# generate swap.txt (disassemble swap.o)
bluefish> objdump -d swap32.o > swap32.txt

# generate swap (compile main.c and link with swap.o)
bluefish> gcc -O2 -m32 -o swap32 swap32.o main.c

# run executable
bluefish> ./swap32
