Masm32 SDK description, downloads and other helpful links

Main Menu


Started by jj2007, May 23, 2012, 10:16:07 PM

Previous topic - Next topic


One lesson a day keeps the teacher away [somehow]  :lol:

The only thing I really miss for an extension of MASM32 like
MasmBasic is a tutorial to learn step by step the use of the
MACROS library and routines.

Probably some help can be found in the editor and in the
examples, but a Tutorial is always welcome.  :t
There are only two days a year when you can't do anything: one is called yesterday, the other is called tomorrow, so today is the right day to love, believe, do and, above all, live.

Dalai Lama


Changes in the update of 26.12.2012 (attached to first post, details in \Masm32\MasmBasic\MbGuide.rtf):

        AddWin$ hEdit=CrLf$+"[one line more]"        ; append some text to an edit control
        ; this line appends the current date and time to an edit control:
        AddWin$ hEdit=CrLf$+"["+Trim$(Launch$("cmd.exe /C date /T"))+", "+Trim$(Launch$("cmd.exe /C time /T"))+"]"

        Launch "cmd.exe /C time", SW_RESTORE, cb:hEdit        ; launch an app that requires console input; show its output in the edit control
        WritePipe "20:40:50"                        ; set the time
        ; you may add a 0 as second argument if you don't want a CrLf sequence to be appended:
        WritePipe esi, 0        ; write zero-delimited string in esi, do not append CrLf
Rem        will show an error message if the pipe was closed for some reason



it seems you've done a great effort for the new update. Did you burn the midnight oil?

You have to know the facts before you can distort them.


Quote from: Gunther on January 03, 2013, 12:00:20 AM
it seems you've done a great effort for the new update. Did you burn the midnight oil?

Yes I did, Gunther - but I just fixed a "midnight bug". Launch$() returns output from a console proggie, but it is not designed for proggies that expect input, and it choked badly when I tried. Version 2 Jan b behaves better, it just returns La$? to indicate an error.
Changes in the update of 2 Jan 2013 concern the handling of pipes in Launch (more in \masm32\MasmBasic\MbGuide.rtf):

        dec ready2load                ; set the "we launched a process" flag
        Launch esi, SW_MINIMIZE, cb:hOutput  ; cb: = we want to see the output


                .if ready2load        ; flag "we launched a process"
                        .if ExitCode()!=STILL_ACTIVE        ; process finished?
                                and ready2load, 0        ; clear the flag and
                                call LvGetFiles        ; load the processed files

Basically, you can thus:
- launch an external preprocessor
- watch its output in an edit window
- and proceed once the external process is no longer STILL_ACTIVE.

It is now also possible to have a permanent pipe, e.g. with cmd.exe, and to retrieve output from other processes with Launch$() in parallel.


Hi jj,

This code compiles fine and works as expected (with the latest MasmBasic)

include \masm32\MasmBasic\

aNumber dd ?

MovVal aNumber,Input$("Input: ")
add aNumber, 123
Print "Result: ",Str$(aNumber)
end start

But if you shorten the input message like this:

include \masm32\MasmBasic\

aNumber dd ?

MovVal aNumber,Input$("N: ")
add aNumber, 123
Print "Result: ",Str$(aNumber)
end start

Then the result is compilation error

JWasm v2.10pre, Dec 30 2012, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

input.asm(7) : Error A2172: Initializer magnitude too large:
repargA(55)[]: Macro called from
  cStyle$(99)[]: Macro called from
   Input$(3)[]: Macro called from
    input.asm(7): Main line code
input.asm: 11 lines, 1 passes, 78 ms, 0 warnings, 1 errors

Is this a bug?


Quote from: anta40 on January 08, 2013, 02:10:34 PM
Is this a bug?

YES, fat and ugly (but harmless). Will be fixed asap, thanks for the feedback :t

The reason is that "abcd" is an immediate for the macro engine, not a string. For example, you can write mov eax, "abcd" or mov al, "x". But the macro can check for the <"> and then decide to treat it as a string. The bug didn't show up until now because all my test examples had more then four chars - and then JWasm & Ml are clever enough to realise "no, can't fit into 32 bits, so it must be a string". Cute, ain't it?  ;)


Ah I see.
Indeed it's not harmful, just a little annoying.
I was confused for a while why my code wouldn't compile, until somehow I reverted back the input message, and finally the assembler accepted it.



Until the new version is ready, you can use Chr$() as a workaround:

