Menu
Coddy logo textTech

Recap: MOV Challenge

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

challenge icon

Challenge

This challenge will test your understanding of:

  • Loading values from memory
  • Storing values to memory
  • Copying between registers
  • Using the correct register size

The data addresses are already created for you. You only need to write the MOV instructions.

Challenge

Complete the following tasks in order. Write one line of assembly for each task.

Data already provided:

  • num1 — contains the value 8 (1 byte)
  • num2 — contains the value 3 (1 byte)
  • result — empty space (1 byte)

Tasks:

  1. Load the value from num1 into al
  2. Load the value from num2 into bl
  3. Copy the value from bl into cl
  4. Store the value from al into result

After your code:

  • al should contain 8
  • bl should contain 3
  • cl should contain 3
  • Memory at result should contain 8

Try it yourself

section .data
    msg_al db 'al = '
    msg_al_len equ $ - msg_al
    msg_bl db 'bl = '
    msg_bl_len equ $ - msg_bl
    msg_cl db 'cl = '
    msg_cl_len equ $ - msg_cl
    msg_result db 'result = '
    msg_result_len equ $ - msg_result
    newline db 0xa

section .bss
    digit resb 1

section .text
    global _start

_start:
    ; Student's code runs first
    
    %include "solution.asm"
    
    mov r12, rax
    mov r13, rbx
    mov r14, rcx
    mov r15, 0
    mov r15b, [result]

    mov rax, 1
    mov rdi, 1
    mov rsi, msg_al
    mov rdx, msg_al_len
    syscall

    mov rax, r12
    add rax, 48
    mov [digit], al
    mov rax, 1
    mov rdi, 1
    mov rsi, digit
    mov rdx, 1
    syscall

    mov rax, 1
    mov rdi, 1
    mov rsi, newline
    mov rdx, 1
    syscall

    mov rax, 1
    mov rdi, 1
    mov rsi, msg_bl
    mov rdx, msg_bl_len
    syscall

    mov rax, r13
    add rax, 48
    mov [digit], al
    mov rax, 1
    mov rdi, 1
    mov rsi, digit
    mov rdx, 1
    syscall

    mov rax, 1
    mov rdi, 1
    mov rsi, newline
    mov rdx, 1
    syscall

    mov rax, 1
    mov rdi, 1
    mov rsi, msg_cl
    mov rdx, msg_cl_len
    syscall

    mov rax, r14
    add rax, 48
    mov [digit], al
    mov rax, 1
    mov rdi, 1
    mov rsi, digit
    mov rdx, 1
    syscall

    mov rax, 1
    mov rdi, 1
    mov rsi, newline
    mov rdx, 1
    syscall

    mov rax, 1
    mov rdi, 1
    mov rsi, msg_result
    mov rdx, msg_result_len
    syscall

    mov rax, r15
    add rax, 48
    mov [digit], al
    mov rax, 1
    mov rdi, 1
    mov rsi, digit
    mov rdx, 1
    syscall

    mov rax, 1
    mov rdi, 1
    mov rsi, newline
    mov rdx, 1
    syscall

    mov rax, 60
    mov rdi, 0
    syscall

All lessons in Fundamentals