Section 8.1 Diving into Assembly: Basics
Checkpoint 8.1.2. Relationship Between C Code and Assembly Code.
- One line of C code always translates into exactly one assembly instruction.
- Incorrect.
- One line of C code often translates into one or more assembly instructions.
- Correct!
- One line of C code always translates into two or more assembly instructions.
- close, but incorrect!
- There is no relationship between C code and assembly code.
- Incorrect.
Which of the following statements is true about the relationship between a single line of C code and assembly code?
Checkpoint 8.1.3. General-Purpose Registers.
%eax
- Correct!
%esi
- Correct!
%eip
- Incorrect.
%eip
is the instruction pointer. It cannot be directly written to. %edx
- Correct!
Which of the following x86-64 registers are general purpose?
Checkpoint 8.1.4. Special Use Cases for Registers.
Answer.
Did you know? Register %eax is also used to hold the return value of a function!
Checkpoint 8.1.5. Registers - Capacity.
Order the following registers from smallest to largest capacity.
Checkpoint 8.1.6. Identifying Operand Types.
For each of the following operands, label it as a (C)onstant, (R)egister, or (M)emory operand.
%eax
(%eax)
(%eax, %ebx, 4)
$0x5
0x5
$8
Hint.
Just enter the letter as your answer (one of C, R, or M)
Checkpoint 8.1.7. Identifying Operand Types.
The following tables provide the contents of several registers and memory locations.
Address | Value |
---|---|
0xFA00 | 0x5F |
0xFA04 | 0x16 |
0xFA08 | 0x42 |
0xFA0c | 0x9C |
Register | Value |
---|---|
%eax | 0xFA04 |
%edx | 0x2 |
For each of the following operands, determine the associated value in hex.
%eax
%edx
(%eax)
(%eax, %edx, 2)
-0x4(%eax)
(%eax, %edx, 4)
Hint.
Remember to include the 0x prefix in your answers.