News:

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

Using the invoke statement

Started by Robert Collins, December 23, 2004, 12:31:40 AM

Previous topic - Next topic

Vortex

Hi pbrennick,

One you create the necessary include files, you can use them to call API functions without needing of invoke macro. The ide behind removing invoke is to call functions like in HLLs. This macro system is a good programming exercise for me, it's a matter of personal preference to use this methode.

Hi Robert,

I am not sure that you can build the executable without the stcall macro as it's used extensively in my macro system:

EXTERNDEF MessageBoxA@16:proc
MessageBox equ <stcall MessageBoxA@16,4>

Robert Collins

Quote from: Vortex on December 25, 2004, 09:56:27 AM
Hi pbrennick,

One you create the necessary include files, you can use them to call API functions without needing of invoke macro. The ide behind removing invoke is to call functions like in HLLs. This macro system is a good programming exercise for me, it's a matter of personal preference to use this methode.

Hi Robert,

I am not sure that you can build the executable without the stcall macro as it's used extensively in my macro system:

EXTERNDEF MessageBoxA@16:proc
MessageBox equ <stcall MessageBoxA@16,4>


Hi Vortex,

Well, unless it is hidden from my view I can't see where the usage of the stdcall macro is. I don't think it is in the MACROS.ASM file. But below is the simple code to use the CTEXT macro and it works fine.


.386
.model flat, stdcall
option casemap:none

ExitProcess PROTO  :DWORD 
                         
include    \masm32\include\windows.inc
include    \masm32\include\kernel32.inc
include    \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
;
; Include only for the switch macro
;
include MACROS.ASM                 

CTEXT MACRO y:VARARG
   LOCAL sym, dummy
   dummy EQU $   ;; MASM error fix
   CONST segment
      IFIDNI <y>,<>
         sym db 0
      ELSE
         sym db y,0
      ENDIF
   CONST ends
   EXITM <OFFSET sym>
ENDM

.data
myvalue          dd     25     

.code
start:
      mov eax,myvalue
               
      switch (myvalue)
        case 20
          invoke MessageBox, 0, CTEXT("myvalue == 20"), CTEXT("The Answer Is"), MB_OK
        case 23
          invoke MessageBox, 0, CTEXT("myvalue == 23"), CTEXT("The Answer Is"), MB_OK
        case 25
          invoke MessageBox, 0, CTEXT("myvalue == 25"), CTEXT("The Answer Is"), MB_OK
      endsw   

invoke ExitProcess,0
END start

pbrennick

Robert,
Nice job and the case logic works very nicely.  That is a method worth remembering.  The following line is not necessary because it is already declared in kernel32.inc:

QuoteExitProcess PROTO  :DWORD

Paul