Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Need debugger for assembler

  1. Jul 9, 2011 #1
    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: Jul 9, 2011
  2. jcsd
  3. Jul 9, 2011 #2


    User Avatar

    I think most people use gdb with nasm
    http://www.cs.umbc.edu/portal/help/nasm/nasm.shtml [Broken]

    With GDB you can debug multiple targets, even cross debug from a remote machine.
    It's a fragile environment, but it works.
    Last edited by a moderator: May 5, 2017
  4. Jul 9, 2011 #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.
  5. Jul 9, 2011 #4


    User Avatar
    Science Advisor

    I second visual studio.

    Also a tool called Numega SoftICE is good, but it's not free.
  6. Jul 10, 2011 #5
    Can a 16 bit debugger work for 32 bit debugger?

    It says * null Null Debug format
    Last edited: Jul 10, 2011
  7. Jul 10, 2011 #6
    Can I use same debugger for debugging programs of other languages?
    Can I use turbo debugger for debugging assembly programs?
  8. Jul 10, 2011 #7


    User Avatar
    Science Advisor

    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).
  9. Jul 10, 2011 #8
    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.

    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?


    This is the main home page for nasm:


    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:


    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!
  10. Jul 12, 2011 #9


    Staff: Mentor

    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.
  11. Jul 12, 2011 #10


    User Avatar
    Homework Helper

    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


    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 (Text):


    ; 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 (Text):

        IF      @Version EQ 611
    Last edited: Jul 12, 2011
  12. Jul 12, 2011 #11
    Thanks Mark!

    Odd that VS can't inline assembly on 64-bit systems.
  13. Jul 12, 2011 #12


    Staff: Mentor

    Yeah, I don't know why they made that decision. You can use assembly, though, in separate files that contain procs/functions.
  14. Jul 13, 2011 #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.
  15. Jul 13, 2011 #14


    User Avatar
    Homework Helper

    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.


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

    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.

    Look for the instructions about adding a custom build step for a source file in a project in my previous post.
    Last edited: Jul 13, 2011
  16. Jul 14, 2011 #15
    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.
  17. Jul 14, 2011 #16


    User Avatar
    Homework Helper

    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: Jul 14, 2011
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook