ASSEMBLY / CHAPTER 01

Registers and operand widths

Master

Read conceptual x86-64 instruction traces in NASM-style Intel syntax.

By the end of this chapter

  • Identify destination-first operands
  • Distinguish RAX, EAX, and AL writes
  • Trace a register without assuming console output

The idea

Enter with binary integers and systems programming experience. Every example in this course uses x86-64 NASM-style Intel syntax, with the destination operand first. These are conceptual instruction traces for a Linux setting, not programs that run in the browser. Registers hold bit patterns; the instructions and your interpretation determine whether those patterns represent numbers, addresses, or other data.

RAX names a sixty-four-bit register, EAX its low thirty-two bits, and AL its low eight bits. Writing EAX clears the upper half of RAX. Writing AL changes only that byte and preserves the remaining bits. Operand width is therefore part of the computation. Track the complete register when mixing widths, and report final state rather than inventing output from a snippet with no output operation.

Assembly example
; Conceptual trace: no I/O
mov rax, -1
mov eax, 5
mov al, 9
Result
Final RAX = 9; no console output.

The EAX write zeroes RAX’s upper thirty-two bits. The AL write then changes its low byte from five to nine.

Try it yourself

Trace mov eax, 256 followed by mov al, 3 and state the final RAX value.

Use your own editor for this exercise. Runnable challenges on CodeQuest are available for JavaScript, Python, and SQL.

CHECK YOUR UNDERSTANDING

Chapter checkpoint

After this trace, what is RAX?
mov rax, -1
mov eax, 2