Section 9.1 Diving into Assembly: Basics
Exercise 9.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?
Exercise 9.1.3. General-Purpose Registers.
x0
- Correct!
x30
- Correct!
pc
- Incorrect.
pc
is the program counter. It cannot be directly written to. x2
- Correct!
Which of the following x86-64 registers are general purpose?
Exercise 9.1.4. Special Use Cases for Registers.
Answer.
Did you know? Register x0 is also used to hold the return value and the first argument to a function!
Exercise 9.1.5. Registers - Capacity.
Order the following registers from smallest to largest capacity.
Exercise 9.1.6. Identifying Operand Types.
For each of the following operands, label it as a (C)onstant, (R)egister, or (M)emory operand.
x3
[x3]
[x3, #8]
[x3, x4]
#0x5
#8
Hint.
Just enter the letter as your answer (one of C, R, or M)
Exercise 9.1.7. Identifying Operand Types.
The following tables provide the contents of several registers and memory locations.
Address | Value |
---|---|
0xFA00 | 0x5F |
0xFA08 | 0x16 |
0xFA10 | 0x42 |
0xFA18 | 0x9C |
Register | Value |
---|---|
x0 | 0xFA08 |
x1 | 0x10 |
For each of the following operands, determine the associated value in hex.
x0
x1
[x0]
[x0, #8]
[x0, x1]
#0xFA18
Hint.
Remember to include the 0x prefix in your answers.