Skip to main content
Logo image

Dive Into Systems: Exercises

Section 7.1 Diving into Assembly: Basics

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

Exercise 7.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 7.1.3. General-Purpose Registers.

    Which of the following x86-64 registers are general purpose?
  • %rax
  • Correct!
  • %rsi
  • Correct!
  • %rip
  • Incorrect. %rip is the instruction pointer. It cannot be directly written to.
  • %r8
  • Correct!

Exercise 7.1.4. Special Use Cases for Registers.

Did you know? Register x0 is also used to hold the return value of a function!

Exercise 7.1.5. Registers - Capacity.

Order the following registers from smallest to largest capacity.

Exercise 7.1.6. Identifying Operand Types.

For each of the following operands, label it as a (C)onstant, (R)egister, or (M)emory operand.
  • %rax
  • (%rax)
  • (%rax, %rbx, 4)
  • $0x5
  • 0x5
  • $8
Just enter the letter as your answer (one of C, R, or M)

Exercise 7.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
%rax 0xFA08
%rdx 0x2
For each of the following operands, determine the associated value in hex.
  • %rax
  • %rdx
  • (%rax)
  • (%rax, %rdx, 4)
  • -0x8(%rax)
  • (%rax, %rdx, 8)
Remember to include the 0x prefix in your answers.