CS201 Lab: Control Flow Structure
Objective of this lab:
To investigate the Control Flow Structure and implement them in PCSpim.
You will learn how to use assembly language to implement an "if statement"
and a "loop".
Read lab lecture notes.
Write a SPIM assembly language program convert.s.
The program will do the following:
- Prompt the user to enter a letter indicating Celsius or Fahrenheit
Prompt the user to enter an integer indicating the temperature
matching the letter just entered.
Convert the temperature to its counter part.
Here are the two formulas for your reference.
- C or c indicates that temperature entered is in Celsius.
- F or f indicates that temperature entered is in Fahrenheit.
- If the letter entered is not C, c, F, or f, print out
error message "Wrong Letter!".
F = (9 * C / 5) + 32
C = 5 * (F - 32) / 9
Print out the converted values with appropriate message.
Testing wrong letters: G and h
Testing values for C or c: 100, 0, 50
Testing values for F or f: 212, 0, 50
You will hand in the following:
- The source code in the file convert.s
- The print out of the screen shot (print screen) to show the program has been successfully loaded
- The print out of the screen shot of the console displaying the results
Copyright: Department of Computer Science, University of Regina.