Debug.exe is my assembler

I find it a good practice to use debug.exe as an assembler. In debug.exe there are no higher level instructions you can do, it’s all the real asm code and debug.exe comes with every Windows OS. Here I have made a simple ‘hello world’ file using debug as my assembler

Step by step:

Enter debug prompt


The sub-command ‘a’ to start assembling at address 0100.
The address where all COM files start in:

a 0100

Then I enter the code:

mov ah,09            ;Int 21 Function to print string
mov dx,010A          ;Address of declared string to print
int 21               ;execute call
int 20               ;terminate program
db "Hello World!$"   ;Declare string data ($ symbolizes termination of string)

Press Enter on new line to return to debug prompt.

Use ‘h’ subcommand to calculate length of my code.
The h subcommand returns first the sum of the two hex numbers, then difference.
The difference will be the length.

h 0116 0100

The result is: {0116h + 0100h = 0216, 0116h – 0100h = 0016}

Use ‘r’ sub-command to read and modify CX register within debug.exe

r cx

Then enter in the length of my code as the new value at prompt: 0016

‘n’ sub-command specifies the filename of my code when assembled:


‘w’ sub-command writes the number of bytes of my code equal to the number of bytes specified by the CX register to the filename I specified by the ‘n’ sub-command. No syntax required.

Then I quit debug with ‘q’.

After running back at cmd.exe I get ‘Hello World!’ printed to the console.

2 thoughts on “Debug.exe is my assembler

  1. The step by step example works, but not the screenshot one. Apparently putting the db instruction first causes problems, but I don’t know why. It appeared to work for you. Also, the step by step example needs a small change too, string to begin at 0109 and not 010A.

  2. Is there some standard ‘comment’ character for the ASM file prepared for DEBUG.EXE? The semicolon causes it annoyance. I can cut blocks of comments prior to use but it would be nice not to have to.

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

%d bloggers like this: