Search code examples
assemblymacrosx86masm32

x86 assembly (masm32) - alternatives to built-in macros


I've been wondering whether using all those include statements at the start of a file is just slowing down the runtime speed of programs because it has to find the file, open it, initialize the code, and then run it. And I am using all these:

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

So I've been thinking, since macros are essentially calling a function of code to save you writing it yourself, I would like to use the actual code, to save my program having to find, initialize and call all these files at the start of my program.

ACTUAL QUESTION:

Now that I've told you what I'm thinking, I can tell you my question. Could someone provide me with the actual code to the StdOut, invoke and ExitProcess macros, because they are the ones that I use most of the time. Any help would be greatly appreciated.


Solution

  • The .inc files are assembler include files and only slow down compilation. Generally only the macros you use will impact your code in any way.

    The .lib files contain lots of tiny chunks of code (.obj files), and only the chunks containing the functions you use will be linked into your program. So for the most part there is little point in worrying about it.

    FYI the MASM32 installer installs and compiles the library source code. look in the include and m32lib directories under your root directory (probably C:\MASM32).

    Note that you may not be allowed to simply copy the code from the source files, but you are allowed to learn what the code does and then re-implement the functionality yourself, which wouldn't be very hard because they are all rather small.