flat assembler
Message board for the users of flat assembler.

Index > Main > A MOV question

Author
Thread Post new topic Reply to topic
bolzano_1989



Joined: 06 Oct 2011
Posts: 4
bolzano_1989
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?
Code:
MOV [myvar1],CH    

Code:
MOV myvar1,CH    


I've just read FASM's document and know that the following 2 statements are different:
Code:
mov eax,3    

Code:
mov eax,[3]    


How about these 2 statements?
Code:
MOV [myvar1],CH    

Code:
MOV myvar1,CH    
Post 06 Oct 2011, 09:56
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

the bottle "x", and the contents of the bottle "[x]" Razz

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 06 Oct 2011, 10:03
View user's profile Send private message Send e-mail Reply with quote
Teehee



Joined: 05 Aug 2009
Posts: 568
Location: Brazil
Teehee
in other words,

Code:
mov eax,3   ; = mov value 3 to eax
mov eax,[3] ; = mov the content of the addresss 3 to eax

MOV [myvar1],CH ; = mov CH value to the address pointed for myvar1.
MOV myvar1,CH   ; this is a invalid operand, doesn't?    


lets say,
Code:
myvar1 dd 33

mov eax,[myvar1] ; eax = 33
mov eax,myvar1   ; eax = 0x04F00000    
Post 06 Oct 2011, 12:51
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
For the assemblers supporting such syntax, mov mem, reg/imm and mov [mem], reg/imm are exactly the same thing, however in fasm no such thing is supported to make sure there is a single way to indicate memory access (i.e. since mov ebx+esi, reg/imm is not supported because you need square brackets in the first operand, then neither mov var, reg/imm is supported, you have to always use mov [var], reg/imm instead).

In the last instruction of Teehee's example, in other assemblers you'd need "mov eax, OFFSET myvar1", but in fasm, using symbos "naked" (without brackets), is the equivalent of using OFFSET.
Post 06 Oct 2011, 13:22
View user's profile Send private message Reply with quote
bolzano_1989



Joined: 06 Oct 2011
Posts: 4
bolzano_1989
Thank you Teehee and LocoDelAssembly Very Happy .
Post 07 Oct 2011, 05:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.