CS232, Spring 2008

Wombat Programming Assignment W1-3
Due: Friday, February 22, at class time

Exercise W1-3

Write and test a Wombat1 assembly language program called "W1-3.<your-last-name>.a" (the ".a" indicates an assembly language program) that reads in two numbers m and n and then computes and outputs m*n (the product of m and n).  Your program is not allowed to use the "multiply" machine instruction of the Wombat1, and so instead it must compute the product using a loop with repeated addition or subtraction.  Note that your program must correctly handle the multiplication regardless of whether the numbers m and n are positive, negative, or zero.

Because of the lack of structural blocks in assembly language, it is very easy for the code to become unreadable. Therefore I want you to include blank lines and comments to separate appropriate segments of your program. Remember: the easier it is for me to read and understand your program, the more points you'll get.

After writing your program, answer the following questions:

  1. How many machine instructions get executed every time through your loop?
  2. How many of those instructions in the loop involve accessing data in main memory? Don't count the fetching of instructions from main memory into the IR.  Just count the number of loads and stores of data, which transfer data between a register and memory, and additions and subtractions, which also access data in main memory.
  3. Why should you care how many of your instructions involve accessing data in main memory?

(Note that I will sometimes ask you to answer questions about your programs as part of your CPU Sim assignments.  Your answers to these questions may form a significant part of your grade, so do not treat them lightly.)

As usual, turn in a hard copy of your assembly language program and your answers to the questions above.  (Put the program and question answers on the same piece of paper to save trees.  I suggest that you type your answers to the questions as comments below the code in your file).   Also, attach your file to an email to me. Please remember to name your program file correctly so that it includes your last name. For example, I would name my file "W1-3.Skrien.a"