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-bit | 32-bit | 16-bit | 8-bit (low) |
|---|---|---|---|
rax | eax | ax | al |
rbx | ebx | bx | bl |
rcx | ecx | cx | cl |
rdx | edx | dx | dl |
rsi | esi | si | sil |
rdi | edi | di | dil |
rsp | esp | sp | spl |
rbp | ebp | bp | bpl |
r8 | r8d | r8w | r8b |
| ... | ... | ... | ... |
r15 | r15d | r15w | r15b |
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:
- Stores the value 72 in
rax(ASCII for 'H') - Stores 105 in
rbx(ASCII for 'i') - Stores 10 in
rcx(newline) - 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.