290 likes | 301 Vues
DEBUG. Functions and Features. * Program name = DEBUG.COM * Target: IBM PC * Extremely useful, when used correctly. Almost a must for Assembler Language programmers * can provide an insight into the operation of the machine at the bit level.
E N D
Functions and Features • * Program name = DEBUG.COM • * Target: IBM PC • * Extremely useful, when used correctly. • Almost a must for Assembler Language programmers • * can provide an insight into the operation of the machine at the bit level. • can display and change any of the registers in the IBMPC • can start and stop program execution at any time, • can change the program • can look at diskettes, sector by sector. • works at the machine code level • can disassemble machine code, • can assemble instructions directly into machine code.
? -? assemble A [address] compare C range address dump D [range] enter E address [list] fill F range list go G [=address] [addresses] hex H value1 value2 input I port load L [address] [drive] [firstsector] [number] move M range address name N [pathname] [arglist] output O port byte proceed P [=address] [number] quit Q register R [register] search S range list trace T [=address] [value] unassemble U [range] write W [address] [drive] [firstsector] [number] allocate expanded memory XA [#pages] deallocate expanded memory XD [handle] map expanded memory pages XM [Lpage] [Ppage] [handle] display expanded memory status XS
R (Register) -R AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0AE6 ES=0AE6 SS=0AE6 CS=0AE6 IP=0100 NV UP EI PL NZ NA PO NC 0AE6:0100 74D0 JZ 00D2 -R AX AX 0000 :1234 -R BX BX 0000 :567U ^ Error -R F NV UP EI PL NZ NA PO NC -PE -R AX=1234 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=0AE6 ES=0AE6 SS=0AE6 CS=0AE6 IP=0100 NV UP EI PL NZ NA PE NC 0AE6:0100 74D0 JZ 00D2 -Q
D (Dump) -D -D 100 -D DS:100 -D 0AE6:100 0AE6:0100 74 D0 F6 06 22 99 80 74-39 F6 06 22 99 20 75 0A t..."..t9..". u. 0AE6:0110 80 3E DF 99 00 75 BB 49-74 B8 BA 18 34 00 D5 0A .>...u.It...4... 0AE6:0120 D2 87 D1 B8 01 42 CD 21-A3 EC 99 89 16 EE 99 80 .....B.!........ 0AE6:0130 3E D2 96 00 74 9C B4 40-CD 21 72 5F C6 06 F0 99 >...t..@.!r_.... 0AE6:0140 1A C3 E8 FF 0F FE 06 DF-96 80 3E DE 96 00 74 48 ..........>...tH 0AE6:0150 8B 1E 20 99 83 FB 00 7E-33 8B 0E EE 99 8B 16 EC .. ....~3....... 0AE6:0160 99 8B C1 0B C2 74 21 B8-00 42 CD 21 33 C9 B4 40 .....t!..B.!3..@ 0AE6:0170 CD 21 80 3E F0 99 00 74-08 41 BA F0 99 B4 40 CD .!.>...t.A....@. ASCII “.”: Unprintable ASCII character 128 bytes
D, D, … -D 0AE6:0100 74 D0 F6 06 22 99 80 74-39 F6 06 22 99 20 75 0A t..."..t9..". u. 0AE6:0110 80 3E DF 99 00 75 BB 49-74 B8 BA 18 34 00 D5 0A .>...u.It...4... 0AE6:0120 D2 87 D1 B8 01 42 CD 21-A3 EC 99 89 16 EE 99 80 .....B.!........ 0AE6:0130 3E D2 96 00 74 9C B4 40-CD 21 72 5F C6 06 F0 99 >...t..@.!r_.... 0AE6:0140 1A C3 E8 FF 0F FE 06 DF-96 80 3E DE 96 00 74 48 ..........>...tH 0AE6:0150 8B 1E 20 99 83 FB 00 7E-33 8B 0E EE 99 8B 16 EC .. ....~3....... 0AE6:0160 99 8B C1 0B C2 74 21 B8-00 42 CD 21 33 C9 B4 40 .....t!..B.!3..@ 0AE6:0170 CD 21 80 3E F0 99 00 74-08 41 BA F0 99 B4 40 CD .!.>...t.A....@. -D 0AE6:0180 21 B4 3E CD 21 E9 6A FA-B4 3E CD 21 BA C9 98 B4 !.>.!.j..>.!.... 0AE6:0190 41 CD 21 C6 06 DE 96 00-E9 57 FA E9 AE FE 24 0C A.!......W....$. 0AE6:01A0 7A 10 50 24 08 A2 E1 99-58 24 04 A2 E5 99 08 06 z.P$....X$...... 0AE6:01B0 DF 99 A0 E5 99 0A C0 C3-80 3E C4 98 FF 75 0C BF .........>...u.. 0AE6:01C0 EE 94 BD C4 98 E8 11 01-E8 6B E4 32 C0 86 06 23 .........k.2...# 0AE6:01D0 99 0A C0 75 03 E9 8C 00-8B 36 C6 98 BF 83 97 B8 ...u.....6...... 0AE6:01E0 00 29 CD 21 80 3C 00 74-06 BA 9B 8A E9 53 FF A1 .).!.<.t.....S.. 0AE6:01F0 C9 98 80 FC 3A 74 02 B0-40 8A 0E E5 99 0C 20 2C ....:t..@..... , -D 0AE6:0200 60 A2 83 97 A0 C8 98 8A-26 2B 99 25 02 02 0A C0 `.......&+.%.... 0AE6:0210 74 13 3A C4 75 0F 80 3E-E6 99 00 74 08 FE 06 24 t.:.u..>...t...$ 0AE6:0220 99 32 C0 EB 06 34 02 22-C4 D0 E8 0A 06 E6 99 A2 .2...4."........ 0AE6:0230 D4 96 D0 E0 D0 E0 A2 DF-99 80 3E E1 99 00 75 24 ..........>...u$ 0AE6:0240 A2 E5 99 0A C9 75 1D 0A-C0 74 19 8B 0E E2 96 E3 .....u...t...... 0AE6:0250 13 B0 1A 06 33 FF 8E 06-C1 96 F2 AE 07 75 05 4F ....3........u.O 0AE6:0260 89 3E E2 96 BB C7 97 80-3E D4 96 00 74 03 BB 0D .>......>...t... 0AE6:0270 98 BE 84 97 8B 3E C6 98-B9 08 00 E8 12 00 80 3C .....>.........<
D addr1 addr2 -D 215 225 0AE6:0210 0F 80 3E-E6 99 00 74 08 FE 06 24 ..>...t...$ 0AE6:0220 99 32 C0 EB 06 34 .2...4
E (Enter) -D 100 0AE6:0100 74 D0 F6 06 22 99 80 74-39 F6 06 22 99 20 75 0A t..."..t9..". u. 0AE6:0110 80 3E DF 99 00 75 BB 49-74 B8 BA 18 34 00 D5 0A .>...u.It...4... 0AE6:0120 D2 87 D1 B8 01 42 CD 21-A3 EC 99 89 16 EE 99 80 .....B.!........ 0AE6:0130 3E D2 96 00 74 9C B4 40-CD 21 72 5F C6 06 F0 99 >...t..@.!r_.... 0AE6:0140 1A C3 E8 FF 0F FE 06 DF-96 80 3E DE 96 00 74 48 ..........>...tH 0AE6:0150 8B 1E 20 99 83 FB 00 7E-33 8B 0E EE 99 8B 16 EC .. ....~3....... 0AE6:0160 99 8B C1 0B C2 74 21 B8-00 42 CD 21 33 C9 B4 40 .....t!..B.!3..@ 0AE6:0170 CD 21 80 3E F0 99 00 74-08 41 BA F0 99 B4 40 CD .!.>...t.A....@. -E 100 12 34 56 78 -D 100 0AE6:0100 12 34 56 78 22 99 80 74-39 F6 06 22 99 20 75 0A t..."..t9..". u. 0AE6:0110 80 3E DF 99 00 75 BB 49-74 B8 BA 18 34 00 D5 0A .>...u.It...4... 0AE6:0120 D2 87 D1 B8 01 42 CD 21-A3 EC 99 89 16 EE 99 80 .....B.!........ 0AE6:0130 3E D2 96 00 74 9C B4 40-CD 21 72 5F C6 06 F0 99 >...t..@.!r_.... 0AE6:0140 1A C3 E8 FF 0F FE 06 DF-96 80 3E DE 96 00 74 48 ..........>...tH 0AE6:0150 8B 1E 20 99 83 FB 00 7E-33 8B 0E EE 99 8B 16 EC .. ....~3....... 0AE6:0160 99 8B C1 0B C2 74 21 B8-00 42 CD 21 33 C9 B4 40 .....t!..B.!3..@ 0AE6:0170 CD 21 80 3E F0 99 00 74-08 41 BA F0 99 B4 40 CD .!.>...t.A....@.
“-” & space “-” : backward Space: forward E DS:100
F (Fill) Format: -F startAddr endAddr list Example: -F 100 110 12 34 56
M (Move) Format: -M startAddr endAddr destAddr Example: -M 100 110 120
C (Compare) Format: -C startAddr endAddr destAddr Example: -C 100 110 120
S (Search) Format: -S startAddr endAddr list Example: -S 100 110 12 34
I (Input) Format: -I addr “addr” is the I/O port address ranging from 0000H to FFFFH. Totally there are 64K byte-wide ports. Example: -I 1234
O (Output) Format: -O addr byte Example: -O 1234 0
H (Hex add/sub) Format: -H num1 num2 “num1” and “num2” are no longer than 2 bytes. Example: -H 1234 1111 2345 0123 -H 0 1234 1234 EDCC Negative of 1234H
U (Unassemble) Format: -U [startAddr [endAddr]] Example: -E 100 88 C3 -U 100
Diskette Format One double-sided double-density diskette = 10001(?) sectors * 512 byte/sector
W (Write); L (Load) Format: -W [startAddr [drive startSectornoOfSectors]] -L [startAddr [drive startSectornoOfSectors]] Example: -W DS:100 a: ?
N (Name) Format: -N fileName Application: -N fileName (指定檔案名稱) (BX CX) number of bytes -W [startAddr] (指定要存到檔案的資料之起始位置, 並將資料寫入檔案) Application: N fileName L [startAddr] (將檔案內的資料讀到記憶體。) Write down the DEBUG commands to write 10H bytes of data from ds:222H into disk directory d:\aa\bb with filename dddd.txt Example: -N a:test1.txt Example: -N c:\users\jzTsai\dbg\test2.txt
A (Assemble) Format: -A startAddr
T (Trace) Format: -T [=startAddr][numberOfInstructions] Example: -T =CS:100 5
G (Go) Format: -G [=startAddr[breakpointAddrList] Example: -G =CS:100 128 -G =CS:100 -G
Example -a 100 0AE6:0100 add dx,1234 0AE6:0104 -d 100 103 0AE6:0100 81 C2 34 12 ..4. -u 100 103 0AE6:0100 81C23412 ADD DX,1234
Example: programming with debug -A CS:100 0AE6:0100 MOV AX,12 0AE6:0103 MOV BX,34 0AE6:0106 ADD AX,BX 0AE6:0108 -d 100 107 0AE6:0100 B8 12 00 BB 34 00 01 D8 ....4... -u 100 107 0AE6:0100 B81200 MOV AX,0012 0AE6:0103 BB3400 MOV BX,0034 0AE6:0106 01D8 ADD AX,BX -N A:TEST2.MCD -R CX CX 0000 :8 -R BX BX 0000 :0 -W CS:100 Writing 00008 bytes
Further reading: Tutorials on the Internet You can find some tutorials of the DEBUG program on the Internet, such as from the following websites: http://netcity2.web.hinet.net/UserData/suchya/ http://www.xploiter.com/programming/asm/debug.shtml http://www.datainstitute.com/debug1.htm http://www.plumb.org/tekmage/Inspire/debug-manual.html http://mirror.href.com/thestarman/asm/debug/debug.htm http://www.geocities.com/thestarman3/asm/debug/debug2.htm
To debug a program >debug calcul.exe