Debug is a program developed by Tim Paterson to write and examine assembly code. It allows viewing memory, comparing blocks, entering data, searching for patterns, tracing CPU instructions, and disassembling machine code. The document provides instructions for various Debug commands and examples of using them to examine registers, perform data transfers, arithmetic operations, and bit manipulation. It also includes examples of assembly language programs for keyboard input, string output, buffered keyboard input, and printer output. The document discusses using the Netwide Assembler (NASM) program for assembling code on different platforms and compares C to assembly languages. It provides steps for running NASM, writing an assembly program, and executing the code.
Debug is a program developed by Tim Paterson to write and examine assembly code. It allows viewing memory, comparing blocks, entering data, searching for patterns, tracing CPU instructions, and disassembling machine code. The document provides instructions for various Debug commands and examples of using them to examine registers, perform data transfers, arithmetic operations, and bit manipulation. It also includes examples of assembly language programs for keyboard input, string output, buffered keyboard input, and printer output. The document discusses using the Netwide Assembler (NASM) program for assembling code on different platforms and compares C to assembly languages. It provides steps for running NASM, writing an assembly program, and executing the code.
Debug is a program developed by Tim Paterson to write and examine assembly code. It allows viewing memory, comparing blocks, entering data, searching for patterns, tracing CPU instructions, and disassembling machine code. The document provides instructions for various Debug commands and examples of using them to examine registers, perform data transfers, arithmetic operations, and bit manipulation. It also includes examples of assembly language programs for keyboard input, string output, buffered keyboard input, and printer output. The document discusses using the Netwide Assembler (NASM) program for assembling code on different platforms and compares C to assembly languages. It provides steps for running NASM, writing an assembly program, and executing the code.
Debug is a program developed by Tim Paterson to write and examine assembly code. It allows viewing memory, comparing blocks, entering data, searching for patterns, tracing CPU instructions, and disassembling machine code. The document provides instructions for various Debug commands and examples of using them to examine registers, perform data transfers, arithmetic operations, and bit manipulation. It also includes examples of assembly language programs for keyboard input, string output, buffered keyboard input, and printer output. The document discusses using the Netwide Assembler (NASM) program for assembling code on different platforms and compares C to assembly languages. It provides steps for running NASM, writing an assembly program, and executing the code.
Download as PPT, PDF, TXT or read online from Scribd
Download as ppt, pdf, or txt
You are on page 1of 42
Debug
Developed by Tim Paterson
Debug is a method of looking at portions of your computer and writing assembly code to perform certain task.
The debug command is an external command and is available in the below Microsoft Operating Systems. All Versions of MS-DOS Windows 95 Windows 98 Windows ME Windows NT Windows 2000 Windows XP / Vista
Assemble: A [address] Creates machine executable code in memory beginning at CS:0100 (or the specified address) from the 8086/8088 (and 8087) -a100
Compare: C range address Compares two blocks of memory. If there are no differences, then DEBUG simply displays another prompt (-).
-c 140 148 340
The bytes at locations 140 through 148 are being compared to those at 340 (through 348, implied); the bytes are displayed side by side for those which are different (with their exact locations on either side of them). Dump: D [range] Displays the contents of a block of memory.
-d c000:0010
-d 100 133 Enter: E address [list] Used to enter data or instructions (as machinecode) directly into Memory locations.
-e ffcb d2 Fill: F range list This command can also be used to clear large areas of Memory as well as filling smaller areas with a continuously repeating phrase or single byte. Examples: -f 100 12f BUFFER -d 100 12f -f 0 ffff 0 Go: G [address] Go is used to run a program and set breakpoints in the program's code.
-g Hex: H value1 value2 A very simple (add and subtract only) hexcalculator.
Enter two Hex values (only up to four hexdigits each), and DEBUG shows first the SUM and thenthe DIFFERENCE (no carries past the fourth digit).
Examples: -h 123 100 -h 100 123 -h ffff 1 0223 0023 0223 FFDD 0000 FFFE Input: I port The use of I/O commands while running Windows maybe unreliable! This is especially true when trying to directly access hard disks through I/O commands!
-o 70 04 <-- Check the hours. -i 71
-o 70 02 <-- Check the minutes. -i 71 Move: M range address This command should really be called: COPY (not Move) as it actually copies all the bytes from within the specified range to a new address.
Examples: -m 7c00 7cff 600 Copies all the bytes between Offset 7C00 and 7CFF(inclusive) to Offset 0600 and following...
-m 100 2ff 70 Proceed: P Proceed acts exactly the same as Debug's T (Trace) command for most types of instructions...
EXCEPT: Proceed will immediately execute ALL the instructions
Quit: Q Immediately quits (exits) the Debug program! Register: R [register] Entering ' r ' all by itself will display all of the 8086 register's contents Search: S range list Searches within a range of addresses for a pattern of one or more byte values given in a list. The list can be comprised of numbers or character strings enclosed by matching single or double quote marks.
Examples:
-s fe00:0 ffff "BIOS"FE00:0021FE00:006F Trace: T [=address] [number] The T command is used to trace (step through) CPU instructions one at a time.
If you enter the T command all by itself, it will step through only ONE instruction beginning at the location specified by your CS:IP registers, halt program execution and then display all the CPU registers plus an unassembled version of the next instruction to be executed; this is the 'default' mode of the TRACE command.
To trace and execute seven instructions beginning at address CS:0205
-t =205 7 Unassemble: U [range] Disassembles machine instructions into 8086 Assembly code.
Example: -u 126 133
Run the following program and examine the effect to the registers Data Transfer
MOV AL, 0F MOV BL, 0F MOV DL, 0A ADD AL, BL SUB AL, DL MUL DL DIV BL Bit Manipulation Prior to execution MOV AL, 0F MOV DL, F0 MOV CL, 0FF AND AL, CL XOR AL, DL Determine the output function of the following program Program 1: MOV AH, 02 MOV DL, 41 INT 21 INT 20
PROGRAM 2: MOV AH, 02 MOV DL, 41 INT 21 MOV DL, 42 INT 21 MOV DL, 45 INT 21 INT 20 Keyboard Input Function Use debug to encode instruction listed below and assemble it on A100
MOV AH,01 INT 21 INT 20 Print String Function Write the program listed below at offset address 0100
xxxx: 0100 MOV DX, 109 xxxx: 0103 MOV AH, 09 xxxx: 0105 INT 21 xxxx: 0107 INT 20 xxxx: 0109 db Reality bites$ xxxx: 011F Buffered Keyboard Input Function On debug write the program listed below MOV DX, 109 MOV AH, 0A INT 21 INT 20 DB 30
Run the program upon pressing g on the prompt. Type string of characters until it stopped Printer Output Function Mov ah,05 Mov dl, 4a Int 21 Mov ah, 5 Mov dl, 41 Int 21 Mov ah, 5 Mov dl, 42 Int 21 Int 20 Using NASM (Netwide Assembler) I/O DOS Function
NASM is an acronym for Netwide Assembler, unlike DEBUG that is specifically for debugging purposes, this software assembles program written in assembly in any platform. NASM was among the first of the Open- Source, freely available, assemblers available for the x86. The project was started in the 1996 time frame as a way of creating a portable x86 assembler.
* Source: Webster
Comparison between C and ASM
How to run NASM 1. Run the NASMIDE software located at c:\NASM. Type NASMIDE at the prompt C:\NASM\> nasmide 2. Click File-New-ASM Assistant, select the options for code generation, starting address and segment code. 3. Encode your assembly language program, save the file (*.asm) and execute (Ctrl-F9) ASCII