The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bolzano_1989 on October 06, 2011, 04:50:35 AM

Title: A MOV question
Post by: bolzano_1989 on October 06, 2011, 04:50:35 AM
In the following tutorial:
http://www.friedspace.com/assembly/moving.php
, could you tell me the differences and the effects of the differences between the following statements?
MOV [myvar1],CH
MOV myvar1,CH
Title: Re: A MOV question
Post by: NoCforMe on October 06, 2011, 04:54:31 AM
Um, one has square brackets and the other one doesn't?

Really, that's the answer. There's no functional difference between the two statements.

The brackets come in handy when you need to index variables or do other fancy stuff:



MOV AX, [BX + Table + 10]

Title: Re: A MOV question
Post by: bolzano_1989 on October 06, 2011, 05:59:18 AM
I think they're not the same.
Title: Re: A MOV question
Post by: Rockphorr on October 06, 2011, 06:04:02 AM
Quote from: bolzano_1989 on October 06, 2011, 04:50:35 AM
In the following tutorial:
http://www.friedspace.com/assembly/moving.php
, could you tell me the differences and the effects of the differences between the following statements?
MOV [myvar1],CH
MOV myvar1,CH


in masm it is the same

but
mov DX,2
and
mov DX,[2]
is diferent - couse first source data is  imm, and second source data is mem.
Title: Re: A MOV question
Post by: Rockphorr on October 06, 2011, 06:10:25 AM
in mov instruction the target always is address or register name
but source also may be immediate (imm) opperand.
by default masm compiler assumes that is imm if it is digit, when it is register that is awesome.

feel diference betveen masm and fasm


masm                                                                                      fasm
memory_label                                                                           [memory_label]
[memory_label]  <-bracets is not req here                                    [memory_label]
offset(memory_label)                                                                 memory_label
Title: Re: A MOV question
Post by: NoCforMe on October 06, 2011, 06:11:20 AM
Quote from: bolzano_1989 on October 06, 2011, 05:59:18 AM
I think they're not the same.

They are.

From the MASM Programmer's Guide (Microsoft):

QuoteThe index operator can contain any direct memory operand. The following statements are equivalent:



mov ax, var
mov ax, [var]



Some programmers prefer to enclose the operand in brackets to show that the contents, not the address, are used.

Title: Re: A MOV question
Post by: bolzano_1989 on October 06, 2011, 09:48:20 AM
Thank you, Rockphorr and NoCforMe for pointing out some differences between MASM and FASM, I'm reading more.
Title: Re: A MOV question
Post by: dedndave on October 06, 2011, 02:41:03 PM
this may vary from one assembler to another   :U
some may even require the braces
Title: Re: A MOV question
Post by: FORTRANS on October 06, 2011, 08:23:36 PM
Quote from: dedndave on October 06, 2011, 02:41:03 PM
this may vary from one assembler to another   :U
some may even require the braces

Hi,

   Yes, NASM, (The Netwide Assemble)r (and FASM?) do require
them.

Regards,

Steve N.


    MASM                  NASM

MOV AL,Label          MOV AL,[Label]
MOV AL,[Label]        MOV AL,[Label]
MOV EAX OFFSET Label  MOV EAX,label
Title: Re: A MOV question
Post by: dedndave on October 06, 2011, 08:58:23 PM
NASM refers to the address of the label if they are not there
so, there can be a difference   :bg