Sei sulla pagina 1di 5

DEBUG commands A (Assemble)

Translates assembly language source statements into machine code, write and test small assembly language programs - a 100 <Enter> nnnn:0100 mov ax,0015 <Enter> nnnn:0103 mov cx,0023 <Enter> nnnn:0106 sub cx,ax <Enter> nnnn:0108 mov [120],al <Enter> nnnn:010B mov cl,[120] <Enter> nnnn:010F nop <Enter> nnnn:0110 <Enter> May correct the instruction in the specific memory locations provided that the new instruction is of the same length as the one that it replaces - a 106 nnnn:0106 sub cx,ax <Enter> nnnn:0108 <Enter> length of program in memory:(010F - 0-100 + 1) = 10h bytes.
The AX-register is also called the accumulator.

(Register)
Displays the contents of registers and allows you to change this value. r Display the contents of all the registers. r f Display the flags register. r register_name Display the contents of a specific register. - r ip <Enter> IP 0180 This means that the current value of IP is 0180h. (You can now enter a new value to be loaded into IP or press Enter to leave the register unchanged.) : 0100 <Enter> (The contents of IP is changed to 0100h.) IP register, which acts as the program counter IP (Instruction Pointer) always points to next instruction to be executed.

(Trace)
Allows you to execute a program step by step. Want to execute instructions from address 100 ensure IP register value 100. use r ip command and reset IP to 100. Enter t command repeatedly until get to NOP instruction. Instruction MOV AX,0015 stored at memory location 100 is executed. response is as follows (after MOV AX,0015): -t AX=0015 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13A0 ES=13A0 SS=13A0 CS=13A0 IP=0103 NV UP EI PL NZ NA PO NC 13A0:0103 B92300 MOV CX,0023 information that interests: First line: AX register contains 0015h as expected. Second line: IP points to address 0103h, next instruction to be executed. NV, UP, EI, PL, NZ, NA, PO and NC represent status flags. - First one - Overflow flag. NV = No Overflow. OV = Overflow occurred. - Fourth one - Sign flag. PL = sign of previous arithmetic operation was Plus (positive). NG = it was NeGative. - Fifth one - Zero flag. NZ = result of previous arithmetic operation was Not Zero. ZR = result of previous arithmetic operation was ZeRo. - Last one - Carry flag. NC = No final Carry resulted previous arithmetic operation. CY = there was a final CarrY. Third line: Hexadecimal number B92300 stored at segment 13A0 and offset (address) 0103. This value, i.e. B92300h, is hexadecimal representation of machine code for the assembly language instruction MOV CX,0023. Instruction executed next IP points 0103.

(Go)
Executes a program up to a certain specified point (called a breakpoint). Suppose want to execute up to location 108h - instruction in 108h will be IP point to when execution halted. Reset IP to 100h and type g 108. All instructions of program executed up to but not including instruction at address 108h.

(Proceed)
Similar to Trace except instructions CALL, INT and LOOP are encountered. If p used, DEBUG will perform ALL machine code instructions associated with instruction and will stop at instruction following CALL, INT or LOOP. Proceed can be used to avoid tracing all instructions of loops or subroutines of which not want to see detail. Also avoid tracing system calls like interrupts (INT instructions).
Use Proceed instead of Trace or Go when the next instruction to be executed is INT.

Add instruction, INT 20. - a 110 <Enter> nnnn:0110 int 20 <Enter> nnnn:0112 <Enter> INT 20 instruction causes program to terminate and return to DEBUG. Rerun program and type p when INT 20 be executed. DEBUG will respond with: program terminated normally -

(Dump or Display)
Detail assembly language, and data, stored in memory. Displays portion of memory in hexadecimal. d 100 10F <Enter> DEBUG responds with: nnnn:0100 B8 15 00 B9 23 00 29 C1-A2 20 01 8A 0E 20 01 90 Program is stored in memory - each instruction following immediately after previous one.

(Unassemble)
Disassembles machine code instructions. List the assembly language instructions associated with program stored in memory. U 100 10F will unassemble the instructions from memory addresses 100h up to 10Fh. u 100 10F <Enter> DEBUG responds with: nnnn:0100 B81500 MOV AX,0015 nnnn:0103 B92300 MOV CX,0023 nnnn:0106 29C1 SUB CX,AX nnnn:0108 A22001 MOV [0120],AL nnnn:010B 8A0E2001 MOV CL,[0120] nnnn:010F 90 NOP

(Enter)
Used for different purposes: Enter data or machine code instructions directly into memory. Type e followed by address and then data or machine code want to store in memory locations, starting at the specified address. Examples: - e 106 23 67 2a <Enter> Enter byte values. Values 23h, 67h and 2Ah stored in three memory positions, 106h, 107h and 108h respectively. - e 109 "I enjoy using DEBUG" <Enter> Enter character string. Each ASCII character in string occupies 1 byte. The first character, i.e. I, is stored in position 109h, the second in 10Ah and so on. - e 108 29 C1 <Enter> Enter instruction SUB CX,AX (machine code 29C1h) directly into memory positions 108h and 109h.

Use e to display contents of memory locations. Example: Display contents of memory positions 108h and 109h. - e 108 <Enter> 119C:0108 29. <Enter> - e 109 <Enter> 119C:0109 C1. <Enter>

(Name), L

(Load), W

(Write)

Created program under DEBUG and store this program for future use. The n command give name to executable program file in which want to store program. The w command write the file to disk, but must first specify how many bytes must be written. The combination of the BX and CX registers that forms a 32-bit register, is used to specify the number of bytes to be written. Programs are going to be relatively small, so BX will normally contain 0000 and CX the size (in bytes) of the program. Suppose want to write 66h bytes, starting from memory location 100h. Want to name program beep.com. (Only assemble .com files with DEBUG.) At the DEBUG prompt: -r bx <Enter. bx ???? :0000 <Enter> -r cx <Enter> cx ???? :66 <Enter> -n beep.com -w writing 66 bytes The l command will load contents of current file into memory from address CS:100 onwards. Load file from disk into memory starting at location 100h, we type (note, that we must first name the file): -n beep.com -l CX will contain length of file after load completed. The 32-bit register which is formed by combination of BX and CX registers, gives length of file being loaded/written. BX contains high order and CX low-order part of file length. For small files, BX = 0 and CX contains length.

(Hexadecimal)
Used to do addition and subtraction of two hexadecimal numbers. Example: -h 65 23 0088 0042 This means that 65h + 23h = 0088h and that 65h - 23h = 42h.

(Input), O

(Output)

The i option is used to input and display one byte from a port, and the o option to send one byte to a port.

(Quit)
Exit from DEBUG and return to DOS

----oooOooo----

Potrebbero piacerti anche