Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 1 : C F and K m / Miles Conversions The purpose of this lab is for you to get familiar with MIPS assembly

Lab 1: CF and Km/ Miles Conversions
The purpose of this lab is for you to get familiar with MIPS assembly language. In this lab,
you are going to write your first program in assembly.
Please write a program that converts temperature from C to F and from F to C. In your
program please use only integer instructions (mul, div, add,...). To convert
Celsius larr Fahrenheit, you can use the equations given below.
F=95C+32,C=59(F-32)
Your program will get inputs/outputs from/to the console (please look at the examples
given in class). It is necessary to have system calls in order to use the console.
For this program, you will need to use the following instructions:
mul rd,rs,rt # multiply to integer numbers rd=rs*rt
div rd,rs,rt # divide two integer numbers rd=rsrt
After getting the temperature conversion program, you are to modify this program to
have conversion from Km to Miles and vice versa.
REPORT
Please include the following items in your report.
Explain how your program works. You may use a flow chart, pseudo C program, or
other way to explain the program.
Show a couple of examples.
Conclusion section. Explain what you learned here and what was difficult about this
lab.
A print out of your program. # Include comments in your program.
CODE
You are to submit your assembly program (i.e. a text file that can be run with QtSpim)
Program "Shell"
. text
. globl main
main:
la $a0, conv # print conversion on terminal
1i$sv0,4
syscall
11 $v0,5 #yscall 5 reads an integer
syscal1
## # if v0=0
### then C to F
### else E_to_?--.
la sa0,prompc print prompt on terminal
1i sv0,4
syscall
11 $v0,5 #yscall 5 reads an integer
syscall
## conversion is done here
## C=95,(F-32)
## make sure your result is put in register $to
la sa0,ans1 #print string before result
1i sv0,4
syscal1
move $a0,st0 # print result (that is in register $to)
1 i $v0,1
syscall
la $a0, endl # system call to print
li $v0,4 # print a new line
syscall
11 $v0,10
syscali # exit
data segment
. data
conv: .asciiz "C-(0) or FF(1): "
prompc: .asciiz "Enter temperature in Celsius: "
ans1: .asciiz "Temperature in Fahrenheit is: "
prompf: .asciiz "Enter temperature in Fahrenheit: "
ans2: .asciiz "Temperature in Celsius is: "
endl: .asciliz "
"
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions

Question

76 Leadership concepts and applications.

Answered: 1 week ago

Question

Define the term Working Capital Gap.

Answered: 1 week ago