Skip to main content
Logo image

Dive Into Systems: Exercises

Section 8.1 Diving into Assembly: Basics

Exercise 8.1.1. Examining Components of Assembly Code (objdump output).

Exercise 8.1.2. Relationship Between C Code and Assembly Code.

    Which of the following statements is true about the relationship between a single line of 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.

Exercise 8.1.3. General-Purpose Registers.

    Which of the following x86-64 registers are general purpose?
  • %eax
  • Correct!
  • %esi
  • Correct!
  • %eip
  • Incorrect. %eip is the instruction pointer. It cannot be directly written to.
  • %edx
  • Correct!

Exercise 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!

Exercise 8.1.5. Registers - Capacity.

Order the following registers from smallest to largest capacity.

Exercise 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)

Exercise 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.