Can someone explain this code from Iczelion's Tut3...

mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc

Please bear with me... I haven't programmed anything in years, and I am NOT an ASM GuRu, and DEFINATELY don't understand much of this windows stuff. I'm an old DOS programmer. :(

Ok,Correct me if I'm wrong here... The 'mov' statements use the 'C' calling convention, meaning that the rvalue is placed in the lvalue... Right? And, just the opposite with the 'invoke' statements... Using the PASCAL calling convention, the lvalue is placed into the rvalue... Right?

What is 'wc' in the, wc.lpfnWndProc, etc..? WindowsClass? What is 'cb' in cbSize, cbClsExtra, etc..? What is the 'lpsz' in lpszClassName ? LongPointerSize? What is 'lpfn' in lpfnWndProc? LongPointerFunction? How about 'mov wc.hIcon,eax'<?>'WindowsClass.HandleIcon'??? ... And, is this putting the or the $address contained in the eax register into the STRUCT/VAR wc.hIcon? Maybe it doesn't matter, but, would help me to understand just what the abbreviations is for.

What does ' mov wc.hbrBackground,COLOR_WINDOW+1 ' do? Increment some default window color code? Turn something on/off (BOOL)? What is the 'hbr' for?

Icze: Your tuts are very informative, but they don't take into account the lack of familiarity of a new ASM programmer (wanna-be). I can code like a beaver if I am familiar with the syntax, and the ide. :)

Any information would be appreciated!

Thank you,
Posted on 2001-10-08 22:04:13 by n0nuf
Looks like somebody needs Petzold and the Intel Docs here!
Hi there n0nuf, i'll try to shed some light...

1) The MOV does not use any 'calling convention'. Basically because it's not calling anything. The MOV instruction copies from the source operand to the destination operand. Example: MOV EAX,5. That will put a 5 inside the EAX register.

2) INVOKE is a MASM32 macro to avoid PUSHing individual parameters and then CALLing the API or function you need to call.
Instead INVOKE let's you write the call in a more 'high level' (and clear and less error prone and more tidy) fashion.

(little) Example:

CALL ExitProcess

INVOKE ExitProcess,0

Windows uses the STDCALL calling convention. This is a snippet from one of Iczelion's tutorials:

STDCALL is the hybrid of C and PASCAL convention. It passes parameter from right to left but the callee is responsible for stack balancing after the call.Win32 platform use STDCALL exclusively. Except in one case: wsprintf(). You must use C calling convention with wsprintf().

3) wc is a structure. A structure is a very tidy way of treating data. Such facility is provided by the compiler or (in this case) assembler . It's yet another 'commodity' that provides us programmers a very nifty to read and or write bytes.
In this case we're talking about a WNDCLASSEX stucture. Which is needed by the RegisterClassEx API. How to know this? well, i assume you have the Win32API Reference (win32.hlp), an essential tool in the arsenal of the win32 coder, which describes all (or most of it) of the Win32Api.

4) 'What is 'cb' in cbSize'
CB stands for 'Count Bytes' . AFAIK (and correct me here F0dder or any other) this is part of the famous 'Hungarian Notation', which was invented by the legendary Hungary Coder Charles Simoy' during his stay in Redmond.
(Very) Basically the hungarian notation prefixes all the variable names with an identification nmemonic.. So 'iMyValue' would be an
Integer, 'lpMyPtr' would be a Long Pointer and so on. Google around for a second or two to find a complete reference to the mentioned notation.Ah..LPSZ Stands for: Long pointer to a 'String Zero terminated'. or better said a 'zero terminated String'.

5) COLOR_WINDOW is a constant value. This one and many others can be found in '' inside the 'include' sub-dir of the MASM32 directory. Suppose that COLOR_WINDOW's value is 5. Then 'mov wc.hbrBackground,COLOR_WINDOW+1 ' would move a 6 to the 'hbrBackground' member of the wc structure. easy :) ah..HBR is a BRush Handle.

Don't be scared for the wealth of information. Just stick to Iczelion's tutorials and the usual books on x86 asm. I learned the x86 basics with 'Peter Norton's 8088 asm book' (thanks magicmac!!!!!) but any (any of the classic ones) PDF out there will make it.

I'd also recommend -= buying =- Charles Petzold's 'Programming Windows' for it's the best Windows coding introductory book ever printed. Petzold is a gifted teacher who will show you the ins and outs of the Win32Api and you'll learn it all in no time (if you are a geek like most of us here :) )

Well..i know i skipped a couple of your questions..but worry not, cos other members are typing their answers right now :)
Happy coding !
Just keep asking if you got doubts, but do read the Intel docs and Petzold's material :)

Bye !!!!!!

Posted on 2001-10-08 23:02:29 by latigo
Hey Larigals, thanks a lot for that big answer !!! :)
It gave me some light also ... :)
Madafaca, you know the History !! :)

cu on Wednesday (if madafaca Yoshquele gimme a break)...

-Your madafaca Friend. :)
Posted on 2001-10-08 23:52:38 by magicmac

I'm in a similar predicament being an old coder waking to modern Win32asm and I'd like to suggest visiting Iczelion's site:

There's lots of well-documented source there to learn from, and be sure to get the Win32 API reference Helpfile on the download page which will answer most all your questions as to syntax and what different structure elements there are.

And welcome to Win32asm :alright:
Posted on 2001-10-09 00:41:42 by gscundiff
hehe...i'm a lighter..
See you on Wednesday if that boss of yours drops the leash...hehehe
Leave my friend alone you cos he's no slave !!!!!

Posted on 2001-10-09 08:54:50 by latigo