Lesson 3 of 15
The MOV Instruction
The MOV Instruction
mov is the most fundamental x86_64 instruction. It copies data from a source to a destination.
Forms of MOV
mov reg, imm ; Load immediate value into register
mov reg, reg ; Copy register to register
mov reg, [mem] ; Load from memory into register
mov [mem], reg ; Store register into memory
mov [mem], imm ; Store immediate into memory
Memory Addressing
x86_64 has powerful addressing modes:
mov rax, [rbx] ; Simple: address in rbx
mov rax, [rbx + 8] ; Base + displacement
mov rax, [rbx + rcx] ; Base + index
mov rax, [rbx + rcx*4] ; Base + scaled index
LEA vs MOV
lea (Load Effective Address) computes an address but does not access memory:
lea rax, [msg] ; rax = address of msg (no memory access)
mov rax, [msg] ; rax = value AT address of msg (memory access)
The EQU Directive
You can define constants with equ:
msg db "Hello", 10
msglen equ 6 ; constant: length of msg
Your Task
Write a program that defines two strings in the data section and prints them both. First print "x86_64 " (7 chars), then print "Assembly\n" (9 chars).
x86_64 runtime loading...
Loading...
Click "Run" to execute your code.