Programming with DOS Debugger (2003)
susam.net
susam.net
These days, I sometimes play with it to debug a pet project (Lithium, an x86 assembler and toy Lisp compiler targetting bare metal and .COM binaries, written in Clojure). And sometimes I discover things I wasn’t aware of: https://blog.danieljanus.pl/2014/04/06/dos-debugging-quirk/
I can't get tracing to work at https://copy.sh/v86/?profile=msdos
Modified OP's code to add more steps to see some stepping through but T makes the program run all the way to termination - https://i.imgur.com/hiYeC2x.png
We resurrected it with great joy and interest as to what we would find on this machine - apparently it had been in his family since it was bought, brand new, back to his grandfathers house, where it was used for a few months (!) before being 'put in the attic because it was broken'.
So, we dig it out, boot it up, and try to figure out what exactly is broken. I immediately notice that any .COM file I execute gradually gets bigger .. yes, its got one of the very first TSR .COM infecting viruses on it, and thats why granddad put it in the attic ..
So we have now isolated it and gotten it booting, and are using the onboard DEBUG.COM to attack the virus, neutralize it, control it and see what else we can do with it. Just the presence of DEBUG.COM alone has made this an exciting and fun project for the kids, who are learning all about filesystems and DOS .com/.exe differences, and TSR's and BIOS calls and so on ..
This aspect of FUN is seriously missing from modern computers!
I lived with the virus and at one point I printed all the assembly in it with my matrix printer and tried reverse engineering it. But it was just way too much code for me to understand it all.
(defun fib2
(x)
(AX-reg x)
(assembly
(CALL 272)
(JMP 320)
272
(CMP AX , 2)
(JC 304)
(push AX)
(sub ax , 1)
(call 272)
(MOV BX , AX)
(POP AX)
(PUSH BX)
(sub ax , 2)
(call 272)
(pop BX)
(add AX , BX)
(RET)
304
(RET)
320)
(AX-reg))"My hovercraft is full of eels"
The height of school humour. As long as the replacement was shorter than the original it was just a text substitution.
Oh well, I guess that day I learned something after all.
My source was in text files. I'd script them into DEBUG to assemble them just like in the article. I'd put NOPs in place of branching instructions, script the source into DEBUG, and then use the output to get the calculated offsets for the intended branches. Then I'd go back and put the branches and offsets into the code.
Nothing frustrated me more than having to insert code and recalculate all subsequent branches. I ended up peppering a lot of NOPs into my early programs so I'd have "spare" bytes to use for instructions I needed to add.
Getting a real assembler made a huge difference in my workflow. Translating DEBUG scripts into MASM/TASM-compatible source wasn't awful either.
I did have a lot of time away from the computer (my parents only allowed one hour per day), so this was overall a pretty good workflow. I did learn a fair amount doing this.
One command that is burned into my memory was invoking the low-level formatting routine on a hard drive:
g=c800:5For a change of pace anyone coming here who hadn't heard of DEBUG.EXE? How old are you???
The most interesting thing I did with debug.exe was to remove the silly write protection our schools PCs had in 7-8th grade and the installed some shareware (I think!) C++ compiler that I had found one the front page of a magazine. I didn't even really program C++ back then, mostly assembly and basic.
Removing the write protection was as simple as overwriting an ISR or something similar. It took very little time anyway.
Currently 21.
Awesome book, it taught me a lot.