Search code examples
assemblyx86mov

What is the difference - MOV instruction


I've started to learn asm, and I wondered what is the difference between these two different ways of using the MOV instruction into AL:

First:

MOV AL,5H

Second:

MOV SI,5H
MOV AL,[SI]

Solution

  • Those two do different things.

    ; let me use friendlier syntax; IMHO, lower case and 0x5 instead of 5h is more
    ; readable in case of assembly
    mov al, 0x5 ; al = 0x5
    
    mov si, 0x5 ; si = 0x5
    mov al, [si] ; al = *si; that is, al is now what was in memory at address 0x5
    

    There is easy wikibook about x86 assembly that will better explain the concepts and syntax to you: x86 Assembly. Assembly is generally easy language, but it's best to just follow tutorial/book about it, to first fully understand syntax, and then - and only then - jump into wild world of assembly reading and writing.

    Also, for other resources, you can look here.