The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Vineel Kumar Reddy Kovvuri on May 15, 2007, 05:25:03 PM

Title: please help me....
Post by: Vineel Kumar Reddy Kovvuri on May 15, 2007, 05:25:03 PM



hi everybody

i am new to assembly and trying to understand the various possible combinations of mov instructions

please look at the following code

include c:\masm32\include\masm32rt.inc

.data
n db 10,20,30
x db ?
.code
start:
cls
lea  esi ,x
mov byte ptr [esi] ,10             ; This is working fine
mov byte ptr [esi] ,n[0]          ;This is not compiling

print str$(x)

exit
end start



plz clarify the differnce b/w the above two mov instructions whats wrong with the second one .


thanks in advance



Title: Re: please help me....
Post by: Vortex on May 15, 2007, 06:34:36 PM
mov     al,BYTE PTR n[0]
mov     BYTE PTR [esi],al
Title: Re: please help me....
Post by: sebart7 on May 15, 2007, 06:49:50 PM
In short, You may NOT use direct memory to memory transfers like mov memory, memory
You should move it to register first and then from register back to memory like Vortex's example above show.

Title: Re: please help me....
Post by: raymond on May 16, 2007, 05:25:18 AM
And, as you experienced yourself, you CAN also move immediate values directly to memory without using registers.

Raymond