Debuggers

Post on 02-Jan-2016

16 views 1 download

description

Debuggers. A program needed when writing any type of code Displays the contents of memory Lets you view registers and variables and see how they change Allows tracing (stepping through a program one line at a time). Debug. A debugger supplied with both DOS and Windows Debug.exe - PowerPoint PPT Presentation

Transcript of Debuggers

Debuggers

• A program needed when writing any type of code

• Displays the contents of memory

• Lets you view registers and variables and see how they change

• Allows tracing (stepping through a program one line at a time)

Debug

• A debugger supplied with both DOS and Windows

• Debug.exe• Found in \Windows\command• Command line driven• A precursor of Microsoft Codeview,

Borland Turbo Debugger, Visual Studio Debuggers, Periscope, Atron, SYMDEB, Codesmith-86, Advanced-Trace-86

Assembly Level Debugger

• Debug is an assembly level debugger– Displays only assembly mnemonics and

machine instructions.

C> debug sample.exe

Debug.exe

Sample.exe

DOS0000

Debugging Functions

• Assemble short programs• View a program’s source code along with its machine

language• View the CPU registers and flags• Trace or execute a program, watching variables for

changes• Enter new values into memory• Search for binary or ASCII values in memory• Move a block of memory from one location to another• Fill a block of memory• Load and write disk files and sectors

Debug Commands

• Can be divided into four categories– Program creation/debugging– Memory manipulation– Miscellaneous– Input-output

Command Parameters

• Addresses– can be given as either a complete segment-

offset or just an offset– Segment portion may be a hex number or a

register name• F000:100 segment, offset• DS:200 segment register, offset• 0AF5 offset

Command Parameters

• Address Ranges– Format 1: address [.address]

• 100, 500• CS:200, 300• 200

– Format 2: address L [value]• 100 L 20 (20h bytes starting at location 100h)

Command Parameters

• Strings – a sequence of characters enclosed in single or double quotes.

• ‘command’• “File can not be opened.”

• Filespec – • B:prog1.com• C:\asm\progs\test.com• File1

• Values – consists of 1- to 4-character hex number.

Example commands

• -D (Dump)– Displays memory on the screen as single

bytes in both hex and ASCIINo range given => dumps 128 bytes from last

referenced location-d 0-200 => dumps offsets 0-200 from DS-d SS:0 5 => dumps the bytes at offsets 0-5

from SS.-d 915:0 => dumps 128 bytes from segment

0915h

Example Commands

• -R (Registers)-r =>display the contents of all registers

-r IP => display the contents of IP and prompt for a new value

-r CX => display the contents of CX and prompt for a new value

-r F => display all flags and prompt for a new flag value.

Flags

Set• OV = Overflow• DN = Direction Down• EI = Interrupts enabled• NG = Sign Flag negative• ZR = Zero• AC = Auxiliary Carry• PO = Odd Parity• CY= Carry

Clear• NV = No Overflow• UP = Direction Up• DI = Interrupts Disabled• PL = Sign Flag Positive• NZ = Not Zero• NA = No Auxiliary Carry• PE = Even Parity• NC = No Carry

Example Commands

• A (Assemble)– Assemble a program into machine language

• A 100 => assemble at CS:100• A => assemble from the current location• A DS:2000 => Assemble at DS:2000h

– Pressing enter at the end of a line, returns a prompt for the next line of input. To terminate input, press the Enter key on a blank line.

-a 1005514:0100 mov ah, 25514:0102 mov dl, 415514:0104 int 215514:0106

Example Commands

• -T (Trace) executes one or more instructions starting at either the current CS:IP location or at an optional address.-t => trace the next instruction

-t 5 => trace the next five instructions

-t =105 10 => trace 16 instructions starting at CS:105

Segment Defaults

Command Description Default Segment

A Assemble CS

D Dump DS

E Enter DS

F Fill CS

G Go(execute) CS

L Load DS

M Move DS

P Procedure Trace CS

S Search DS

T Trace CS

U Unassemble CS

W Write CS

Lab #1 and Lab #2

• First two labs will allow you to explore using Debug.