Professional Documents
Culture Documents
Desc
Desc
Background
This lab will introduce you to some of the basic ‘‘tools of the trade’’. The assemblers introduced in this
lab will be used throughout the laboratory course, in the class, and may help you customize your PC
through machine language programming.
DEBUG, supplied by MS-DOS, is a program that traces the 8086 instructions. Using DEBUG, you can
easily enter 8086 machine code program into memory and save it as an executable MS-DOS file (in .COM
format). DEBUG can also be used to test and debug 8086 and 8088 programs. The features include
examining and changing memory and register contents including the CPU register. The programs may also
be single-stepped or run at full speed to a break point.
You will also become familiar with DEBUG32 which is the program supplied in your textbook on the
diskette. It is similar to DEBUG but offers full support for 32-bit instructions and addressing. DEBUG32
includes the 80x86 instructions through the Pentium instructions.
Objectives: Learn to
A. Use DEBUG and DEBUG32 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 DEBUG32.
D. Single step through a program using the T (trace) function.
E. Assemble and Unassemble code using DEBUG and DEBUG32.
Pre-Lab
Draw a figure like Figure 3.9 in the Uffenbeck text to be completed in lab. Make 3 copies of the map
blank. Read section 4.2 in the Uffenbeck textbook.
Lab
In the first portion of the lab, we will work with DEBUG the program supplied with MS-DOS. The next
portion will utilize DEBUG32 which is the program supplied with your textbook.
A. Loading 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>).
You may enter the key sequence (Ctrl) (PrtSc) to print the displayed information.
While in the DEBUG program, type D to initiate the dump command. The dump command displays the
contents of memory.
There are three types of addresses, the physical address, the logical address, and the offset address. The
physical address if the 20 bit address that is actually put on the address pins of the microprocessor and
decoded by the memory interface. For the 80x86 CPUs, the address range is 00000H to FFFFFH for the
actual physical location in the RAM or ROM within 1 megabyte of memory. The offset address is the
location with in a 64 kbyte segement range. Therefore the offset range is from 0000H to FFFFH. The
logical address consist of the segment value and an offset address. For a code segment (CS:IP) with
logical address 2500:0010 has a physical address of 25010H. Shft CS left one bit -> 25000 and add IP (the
offset) 25000H+0010H = 25010H the 20 bit physical address.
How would you display memory locations 10000H thru 1000EH? Remember the physical address
location displayed is a combination of the segment address, 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 space 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.
Use the Dump command to view the contents at location 10000H. Are the values you entered in
memory at that location?
We can also use the assemble command to enter data. Type A1000:0000 <CR> 1000:0000 DB
12,13,14 <CR> 1000:0003 <CR>. Use the dump command to display the contents of the segment
address 1000:0000,0002. What difference do you find between A and E?
The A command accesses a mini assembler. Example 1.1 is a short program that uses the DOS function
(option 9) to display a character string. The DOS function option 9 requires that the DS:DX register
combination address the character string and that AH is loaded with a 09H before executing the INT 21H
instruction. The INT 21 command accesses the DOS functions. The character string must end with a $.
The INT 3 provides a break point.
Example 1.1
-A0A88:0100 <CR>
MOV DX,0107
0A88:0103 MOV AH,9
0A88:0105 INT 21H
0A88:0107 DB ’This is my first assembly program$’
0A88:0129 INT 3
0A88:012A
Follow the example to store the program in memory. Use the U0100,0105 command to unassemble the
program and to display it on the monitor using DEBUG.
How does the displayed program differ from Example 1.1?
What is the logical address of the character string?
Type D0107 L21, how does the ascii text appear?
What is the logical address of the program? What is the physical address?
Once we are sure that the program is stored in memory, we can execute it using the G (Go) command. For
example, the G=1000:0000 command informs DEBUG to execute the program beginning at location
1000:0000. The = sign must precede the address. If a breakpoint is desired, it is entered as a second
parameter. Use the G command to execute the example program and stop it at offset address 0005.
(G=0100,0105).
Why don’t we include the code segment address (0A88:0100 in figure) in the G command?
What are the contents of the register?
What are the contents of all registers at the breakpoint?
Rewrite the program using INT 3 as the breakpoint, how does this change the G command?
Have the contents of the registers changed?
Issue the Register command to examine the contents of the internal registers.
B. Loading DEBUG32
At a MS-DOS prompt, type debug32. 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>). You may enter the key sequence
(Ctrl) (PrtSc) to print the displayed information. While in the DEBUG32 program, initiate the dump
(display) command. The dump command displays the contents of memory.
To load a program into debug32 use the load command. Use the load command and unassemble the
program ascii.exe provided on the diskette provide in the text in the directory Chap2. (Ask the TA what
directory the diskette has been stored on for lab.)
What command do you use to name and save a file using DEBUG32?
Does the program have to reside at a certain address in order to be saved?
Why or why not?
Lab Report