Ok, it may sound useless for modern PCs... but is amazing to watch how a 21 bytes .COM file can display text on screen. even on a 286 if you still have them :)
This guide will use "debug.exe", a nice app that comes after DOS 2.0 and you possibly have it on Windows folder if your running Windows OS. So, no need to download fancy assemblers or compilers.
I'll try to explain each step... but dont expect more that a text on screen...

A nice description about DEBUG.EXE can be found in...
and http://en.wikipedia.org/wiki/DEBUG

Step 1: Undestanding DEBUG.EXE

Our task should be creating a very small executable (in this case is a .COM file) in x86 assembly that should print "Hello World!" on the screen.

We will be using DEBUG.EXE that was released after DOS 2.0, it's mainly used to debug 16-bits applications.

You possibly have it on Windows System folder if your running Windows OS.
In Windows XP, it can be found in C:\WINDOWS\SYSTEM32\DEBUG.EXE

Enter in command-lines (I hope you know how to do this... if not, maybe this tutorial isn't good for you), first step should be calling DEBUG.EXE, since C:\WINDOWS\SYTEM32 is included in "PATH" enviroment, you can call it any path or drive:

C:\> debug.exe

You can type "?" then press ENTER to see the help.

(Again) A nice description about DEBUG.EXE can be found in...
and http://en.wikipedia.org/wiki/DEBUG
<p>Thank you - I miss those days :)</p>
You can cut one more byte replacing MOV AH, 09h with XCHG AX,BP
There's guarantee that before the COM file is executed the register BP holds value 0x0009 ? If not, some unexpected things may happens (or a crash)... A lot of different versions of DOS OS exist (The most common ones now are MS-DOS), so probably shouldn't trust that general registers are initialized all the same between different versions of DOS. Also if I'm not wrong, only SP, DS, ES, SS, CS and IP are initialized, the rest is expected to be random (Remember I'm talking about 286 registers).
You can make it faster (cpu-cycle wise) using XOR AX,AX instead of MOV AX,0 <br>
Sorry, that should be XOR DX,DX but im sure you get my point :)
two more points: MOV AH, 0x09 leaves you with undefined AL (or maybe im not seeing where you zero out AL. secondly - holy lateness batman, didnt notice how old this instructable was untill just now :) <br>
I liked it very much! Where can i find more tutorials and examples about Debug.exe? Where can i find more of your tutorials? Thank you!
Thanks! You can google or check the wikipedia: <a rel="nofollow" href="http://en.wikipedia.org/wiki/DEBUG">http://en.wikipedia.org/wiki/DEBUG</a><br/>If you want to play around with x86 assembly, I'll recommend:<br/>NASM, best for 16-Bits DOS: <a rel="nofollow" href="http://www.nasm.us/">http://www.nasm.us/</a><br/>MASM32, best for 32-Bits WIN: <a rel="nofollow" href="http://www.masm32.com/">http://www.masm32.com/</a><br/>They are both free.<br/><br/>
Thank you so much ;D
try this:<br/><br/>@Echo Off<br/>msg * Hello World<br/>pause<br/><br/>=)<br/>
nice! although message service only work on Win2K based OS.. but still fun to do some interesting pop-up messages with batching :)
most assemblers have some quality of code checking to make sure that the code doesn't do much other than intended. Debug however, does not. This makes it dangerous to use to much, as I learned first hand a while ago. I was doing something like this, and I typed in the wrong register. When I ran it, garbage characters spewed across the screen and made a very annoying sound. It was even more annoying that you couldn't close out the program without shutting off the computer. Of course, the next day I loaded it into my bro's computer and changed the registry to start it on boot. ;)
Hello World! I liked it! :) Could ne1 explain me how to ask for two numbers and sum them using windows xp debuger? Thank you
I didn't understand a thing you said in this instructable.... :'(
echo Hello World! ;) Pretty neat stuff though. You know quite a bit about this :)
Thank's :D I just love this kind of hardcore stuff, it remind me when had my 286 PC and lost hours messing with the system, playing EGA/VGA games and getting my nerves to make some programs to work because didn't had enough free convensional memory (640K!)... oh, "hellow.bat": @echo Hello World! 18 Bytes! But .BAT is basically like scripting, not real machine-code :P The "@" character avoid the command to be echoed, btw.
Bahaha, did gates not once say, "No one will ever need more than 640K!" or something like that?
HAHA-back in the day, trying to configure your system to free up more conventional memory was half the fun of playing games! nearly makes me miss DOS.
when did you pick that picture of &quot;Cosmo Kramer&quot; as an avatar?<br/>for those who haven't seen the N-bomb <a rel="nofollow" href="http://www.friedbrains.com/video35.htm">http://www.friedbrains.com/video35.htm</a><br/>
&quot;640K ought to be enough for anybody.&quot;, but Bill Gates deny that actually said this. :)<br/><br/><a rel="nofollow" href="http://en.wikiquote.org/wiki/Bill_Gates">http://en.wikiquote.org/wiki/Bill_Gates</a><br/>
I made a dos executable a couple years back. It was a nasty hd bomber. Wiped a few people's drives with it, they pissed me off.
Now that's a guy that no one should piss him off. =P<br/><br/>Releasing virus is a serious crime now, i remember the case of the &quot;ILoveYou&quot; virus, the programmer were a woman, she got caught and sent to jail.<br/><br/>For my point of view, the HDD Bombers (Destroy file-system) and/or some BIOS ones(Make the PC un-bootable anymore without a BIOS reflash) were always the most scary type of virus to me.<br/>
Yea that would scare me. And it wasn't exactly a hd bomber, but it did just that. I wanted to test it to see if it worked and all it was somewhat simple format command and it wrecked the guys hd because it was too late when he canceled it. I'm not out to wreck people's computers nor am I a hacker. I was just a nasty little shit back then :-P
Cool, I haven't seen debug used since the late '80s.

About This Instructable


10 favorites


More by JustBurn: How to write the world's smallest &quot;Hello World!&quot; executable for PC
Add instructable to: