Step 6: Still Not Happy With the Result?

Still want more that just a Hello World?

Well, ok, i'll show you some usefull stuff, but only recommended for experienced PC users with a little knoledge of CPUs :)
From now on, try to SAVE BEFORE EXECUTE, because if the code go bad for some unknown reason, you will loose everything in memory if you didnt saved first.

to load a file, use "debug.exe (filename)", also you wont need the "n" command.

This extra code will make the app to wait for the user to press a key:
MOV AH, 00 ; "Function 00h - get character from keyboard" of Interrupt 16h
INT 16 ; Interrupt 16h

The "Hello World!" text with new-line at the end (0x24 is "$" if you forgot):
DB "Hello World!",0D,0A,24

Multi-line text:
DB "First Line!!",0D,0A
DB "Second Line!!",0D,0A,24

Correct way to terminate current application in DOS:
MOV AL, 00 ; Errorlevel 0
INT 21 ; Interrupt 21h - DOS Interrupt

You can jump to other locations in the code with JMP opcode:
JMP 0180 ; Jump to ????:0180

You can read a key press and jump to another location of the program if the key match (DON'T WORK VERY WELL WHEN EXECUTED INSIDE DEBUG.EXE, IT MAY CRASH).
INT 21 ; Call DOS Intrerrupt, AL register will have the key that the user pressed.
CMP AL, 31 ; Compare AL with 0x31 (0x31 = Character '1')
JZ 0180 ; Jump to 0180 if AL equal to 31
JNZ 0200 ; Jump to 0200 if AL not equal to 31

If you want to go serious with x86 assembly, I'll recommend:
NASM, best for 16-Bits DOS: http://www.nasm.us/
MASM32, best for 32-Bits WIN: http://www.masm32.com/
The best is, they are both free and much nicer than DEBUG.EXE for managing asm code!

Thanks for reading my instructable and have fun! :)
<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




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