CS 2011, A Term 1999
Prof. Sergio A. Alvarez
The goal of this lab is to help you become acquainted with the Turbo
Assembler tools for assembling, linking, and debugging assembly
language programs. You'll also see examples of loops and indexed
addressing as required for HW 2. Finally, you'll have a chance
to resolve the mystery of the weird input string (what string?
read on). Don't worry if you can't finish the entire lab in the
time allotted. You can finish later. The main point is to help you
think about some important points that are relevant to
both HW 2 and Test 1.
- Attend your TA's in-lab mini-lecture about tasm, tlink, and td.
Additional information about td in particular is available in
Appendix D of Irvine.
- 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 8086 assembly language source file
index.asm onto your floppy disk,
to a file named A:\index.asm. Notice the weird string named
string1 defined in index.asm.
- Assemble the file using the command tasm/la/zi index.asm
(this produces the object file index.obj), and link using
tlink/m/v index.obj (this produces the executable file index.exe).
Examine the auxiliary listing file index.lst produced during the
assembly step and the map file index.map produced during the linking step.
The listing file includes hex encodings of the program's instructions.
Notice for example that the loop copyloop instruction is encoded as a
one-byte opcode plus a second byte that gives the displacement of the
start of the loop relative to the next instruction (check this).
- Enter the debugger by giving the command td index.exe.
In the debugger window, locate the arrow that points to the
next instruction to be executed at all times.
Trace past the .startup directive by pressing the function key F7.
The .startup directive generates machine code that initializes the
segment registers DS and SS. It's crucial to intialize DS before
doing any memory dumps (otherwise you'll see the wrong region of memory).
- Do a memory dump by using the View option in the menu bar
across the top part of the td screen (select Dump in the View menu).
You should see a few memory locations in the DS segment containing
the weird input string (string1) specified in the assembly source
- Again using the View option, open a window to view the
register contents. Examine the segment registers CS and DS.
Do you understand how the map file index.map relates to their
contents? Compare with the class discussion and with Irvine
- Now trace through the program one instruction at a time, using
function key F7. Keep an eye on register and memory contents.
Can you predict what will happen before you actually press F7 the
next time? Experiment a little bit. Notice that to see how the
memory locations corresponding to the output string (string2)
are changing, you may have to scroll down a bit in the memory
- Curious about string1? What if I told you that string1 is
the result of adding a fixed (signed) quantity to the ASCII codes
of all of the characters of some originally readable string?
You could probably whip up a simple modification of the assembly
language program index.asm to try out some possible values for
the "shift" quantity (a careful look at a memory dump of string1
and some basic information about ASCII may reveal some natural
candidates for the shift value) ...
A suggestion in case you decide to try:
place the new program in a different file (newindex.asm, say).
- When you're done, 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.