What debugger should I use for my assembler in a DOS environment?

  • Thread starter pairofstrings
  • Start date
In summary: I'm not sure about earlier versions.In summary, the debugger does not work because the hardware configuration is different and the debugger requirements are not met.
  • #1
pairofstrings
411
7
I am trying to debug an assembly language program using a debugger but it is not working because hardware configuration is different and don't match the debugger requirements.
I am running windows vista 32 bit on x86 pentium Dual CPU T2310 @ 1.46 GHz.
I need a debugger for my assembler - NASM.

Edit: I was using AFD - Advanced fullscreen debugger. But it is not working on my PC because I think it supports only 16 bit and I have a 32 bit processor. What it does is it doesn't shows the changes that take effect in the register after any instruction is executed. So, I have to look for another debugger which can replace AFD for 16 bit and work on a 32 bit processor.

[Moderator's Note: Threads merged]
 
Last edited by a moderator:
Technology news on Phys.org
  • #2
I think most people use gdb with nasm
http://www.cs.umbc.edu/portal/help/nasm/nasm.shtml

With GDB you can debug multiple targets, even cross debug from a remote machine.
http://www.linux.com/archive/feature/121735
It's a fragile environment, but it works.
 
Last edited by a moderator:
  • #3
Just about any debugger will do the job. The trick is to get nasm to output the proper debug format. You could probably use Visual Studio.

You can see the list of supported output formats with nasm -hf. You're probably interested in win32. Then you can use the proper output format as a parameter like this:

nasm -f win32 -y

That should give you a list of the supported debug formats.

You can then give the debug format as an argument to nasm with the -F flag.

My friend suggests you might try IDA Pro. He says the "evaluation version" is not time limited or anything, it's just a slightly older version. He says it's very powerful. I haven't used it myself, but it's something to look at.
 
  • #4
I second visual studio.

Also a tool called Numega SoftICE is good, but it's not free.
 
  • #5
Grep said:
Just about any debugger will do the job. The trick is to get nasm to output the proper debug format.
Can a 16 bit debugger work for 32 bit debugger?

Grep said:
nasm -f win32 -y
That should give you a list of the supported debug formats

It says * null Null Debug format
 
Last edited:
  • #6
Can I use same debugger for debugging programs of other languages?
Can I use turbo debugger for debugging assembly programs?
 
  • #7
pairofstrings said:
Can I use same debugger for debugging programs of other languages?
Can I use turbo debugger for debugging assembly programs?

Any executable can be debugged in a standard debugger that works in that particular platform (like say Visual Studio) that works with that particular executable format.

As for other languages and platforms, you will need to use a particular debugger for that platform/language combination.

Just so you know you can have remote debuggers for particular platforms. Examples include things like doing debugging work on XBOX360 (you use remote debugging with Visual Studio).
 
  • #8
pairofstrings said:
Can a 16 bit debugger work for 32 bit debugger?

Well, the debugger does need to support your binary format, which is at least 32 bit. So probably not, no. I looked it up, and it said AFD is for "86 and 286 only". So no way that will ever work on even remotely recent software.

pairofstrings said:
It says * null Null Debug format

Hm, I presume I got the binary format right (win32 seems too darn obvious). If it doesn't support any debug formats for win32 binaries, then it really can't be debugged with that version of nasm. As far as I know, anyways.

Did you get it from here?

http://www.nasm.us/pub/nasm/releasebuilds/2.09.09/win32/

This is the main home page for nasm:

http://www.nasm.us/

I would think that version would support win32 debugging. I'd test it, but I'm on Linux and the nasm I have is for that.

This page might be useful, though it's from 2003 and might be out of date. It deals with debugging nasm in Visual Studio:

http://www.cs.uaf.edu/2003/fall/cs301/usingnasm.htm

Looks like it's called nasmw.exe in Windows. If you're calling it as just "nasm", I wonder if you aren't getting a different nasm.

To any Windows/Visual Studio people here, doesn't VS come with an assembler called 'nasm'? Perhaps that's the problem. Either way, you might try downloading the one I linked to and seeing if that works better.

Hope you get it working!
 
  • #9
Grep said:
To any Windows/Visual Studio people here, doesn't VS come with an assembler called 'nasm'? Perhaps that's the problem. Either way, you might try downloading the one I linked to and seeing if that works better.
I'm pretty sure VS does not come with an assembler named nasm. There is a Microsoft assembler named MASM that is, I believe, a separate product. Some VS compilers let you insert inline assembly, although if you're compiling code to run on a 64-bit machine, you can't include inline assembly. This is true for VS 2010 and VS 2008.
 
  • #10
The assembler in VS is ML.EXE. In the case of Microsoft, MASM.EXE was superceded by ML.EXE when it went from version 5.xx to 6.xx. If you use any library functions, it's easiest to write the code in C or C++, then add the /Fa option to generate assembly code to get the exact names (some of them are mangled a bit) to use for a .ASM file (see example code below).

To create a VS project for an assembly file, you'll need to create a win32 console "empty project". Then add "existing item" to the project to add your .ASM file. You'll then need to right click on the .ASM file name in the project window and add a custom build step with command line:

ml /Zi /c /Fo$(outdir)\example.obj example.asm

and output

(outdir)\example.obj

For a release build, use the same command line but without the /Zi:

ml /c /Fo$(outdir)\example.obj example.asm

and also for release builds, change the project linker output to default (/LTGC is enabled when you create the project, but it ends up generating a warning stating it's not needed).

For standard libaray references, add this to your .ASM file, the @# refers to the number of bytes used for the parameters for the default library model. For 64 bit mode, the libraries only use a single (fastcall) model where 4 of the parameters are passed in registers and the rest on the stack.

Code:
	INCLUDELIB	MSVCRTD 
	INCLUDELIB	OLDNAMES

; some common library function names defined as externs

	extrn	_clock:NEAR
	extrn	_free:NEAR
	extrn	_malloc:NEAR
	extrn	__imp__CreateFileA@28:NEAR
	extrn	__imp__WriteFile@20:NEAR
	extrn	__imp__CloseHandle@4:NEAR

The INCLUDELIB used to be LIBC for older versions of Visual C. To make a source compatable with old and new use this:

Code:
	IF		@Version EQ 611
	INCLUDELIB	LIBC
	ELSE
	INCLUDELIB	MSVCRTD
	INCLUDELIB	OLDNAMES
	ENDIF
 
Last edited:
  • #11
Mark44 said:
I'm pretty sure VS does not come with an assembler named nasm. There is a Microsoft assembler named MASM that is, I believe, a separate product. Some VS compilers let you insert inline assembly, although if you're compiling code to run on a 64-bit machine, you can't include inline assembly. This is true for VS 2010 and VS 2008.

Thanks Mark!

Odd that VS can't inline assembly on 64-bit systems.
 
  • #12
Yeah, I don't know why they made that decision. You can use assembly, though, in separate files that contain procs/functions.
 
  • #13
So, how to use Visual studio with NASM separately for debugging assembly program?
Should I install VS on my PC? Please include any command line that I may have to use for opening assembly program in VS...
As mentioned above I tried Advanced Full screen Debugger, using AFD was very easy. Only commands like
C:/>NASM>AFD (filename.asm) would work.
 
  • #14
pairofstrings said:
So, how to use Visual studio with NASM separately for debugging assembly program?
Assuming NASM object output with debugging info is compatable with VS tools, you could copy NASM.EXE and any other required files to:

\Program Files\Microsoft Visual Studio...VC\bin

Then replace the custom build steps I showed in my previous post, changing the usage of ML.EXE to NASM.EXE.

I'm not sure why you couldn't just switch to ML.EXE though. It has some nice features, including some higher level language fieatures such as the .if .else .endif directives.

http://msdn.microsoft.com/en-us/library/afzk3475.aspx

Microsoft seems to change url's for this stuff occasionally, so if you need to find it again, look for "microsoft macro assembler reference".

pairofstrings said:
Should I install VS on my PC?
I find it useful. I have VS2005 that I bought on one system, and VS 2010 C++ express which is a free downloadable version on a second system.

pairofstrings said:
Please include any command line that I may have to use for opening assembly program in VS.
Look for the instructions about adding a custom build step for a source file in a project in my previous post.
 
Last edited:
  • #15
rcgldr said:
I'm not sure why you couldn't just switch to ML.EXE though.
I want to try programing in a complete DOS environment, just like the olden days, when there was no Operating system and all the things were done using NASM and other debuggers like AFD.
 
  • #16
pairofstrings said:
I want to try programing in a complete DOS environment, just like the olden days.
VS includes a command prompt option (accessed via start / programs / vs ... / tools / vs command prompt), that opens a dos console window with the path and other environment variable set up so you can invoke ML.EXE from the command line. I don't think there's a console window debugger though, so you'd be stuck with the windows debugger, and you'd probably have to add a "INT 3" to your program to invoke the debugger.

Note that ML.EXE (up to version 6.11) dates back to the days of 16 bit msdos.

By DOS, do you mean 16 bit programming? If so, you could try to find an old 16 bit tool set, but that would be difficult. For Microsoft, a DOS toolset would include ML, CL (C complier), nmake, codeview (debugger), and programmers work bench (a text based version of a GUI). For Borland it would be an old version of Turbo C++. The only other toolset I remember was Watcom (which had a short period of popularity because it included a 32 bit flat model for Windows 3.11 that didn't require installaion of win32s). You could use Virtual PC and install MSDOS 6.22 on it if you wanted.
 
Last edited:

FAQ: What debugger should I use for my assembler in a DOS environment?

What is a debugger for assembler?

A debugger for assembler is a software tool that helps programmers identify and fix errors in their assembly language code. It allows them to step through the code, examine variables and registers, and track the execution flow of the program.

Why do I need a debugger for assembler?

A debugger is essential for programming in assembly language as it can be challenging to identify errors due to the low-level nature of the code. A debugger makes the debugging process more efficient and helps in writing error-free code.

How does a debugger for assembler work?

A debugger for assembler works by executing the assembly code line by line and allowing the programmer to pause the execution and examine the program's state at any point. It can also provide information about memory and register values, helping identify errors in the code.

Are there any free debuggers for assembler?

Yes, there are several free and open-source debuggers available for assembler, such as GDB, OllyDbg, and WinDbg. These debuggers offer similar functionality as paid ones and can be a great resource for programmers on a budget.

Can a debugger for assembler be used for other programming languages?

No, a debugger for assembler is specifically designed for debugging assembly language code. Other programming languages have their own debuggers that are optimized for their respective syntax and structure.

Back
Top