CS 10, Spring 1998
Lab 5.3: Assembly Language
Assignment for next lab
- Study for the practical exam.
- Be sure to bring a disk to next class. You will turn your practical
exam in on this disk.
Assignment for the Tuesday after break:
- Read pp. 202-210
- Email me a list of the students (if any) who you will be working
with on your final project. An initial proposal for your final
project will be due the Thursday after break, so you may want to start
thinking about possible topics.
- Read the articles linked to from the discussion entry for March
17 on the schedule on the class web site
(http://www.cs.swarthmore.edu/~mirarchi/spring98/schedule.html)
Lab Instructions
Turn to the PIPPIN User's Guide on p. 188 in your book and read through the
summaries of each command. Notice that PIPPIN gives us commands for addition
and subtraction (ADD, ADI, SBD, SBI), but not multiplication.
Your goal today is to use
the Apple MacPippin stack to write a PIPPIN program which will perform
multiplication of two non-negative integers.
Assume that the two integers to multiply will be stored in memory
cells 14 and 15.
Your PIPPIN program should compute their product and store it in cell 16.
Below is an algorithm for performing multiplication through a series of
repeated additions. It assumes that the two numbers to be multiplied are
stored in cells 14 and 15, and stores their product in cell 16:
- Initialize the contents of cell 16 to 0.
- If cell 15 contains the value 0, then go to step 3. If cell 15 contains
a value a greater
than 0, then perform the following steps:
-
a. Add the contents of cell 14 to the contents of cell 16
-
b. Decrease the value of cell 15 by 1
-
c. Go back to step 2
- Halt
Refer to the PIPPIN User's Guide on p. 188 to help you implement
this algoirthm as an
assembly language program.
Call one of us over and show us your program when you have finished.
Hints :
- Step 1 can be implemented using only the Data Flow commands
(STO, LOD, and SET).
- The decision in step 2 as to whether to jump to step 3 or to go to
step (a) can be
implemented using the Control commands JMP and JMZ. Step (c) can also be
implemented using these commands.
- Steps (a) and (b) can be implemented using the Data Flow
commands (STO, LOD,
and SET) and the Arithmetic-Logic Commands (ADI, ADD, SBI, SBD).