Thursday, August 19, 2010

DOS redeemed

To misquote Nine Inch Nails' Happiness In Slavery (Broken, 1992):

"I have found you can find happiness in assembly"

(sidenote: I bought Broken thinking that track 4, "Help Me I Am In Hell" was "Closer"... not even close)

(once I overcame my disappointment at my musical ignorance, I greatly enjoyed the album, especially track 99 Suck)

I've also found that you can find happiness with something copyrighted by Microsoft!

I'm currently reading Jeff Duntemann's "Assembly Language Step-by-Step: Programming with DOS and Linux, Second Edition" and LOVING IT!  In keeping with more code than babble, here's some juicy tidbits either from the book or from my experiments:

Go to a DOS prompt and type debug then hit enter.

I'M SO SORRY THE VIDEO QUALITY IS $╠╬¡T  it looks fine in the .avi on my comp. Here's a link to the command-prompt session...


I used the d command (dump) to show a certain 128 byte range of memory.  Values are shown in hex.  The memory dump starts at XXXX:0100, which is the default for the instruction pointer as well. (Segment address will vary for your computer, which is the XXXX)

Found these defaults out from Kip Irvine's Debug Tutorial

If you type the d command again, it will display the next 128 bytes of memory following the previous dump.  The r command is used to display 1) the contents of the registers, 2) the contents of the next instruction in op code, and 3) a disassembled machine instruction of whatever happens to be where the instruction pointer is pointing (not necessarily a machine instruction!!).

In the video, you see me use the e command to manually write values to memory.  This requires you enter an address parameter.  Debug will display the segment and offset address (i.e. 13E8:0100) followed by the current value there, and a period.  The prompt will wait for you to either put a new hex value for this byte or put nothing to leave it the same.  Once you've entered a new hex value (or done nothing at all), you can either 1) press spacebar to move to the next byte, or 2) press enter to finish writing memory values.
(I like to zero out my dump.  It makes it look like not so much of a.... dump.)

Use q to quit.  Use ? to get a list of commands.  Hope you liked my first post!

No comments:

Post a Comment