The MASM Forum

General => The Campus => Topic started by: amrak on April 30, 2015, 04:51:34 AM

Title: Doubt on Iczelion's Win32 Assembly tutorial
Post by: amrak on April 30, 2015, 04:51:34 AM
Hi, I am a bit confused with the following statement from http://win32assembly.programminghorizon.com/tut3.html (http://win32assembly.programminghorizon.com/tut3.html) the tutorial I am refering to at the moment.
.code
start:
invoke GetModuleHandle, NULL
mov    hInstance, eax
invoke GetCommandLine
mov    CommandLine,eax
invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess, eax

Is the statement mov    hInstance, eax
and mov eax, hInstance the same.  As I have understood from the books I have refered so far, mov instruction will move the contents/address of the operand after coma (eax) into the operand before the coma (hInstance). I changed the code into mov eax, hInstance and run it, I still get the same result which makes me believe that there is no difference at least for this mov operation. Are they the same and what is really getting moved in this code?  Great tutorial though!
Title: Re: Doubt on Iczelion's Win32 Assembly tutorial
Post by: dedndave on April 30, 2015, 05:20:39 AM
for MASM syntax,
mov destination,source
some assemblers reverse the operands though - i hate them - lol

"i get the same result" will depend on how you verify that fact   :P
Title: Re: Doubt on Iczelion's Win32 Assembly tutorial
Post by: amrak on April 30, 2015, 05:52:47 AM
Thanks @Dedndave. Please can you tell me why there is a NULL in here (invoke GetModuleHandle, NULL). Is it there for the same reason as terminating a string with null
Title: Re: Doubt on Iczelion's Win32 Assembly tutorial
Post by: dedndave on April 30, 2015, 05:57:49 AM
NULL indicates that you want the handle of the current process
in some cases, you might want the handle of some other module...
    .DATA

szKernel32 db 'kernel32.dll',0

    .CODE

    INVOKE  GetModuleHandle,offset szKernel32


https://msdn.microsoft.com/en-us/library/windows/desktop/ms683199%28v=vs.85%29.aspx (https://msdn.microsoft.com/en-us/library/windows/desktop/ms683199%28v=vs.85%29.aspx)
Title: Re: Doubt on Iczelion's Win32 Assembly tutorial
Post by: habran on April 30, 2015, 06:24:35 AM
NULL means ZERO it is 0 and it is assembled to 0
it means empty handle or pointer
if you write 0 that means it is ZERO integer
if you write FALSE that means ZERO Boolean
we write it that way for us programmers for better understanding
computers don't care, they want there a zero and assemblers translate it for them :biggrin:

Title: Re: Doubt on Iczelion's Win32 Assembly tutorial
Post by: dedndave on April 30, 2015, 02:32:21 PM
sorry - i misunderstood the question
NULL is a standard windows constant that is defined in windows.inc
as Habran mentioned...
NULL EQU 0
Title: Re: Doubt on Iczelion's Win32 Assembly tutorial
Post by: amrak on April 30, 2015, 11:53:59 PM
Thank you Dedndave and Habran