Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference - MOV instruction

Tags:

x86

assembly

mov

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]
like image 973
Lior Avatar asked Nov 18 '25 06:11

Lior


2 Answers

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.

like image 190
Griwes Avatar answered Nov 20 '25 21:11

Griwes


  1. Simply sets the value of the AL register to 5H
  2. First it sets the SI register to 5H Then it moves the value dereferenced by SI into AL (i.e. whatever was in memory address 5H is now moved into AL).

You can also apply a non-zero base offset when using the index registers like SI, for instance:

MOV AL,[BX + SI]

After first setting BX to the appropriate base offset address.

like image 44
StuartLC Avatar answered Nov 20 '25 19:11

StuartLC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!