THE DEBUG UTILITY PROGRAM

in steemstem •  7 years ago 

Hello great people,
Today, we will be discussing on this part of programming called debug utility program. I urge you to relax and i believe you will grab something.

images (5).jpg
image from pixabay

The MS-DOS Debug utility is a debugging program that provides a I controlled testing environment for binary and executable object files. Debug eliminates the need to reassemble a program to see if a problem has been fixed by a minor chance. It also allows you to alter the contents of the files or the contents of the CPU register, and then immediately re-executes the program to check the validity of the changes made.

All debug commands may be aborted any time by pressing Ctrl +C. the Ctrl +S key sequence suspends the display so that you can read it before the output scrolls away. You have to note that pressing any key other than Ctrl +S or Ctrl +C restarts the display.

For anyone intending to study assembly language programming, Debugging can provide a good starting point, in fact that’s how I even started. Now in debug mode, you can execute a single assembler instruction and observe the results by examining the registers. You can also execute a series of instructions without knowing so much about assembler directives. If you are careful enough, you can create powerful programs using only the Debug utility program.

Right now as we proceed, you have to read carefully as I sail you to the world of Debug commands needed in the beginning of assembly language programming.

In starting Debug, you must have the debug utility program – DEBUG.EXE before you can be able to use debug. If your computer is running on windows, I always advice that you restart your machine in raw MS-DOS mode before starting debug.* Must tell you, programming is a beautiful thing, winks*. So lets move on.

Debug is usually contained in the MS=DOS or windows/ Command directory. You may wish to go to this directory first before Debug. >You may verify whether debug is contained in your MS-DOS or windows/ Command directory using the MS-DOS dir command.
images (6).jpg
from pixabay

To start Debug, type the following at the DOS prompt;
Debug
And then press the Enter key. If all is so well, Debug starts and display its prompt - , the hyphen character (-), and waits for you to issue it a debug command.

DEBUG COMMAND
Each debug command consists of a single letter followed by one or more parameters. If a syntax error occurs in a Debug command, Debug reprints the command line and indicates the error with the caret ( ) and the word “Error”, let me so you an example;

des: 100 cs: 110
^Error

You may choose to use a combination of uppercase and lowercase when typing a Debug command. Debug is not case sensitive. In these debug commands, I will only explain only those we might need to get started with assembly language programming. This is especially true for those of you who may want to Debug (remove errors from) executable files.

DEBUG COMMAND PARAMETERS
All debug commands accept parameters except the Quit command (Q). delimeters (spaces or commas)may be used to separate parameters but a delimeter is required only between two consecutive hexadecimal values. Thus the following commands are equivalent:
dcs: 100110
d cs: 100 110
d, cs: 100, 110
that’s it, so now we are going to look at the brief definitions of these debug command parameters.

Drive: it’s a one digit hexadecimal value that indicates which drive a file will be located from or written to. The valid values are 0-3, where 0=A, 1=B, 2=C, 3=D.

Byte: a two digit hexadecimal value placed in or read from an address or register.

Record: it’s a one digit to three digit hexadecimal value that indicates the logical record, number on the disk and number of the disk sectors to be written or loaded. Logical records correspond to sectors; however, since they represent the entire disk space, their numbering differs.

Address: it’s a two part designation containing either an alphabetic segment register or for unit segment address plus an offset value. You may omit segment name, or segment address, in which case, the default segment DS for all commands except A, G, L, T and W, for which the default segment is CS. Remember, all numeric vales are hexadecimal.

Range: it contains two addresses; like address L value where the value is the number of lines on which the commands should operate (L80). The second type of range cannot be used if another hexadecimal value follows since the hexadecimal value should be interpreted as the second address of the range. The limit for range is 1000H. to specify any range of 1000H with only 4 digits, type 0000(or 0).

List: it’s a series of byte values or strings. List must be the last parameters on the command line. This is the simplest list:
fcs: 10042 45 48 54 41

String: it refers to any number of characters enclosed in quotation marks. Either single quotes(“) or double quotes(“ “) may be used.
board-1429542_1920.jpg
pixabay image

Now let s see how Debug can be used to write simple assembly language program. Lets write a program to add two numbers -245H and 2FCH using registers and then examine the results.
To assemble program into memory in debug mode, we use the A(assemble) command. We ths proceed:
A
3866:0100 MOV AX,245 :copy the value 245H into the AX register
3866:0103 ADD AX,2FC :copy 2FCH to the contents of AX
3866:0106
-G 0106

When you type the A command, Debug responds with a prompt, (I got the following when I typed this on my computer). This message is actually the address of the first instruction in the code segment. It then waits for you to enter assembler instructions.
When you press the Enter key at the end of each assembler instruction line, Debug generates the next instruction address like in the example 3866:0103 and again waits for further assembler instruction. you should realize however that the value 3866 might not be the same in your own computer. At the end of your assembler instructions just press the Enter key.

The MOV mnemonic instruction copies the value contained in the source operand to the destination operand. As used here, it copies the literal value 245H to the AX register replacing whatever was there previously.
The G(go) instruction executes your assembler instruction up to and including a specified address or range. When you type the G command as shown in the above, debug executes the program currently in memory and displays the value of the registers and flags.
The following output was displayed when we pressed Enter after entering the G0106 command line in the above program.
Ax=541 Bx=0000 Cx=0000 Dx=0000 SF=FFEE BP=0000 D1=0000 DS=3866 ES=3866 CS=3866 IP=0106 NV P EI PL NZ AC PE NC 3866:0106 26

When you examine the values displayed, you will discover that the AX register contains the some of 245H and 2FCH which is 541H.

So i hope you learnt a lot from our discussion so far. Just feel free to ask any question on the comment box. Still your humble friend, @setapart.

REFERENCES
Kip R. Irvine (2010). "Using Debug". Assembly language for Intel-based computers(6th ed.). Prentice Hall. ISBN 978-0136022121. Retrieved 2014-03-18.

Vernon Brooks (2014-04-08). "Enhanced DEBUG for PC DOS and MS-DOS. PC DOS Retro. Retrieved 2014-05-08.

Andreas Zeller: Why Programs Fail: A Guide to Systematic Debugging, Morgan Kaufmann, 2005. ISBN 1-55860-866-4

"SuperTrace Probe hardware debugger". www.ghs.com. Retrieved 2017-11-25.

DQmdEhYBwAGZDsmgdeDywfrba4DRJvaPFToR4HvSKjY8rim.gif
Much love @steemstem

bloggif_5a8b1206cbe34.gif

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

You are a genius...nice research work.

Nice work bro...thank you for sharing