CS201 Lab: Procedure Calls

Objective of this lab:


	In this lab assignment, you are going to practice  
	implementing procedure calls in SPIM. 

Preparation


	Read lab lecture notes.

Lab Assignment

Program#1:

In the Control Structure lab, you were assigned the following assignment:


Write a SPIM assembly language program convert.s. 

The program will do the following:
  1. Prompt the user to enter a letter indicating Celsius or Fahrenheit.
  2. Prompt the user to enter an integer indicating the temperature matching the letter just entered.
  3. Convert the temperature to its counter part.
  4. Here are the two formulas for your reference:
  5.  
    
    	F = (9 * C / 5) + 32
    	
    	C = 5 * (F - 32) / 9
    
    
  6. Print out the converted value with an appropriate message.

For this lab, you will modify the previous program convert.s to convertP.s
so that it will implement the same thing by using procedure calls:

  1. You will write a procedure/function named "formulaCtoF" to convert a temperature from Celsius to Fahrenheit.
  2. You will write a procedure/function named "formulaFtoC" to convert a temperature from Fahrenheit to Celsius.
  3. The integer temperature entered will be passed into an appropriate function.
  4. Two different functions can be called when needed.
  5. The converted temperature will be returned to the calling function.

You will hand in the following:

  1. The source code in the file convertP.s
  2. The print out of the screen shot (print screen) to show the program has been successfully loaded.
  3. The print out of the screen shot of the console displaying the testing
    results: C or c with 100, 0, 50 and F or f with 100, 0, 212. G and h will be used to test the wrong letter case.

Program#2:

Write a SPIM assembly language program num-vowel.s based on the example program Is-vowel.s in the lab notes.
The program will do the following:
  1. Prompt the user to enter a null terminated string.
  2. The program will call the procedure vowelp to check if a character entered in the string is a vowel or not.
  3. Count how many vowels and how many other characters are in the string.
  4. Print out the calculated results with appropriate message.
  5. Hint: A loop is needed.

You will hand in the following:

  1. The source code in the file num-vowel.s
  2. The print out of the screen shot (print screen) to show the program has been successfully loaded.
  3. The print out of the screen shot of the console displaying the testing result
    for "I am going to run this program with the real hardware next week."

This page last modified:
Thursday, 31-Aug-2017 10:25:40 CST
Accessed     times.


Copyright: Department of Computer Science, University of Regina.