Recently was working on a project to include 64-bit code when assembled under ML64.exe. However, this code actually included the 32-bit MASM directives, so the build failed.
IFNDEF RAX
.686P
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
OPTION PROLOGUE:W32Prologue
ELSE
OPTION CASEMAP:NONE
OPTION PROLOGUE:W64Prologue
OPTION EPILOGUE:NONE
ENDIF
The fix was to change IFNDEF RAX to IFDEF RAX as follows
IFDEF RAX
OPTION CASEMAP:NONE
OPTION PROLOGUE:W64Prologue
OPTION EPILOGUE:NONE
ELSE
.686P
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
OPTION PROLOGUE:W32Prologue
ENDIF
Wrote a simple example to show why using IFNDEF RAX is misleading
rax.asm
option casemap:none
extrn printf:proc
.data
szRAX db 'Symbol RAX exists',0ah,0
.code
main proc
ifdef RAX
mov rcx,offset szRAX
call printf
endif
ifndef RAX
mov rcx,offset szRAX
call printf
endif
ret
main endp
end
Building and running shows this output
C:\masm32>ml64.exe rax.asm /link /subsystem:console /defaultlib:kernel32.lib /defaultlib:user32.lib /defaultlib:libcmt.lib
Microsoft (R) Macro Assembler (x64) Version 14.29.30146.0
Copyright (C) Microsoft Corporation. All rights reserved.
Assembling: rax.asm
Microsoft (R) Incremental Linker Version 14.29.30146.0
Copyright (C) Microsoft Corporation. All rights reserved.
/OUT:rax.exe
rax.obj
/subsystem:console
/defaultlib:kernel32.lib
/defaultlib:user32.lib
/defaultlib:libcmt.lib
C:\masm32>rax.exe
Symbol RAX exists
Symbol RAX exists
Why does MASM output the same string twice?