Concepts/Memory/Writing to memory: Wrong memory size in mov

In the introduction relating to Color Palette in x86-64 Assembly on Exercism

In the section called “Writing to memory”, example3 is a dword, but rax is a qword, and it fails.

Should it be the variable to be changed or pass eax instead?

Sample:

section .data
    example1 db 10            ; example1 is a 1-byte memory location initialized with value 10
    example2 dq -456          ; example2 is a 8-byte memory location initialized with value -456
    example3 dd 54            ; example3 is a 4-byte memory location initialized with value 54

section .text
fn:
    mov byte [example1], 20   ; example1 now has value 20
    mov qword [example2], rdx ; example2 now has value equal to the contents in rdx
    mov dword [example3], rax ; example3 now has value equal to the contents in rax

I opened

2 Likes

This probably, given:

example3 is a 4-byte […]

cc @oxe-b

1 Like

@IsaacG Could you please move this to Programming > x86-64 Assembly?

2 Likes