Click to See Complete Forum and Search --> : Using VS.NET 2003 to assemble/link/compile MASM611 code?


MrDoomMaster
February 21st, 2004, 01:27 PM
Hey guys, I'm in a college class for Assembly right now, and at the moment we're using MASM 6.11 (which is all dos commands) to compile and link our assembly programs. I really dread the DOS environment, and since I have Visual Studio 2003 .NET Enterprise, I figured there has to be a way to do all of the assembly work in it!

So far I have created a custom build which uses the file C:\masm611\bin\ml.exe to compile and link a .ASM file into a .EXE.

I went to TOOLS >> EXTERNAL TOOLS and created a custom build with the following information:

---------------------------------------------------------
TITLE: Assemble/Link .EXE (MASM)
COMMAND: C:\MASM611\BIN\ML.EXE
ARGUMENTS: $(ItemDir)$(ItemFileName).ASM
INITIAL DIRECTORY: $(ItemDir)
(also enabled 'Use Output Window')
---------------------------------------------------------

This information provides a button on the TOOL menu to compile and link my ASM code.

To test this, I entered the following code:


PAGE 60,132
TITLE ASM1 (EXE) simple proggy
;-----------------------------------------------------
STACK SEGMENT PARA STACK 'Stack'

STACK ENDS
;-----------------------------------------------------
DATASEG SEGMENT PARA 'Data'
DW 32 DUP (0)

DATASEG ENDS
;-----------------------------------------------------
;-----------------------------------------------------
CODESEG SEGMENT PARA 'Code'
MAIN PROC FAR
ASSUME SS:STACK, DS:DATASEG, CS:CODESEG
MOV AX,DATASEG
MOV DS,AX

MOV AX,4C00H
INT 21H
MAIN ENDP
CODESEG ENDS
END MAIN


This is the basic assembler code for any EXE program. This code compiles perfectly when I use MASM611 from DOS to compile and link, with no errors. Yet when I use VS.NET to compile this very same code, I get the following information in my output window:


Microsoft (R) Macro Assembler Version 6.11
Copyright (C) Microsoft Corp 1981-1993. All rights reserved.

Assembling: C:\Programming\Assembler\Solution1\Untitled1.ASM
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/z2
"Untitled1.obj"
"Untitled1.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2"; ignored
LINK : warning LNK4044: unrecognized option "r"; ignored
LINK : error : Segment reference in fixup record
Untitled1.obj : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt


I know it is so possible to use the VS.NET IDE to compile this code... I hope someone can help! Thanks a lot!

