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

Code: # this programs asks for temperature in Fahrenheit # and converts it to Ce

ID: 3628167 • Letter: C

Question

Code:
# this programs asks for temperature in Fahrenheit
# and converts it to Celsius

.text
.globl main
main: # main has to be a global label
addu $s7, $0, $ra # save return address in a global register


# GETTING INPUT VALUE

la $a0,input # print message "input" on the console
li $v0,4
syscall

li $v0,5 #insert here code to get number entered on the console
syscall

# CALCULATING

addi $t0,$v0,-32 # a = a + (-32)
mul $t0,$t0,5 # a = a * 5
div $t0,$t0,9 # a= a/9

# PRINTING

la $a0,result # Store the string named 'result' in $a0
li $v0,4 #
syscall # __?

move $a0,$t0 # __?
li $v0,1 # __?
syscall # __?

.data
input: .asciiz " Enter temperature in Fahrenheit: "
result: .asciiz "The temperature in Celsius is: "

addu $ra, $0, $s7 # restore the return address
jr $ra # return to the main program
add $0, $0, $0 # nop (no operation)

Question:
a) change directly in memory first four characters of the message from “have” to: “-not”.
Complete the run, check the result in the console window.

I have done majority of question asked to do. Though i am stuck on this, i tried numerous attempts to change the output. Only way i could find is using ".asciiz" , though of course this is not what is asked.

Also if possible could you help out with the comments so i fully understand this code, im having a little trouble. I think i kinda get it but im not 100% sure.







Explanation / Answer

please rate - thanks

# this programs asks for temperature in Fahrenheit
# and converts it to Celsius

.text
.globl main
main: # main has to be a global label
addu $s7, $0, $ra # save return address in a global register


# GETTING INPUT VALUE

la $a0,input # print message "input" on the console
li $v0,4
syscall

li $v0,5 #insert here code to get number entered on the console
syscall

# CALCULATING

addi $t0,$v0,-32 # a = a + (-32)       Celsius=(Fahrenheit-32)*5/9      formula
mul $t0,$t0,5 # a = a * 5
div $t0,$t0,9 # a= a/9

# PRINTING

la $a0,result # Store the string named 'result' in $a0
li $v0,4 #
syscall     # __?     outputs the string in result (outputs   The temperature in Celsius is: )

move $a0,$t0 # __?    puts the value in a0 (the Celsius temperature that was calculated in register $a0 which is where an integer that is being output has to be
li $v0,1 # __?   puts a 1 in $v0. v0 holds the code of what type of output is being done 1 means a number is being output
syscall # __?     outputs the number in $a0 which is the value that was calculated for Celsius

.data
input: .asciiz " Enter temperature in Fahrenheit: "
result: .asciiz "The temperature in Celsius is: "

addu $ra, $0, $s7 # restore the return address
jr $ra # return to the main program
add $0, $0, $0 # nop (no operation)

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