I installed masm32 on my Windows XP SP3 machine. I downloaded masm32 from here:
http://www.masm32.com/masmdl.htm
Installed it. I added the path, C:\masm32\bin to the PATH environment variable. Now, I am trying to assemble and link an example program. It creates the object file but does not create the executable file.
sample program:
include \masm32\include\masm32rt.inc
.data
MyTitle db "ASM!",0
MyText db "Some Text!",0
.code
start:
push 0
push offset MyTitle
push offset MyText
push 0
call MessageBoxA
call ExitProcess
end start
Also, please note that the default link.exe file which was present in the c:\masm32\bin directory was throwing an error while linking as shown below:
Assembling: sample.asm
***********
ASCII build
***********
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/z2
"sample.obj+"
"sample.obj"
"sample.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2"; ignored
LINK : fatal error LNK1181: cannot open input file "sample.obj+"
I got another version of link.exe from here:
http://download.microsoft.com/download/vc15/Update/1/WIN98/EN-US/Lnk563.exe
when I assemble and link using the following command:
ml.exe sample.asm sample.obj
It gives the error:
Assembling: sample.asm
***********
ASCII build
***********
Microsoft (R) Segmented Executable Linker Version 5.60.339 Dec 5 1994
Copyright (C) Microsoft Corp 1984-1993. All rights reserved.
Object Modules [.obj]: sample.obj+
Object Modules [.obj]: "sample.obj"
Run File [sample.exe]: "sample.exe"
List File [nul.map]: NUL
Libraries [.lib]:
Definitions File [nul.def]:
LINK : fatal error L1104: \masm32\lib\masm32.lib : not valid library
Well, you definitely don't want to use the Segmented linker, this is for 16bit code. Continue using the Incremental Linker Version 5.12.8078
So, your getting an obj file? That is what ML.exe does. It is the MASM Assembler and it will Assemble your code into an obj file that you pass to the linker of your choice to create the exe. I say the linker of your choice, since there are a few linkers that you can use all with their own pros and cons.
To create an object file: ml /c /coff /Cp sample.asm
The /c
option tells ml to Assemble only and not attempt to link
The /Cp
option tells ml to preserve the case of all identifiers
/coff
creates the obj file in the Common Object File Format, this is what we use for x86 on Windows.
Now, you need to link the obj file into the exe: link /subsystem:windows sample.obj
/subsystem:windows
creates a GUI Windows exe. Change to console
to create a console based app (NOT the same as a DOS app)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With