Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a SPIM assembly language program convert.s. The program will do the follow

ID: 3739493 • Letter: W

Question

Write a SPIM assembly language program convert.s. The program will do the following: F = (9 * C / 5) + 32 C = 5 * (F - 32) / 9 Prompt the user to enter a letter indicating Celsius or Fahrenheit 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!". 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. 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

I need good source code for this SIPM language to run PCspim.

Explanation / Answer

.data

prompt1: .asciiz "What is the format of input temperature:"

prompt2: .asciiz " Enter the temperature:"

prompt3: .asciiz " Wrong format!!"

C: .asciiz "C"

F: .asciiz "F"

.text

#ask for format

la $a0,prompt1

li $v0,4

syscall

#read enterd format in $v0, just a character

li $v0,12

syscall

li $a0,'f'

beq $a0,$v0,F2C

li $a0,'F'

beq $a0,$v0,F2C

li $a0,'c'

beq $a0,$v0,C2F

li $a0,'C'

beq $a0,$v0,C2F

#print wrong format

la $a0,prompt3

li $v0,4

syscall

b exit

F2C:

#ask for temperature

la $a0,prompt2

li $v0,4

syscall

#read entered temperature in $v0

li $v0,5

syscall

#C=5*(F-32)/9

subi $a0,$v0,32 #F-32

li $a1,5

mul $a0,$a1,$a0 #5*(F-32)

li $a1,9

div $a0,$a0,$a1

#print converted temp

li $v0,1

syscall

#print C

la $a0,C

li $v0,4

syscall

b exit

C2F:

#ask for temperature

la $a0,prompt2

li $v0,4

syscall

#read entered temperature in $v0

li $v0,5

syscall

#F=(9*C/5)+32

li $a1,9

mul $a0,$v0,$a1

li $a1,5

div $a0,$a0,$a1

addi $a0,$a0,32

#print converted temp

li $v0,1

syscall

#print C

la $a0,C

li $v0,4

syscall

b exit

exit:

li $v0,10

syscall

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote