Menu
Coddy logo textTech

MOV Register to Register

Part of the Fundamentals section of Coddy's Assembly journey — lesson 16 of 45.

Now that you know how to put a number directly into a register (MOV immediate), you can also copy values between registers.

Syntax:

mov destination_register, source_register

The value from the source register is copied into the destination register. The source register remains unchanged.

Example:

mov rax, 5      ; rax = 5
mov rbx, rax    ; rbx = 5 (copied from rax)

After these two instructions, both rax and rbx contain 5.

Important: The source register (rax) still has its value. MOV copies — it does not cut or move.

Another example:

mov rax, 7      ; rax = 7
mov rcx, 3      ; rcx = 3
mov rdx, rcx    ; rdx = 3 (copied from rcx)
mov rbx, rax    ; rbx = 7 (copied from rax)

After these instructions:

RegisterValue
rax7
rcx3
rdx3
rbx7

Why this matters:

  • You can save a value by copying it to another register before changing the original
  • You can reuse values without loading from memory again
  • This is the foundation of most assembly operations
challenge icon

Challenge

Write the assembly code for these tasks:

  1. Put the number 4 into rax
  2. Copy the value from rax into rbx
  3. Copy the value from rbx into rcx

After your code, all three registers should contain 4.

Try it yourself

section .data
    msg_rax db 'rax = '
    msg_rax_len equ $ - msg_rax
    msg_rbx db 'rbx = '
    msg_rbx_len equ $ - msg_rbx
    msg_rcx db 'rcx = '
    msg_rcx_len equ $ - msg_rcx

section .bss
    digit resb 1

section .text
    global _start

_start:
    %include "solution.asm"
    
    ; Save values
    mov r12, rax
    mov r13, rbx
    mov r14, rcx
    
    ; Print "rax = "
    mov rax, 1
    mov rdi, 1
    mov rsi, msg_rax
    mov rdx, msg_rax_len
    syscall
    
    ; Print rax value
    mov rax, r12
    add rax, 48
    mov [digit], al
    mov rax, 1
    mov rdi, 1
    mov rsi, digit
    mov rdx, 1
    syscall
    
    ; Print "rbx = "
    mov rax, 1
    mov rdi, 1
    mov rsi, msg_rbx
    mov rdx, msg_rbx_len
    syscall
    
    ; Print rbx value
    mov rax, r13
    add rax, 48
    mov [digit], al
    mov rax, 1
    mov rdi, 1
    mov rsi, digit
    mov rdx, 1
    syscall
    
    ; Print "rcx = "
    mov rax, 1
    mov rdi, 1
    mov rsi, msg_rcx
    mov rdx, msg_rcx_len
    syscall
    
    ; Print rcx value
    mov rax, r14
    add rax, 48
    mov [digit], al
    mov rax, 1
    mov rdi, 1
    mov rsi, digit
    mov rdx, 1
    syscall
    
    ; Exit
    mov rax, 60
    mov rdi, 0
    syscall
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals