Assembling & Running a Program in DOS: MASM/NASM/TASM

Click For Summary

Discussion Overview

The discussion revolves around how to write, compile, link, and execute assembly language programs in a DOS environment. Participants explore various tools and interfaces available for assembly programming, including MASM, NASM, and TASM, while addressing the specific needs of the user regarding low-level programming in DOS.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant inquires about the best assembler to use for writing assembly language programs in DOS, specifically asking about MASM, NASM, or TASM.
  • Another participant shares insights from their experience with DOS programming, emphasizing the importance of understanding DOS interrupt calls and the segmented memory model.
  • A user expresses the need for a stand-alone interface similar to Turbo C for writing assembly programs, highlighting the desire for a straightforward workflow to compile and execute code.
  • It is noted that Borland's Turbo C includes TASM and a linker, which could facilitate writing assembly code in a familiar environment.
  • Microsoft Visual Studio is mentioned as an option that includes a DOS console for assembling code, though it lacks a comprehensive toolbox for assembly programming.
  • A later reply indicates that the original poster has found a solution, but details of that solution are not provided.

Areas of Agreement / Disagreement

Participants generally agree on the need for specific tools and interfaces for assembly programming in DOS, but there is no consensus on which assembler is the best choice, as multiple options are discussed without resolution.

Contextual Notes

Participants mention various tools and their functionalities, but the discussion does not clarify the limitations or specific requirements of each assembler or the DOS environment.

Who May Find This Useful

This discussion may be useful for individuals interested in low-level programming, particularly those looking to work with assembly language in a DOS environment.

pairofstrings
Messages
411
Reaction score
7
How to write assembly language program in DOS environment? I want to type my assembly language program in some interface and compile and link and execute it. How do I do that? Should I use one of those Masm/Nasm/Tasm assemblers or what?
 
Last edited:
Technology news on Phys.org
pairofstrings said:
How to write assembly language program in DOS mode? I want to type my assembly language program in some interface and compile and link and execute it. How do I do that?

Hey pair of strings and welcome to the forums.

I wrote DOS based assembly a long time ago (when DOS was the only thing for games), so I can give you some pointers.

If you want to write DOS based code, one thing you need to know is the DOS "interface" and by interface I mean the interrupt calls.

The interrupt calls are used for everything from opening files, to setting your video mode, to playing CD audio, to allocating memory, to basically everything!

Also you have to be aware of segmented memory model vs the flat memory model. When I did DOS programming back then, segments were the model over flat. Segments in my view are really stupid since segments actually overlap, where as with the flat model memory addresses are unique: don't ask me why they did the segmented model the way they did, but yeah that's just the way it is.

I can't help you out any more unless you be more specific about it is that you want to do. If you want to write library code for some platform like say BASIC (with CALL ABSOLUTE), then you just have to basically restore the state before you leave your call.

If you want to write an entire program in complete assembler, you will need to really get a good grasp of the DOS dev environment (i.e, the interrupts). You will probably have to implement some custom interrupt code for the keyboard and that requires writing an ISR and getting DOS to use that ISR when you're code is running.

If you want to do things like write a joystick or sound driver (to play wave files) you need to get specs for IO port calls and the like. Same if you want to do graphics stuff in 256 color mode.

Then on top of your code that deals with files, memory, input and so on, you need your program specific code.

Maybe you can tell me what you want to do so I can give you some specific advice. Also I'm wondering why you want to want to code in DOS: you can write code in assembly using something like windows, but I guess if you want the kind of low level control that the DOS environments offers (no protected memory!) then I can understand.
 
I need a stand-alone interface which will help me to write my program at low level using assembly.
like the way i do to write a C program
c:\>cd tc
c:\>tc\cd bin
c:\>tc\bin\tc.exe
opens up an interface where I can type my program and do stuff.
Similarly, I need some interface where I can type assembly language program then compile it then link it and execute it, if I am right with the order.
I want to do this in DOS environment, not in OS
 
Last edited:
It appears that you are using Borland's Turbo C. The last version of Turbo C that I had, included their assembler, tasm.exe, and their linker, tlink.exe. If you have those tools, you should be able to write your assembly code using the same interface that can be used to write C code, but you will need to assemble and link your code from the DOS command line.

You can debug your assembly code using their debugger, tdbug.exe or tdebug.exe. I think that's what it is called.
 
Microsoft Visual Studio includes a dos console (command) option under "tools" folder in the start / programs / ... folder. Once there you can use ML to assemble code. You don't get a toolbox like Programmers Workshop + Codeview though.

You could use the normal VS windows interface and create a dos console program, but you'd have to set a break point at the end of the program. or call a console input function at the end of the program to prevent the console window from closing when the program completes.
 
thank you all of you, i have found the solution. thanks.
 

Similar threads

  • · Replies 102 ·
4
Replies
102
Views
4K
  • · Replies 25 ·
Replies
25
Views
1K
  • · Replies 122 ·
5
Replies
122
Views
18K
Replies
6
Views
3K
Replies
16
Views
4K
  • · Replies 14 ·
Replies
14
Views
5K
Replies
60
Views
18K
Replies
12
Views
4K
  • · Replies 397 ·
14
Replies
397
Views
22K
Replies
10
Views
3K