🔬 Lab
CS 240 Lab 7
Learning Goals & Reflection
CS 240 Lab 7
Learning Goals
Core Goals
Students can:
- Use
gcc
to compile code.- Look up the meaning of
gcc
flags. - Use
gcc
to compile C code into assembly code. - Use
gcc
to compile C code into an executable binary. - Explain how the
-Wall
,-std=c99
,-S
, and-o
flags forgcc
change its behavior.
- Look up the meaning of
- Use
objdump
and/orgdb
to disassemble an executable file.- Explain how to use
objdump
on a binary file. - Explain what the three columns of output from
objdump
are. - Explain how to use the
disas
command ingdb
to disassemble a function. - Explain What the
+
numbers in thedisas
output mean.
- Explain how to use
- Identify and explain core x86 assembly instructions.
- Look up the reference for an unfamiliar assembly instruction and understand what it is saying.
- Explain what the
mov
family of instructions does. - Explain what the
j*
family of instructions does. - Explain what the
cmp/test
family of instructions does.
- Explain the relationship between assembly code and C code.
- Identify function calls in assembly code.
- Explain how comparison instructions link with conditional jump instructions in assembly code.
- Identify how many parameters a function uses by looking at its assembly code, for functions with up to 6 parameters.
- Identify which line(s) of code in an assembly program set return value(s) for a function.
- Identify conditionals and loops within assembly code.
- Identify which registers are used as pointers in assembly code.
- Explain the usage of key x86 registers.
- Explain what the
%rax
register is used for in x86 assembly code. - Explain what the
%rdi
,%rsi
,%rdx
,%rcx
,%r8
, and%r9
registers are used for when calling functions in x86 assembly code.
- Explain what the
- Reverse engineer an executable file to figure out what the code is
doing.
- Given a binary file, disassemble it to read the assembly instructions.
- Given assembly code for a function which compares input against a
specific string, use
gdb
to figure out what that string is, and provide input to manipulate the comparison.
Stretch goals
- Identify and explain core x86 assembly instructions.
- Explain what the
lea
instruction does. - Explain what the
push
andpop
instructions do.
- Explain what the
- Explain the relationship between assembly code and C code.
- Explain how the
lea
instruction is used in relation to the&
operator and also explain its use for general arithmetic.
- Explain how the
- Explain the usage of key x86 registers.
- Explain what the
%rsp
register is used for in x86 assembly code.
- Explain what the
- Reverse engineer an executable file to figure out what the code is
doing.
- Given assembly code that uses a loop to check relationships among a sequence of numbers, figure out exactly what the loop checks for, and provide a sequence of numbers that will pass the checks.
Extra goals
- Explain the usage of key x86 registers.
- Explain what the
%rbp
register is used for in x86 assembly code.
- Explain what the
Reflection
Fill out the CS 240 Lab 7 Reflection form to complete today’s lab reflection.