News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Some Basic Questions

Started by just_curious, May 07, 2005, 12:17:05 AM

Previous topic - Next topic

just_curious

Hi All,
Simple Questions...
Can anyone tell me exactly what the differnence between

call blahblahblah

and

invoke blahblahblah

is?

Also...
.if and .else statements, is this just an easier way to do this than jxx? Is a jxx statement faster? And where are these macros defined (if that is indeed what they are still called) so that I can take a look at them.

Sorry about the questions being probably some what strange and simple... just the material I read didn't bring back any memories and looking at the code pasted here is somewhat discouraging, I used to know this  :(  I may just be confused as to the original calling conventions, in High school I played with asm, I no longer have my books and everything turned into 32bits... the technology is frightening.
Thanks All.

hutch--

just_curious,

CALL is a direct processor mnemonic where INVOKE is an internal prcess in MASM that automates manual PUSH/CALL syntax. They both have their place in MASM coding.

With a simple example in win32, a system MessageBox is done this way manually.


push MB_OK
push OFFSET TitleText
push OFFSET MessageText
push wHandle
call MessageBox


With the invoke syntax you do it like this,


invoke MessageBox,wHandle,ADDR MessageText,ADDR TitleText,MB_OK


Invoke is very useful for the vast majority of hack OS function calls but if you need to run it manally instead, its no big deal to do.

32 bit code is actually a lot simpler than the old segmented 16 bit code and it is far more powerful. What most people balk at is the number of system API calls available. Differing from DOS where you use interrupts, Windows supplies OS functionality through the API functions with a far greater range.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

raymond

The other main advantage of invoke vs push/call is that MASM checks if the correct number of parameters are being passed to the function being called. Each function called with the invoke statement must have a declared "prototype" indicating the number and types of parameters required by the function.

Without using invoke, the number of parameters pushed separately on the stack is NOT checked. Missing a parameter would most probably lead to the crashing of the program when the function returns and adjusts the stack according the number of parameters it was supposed to receive, not to mention that it may produce an erroneous result or even crash itself.

And your source code is a bit easier to read in addition to saving a bit of typing.

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com