This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

2. More Work with Debug Background This lab will continue the exploration of the DEBUG program introduced in Lab #1. DEBUG, supplied by MS-DOS, is a program that can be used to debug x86 programs. Using DEBUG, you can easily enter an x86 program into memory and save it as an executable MS-DOS file (in .COM format). Other features of DEBUG include examining/changing memory/register contents, single-stepping programs, and inserting breakpoints into programs. DEBUG cannot be used to debug programs that contain 32-bit instructions (i.e., new instructions added to later versions of the 8086 such as the Pentium). This lab reviews some of the DEBUG features discussed in the previous lab and covers some additional concepts within DEBUG and the x86 instruction set. Objectives: Learn to A. Use DEBUG to examine the contents of memory and internal registers. B. Modify contents of memory, registers, and address space. C. Write short assembly language sequences using DEBUG. D. Single step through a program using the P (trace) function. E. Assemble and Unassemble code using DEBUG. F. Learn what the flags register is used for. Pre-Lab 1. Define the difference between a logical address and a physical address. Show how a physical address is generated from a logical address. 2. Define what each of the following registers are used for: DS, CS, IP, AX 3. Define the function each of the following flag bits in the flag register: Overflow, Carry, Sign, and Zero. Lab In the first portion of the lab, we will work with the DEBUG program. The answers to any questions marked as 'Lab Questions' must be included in your lab report. A. Working with DEBUG At a MS-DOS prompt, type debug. DEBUG’s prompt is a dash (-). Type a question mark (?) to get a list of available commands. You may return to the DOS prompt by entering Q and carriage return (<CR>).While in the DEBUG program, type D to initiate the dump command. The dump command displays the contents of memory. Lab Question 1: A). What occurs for this command? How many bytes are displayed? B) What is starting SEGMENT value, Offset value (on left hand side, displayed as XXXX:XXXX) C) What is the relationship between what is displayed on the right hand side and the HEX codes that are displayed?. Lab Question 2. The command also accepts a logical address (segment:offset) A) What happens if you type D1000:0100? B) What is different about this memory range and the previous memory range? On the x86 there are two types of addresses: the physical address and the logical address. The physical address is the address that is actually put on the address pins of the microprocessor and decoded by the memory interface. For the 8086/8088 CPUs, the address range is 00000H to FFFFFH which is equal to 1 megabyte of memory (220 memory locations, 20 address pins for the 8088/8086) . The logical address consists two parts, each 16 bits in length: the segment and the offset. The segment and offset values are combined to form the physical address. A logical address of 2500:0010 (segment:offset) has a physical address of 25010H. To convert a logic address to a physical address, shift the segment value to the left by four bits (shift left 2500H by 4 = 25000H) and add the offset value (25000H+0010H = 25010H) to produce the 20 bit physical address. How would you display memory locations 10000H thru 1000EH? Remember the physical address locations are displayed as a combination of the segment address and the offset. Use the ENTER command to load 12H, 13H, 14H into location 10000H (E1000:0000). The E command displays the contents of the memory location and waits for new data or a space character (hit the spacebar) to advance to the next location. The number before the period is the contents of the memory before the change. If no change is necessary, enter a space to go to the next location. Lab Question 3: Use the Dump command to view the contents at location 10000H. A) Are the values you entered in memory display at that location? B) How is the physical address 10000H calculated from the logical address 1000:0000? Show this calculation in your lab report. We can also use the mini-assembler to enter data. The A command accesses the mini-assembler. An assembler is a program that translates x86 instructions into machine code. Enter the following data (<CR> stands for carriage return - the enter key. The bold type is what you enter, the italicized is what DEBUG displays): A 1000:0000 <CR> 1000:0000 DB 15,64,FE <CR> 1000:0003 <CR>. Use the dump command to display the contents of the segment address 1000:0000,0002 and verify that the data you entered is actually in memory. The 'DB' command above stands for "DEFINE BYTE" and is used to tell the assembler to enter these 8-bit values into memory (the 8-bit values are in HEX). Use the mini-assembler to enter the following data:A 1000:0000 <CR> 1000:0000 DW 1234, 88AB <CR> 1000:0004 <CR>. The 'DW' command above stands for "DEFINE WORD" and is used to tell the assembler to enter 16 bit values in memory (16 bits = 2 bytes). Dump the contents of memory using "D 1000:000". Lab Question 4: A) What bytes are in locations 1000:0000, 1000:0001, 1000:0002, 1000:0003? Explain this byte arrangement (look in the notes and see what 'little endian' means in terms of byte ordering). Example 1.1 is a short program that uses a DOS software interrupt to display a character string (you can think of a DOS software interrupt as a 'function call' to DOS). For the DOS software 21H interrupt, we use the 'AH' register value to select a particular operation. In this case, AH=9 selects the function that prints out a character string. The starting address of the character string must be passed in the DS:DX registers. The character string must end with a $. The "INT 3" instruction is a breakpoint that stops program execution and causes the registers to be displayed. Example 1.1 -A 0100 <CR> MOV DX,0108 ????:0103 MOV AH,9 ????:0105 INT 21 ????: 0107 INT 3 ????:0108 DB ’This is my first assembly program$’ ????:012A The ???? above represents the code segment value. This value may differ depending on your computer configuration. Follow the example above and store the program in memory. Use the U 0100,0105 command to unassemble the program and to display it on the monitor using DEBUG to verify that your program


View Full Document

MSU ECE 3724 - More Work with Debug

Documents in this Course
Timers

Timers

38 pages

TEST 4

TEST 4

9 pages

Flags

Flags

6 pages

Timers

Timers

6 pages

Timers

Timers

54 pages

TEST2

TEST2

8 pages

Load more
Download More Work with Debug
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view More Work with Debug and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view More Work with Debug 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?