News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Where to get "MASM for Dos".

Started by Vishwas, May 23, 2005, 09:25:34 AM

Previous topic - Next topic

Vishwas

May anyone please tell me, where can i download "MASM for dos". Thanks.

Vortex

Hi Vishwas,

Welcome to the forum.

Masm V6.14 coming with Hutch's masm32 package can create 16-bit object files targetting DOS :

http://www.website.masmforum.com/masm32.htm

What you need is the 16-bit linker available from:

http://www.website.masmforum.com/microsoft/Lnk563.exe



Vishwas

First of all thanks for the quick response.
Actually i have masm32 ( with some Qedit named editor). But it is not able to run the following program : ( Although, i know, you told me about downloading some linker.. for dos version, but please give me a post, just to confirm that the following code will give NO problem, if i run it on the masm32's editor (Qedit), if i download the linker you told.
Thanks a lot.

; This probram adds two 8-bit words in the memory locations
;called NUM1 and NUM2. The result is stored in the memory location called
; RESULT. If there was a carry from teh addition it will be stored as 0000
;0001 in the location CARRY.

DATA SEGMENT

NUM1 DB 15h ;First number is stored here
NUM2 DB 20h ; Second number stored here
RESULT DB ? ; Put sum here
CARRY DB ? ; Put any carry here
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX, DATA ;Initialize data segment
MOV DS, AX ; register ; register
MOV AL, NUM1 ; Get the first number
ADD AL, NUM2 ; Add it to 2nd number
MOV RESULT, AL ; Store the result
RCL AL, 01 ; Rotate carry into LSB
AND AL, 00000001B ; Mask out all but LSB
MOV CARRY, AL ; Store the carry result
MOV AX, 4C00H
INT 21h
CODE ENDS
END START

MichaelW

Hi Vishwas,

The file will assemble, link, and run OK, but he linker returns:

LINK : warning L4021: no stack segment

I normally use a different editor for DOS code, and assemble with simple batch files. But you can use the MASM32 Quick Editor to load, edit, and save the files, and run the batch file that assembles and links. To do so your working directory must be under the MASM32 directory, the 16-bit linker must have been renamed to link16.exe and copied to the \masm32\bin directory, and a batch file containing the necessary ML and LINK16 command lines, and named makeit.bat, must be in the working directory. After editing/saving your source file, to assemble and link you would select "Run Makeit.bat" from the Project menu. Here is a sample batch file:

@echo off
rem This will assemble test.asm to test.obj, without linking:

echo on
\masm32\bin\ml /c "test.asm"
@echo off

rem Same as above, but will generate a listing file:

rem echo on
rem \masm32\bin\ml /c /Fl /Sa "test.asm"
rem @echo off

pause

rem This will link test.obj to test.exe, BUT ONLY IF THE 16-BIT
rem LINKER HAS BEEN RENAMED TO LINK16.EXE AND COPIED TO THE
rem MASM32\BIN FOLDER:

echo on
\masm32\bin\link16 "test.obj";
@echo off

rem Same as the above, but will generate a MAP file.

rem echo on
rem \masm32\bin\link16 "test.obj",,"test.map";
rem @echo off

rem This will create a COM file, assuming the source is compatible
rem with a COM file (link16 will return an error if it isn't).

rem echo on
rem \masm32\bin\link16 /tiny "test.obj","test.com";
rem @echo off

rem Same as the above, but will generate a MAP file.

rem echo on
rem \masm32\bin\link16 /tiny "test.obj","test.com","test.map";
rem @echo off

pause

eschew obfuscation

Vishwas

Yes, i am also getting the linker error. But what does that mean. Would i not be able to see the output. Or, is there some other way of viewing the output. Actually i am new to MASM, and want to ask whether the output comes on the screen directly, or one has to give some command (After assembling,linking...etc) for viewing the output.

MichaelW

It is not a linker error it is a warning. The loader will provide the program with a useable stack, so not defining a stack segment in the source code will not prevent the program from running.

I'm not sure what output you mean. The assembler and linker will display any error or warning messages to the screen, but you can code the batch file to redirect the output to a file and then open the file in notepad or whatever. To see how this is done take a look at the batch files in \masm32\bin.

If you mean the program output, the source code you posted does not generate any output. To display the results you would need to add code. For example, to display RESULT you would convert the value to a decimal, hexadecimal, or possibly binary (base 2) string and then display the string.

If the program displayed the output and immediately closed, you would not be able to see the output. To correct this you could add code that would wait for a key press, or you could run the program from a command prompt. For DOS apps I normally use a call to the BIOS Get Keystroke function (Interrupt 16h, function 0 or 10h) to wait for a key press. If you are working in Quick Editor, you can open a command prompt by selecting the Prompt from the File menu, or by pressing Ctrl+D.
eschew obfuscation

Vishwas

Oh yes, it is warning, i am also getting the linker warning.
By output, i mean the RESULT of the program ( for example, in the program for addition, by output i mean is 12 if i add 7 and 5, with the help of the program). But, i am getting nothing as an output. After i get the linker warning, i tried to run the .exe file, by double clicking over it. ( And just as you said the Dos prompt flashed for a while and disappeared ), After that i went to the DOS mode and tried running it there, by the command <Filename>.exe . But i got nothing, and was returned the prompt.
Please may you tell, what code to  add in the previous program of addition so as to get result, or how to redirect it to any file, as you mentioned in your post. Thanks a lot, for being with me up to this point.

MichaelW

You need to add code to display the output. Try displaying the value of CARRY first. The value can be represented by a single digit so just 4 instructions are required to convert it to a '0' or a '1' and display it. If you do a search of the forum you should be able to find code examples that will show you how to convert and display multi-digit values.

You can find the information on the DOS and BIOS interrupts in Ralf Brown's Interrupt list.

An HTML version is here:

http://www.ctyme.com/rbrown.htm

And the download version here:

http://www-2.cs.cmu.edu/~ralf/files.html
eschew obfuscation

lingo


Vishwas

Quote from: Vishwas on May 26, 2005, 12:19:43 PM
Oh yes, it is warning, i am also getting the linker warning.
By output, i mean the RESULT of the program ( for example, in the program for addition, by output i mean is 12 if i add 7 and 5, with the help of the program). But, i am getting nothing as an output. After i get the linker warning, i tried to run the .exe file, by double clicking over it. ( And just as you said the Dos prompt flashed for a while and disappeared ), After that i went to the DOS mode and tried running it there, by the command <Filename>.exe . But i got nothing, and was returned the prompt.
Please may you tell, what code to  add in the previous program of addition so as to get result, or how to redirect it to any file, as you mentioned in your post. Thanks a lot, for being with me up to this point.
I wonder about all this. Displaying an output is the cruical part of any program in the world, no matter it is written in C, C++, Java, VB etc. But i just donot understand what type of language is MASM. What is the problem ? Is their no simple way, such as printf in C, which can display the result. The number of posts i did, has made me to think that seeing result in MASM (say for adding two numbers) is a very very difficult job. The reply you posted me also leads me to think that, even you have never coded for viewing the result, of your code, and if this is true, MASM is really very very strange.
            The same thing, happened when i referred to my course book. All the programs do something, but never show the result. Strange!. They didnot give the code to display the result, or redirect it.

AeroASM

There is no printf in MASM. You can use the DOS function int 21 / ah=9 to print a string very easily. However it is hard to convert a number into a string.

MichaelW

#11
Vishwas,

The MASM language has no functions to display output just as the C language has no functions to display output. The printf function is not a part of the C language; it is a part of the C "run-time" library. Such libraries can and have been produced for use with MASM:

http://webster.cs.ucr.edu/Articles/X86FAQ/gen1.html#14

I should also mention that a significant part of the MASM32 project is the MASM32 library, which provides several hundred procedures for use in Win32 applications. The source code for the MASM32 library is included in the MASM32 package, and the number-to-string conversion procedures can readily be adapted for use in a DOS program, but I don't recommend that you do so because most of the source is too advanced for a beginner.

The reason you are getting descriptions instead of code is here:

http://www.masmforum.com/simple/index.php?topic=1295.0

If you had searched as I suggested, you would have found this:

http://www.masmforum.com/simple/index.php?topic=163.0

I coded the procedure specifically so it would be easy to use and easy for a beginner to understand.

Here is the original header for the procedure:

;----------------------------------------------------------
; This proc converts the argument to decimal digits and
; displays the result on the screen.
;
; The conversion process consists of repeatedly dividing
; the argument value by ten and pushing the remainder
; onto the stack, continuing until the quotient is zero.
; The stack provides a convenient method of reversing the
; order of the digits. Example:
;
;  123 / 10 = 12 remainder 3
;  12 / 10 = 1 remainder 2
;  1 / 10 = 0 remainder 1
;----------------------------------------------------------


EDIT:

The PrintDec procedure is coded to accept an argument passed on the stack, as would be the norm for high-level languages. To include the procedure in the code you posted above, because the code does not include a MODEL directive that specifies a language type, you must specify the language type in the PROC directive. Alternatively, you can remove the numb parameter from the procedure definition and the reference to it in the procedure code, and pass the argument in AX.

BTW, the procedure is actually based on one of the example procedures that Microsoft included with the commercial MASM distributions.
eschew obfuscation

Vishwas

Thanks Michael, for helping upto this point. Although everything seems to be strange in MASM, because i am not able to find  beginning programs. Well, no problem, i am searching through the tutorials. Thanks again for all the links, helpful instructions and advice.