Storing and loading the programs
It would not seem practical to type an entire program each time it is needed, and to avoid this it is possible to store a program on the disk, with the enormous advantage that by being already assembled it will not be necessary to run Debug again to execute it.
The steps to save a program that it is already stored on memory are:
- Obtain the length of the program subtracting the final address from the initial address, naturally in hexadecimal system.
- Give the program a name and extension.
- Put the length of the program on the CX register.
- Order Debug to write the program on the disk.
Using the following program as an example, we will have a clearer idea of how to take these steps. When the program is finally assembled it would look like this:
0C1B:0100 mov ax,0002
0C1B:0103 mov bx,0004
0C1B:0106 add ax,bx
0C1B:0108 int 20
-h 10a 100
Writing 000A bytes
To obtain the length of a program the "h" command is used, since it will show us the addition and subtraction of two numbers in hexadecimal. To obtain the length of ours, we give it as parameters the value of our program's final address (10A), and the program's initial address (100). The first result the command shows us is the addition of the parameters and the second is the subtraction.
The "n" command allows us to name the program. The "rcx" command allows us to change the content of the CX register to the value we obtained from the size of the file with "h", in this case 000a, since the result of the subtraction of the final address from the initial address.
Lastly, the "w" command writes our program on the disk, indicating how many bytes it wrote. Also, to save an already loaded file two steps are necessary:
- Give the name of the file to be loaded.
- Load it using the "l" (load) command.
To obtain the correct result of the following steps, it is necessary that the above program be already created.
Inside Debug we write the following:
-u 100 109
0C3D:0100 B80200 MOV AX,0002
0C3D:0103 BB0400 MOV BX,0004
0C3D:0106 01D8 ADD AX,BX
0C3D:0108 CD20 INT 20
The last "u" command is used to verify that the program was loaded on memory. What it does is that it disassembles the code and shows it disassembled. The parameters indicate to DEBUG from where and to where to disassemble. DEBUG always loads the programs on memory on the address 100H, otherwise indicated.
|Sample Chapters from book DATA RECOVERY WITH AND WITHOUT PROGRAMMING by Author Tarun Tyagi
Publishers of the Book
Number of Pages
Price of the Book
BPB Publications, New Delhi, India
$69.00 (Including Shipping Charges, Cost of Book and Other expenses, Free Source Code CD included with the Book)