Debug programming example

Source: Internet
Author: User

The luxurious and brilliant Windows system allows people to throw DOS to a distant memory corner. However, the real valuable things won't easily exit the stage of history. debug is one of these classic works. From the old DOS to today's Windows XP, debug has been closely following Microsoft's operating system, quietly lying in the system folder. Maybe you don't care about it at ordinary times, but if you want to become a system master that everyone envy, we have to wake up this long-sleeping command line tool. by reading this article's research on it, I believe you will feel the same as the author: Ginger is still old and hot!

I. Tracing: the world's first computer bug and debug

While pursuing a doctorate in physics at Harvard University, Howard Aiken began to dream of creating a computer to help him solve his mathematical difficulties. After working, he found IBM to invest $1 million in computer development, the first finished product Aiken named it Mark I, also known as "Automatic sequence controlled computer ", since then, the IBM company has officially moved into the computer "territory" by producing zombie machines, meat shop scales, coffee mills, and other messy industries ".

On October 16, September 9, 1945, Grace hobo, a female mathematician who compiled the computation program for Mark II, experienced a fault while debugging the program. After disassembling the relay, it was found that only the moth was flattened in the middle of the contact, thus, the operation of the machine is stuck. Therefore, hoobo stuck the moth to the computer's work log and collectively referred to program faults as "bugs". Since then, as soon as the computer stops running (which was a regular occurrence at that time), my colleagues will jokingly say to Howard Aiken that we are "debugging! Later, "bug" became a professional line in the computer field. For example, the program name in the DOS system is debug.

Currently, the moth is stored in the American Museum of History at the American Museum of Musenyi.

In 1981, debug.com was launched when the first PC DoS (DOS 1.00) was launched. However, so far, there has been no major changes to debug-of course, this refers to the function that debug provides to users, the code and internal running mechanism of DEBUG must change with the changes of the operating system. However, whether it is Windows 98, 2000 or XP, the debug operation is basically the same as that in a pure DOS environment.

2. Beginners: Just a few lines of command to learn how to use DEBUG

