Programming tools 6: debug

MS-DOS debug command on-the-fly assembly

Image via Wikipedia

I can remember back in the day, sitting at my newish Tandy RL computer and playing with debug. I was using debug to edit so that the string it wrote to the screen was not Microsoft Dos 5.0 but
>>> Echlin Dos 1.0–

Debug is such an interesting and useful little program. You can use it to alter existing programs, write new little machine language apps, edit your hard drive contents, by file or by sector (which is just dangerous and often ends up in an unusable hard drive) or as it was intended, run programs step by step and edit the contents of variable memory to test/see why a program crashes. I have used it for investigating viruses, reverse engineering applications and other stuff that I probably shouldn’t mention here.

I always liked using it to make small apps that did nothing but prove concepts. Like a little program that uses just bios level interrupt calls to write something to the screen like say the cmos chip time, compared to the timer-tick software time. This one was fun in that it worked just fine on both Linux and Windows without reassembling (well it was machine so I guess it was manually assembled just once.)

Machine language is fun in that it allows so much flexibility. You can truly do anything. But it’s a pain because you are constantly doing a lot of math in your head and isn’t this why we have compilers? Well yes, but you should know assembler at least and you should then try your hand at machine as well.

I have a library, a series of books on assembler for the Intel x86 series of chips. At this level you are not writing for DOS or Windows or Linux or MAC because you are using the bios interrupts and the chips own instruction set. The one book I recommend for starters is Assembly Language for the PC. It starts with how to run debug (> debug) (-Q to quit.)

And then how to use debug, h 3 2, returns 0005 0001 (h 2 3 returns 0005 ffff. I will let you figure out what that means 🙂

It goes on to loading registers, and what you can do by then calling interrupts. I also recommend a goos DOS Programmers reference which while we are no longer writing for DOS gives you a definition of all of the DOS and BIOS interrupts. A good at a glance reference is good as well and all of these are available in one form or another on the net.

I’m not going into all the stuff you will need to know about debug to get you programming and it’s not easy but it’s fun. Be careful writing to memory you don’t own. Don’t edit files you can’t figure out how to replace and if editing your hard drive parameters, do it on a throw away drive like say a floppy first and probably for a long time until you know you are getting it right. We’ll make a hacker out of you yet.

But debug, while available on every dos/windows system for ever is great for low level tasks like hacking it’s not the only debugger around and I like the Java debugger and how it’s interfaced in Eclipse. Eclipse has a lot of tools and I found only one eclipse plugin for assembler called, oddly enough, asmplugin which is available on sourceforge at

It requires an assembler other than the dos debug program so there are a few good ones out there, you will have to pick one, TASM, NASM(free), MASM. I picked NASM and installed both. You have to figure out the right parameters for the compiler and pu them in yourself. The help for asmplugin is at

Nasm is at and it has good online docs and the like, works with 32 bit and 64 bit I am told as well as windows. There is Linux version, probably already available for your distribution.

Have fun assemblers!


About echlinm

Computer Programmer/Systems Analyst/Hacker S31
This entry was posted in Computers and Internet, hackers, modding, Programming and tagged , , , , , , , . Bookmark the permalink.

One Response to Programming tools 6: debug

  1. najmahilmi says:

    link to you blog, thank’s.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s