The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: Larry Hammick on November 22, 2009, 05:39:34 PM

Title: A simple space-saving macro
Post by: Larry Hammick on November 22, 2009, 05:39:34 PM
It would go in windows.inc or whatever file contains your favorite macros.
includem MACRO m1,m2,m3,m4,m5,m6,m7,m8,m9,m10
   IRP s,<m1,m2,m3,m4,m5,m6,m7,m8,m9,m10>
      IFB <s>
         EXITM
      ENDIF
      include \masm32\include\s.inc
      includelib \masm32\lib\s.lib
   ENDM
ENDM

so, for example, you can go
includem user32,kernel32,gdi32
instead of this familiar stuff
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
include \masm32\include\gdi32.inc
includelib \masm32\lib\gdi32.lib


Title: Re: A simple space-saving macro
Post by: dedndave on November 22, 2009, 06:42:09 PM
a lot of us just use "include \masm32\include\masm32rt.inc"
you may want to take a look inside that file to see what it has
although - nice macro, anyways
Title: Re: A simple space-saving macro
Post by: japheth on November 22, 2009, 06:58:37 PM

includem MACRO m1,m2,m3,m4,m5,m6,m7,m8,m9,m10
   IRP s,<m1,m2,m3,m4,m5,m6,m7,m8,m9,m10>
      IFB <s>
         EXITM
      ENDIF
      include \masm32\include\s.inc
      includelib \masm32\lib\s.lib
   ENDM
ENDM


using VARARG qualifier simplifies this macro:


includem MACRO m:VARARG
   IRP s,<m>
      include \masm32\include\s.inc
      includelib \masm32\lib\s.lib
   ENDM
ENDM

Title: Re: A simple space-saving macro
Post by: jj2007 on November 22, 2009, 07:14:57 PM
Quote from: dedndave on November 22, 2009, 06:42:09 PM
a lot of us just use "include \masm32\include\masm32rt.inc"

One might suspect that assembly takes longer if unnecessary files are being included. Here are some timings:
Manual as below:
JWasm 290
ml 460

masm32rt.inc:
JWasm 310
ml 510

MasmBasic.inc (includes masm32rt.inc plus many macros):
JWasm 270
ml 480



Conclusion: It doesn't matter. Be lazy and use masm32rt.inc
(but the macro is nice and useful anyway :thumbu)

      .486                                      ; create 32 bit code
      .model flat, stdcall                      ; 32 bit memory model
      option casemap :none                      ; case sensitive

      include \masm32\include\windows.inc       ; main windows include file
      include \masm32\include\masm32.inc        ; masm32 library include
      include \masm32\include\user32.inc
      include \masm32\include\kernel32.inc

      include \masm32\macros\macros.asm         ; masm32 macro file
      includelib \masm32\lib\masm32.lib         ; masm32 static library
      includelib \masm32\lib\user32.lib
      includelib \masm32\lib\kernel32.lib

.code
start:
MsgBox 0, "Hello World", "Hi", MB_OK
exit ; short form of invoke ExitProcess, 0

end start
Title: Re: A simple space-saving macro
Post by: Larry Hammick on November 23, 2009, 08:10:38 AM
Thanks, folks. I hadn't heard about masm32rt.inc.
Title: Re: A simple space-saving macro
Post by: hutch-- on November 28, 2009, 03:24:27 PM
Larry,

You may like thios one, its in the tail end of the masm32 macros file.


comment * -------------------------------------------------

        The "uselib" macro allows names that are used for
        both include files and library file to be used in a
        list without extensions. Note the following order
        of include files where WINDOWS.INC should be
        included first then the main macro file BEFORE this
        macro is called.

        include \masm32\include\windows.inc
        include \masm32\macros\macros.asm
        uselib masm32,gdi32,user32,kernel32,Comctl32,comdlg32,shell32,oleaut32,msvcrt

        ------------------------------------------------- *

    uselib MACRO args:VARARG
      LOCAL acnt,buffer,var,lbl,libb,incc,buf1,buf2
      acnt = argcount(args)
      incc equ <include \masm32\include\>
      libb equ <includelib \masm32\lib\>
      var = 1
    :lbl
      buffer equ getarg(var,args)

      buf1 equ <>
      buf1 CATSTR buf1,incc,buffer,<.inc>
      buf1
      ;; % echo buf1

      buf2 equ <>
      buf2 CATSTR buf2,libb,buffer,<.lib>
      buf2
      ;; % echo buf2

      var = var + 1
      IF var LE acnt
        goto lbl
      ENDIF
    ENDM

  ; -----------------------------------------------