Peter Mawhorter
There’s too much information here for us to understand all at once. But as in other parts of the class, we are honing our dealing-with-information-overload skills:
INST OPERAND, DEST ↔︎ add %rdi, %rax
mov
vs. movl
).Beware Intel vs. AT&T syntax and GAS vs. NASM vs. MASM (we use AT&T/GAS)
%RRR
or %RR
- register name (%rax
,
%ah
)$CONST
- constant value
($0xF0
, $240
)
0x
prefixNUMBER
- constant memory
address (0xF0
, 123
)
$
means memory accessNUMBER(%RRR, %RRR, STRIDE)
-
variable memory address
8(%rdi, %rsi, 4)
mov
copies stuffj*
jumps (lots of varieties
like je
, jge
, etc.)cmp
/test
compares (to set up for conditional
like je
)push
and pop
stores/reads stacklea
stores address in register
(think of &
)
Credit to Ben Wood for “Lovely Efficient Arithmetic”
Apparently this mnemonic is from Geoff Kuenning who I took classes from at HMC
ADD R1, R2, R3
vs. add %rdi, %rax
x = a + b
we only get
x += a
ADD R1, R1, R6
vs. mov $2, %rsi
LW R2, 3(R5)
vs. mov 3(%rax, %rdi, 8), %rdx
BEQ R1, R2, 3
vs. cmp $rax, $rdi
/ jeq 0x54321
push
, pop
, call
and ret
)objdump -d
or disas
command within
gdb
-S
flag for gcc
to
get a file
-O0
(the default) does no optimization; many
things will be stored on the stack unnecessarily-O3
does lots of optimization; gets stuff done
without the stack where possiblestring_length_a
objdump -d practice.bin
gdb practice.bin
and then
disas string_length_a