; MovVal aNumber,Input$("nu: ", "1000")
MovVal aNumber, Input$(Chr$("nu: "), "1000")


I have this problem  :(
Then the result is compilation error (5871): error A2102: Symbol not defined: CP_UTF8 (6288): error A2102: Symbol not defined: OFN_ENABLESIZING (6289): error A2102: Symbol not defined: OFN_ENABLESIZING

some solution?


both symbols are defined in

you are simply not including the proper include files
it is possible that you are trying to assemble a file on a different drive than the one where masm32 is installed


Dave is correct, they are defined in

How does your source start? There should be no problem if your first line is
include \masm32\MasmBasic\

On top of you find this:
IFNDEF _wininc_
   include   \masm32\include\
   .686   ; JWasm needs this

In other words, all standard includes are in anyway.


With 145 downloads, the Jan 2 version got a bit stale, so I guess it's time for an update.

Many improvements "under the hood", but also some visible goodies; inter alia, all arrays (strings, byte/word/dword, REAL4/8/10, structures) can now be dynamically defined, e.g.

        Dim My$()
        Dim NormalDist() As DWORD
        Dim Sinus() As REAL8

Note though, that values can be assigned only incrementally, e.g.

        Dim My$()
        Let My$(99)="Hello"        ; illegal, will throw an error
        xor ecx, ecx
                Let My$(ecx)=Str$("#%i", ecx)
                inc ecx
        .Until ecx>9999

The deb macro has learned to display flags (without changing them, of course):

        deb 4, "End of loop:", ecx, flags, FLAGS

flags displays carry, zero, sign and overflow, FLAGS the whole set:

End of loop:
ecx             10000
flags:          czso
FLAGS:          cpAzstIdo

c means carry clear, C carry set, etc.

Last but not least, attached a minimally modified \Masm32\examples\exampl01\generic\generic.asm:
1. Includes were replaced by the usual one-liner: include \masm32\MasmBasic\
2. These few lines were added below "end menu commands":

    ;====== end menu commands ======

    .elseif uMsg == WM_CREATE
        ToolTips start        ; we'd like to see the country names
        ToolTips end

        Dim NormalDist() As DWORD        ; read the data of a normal distribution from file
        ArrayRead NormalDist(), "NormalDist.dat"

        ArrayLoadMap 0, "Europe"        ; load a map

        Dim Sinus() As REAL8        ; define an array for a sinus curve
        xor ecx, ecx
        push 180
        fild stack        ; stack is an equate for dword ptr [esp]
        push ecx
        fstp REAL4 PTR stack[4]
                mov stack, ecx
                fild stack
                fmul REAL4 PTR stack[4]
                fstp Sinus(ecx)
                inc ecx
        .Until ecx>500
        pop ecx
        pop eax

    .elseif uMsg == WM_MOUSEMOVE
                ArrayMapRegion(lParam, 0, hWnd)

    .elseif uMsg == WM_PAINT
        ArrayPlot hWnd, RgbCol(200, 255, 240)                ; init with window (or control) handle and background colour
        ArrayPlot 0, RgbCol(200, 200, 200), lines:2        ; plot map 0 as loaded above, with grey border and 2px lines
        ArrayPlot Sinus()        ; plot the sinus curve defined above
        ArrayPlot NormalDist()
        ; ------ here you could add additional features, e.g. a legend ------
        ArrayPlot exit, "Europe"        ; finish with a title

    .elseif uMsg == WM_CLOSE

The output? Check yourself :biggrin:

P.S.: With more recent MasmBasic versions, replace the start: label with Init, otherwise it will crash.


so - what are we looking at, Jochen ???
is it, in any way, related to the pr0n ban in Iceland ?   :redface:
it seems not to have affected pr0n in Western Europe   :P

btw - when i "install" MasmBasic, where are the read-me's that outline how to do that ?


Quote from: dedndave on March 02, 2013, 10:41:08 AM
btw - when i "install" MasmBasic, where are the read-me's that outline how to do that ?

After unzipping with "use folder names" with the root of your Masm32 as start directory, there is one in

\Masm32\MasmBasic\MbGuide.rtf is more interesting, though ;-)


Quote from: jj2007 on March 02, 2013, 10:45:17 AM\Masm32\MasmBasic\MbGuide.rtf is more interesting, though ;-)
yea, if one has no problem with developing eye cancer  ;-D

BTW: what about double buffering?
MREAL macros - when you need floating point arithmetic while assembling!