Lesson 2 of 15

Registers

x86_64 Registers

x86_64 processors have 16 general-purpose 64-bit registers. Each register can also be accessed as smaller sub-registers:

64-bit32-bit16-bit8-bit (low)
raxeaxaxal
rbxebxbxbl
rcxecxcxcl
rdxedxdxdl
rsiesisisil
rdiedididil
rspespspspl
rbpebpbpbpl
r8r8dr8wr8b
............
r15r15dr15wr15b

Important Rule

When you write to a 32-bit register (like eax), the upper 32 bits of the corresponding 64-bit register (rax) are automatically zeroed. This does not happen with 8-bit or 16-bit writes.

Using mov to Set Registers

The mov instruction copies data:

mov rax, 42       ; rax = 42
mov rbx, rax      ; rbx = rax (copy)
mov rcx, 0xFF     ; rcx = 255 (hex)

Your Task

Write a program that:

  1. Stores the value 72 in rax (ASCII for 'H')
  2. Stores 105 in rbx (ASCII for 'i')
  3. Stores 10 in rcx (newline)
  4. Writes the character 'H' to stdout, then 'i', then a newline

Hint: To write a single byte, you can store it in memory on the stack and point rsi at it.

x86_64 runtime loading...
Loading...
Click "Run" to execute your code.