News:

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

Main Menu

Can you detect assembling under ML.EXE as opposed to under Visual Studio?

Started by Rav, June 07, 2022, 10:31:28 AM

Previous topic - Next topic

Rav

When assembling my assembly routine, I want to have a section of conditional assembly which is only included if assembly is occurring via ML.EXE (from the Windows command prompt), and not include that section if it's being assembled within the Visual Studio app (by clicking the Local Windows Debugger button).  For example, I could pass some argument to ML.EXE which an IF statement in the assembly routine could detect the presence of.  Or I could set a Windows environment variable only when I'm running ML.EXE -- similarly, the IF statement would read the environment variable and decide to assemble (or not) the conditional section based on the environment variables contents.  For example, something like this:

; Include the following statements if we're being assembled by ML.EXE:
IF "%isRunUnderML%" == "1"
   statement
   statement
ENDIF

Thanks for any leads.  / Rav

jj2007

If you assemble a source using a batch file, you can set an environment variable. RichMasm, for example, recognises comment lines starting with OPT_xxx, such as OPT_Susy Console, and passes them on as e.g. set oSusy=console. In your code, you can access the variable as follows:

ifidni @Environ(oSusy), <Windows>
MsgBox 0, fname, "Map not found:", MB_OK
else
Inkey "Map not found: ", fname
endif


If you assemble a windows GUI application with /Subsystem:Windows, an Inkey would be dangerous because the user will never see it - therefore the MsgBox.

Rav

Quote from: jj2007 on June 07, 2022, 11:01:58 AM
If you assemble a source using a batch file, you can set an environment variable. RichMasm, for example, recognises comment lines starting with OPT_xxx, such as OPT_Susy Console, and passes them on as e.g. set oSusy=console. In your code, you can access the variable as follows:

ifidni @Environ(oSusy), <Windows>
MsgBox 0, fname, "Map not found:", MB_OK
else
Inkey "Map not found: ", fname
endif


If you assemble a windows GUI application with /Subsystem:Windows, an Inkey would be dangerous because the user will never see it - therefore the MsgBox.

ifidni @Environ works perfectly!  Thanks!  / Rav