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

  1. Attend your TA's in-lab mini-lecture about the debug utility.
  2. 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.
  3. Download the executable file lab1.exe onto your floppy disk, to a file named A:\lab1.exe.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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):
  9. 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).
  10. Make sure you've signed the TA's sign-in sheet.