Memory refrencing Assembly Language
i am a beginner in assembly language i understand many things till now but for many days i stuck in one section it's confusing to me and what make it worst that through the many pages i visited over internet the information is twisted again ,this section is the Addressing Modes specifcally the memory refrence so for example in this Addressing Modes in Assembly Language (IA-32 NASM)
two instructions seems same but the comment is diffrent
specified by eax
both instructions deals with var or var1 which are labels but in comments for one it's mentioned it's copy the content ,while for the other it's copy the address.
and so another question i ask what will be the cooment for this instruction:
and what is the diffrence between these instructions also
so i need to know what is difference and is there is a confidence source that i can read from and be sure it's correct,by the way i'am using this tutorial,and NASM as assembler under windows.
mov dword [eax], var1
: copies value in var1 into the memory slot specified by eax
Nope. If var1
is a label, this will store the address of var1
as a 32-bit value into the memory pointed to by eax
. For example, if the address of var1
is 0x04000000
and eax contains 0x12345678
then this would write 0x04000000
to memory at 0x12345678
.
what will be the comment for this instruction: mov bx, [var]
?
; Move the word located at var into bx
(note: "move" in assembly really means copy)
mov [var], bx
is this only applicaple if var
is an array? if not what it differ from mov var, bx
?
Types aren't really enforced by the assembler. You can store anything anywhere (well, anywhere that your program is allowed to write to). So what you declared var
as is largely irrelevant. There could be code located at var
for all the assembler cares (that would probably not be such a good idea unless you really know what you're doing).
The difference to mov var,bx
is that mov var,bx
isn't a valid instruction. The address of var
is an immediate, so this would be kind of like saying mov 5, bx
, which obviously doesn't work.
lea eax, [var]
— the value in var
is placed in EAX
No. The address of var
is placed in eax
. LEA
means Load Effective Address. You give it a memory operand the same way as if you were going to access memory, but instead of the value at that address you get the address itself.
LEA
can also be used to perform some simple arithmetic. For example, lea ebx,[eax*4 + eax]
would calculate eax*5
and put the result in ebx
.
LEA EBX, [MY_TABLE]
here its mean effective address
Yes. There's no difference between this and the previous example.
链接地址: http://www.djcxy.com/p/72424.html上一篇: 确定NASM何时可以推断mov操作的大小
下一篇: 内存折叠汇编语言