Presentation is loading. Please wait.

Presentation is loading. Please wait.

Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.

Similar presentations


Presentation on theme: "Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization."— Presentation transcript:

1 Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization & Assembly Language Lecture 15 Debug Program

2  Introduction  A demo program  Using the debug program Debug Program2

3  The DEBUG program provides an environment in which a program may be tested.  The user can step through a program, and display and change the registers and memory.  It is also possible to enter assembly code directly, which DEBUG converts to machine code and stores in memory. Debug Program3

4 TITLE demo: CHECK FLAGS ; used in DEBUG to check flag settings.MODEL SMALL.STACK 100H.CODE MAIN PROC MOV AX,4000H; AX = 4000h ADD AX, AX; AX = 8000h SUB AX, 0FFFFH; AX = 8001h NEG AX; AX = 7FFFh INC AX; AX = 8000h MOV AH, 4CH; DOS exit function INT 21H; exit to DOS MAIN ENDP END MAIN Debug Program4

5  To enter DEBUG, (after assembling and linking the code) type: c:\asm> DEBUG demo.exe  DEBUG responds by its prompt, “-”, and waits for a command to be entered.  Basic DEBUG commands:  R: to view the registers.  T: to trace the program.  G: to complete execution of the program.  Q: to exit the DEBUG program Debug Program5

6 6 - R AX=0000 BX=0000 CX=000F DX=0000 SP=0100 BP=0000 SI=0000 DI=0000 DS=19FA ES=19FA SS=1A0B CS=1A0A IP=0000 NV UP EI PL NZ NA PO NC 1A0A:0000 B80040 MOV AX, 4000 Address of the next instruction to be executed Machine code of the next instruction to be executed Current flag settings To view the registers, type R:

7 Debug Program7 Status FlagSet (1) SymbolClear (0) Symbol CFCY (carry)NC (no carry) PFPE (even parity)PO (odd parity) AFAC (auxiliary carry)NA (no auxiliary carry) ZFZR (zero)NZ (nonzero) SFNG (negative)PL (plus) OFOV (overflow)NV (no overflow) Control Flag DFDN (down)UP (up) IFEI (enable interrupts)DI (disable interrupts)

8 Debug Program8 -T AX=4000 BX=0000 CX=000F DX=0000 SP=0100 BP=0000 SI=0000 DI=0000 DS=19FA ES=19FA SS=1A0B CS=1A0A IP=0003 NV UP EI PL NZ NA PO NC 1A0A:0003 03C0 ADD AX, AX Unchanged, since a MOV doesn’t affect the flags To step through the program, type T : The first instruction is MOV AX, 4000h

9 Debug Program9 -T AX=8000 BX=0000 CX=000F DX=0000 SP=0100 BP=0000 SI=0000 DI=0000 DS=19FA ES=19FA SS=1A0B CS=1A0A IP=0005 OV UP EI NG NZ NA PE NC 1A0A:0005 83E8FF SUB AX, -01 To step through the program, type T: Next, ADD AX, AX

10 Debug Program10 -T AX=8001 BX=0000 CX=000F DX=0000 SP=0100 BP=0000 SI=0000 DI=0000 DS=19FA ES=19FA SS=1A0B CS=1A0A IP=0008 NV UP EI NG NZ AC PO CY 1A0A:0008 F7D8 NEG AX To step through the program, type T: Next, SUB AX, 0FFFFh

11 Debug Program11 -T AX=7FFF BX=0000 CX=000F DX=0000 SP=0100 BP=0000 SI=0000 DI=0000 DS=19FA ES=19FA SS=1A0B CS=1A0A IP=000A NV UP EI PL NZ AC PE CY 1A0A:000A 40 INC AX To step through the program, type T: Next, NEG AX

12 Debug Program12 -T AX=8000 BX=0000 CX=000F DX=0000 SP=0100 BP=0000 SI=0000 DI=0000 DS=19FA ES=19FA SS=1A0B CS=1A0A IP=000B OV UP EI NG NZ AC PE CY 1A0A:000B B44C MOV AH, 4C To step through the program, type T: Finally, INC AX

13 Debug Program13 Program terminated normally To complete execution of the program, type G: -Q c:\asm> To exit the DEBUG program, type Q:

14  There are many other DEBUG commands, among them are:  R{register}: to change the contents of a register.  E: to change the contents of a memory location.  D: to display memory contents byte by byte.  U: to display the corresponding machine code.  Appendix E contains a detailed description of all DEBUG commands !!! Debug Program14


Download ppt "Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization."

Similar presentations


Ads by Google