mdmd
February 21st, 2004, 02:21 PM
Maybe this (http://www.nuvisionmiami.com/books/asm/ide/vsnet/) will help ?

mdmd
February 21st, 2004, 02:38 PM
Actually, visual studio .net comes with an updated ML.exe in the
bin directory, unlike visual studio 6. Probably you should use that
version or perhaps specify the linker also with the old ML.exe if
you need that . I'll guess you're just running into a problem with
different incompatible versions of the tools.

MrDoomMaster
February 21st, 2004, 03:09 PM
sorry the website didn't help. They use a .BAT file for their command, and also MASM 615. I want to refer to the EXE's directly, not BAT files. Also I'm using masm611.

I am only programming 16bit MASM in my class, so no need for 32 bit. Also I don't see a way to specify that both the LINK and ML executables be used to create the final executable for my program. In the "COMMAND" option for creating my custom build, it only accepts one reference, and I chose ML.EXE.

Anything else you can give me?

MrDoomMaster
February 21st, 2004, 03:19 PM
Also, how do I make it use the LINK.EXE file? I already have it set to use the old ML.EXE... but how do I make it use the old LINK.EXE also?

mdmd
February 21st, 2004, 03:44 PM
All I can think of is put the MASM tool directory in front of the
visual studio.net tool directory. Try in the tools/options/directory.

To see what one its using, try renaming the one in the vstudio.net
directory ( to something: link._xe ) so it can't use it. Keep trying
till it uses the one compatible with the 16 bit masm. I don't have
masm installed, I can't fool with it to see for sure.

MrDoomMaster
February 21st, 2004, 03:58 PM
Originally posted by mdmd
All I can think of is put the MASM tool directory in front of the
visual studio.net tool directory. Try in the tools/options/directory.

To see what one its using, try renaming the one in the vstudio.net
directory ( to something: link._xe ) so it can't use it. Keep trying
till it uses the one compatible with the 16 bit masm. I don't have
masm installed, I can't fool with it to see for sure.

Install MASM 611 from my FTP if you would like. Here's the link:

blhasldhfoiajsdlifjoji <removed!>

I like that you're helping me, I really appreciate it. I offer you this download so that maybe you can find more solutions, and that maybe also you can find it useful sometime for your own personal use. I am not sure if MASM611 is free or not, so I apologize if the link causes any trouble. I got it for free from my professor, so I assume it's free.

Thanks man, I'll try your suggestion and post back if it doesn't help.

MrDoomMaster
February 21st, 2004, 04:05 PM
Just a note, I went to Tools >> Options, and I saw nothing for directory. I saw VC++ Directories, but there wasn't really anything significant to Assembler.

I create a solution as my workspace for assembler in VS.NET 2003, then I just add my ASM files to the project and assemble/link them via the options I created via External Tools.

I'll keep looking around the program on how to change the link.exe used, but I don't think I'll have any luck.

I know I"m being frustrating, maybe even retarded, but I do what I can lol. Thanks for your patience, I'm glad you're helping out.

mdmd
February 21st, 2004, 04:22 PM
OK, I'm downloading that. I'm sure you'll want to edit the post
and delete that link. :thumb:

You should be able to rename the LINK.exe from vstudio and copy
the one you need from the MASM directory to the vstudio directory
and see if this theory works.

I was thinking of VC6 regarding the directories. I don't remember
how to do it with VC7. It might be getting it from the PATH
enviornment variable and not the project or compiler settings.

Seems the server is dishing out at about 4bits per minute so
It'll take another 15 minutes or so.

MrDoomMaster
February 21st, 2004, 04:33 PM
Tried pasting the LINK.EXE into the correct BIN directory under VC7, didn't help at all! :(

MrDoomMaster
February 21st, 2004, 06:18 PM
Hey, I figured it out! I created a batch file!

mdmd
February 21st, 2004, 06:20 PM
Sorry man, I can't get it to use the old LINK.exe. Tried with just
the custome build step and tried with the bat file. Tried running
the linker on its own ( /c option for ML ) and it couldn't execute
it. So, I don't know whats happening or what it is looking for.

If you want an IDE other than PWB ( I don't know why, that thing
is awesome ), I noticed there are a couple in the ftp site you listed
( I'm pretty sure masm32 comes with one, at least there is one
listed on the masm32 site ).There are some others on the web if
you want some references if you can't get this to work and you
need one.

mdmd
February 21st, 2004, 06:21 PM
Heh, I couldn't get the batch file to acknowledge it.
I used the batch file from the original link and modified it with
the bat file that is installed with MASM. What else did you change ?

MrDoomMaster
February 23rd, 2004, 08:38 AM
You're talking about the batch file I used in VS right? Okay, here's what I did:

First, I created my own batch file via notepad. You can take a look at it from my FTP at the following link:

ftp://guest1:guest1@24.162.146.233:21/IT/VSNETASM.BAT

This batch file provides the necessary commands to execute both the linker and assembler simultaneously to build 16 bit asm programs in Visual Studio .NET

Specify this batch file as the "Command" in your custom build (Tools >> External Tools). Next, under "Arguments", you must enter the following commands:

$(ItemDir)$(ItemFileName)

and under Initial Directory, The following:

$(ItemDir)


I don't know if other commands will work under Arguments and Initial Directory, but you're welcome to try them. These, for sure, work.

That's basically it. Make sure you select "Use Output Window" so that the linking data is displayed!


The only bad thing about this is that if the Assembly fails, it still continues to link. But, this really doesn't cause any other problems than just unessessary scrolling in the output window!

Thanks for all of your help, I really do appreciate it.