News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Macro for argument count testing in procedure calls.

Started by hutch--, October 26, 2016, 01:04:06 AM

Previous topic - Next topic

hutch--

I have got used to the economy of not be burdened with endless prototypes but I have tested a macro that does reliable arg count testing. The multiple argument macro ".ma" is used to reduce the line count so you could fit more pseudo prototypes into a smaller space.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .MessageBox MACRO args:VARARG
      .ma cnterr .MessageBox,4,args # invoke __imp_MessageBoxA,args
    ENDM

    cnterr MACRO mname,cnt,args:VARARG
      IF argcount(args) NE cnt
      echo ****************************************************
      echo mname Incorrect Argument Count, cnt Expected
      echo ****************************************************
      .err <mname Incorrect Argument Count, cnt Expected>
      ENDIF
    ENDM

    api MACRO args:VARARG
      args
      EXITM <rax>
    ENDM

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    LOCAL rval :QWORD

    .MessageBox 0,"Statement Version","Test 1",MB_OK

    mov rval, api(.MessageBox 0,"Function Version","Test 2",MB_OK)

    invoke ExitProcess,0

    ret

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end