Presentation is loading. Please wait.

Presentation is loading. Please wait.

DEBUG.

Similar presentations


Presentation on theme: "DEBUG."— Presentation transcript:

1 DEBUG

2 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.

3

4 ? -? 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

5 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= NV UP EI PL NZ NA PO NC 0AE6: D JZ 00D2 -R AX AX 0000 :1234 -R BX BX 0000 :567U ^ Error -R F NV UP EI PL NZ NA PO NC -PE 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= NV UP EI PL NZ NA PE NC -Q

6 Flag Flag “1” “0” Overflow Direction Interrupt Sign Zero
Auxiliary Carry Parity Carry OV DN EI NG ZR AC PE CY NV UP DI PL NZ NA PO NC

7 D (Dump) -D -D 100 -D DS:100 -D 0AE6:100 ASCII
0AE6: D0 F F A t..."..t9..". u. 0AE6: E DF BB B8 BA D5 0A .>...u.It 0AE6:0120 D2 87 D1 B CD 21-A3 EC EE B.! 0AE6: E D C B4 40-CD F C6 06 F0 99 0AE6: A C3 E8 FF 0F FE 06 DF E DE >...tH 0AE6: B 1E FB 00 7E-33 8B 0E EE 99 8B 16 EC ~ 0AE6: B C1 0B C B CD C9 B4 40 0AE6:0170 CD E F BA F0 99 B4 40 CD ASCII 128 bytes “.”: Unprintable ASCII character

8 D, D, … -D 0AE6: D0 F F A t..."..t9..". u. 0AE6: E DF BB B8 BA D5 0A .>...u.It 0AE6:0120 D2 87 D1 B CD 21-A3 EC EE B.! 0AE6: E D C B4 40-CD F C6 06 F0 99 0AE6: A C3 E8 FF 0F FE 06 DF E DE >...tH 0AE6: B 1E FB 00 7E-33 8B 0E EE 99 8B 16 EC ~ 0AE6: B C1 0B C B CD C9 B4 40 0AE6:0170 CD E F BA F0 99 B4 40 CD 0AE6: B4 3E CD 21 E9 6A FA-B4 3E CD 21 BA C9 98 B4 !.>.!.j..>.!.... 0AE6: CD 21 C6 06 DE E9 57 FA E9 AE FE 24 0C A.!......W....$. 0AE6:01A0 7A A2 E A2 E 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 E E8 6B E4 32 C k.2...# 0AE6:01D A C E9 8C 00-8B 36 C6 98 BF B u 0AE6:01E CD C BA 9B 8A E9 53 FF A1 .).!.<.t.....S.. 0AE6:01F0 C FC 3A B0-40 8A 0E E5 99 0C 20 2C , 0AE6: A A0 C8 98 8A-26 2B A C0 ` &+.%.... 0AE6: A C4 75 0F 80 3E-E FE t.:.u..>...t...$ 0AE6: C0 EB C4 D0 E8 0A 06 E6 99 A " 0AE6:0230 D4 96 D0 E0 D0 E0 A2 DF E E >...u$ 0AE6:0240 A2 E5 99 0A C9 75 1D 0A-C B 0E E2 96 E u...t...... 0AE6: B0 1A FF 8E 06-C1 96 F2 AE F u.O 0AE6: E E2 96 BB C E D BB 0D .>......>...t... 0AE6: BE B 3E C6 98-B E C > <

9 D addr1 addr2 -D 0AE6: F 80 3E-E FE >...t...$ 0AE6: C0 EB

10 E (Enter) -D 100 0AE6: D0 F F A t..."..t9..". u. 0AE6: E DF BB B8 BA D5 0A .>...u.It 0AE6:0120 D2 87 D1 B CD 21-A3 EC EE B.! 0AE6: E D C B4 40-CD F C6 06 F0 99 0AE6: A C3 E8 FF 0F FE 06 DF E DE >...tH 0AE6: B 1E FB 00 7E-33 8B 0E EE 99 8B 16 EC ~ 0AE6: B C1 0B C B CD C9 B4 40 0AE6:0170 CD E F BA F0 99 B4 40 CD -E 0AE6: F A t..."..t9..". u.

11 “-” & space “-” : backward Space: forward E DS:100

12 F (Fill) Format: -F startAddr endAddr list Example:

13 M (Move) Format: -M startAddr endAddr destAddr Example: -M

14 C (Compare) Format: -C startAddr endAddr destAddr Example:

15 S (Search) Format: -S startAddr endAddr list Example: -S

16 I (Input) Format: -I addr Example: -I 1234
“addr” is the I/O port address ranging from 0000H to FFFFH. Totally there are 64K byte-wide ports. Example: -I 1234

17 O (Output) Format: -O addr byte Example: -O

18 H (Hex add/sub) Format: -H num1 num2 Example: -H 1234 1111 2345 0123
“num1” and “num2” are no longer than 2 bytes. Example: -H -H 1234 EDCC Negative of 1234H

19 U (Unassemble) Format: -U [startAddr [endAddr]] Example: -E 100 88 C3

20 Diskette Format One double-sided double-density diskette
= 10001(?) sectors * 512 byte/sector

21 W (Write); L (Load) Format:
-W [startAddr [drive startSector noOfSectors]] -L [startAddr [drive startSector noOfSectors]] Example: -W DS:100 a: ?

22 N (Name) Format: -N fileName Example: -N a:test1.txt
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

23 A (Assemble) Format: -A startAddr

24 T (Trace) Format: -T [=startAddr] [numberOfInstructions] Example:
-T =CS:100 5

25 G (Go) Format: -G [=startAddr [breakpointAddrList] Example:
-G =CS: -G =CS:100 -G

26 Example -a 100 0AE6:0100 add dx,1234 0AE6:0104 -d 100 103
0AE6: C -u 0AE6: C ADD DX,1234

27 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 0AE6:0100 B BB D -u 0AE6:0100 B MOV AX,0012 0AE6:0103 BB MOV BX,0034 0AE6: D ADD AX,BX -N A:TEST2.MCD -R CX CX 0000 :8 -R BX BX 0000 :0 -W CS:100 Writing bytes

28 Further reading: Tutorials on the Internet
You can find some tutorials of the DEBUG program on the Internet, such as from the following websites:

29 To debug a program >debug calcul.exe


Download ppt "DEBUG."

Similar presentations


Ads by Google