The debug.exe file is located in the Windows/system32 directory (Windows XP) or Windows/command directory (Windows 9x. The basic usage is as follows:

Step 1: click "Start> Run" and enter "cmd" (Windows 2000/XP) or "command" (Windows 9x) to open the Command Prompt window.

Step 2: Enter "debug" and press Enter. The prompt "-" appears. Now you have enabled the mysterious debug world.

Tips

Execute "?" For commands, see the main Commands and parameters of debug.

Step 3: Enter "d fe00: 0" and press enter to view the result (see figure 1). This is the manufacturer information of the motherboard BIOS. Enter "d FFFF: 5 L 8", Press enter, and the BIOS version date of the motherboard will also come out.

Step 4: Enter the "Q" command and press enter to exit the debug program.

III. Further dive: Debug classic instance show

Before operating on the following instances, you must be aware of operation security, because the DEBUG command has certain risks. If the input is incorrect, the system may be damaged.

Instance 1: view your video card information

Enter the "d c000: 0090" command and press Enter. Then, you can view the video memory, manufacturer, and other information of the video card on the right.

Example 2: Create a BIOS password Breaker

If you forget the BIOS password, the discharge method is generally used to clear the password. However, this is difficult for common users and requires the chassis to be opened. In fact, using the debug 0 command is much simpler! Enter the following command after:

O 70 19
O 71 15
Q

Restart the computer, the system prompts a CMOS checksum error, and requires you to re-enter the BIOS to set CMOS.

Tip: 70 and 71 are two CMOS ports. We can write some error data (such as 19, 16, and 17) after them, and all the settings in CMOS will be cleared, if not, try using a few more data.

If you think it is too troublesome to enter the DEBUG command every time, you can save the command as a COM file using the following method. You only need to run the command once you need to unbind the password. Run the "-" command at the command prompt in debug and enter the following command:

A 100
MoV dx, 70
MoV Al, 10
Out dx, Al
MoV dx, 71
MoV Al, 01
Out dx, Al (here we need to press ENTER twice, then the "-" prompt will appear, and then enter the following command)
R Cx ("CX 0000" will appear after you press enter, and then press enter again)
0c
N pass. com
W
Q

In this way, pass.com is generated in the current directory of DEBUG. It is a program for clearing BIOS password settings. You only need to enter "pass" at the DOS prompt and press Enter. After testing, we can run it successfully in windows. The knowledge is not stable, and sometimes the computer is restarted.

Example 3: detecting bad points of an LCD display

When purchasing an LCD display, we should not have any bright spots or dark spots. We can use the relevant detection software to assist in viewing the display. However, when configuring a computer, the boss often won't let us install software, in fact, the F command in debug can be clearly viewed!

To check whether the LCD screen has bad points, you can fill the screen with solid colors such as red, green, blue, and white for inspection. Below are several commonly used display detection F commands (the debug window is generally small, press Alt + enter to enlarge it to the entire screen ):

F b800: 00 f9f 20 70 full screen white
F b800: 00 f9f 20 40 full screen red
F b800: 00 f9f 20 20 full screen green
F b800: 00 f9f 20 10 full screen blue
F b800: 00 f9f C5 07 C4 07 full screen white cross Grid
F b800: 00 f9f C5 04 C4 04 full screen Red Cross Grid
F b800: 00 f9f C5 02 C4 02 full screen Green Cross Grid
F b800: 00 f9f C5 01 C4 01 full screen Blue Cross Grid

Example 4: use DEBUG to recover Windows 98

On a computer with both Windows 98 and Windows 2000 installed, sometimes after the disk fragments of drive C are sorted under Windows 98 (assuming Windows 98 is installed on drive C), Windows 98 may not be started next time. In this case, you must regenerate bootsect. Dos (this file is used to Boot Windows 98) to reboot Windows 98. You can use DEBUG to generate the bootsect. DOS file and start it to the DOS state with a floppy disk:

C:> debug
L 100 2 0 1
N bootsect (bootsect indicates the file name of the Windows 98 Boot Record)
RcX
CX 1, 0000
200
W
Q

Change C:/bootsect to bootsect. DOS to overwrite the original bootsect. Dos.

Be an endless loop bomb

The so-called endless loop is actually a kind of mistake in programming, causing the program to repeatedly execute the same command, resulting in a software deadlock. With Debug, we can make a small endless loop. At the DEBUG command prompt "-", enter the following command:

A100
MoV DL, 1
MoV ah, 2
Int 21
INC DL
JMP 102 (Press ENTER twice)
Nboot.com
RBx (Press ENTER twice, and an error message may appear. Leave it alone and enter it again)
RcX
A
-W

Now you can execute the generated boot.com under DOS to try the effect. At the same time, press Ctrl + break or Ctrl + C to force the stop. If it is in windows, force exit. However, the sound of the PC speaker may take some time to stop.

Iii. Hard drive: use DEBUG to play with disks

Note: As the following operations are very dangerous, we recommend that you think twice, and you 'd better hook up the hard disk on your computer to avoid misoperation of other hard disks.

Instance 1: Clear all information about the hard drive

Fdisk can be used to clear hard disk information easily. If you cannot delete partition information by using the fdisk command, the fdisk will crash even if you run the fdisk command, so we have to turn to debug. The following command clears information about all partitions on the hard disk.

TIPS: dangerous operations! Please proceed with caution!

C:/> debug
F 200 L1000 0
CS: 100
XXXX: 0100 mov ax, 301
XXXX: 0103 mov BX, 200
XXXX: 0106 mov CX, 1
XXXX: 0109 mov dx, 80 (Note: 80 represents the master disk, 81 represents the slave disk)
XXXX: 010c INT 13
XXXX: 010e INT 20
XXXX: 0110
G
Program terminated normally
Q

After the above program is executed, restart the computer, and the partition information of the hard disk has been cleared, we can use fdisk to re-partition the hard disk, and then format it to work properly.

TIPS: delete all partitions

To quickly delete all partitions, save the following command to a text file (for example, delpart.txt ):

A 100 int13rax
0301
RBx
0200
F 200 L 200 0
RcX
0001
RDX
0080
P
Q

Then execute "debug" in pure DoS (such as starting the system with a boot floppy disk ).

Instance 2: Saving floppy disk data

A floppy disk that was opened one minute ago, and one minute later it said, "This floppy disk is not formatted. Do you want to format it ?" However, important data is stored here. In fact, this situation is often caused by the logic corruption of the 0-side and 0-way and 1-sector of the floppy disk. You can try the following methods:

Step 1: Insert a good floppy disk into the floppy disk.

Step 2: Run debug and enter the following command after the prompt:
  
-L 100 0 0 1

Step 3: Remove a good floppy disk, insert the disk to be restored, and then enter the following command:

-W 100 0 0 1

However, if 0 side 0 side 1 fan is physical damage, debug will tell us that we can not write the disk, at this time, you can only try HD-COPY and other tool software.

Instance 3: Clear the Master Boot Record of the hard disk

If you encounter an error message indicating that fdisk cannot recognize the hard disk or that there is no hard disk when the computer starts, for example, "Fixed Disk 0 failure", try the following method, however, it should be noted that all hard disk partitions (including non-dos partitions) will be deleted, and all data will be lost.

Step 1: Create a boot floppy disk, including debug, fdisk, format, and other programs. Use it to start the computer, enter "debug", and press Enter.

Step 2: Enter the following command at the DEBUG command prompt:

FCS: 200 400 0
Rax
0301
RBx
0600
RcX
0001
RDX
0080
E 100 CD 13
P
Q

Step 3: Run fdisk and format to partition and format the disk separately.

Instance 4: Low Disk

Method 1: Completely low

-A 100
MoV ax, 0703
MoV CX and 0001
MoV dx, 0080
INT 13
INT 3
010d
G 100

TIPS: some BIOS of the motherboard already contains low-case programs, so you can use DEBUG to call it directly. The command is "G c800: 0005 ".

Method 2: fast and low-case

-A 100
MoV ax, 0500
MoV X, 0180
MoV CX and 0001
MoV dx, 0080
INT 13
INT 3
E 0180 0 0 0002
G 100

Do you know?

Debug mode for Windows 2000/XP

Enable "boot. INI file, and then in the Multi (0) disk (0) RDISK (0) Partition (1) add a space after the/winnt = "Microsoft Windows 2000 Professional"/fastdetect "statement, and then enter"/debug "to call the debugging program in the system when you start Windows 2000/XP, it can be activated at any time. This parameter can be used to solve regular errors.

If it is changed to "/crashdebug", it will not take effect until there is no error in the system core. If a random kernel error occurs, it will help you get rid of the error.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.