CS 2011, A Term 1999
Prof. Sergio A. Alvarez
Lab 1
Objective
The goal of this lab is to help you become acquainted with the Debug utility.
You'll also see a few assembly language instructions in action,
and you'll have a chance to review concepts in representation of
integers and floating point numbers, as well as byte ordering.
Instructions
- Attend your TA's in-lab mini-lecture about the debug utility.
- Insert a floppy disk. Open a DOS window on your PC.
At the DOS prompt, type "cd A:\" (no quotes) to change the
directory to the floppy drive.
- Download the executable file lab1.exe
onto your floppy disk, to a file named A:\lab1.exe.
- Type "debug lab1.exe" (no quotes) at the DOS prompt.
This command instructs debug to load the machine language program
contained in lab1.exe. You should see a hyphen "-"; this is the
debug prompt. Several debug commands were explained in the mini-lecture;
information about debug is also available in Appendix B of Irvine.
- At the debug prompt, type "r" to see the register contents.
The CS and IP registers together tell you the segment:offset
address of the first instruction to be executed.
- At the debug prompt, type "u offset" (where offset is
the offset of the first instruction). This lists the contents
of the first dozen or so instructions. The program lab1.exe
in fact contains only 8 instructions; any additional instructions
that you see do not belong to this program.
For each instruction, you will see the segment:offset address
of the first byte of the instruction (left column), the hex code
for the instruction (next column), and a symbolic representation
(mnemonic) of the instruction in the remaining columns,
with any operands appearing in the rightmost column.
- Type "r" at the debug prompt to capture the initial register
contents. Then trace through the program using the "t" command,
taking care not to go past the final (8th) "INT 21" instruction.
Keep track of changing register contents. For example, the first
instruction moves a constant into register AX; you will see that
the contents of AX change the first time you type "t".
You may use the "d offset" command at any time to view a
memory dump starting at the given offset relative to the
DS register; notice that the contents of the DS
register are changed by the second instruction, so subsequent
data offsets in the program are relative to this new segment value.
- Once you've finished tracing through the program,
answer the following questions
(feel free to start over if you wish; you're not being
graded on this today, but you will be graded on very similar
things in the near future, so now's a good time to practice):
- Assuming that the values transferred to AX and BX represent
signed integers, what are the decimal values of those integers?
- Are we having fun yet?
- Assuming that the four bytes transferred to registers
CX and DX together form the IEEE 754 representation of
some floating point number, what is the decimal representation
of that number?
- What would a byte-by-byte picture of the region of memory
initially containing the information subsequently loaded into
registers AX, BX, CX, and DX by the above program lab1.exe look like?
Such a picture should give the full address and hex contents of each
of the several bytes involved.
- Quit debug using the "q" command, remove your floppy disk
from the drive, and return the computer to a state in which
other students will be able to make full use of it (in case
of doubt, ask your TA).
- Make sure you've signed the TA's sign-in sheet.