include \masm32\include\masm32rt.inc
if 0 ; MasmBasic redefinition of the Masm32 macro (this is not the Exit (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1010) macro!)
exit macro optional_return_value:=<0>
invoke ExitProcess, optional_return_value ; works correctly
ENDM
else
; original macro from \Masm32\macros\macros.asm (180016 bytes, 3 Dec 2011)
; --------------------------------------------------------
; exit macro with an optional return value for ExitProcess
; --------------------------------------------------------
exit MACRO optional_return_value
IFNDEF optional_return_value
invoke ExitProcess, 0
ELSE
invoke ExitProcess,optional_return_value
ENDIF
ENDM
endif
.code
start:
int 3
exit ; push 0
exit 123 ; push 0
exit ecx ; push ecx
end start
Behaviour by assembler:
ML 6.14, 6.15, JWasm: 0, 0, ecx
ML 8.0 ... 10.0: 0, 0, 0 (!)
exit MACRO optional_return_value:=<0>
INVOKE ExitProcess,optional_return_value
ENDM
Quote from: dedndave on December 16, 2013, 09:52:30 PM
exit MACRO optional_return_value:=<0>
INVOKE ExitProcess,optional_return_value
ENDM
Yes, that's what I use (see above) in MasmBasic as replacement for the original Masm32 macro, ever since JWasm greeted me the first time with
Warning A4248: IF[n]DEF expects a plain symbol as argument: IFNDEF 123I never use
exit, simply because
Exit handles some other issues (closing files & libraries etc). I just stumbled over this bug by accident when ExitCode() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1048) didn't return what I expected.
you know me - i am far from a macro guru :P
(i always turn to you and qWord for macros - lol)
but - shouldn't IFNB be used ?
which brings up an interesting point
doesn't qWord have a human name ?
or is he some code-crunching robot ?
> but - shouldn't IFNB be used ?
That would indeed work better, but
value:=<0> is more elegant.
The problem, by the way, is caused by different "opinions" about what is defined and what's not:
OxPT_Assembler MLv615
NOT defined: <>
NOT defined: <123> ; a number is never "defined", i.e. it's not a name
defined: <ecx> ; a register is "defined" for ML 6.14 + 6.15
OxPT_Assembler MLv8
NOT defined: <>
NOT defined: <123>
NOT defined: <ecx> ; a register is not "defined" for ML 8.0 and higher
OxPT_Assembler JWasm
NOT defined: <>
NOT defined: <123>
NOT defined: <ecx> ; same for JWasm: a register is not "defined"Quote from: dedndave on December 17, 2013, 12:43:19 AM
doesn't qWord have a human name ?
In my Masm32 installation, only JWasm recognises qWord as "defined" ::)
Interesting,
; --------------------------------------------------------
; exit macro with an optional return value for ExitProcess
; --------------------------------------------------------
exit MACRO optional_return_value
IFNDEF optional_return_value
invoke ExitProcess, 0
ELSE
invoke ExitProcess,optional_return_value
ENDIF
ENDM
This macro was written for MASM and has been working well for years.
it terminates the program
but how often do we really examine the exit code ?
it went unnoticed because it hasn't been "fully" tested with newer versions of masm
i can see how it's hard to devise a 100% test, everytime something changes
Quote from: hutch-- on December 17, 2013, 03:11:30 AM
This macro was written for MASM and has been working well for years.
One reason may be that the most frequently used parameter is "defined":
exit msg.wParam ; works as expected for all assemblers