1 / 14

Riyadh Philanthropic Society For Science Prince Sultan College For Woman

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. Outline. Introduction A demo program Using the debug program. Introduction.

chen
Télécharger la présentation

Riyadh Philanthropic Society For Science Prince Sultan College For Woman

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. Outline • Introduction • A demo program • Using the debug program Debug Program

  3. Introduction • 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 Program

  4. A Demo Program 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 Program

  5. Using the Debug Program • 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 Program

  6. Using the Debug Program (R) • To view the registers, type R: -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=0000NV UP EI PL NZNA 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 Debug Program

  7. DEBUG Flags Symbols Status Flag Set (1) Symbol Clear (0) Symbol CF CY (carry) NC (no carry) PF PE (even parity) PO (odd parity) AF AC (auxiliary carry) NA (no auxiliary carry) ZF ZR (zero) NZ (nonzero) SF NG (negative) PL (plus) OF OV (overflow) NV (no overflow) Control Flag DF DN (down) UP (up) IF EI (enable interrupts) DI (disable interrupts) Debug Program

  8. Using the DEBUG Program (T) --1 • To step through the program, type T: • The first instruction is MOV AX, 4000h -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=0003NV UP EI PL NZ NA PO NC 1A0A:0003 03C0 ADD AX, AX Unchanged, since a MOV doesn’t affect the flags Debug Program

  9. Using the DEBUG Program (T) --2 • To step through the program, type T: • Next, ADD AX, AX -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=0005OV UP EI NG NZ NA PE NC 1A0A:0005 83E8FF SUB AX, -01 Debug Program

  10. Using the DEBUG Program (T) -- 3 • To step through the program, type T: • Next, SUB AX, 0FFFFh -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=0008NV UP EI NG NZ AC PO CY 1A0A:0008 F7D8 NEG AX Debug Program

  11. Using the DEBUG Program (T) -- 4 • To step through the program, type T: • Next, NEG AX -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=000ANV UP EI PL NZ AC PE CY 1A0A:000A 40 INC AX Debug Program

  12. Using the DEBUG Program (T) -- 5 • To step through the program, type T: • Finally, INC AX -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=000BOV UP EI NG NZ AC PE CY 1A0A:000B B44C MOV AH, 4C Debug Program

  13. Using the DEBUG Program (G – Q) • To complete execution of the program, type G: Program terminated normally • To exit the DEBUG program, type Q: -Q c:\asm> Debug Program

  14. Using the DEBUG Program • 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 Program

More Related