CS 2011, A Term 1999
Prof. Sergio A. Alvarez
Lab 6


The goal of this lab is for you to gain additional practice in using stack frames and stack reference parameters for procedure calls, as required for example in problems 1 and 2 of HW 6. Today's lab is intended to be relatively brief (you guys deserve a break!)


  1. 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 80X86 assembly language source file add1.asm onto your floppy disk, to a file named A:\add1.asm. This file contains the outline of a procedure named addonebyref which accepts an incoming unsigned integer parameter by reference on the stack and increments the parameter's value by 1.
  2. Place your copy of the Irvine link library irvine.lib in the A:\ directory. If you didn't bring your copy, you may download one in zipped form from Irvine's site at http://www.nuvisionmiami.com/books/asm/. Be sure to unzip it before attempting to use it. Ask the TA if you need help.
  3. Using a text editor (for example the DOS edit command), edit add1.asm, adding code for addonebyref to set up a stack frame, retrieve the value of the incoming parameter, increment it, dismantle the stack frame, and return (do not perform stack clean-up within addonebyref). Remember that the incoming parameter is passed by reference, not by value. Assemble add1.asm using the command tasm/la/zi add1.asm.
  4. Write a calling program, also in the file add1.asm, that prompts the user to input an unsigned integer, stores it in a memory variable, calls addonebyref with the address of this variable as its argument, and displays the resulting incremented value to the user. Stack clean-up should be handled by the calling program. For I/O, use the Irvine library functions Writestring, Readint, and Writeint. Include suitable extrn declarations. The following descriptions are from section 4.7 of the textbook:
  5. Link the object file add1.obj with the Irvine library irvine.lib using the command line tlink/3/m/v add1.obj irvine.lib. To speed up the assembly and linking process, you may place the above full sequence of tasm and tlink commands together in a batch file named addlink.bat and then simply type addlink at the DOS prompt.
  6. Run the resulting executable file add1.exe by typing add1 at the DOS prompt. Test your program for several input values.
  7. If you'd like, use any remaining time (hopefully you'll have some extra time after today's short lab!) to continue working on HW 6.
  8. 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).
  9. Make sure you've signed the TA's sign-in sheet.