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

Click For Summary
To write an assembly language program in a DOS environment, it's essential to understand the DOS interface, particularly the use of interrupt calls for various functions like file handling and graphics. The segmented memory model is crucial in DOS programming, differing from the flat memory model used in modern systems. For development, assemblers such as MASM, NASM, or TASM are recommended, and tools like Turbo C can provide an interface for writing and compiling assembly code. Users can utilize the command line to assemble and link their programs, and debugging tools like TDBUG can assist in troubleshooting. The discussion emphasizes the need for familiarity with DOS-specific development practices and tools to effectively write and execute assembly programs in this 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.
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 102 ·
4
Replies
102
Views
2K
  • · Replies 25 ·
Replies
25
Views
722
  • · Replies 122 ·
5
Replies
122
Views
16K
Replies
6
Views
3K
Replies
16
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K
Replies
60
Views
18K
Replies
12
Views
4K
  • · Replies 397 ·
14
Replies
397
Views
20K
  • · Replies 4 ·
Replies
4
Views
15K