Question

(Mips) The below program is "Broken" , what 4 instructions need to be added to fix...

(Mips) The below program is "Broken" , what 4 instructions need to be added to fix it, make sure you care clear where the instructions are added in the program.

.data

input : .asciiz "\nPlease Enter the Temperature in Fahrenheit:"

Output: .asciiz"\nThe Temperature in Celsius is:"

zero1: .float 0.0

onept8:.float 1.8

thirty2: .float 32.0

.text

.global main

main:

la $a0,input

li $v0,4

syscall #print input String

li $v0,6

syscall #read floating point number in $f0

l.s $f4, zero1 #initialize $f4 with 0.0

add.s $f12, $f4, $f0 #move input number into $12 as input parameter

jal T_Convert #call procedure T_convert with input in $f12

l.s $f4, zero1 #initialize $f4 with 0.0

add.s $f12, $f4, $f1

la $a0,Output

li $v0,4

syscall

li $v0,2

syscall

End_Prog:

li $v0,10

syscall

T_Convert:

l.s $f5, onept8

l.s $f6, thirty2

sub.s $f1, $f12, $f6

div.s $f1, $f1, $f5

jal Test

jr $ra

Test:

addi $t6, $t6,11

jr $ra

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.data

input : .asciiz "\nPlease Enter the Temperature in Fahrenheit:"

Output: .asciiz"\nThe Temperature in Celsius is:"

zero1: .float 0.0

onept8:.float 1.8

thirty2: .float 32.0

.text

.globl main

main:

la $a0,input

li $v0,4

syscall #print input String

li $v0,6

syscall #read floating point number in $f0

l.s $f4, zero1 #initialize $f4 with 0.0

add.s $f12, $f4, $f0 #move input number into $12 as input parameter

jal T_Convert #call procedure T_convert with input in $f12

l.s $f4, zero1 #initialize $f4 with 0.0

add.s $f12, $f4, $f1

la $a0,Output

li $v0,4

syscall

li $v0,2

syscall

End_Prog:

li $v0,10

syscall

T_Convert:

l.s $f5, onept8

l.s $f6, thirty2

sub.s $f1, $f12, $f6

div.s $f1, $f1, $f5

#jal Test

jr $ra

#Test:

#addi $t6, $t6,11

#jr $ra

Explanation: The instruction which are not needed are commented out in the answer code. All the four instruction are present at the end of the code. This assembly program converts temperature in Fahrenheit to Celsius.

It's sample out put is given below which I have run in QtSpim.

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
(Mips) The below program is "Broken" , what 4 instructions need to be added to fix...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In the SPIM simulator in MIPS assembly, write the itri routine in the itri.s skeleton to...

    In the SPIM simulator in MIPS assembly, write the itri routine in the itri.s skeleton to make it print an inverted triangle. The height of the triangle will be given in $a0, and will be between 1 and 40 inclusive. For the first three tests, the included test harness should print (spimsimulator(dot)sourceforge(dot)net) 1. (25 pts.) In the SPIM simulator in MIPS assembly, write the itri routine in the itri.s skeleton to make it print an inverted trian- gle. The height...

  • .data prompt: .asciiz "Input an integer x:\n" result: .asciiz "Fact(x) = " .text main: # show prompt li $v0, 4 la $a0, prompt syscall # read x li $v0, 5 syscall # function call move $a...

    .data prompt: .asciiz "Input an integer x:\n" result: .asciiz "Fact(x) = " .text main: # show prompt li $v0, 4 la $a0, prompt syscall # read x li $v0, 5 syscall # function call move $a0, $v0 jal factorial # jump factorial and save position to $ra move $t0, $v0 # $t0 = $v0 # show prompt li $v0, 4 la $a0, result syscall # print the result li $v0, 1 # system call #1 - print int move $a0,...

  • Hello, I'm having trouble completing this program in less than four lines using MIPS programming language,...

    Hello, I'm having trouble completing this program in less than four lines using MIPS programming language, we are required to fill in the missing code as indicated (via comments). IMPORTANT: As indicated in the program's comments: ⇒ Write no more than certain number of lines of code as indicated. (One instruction per line, and there will be penalty if your code consumes more lines.) ⇒ Code MUST use only instructions that are allowed i.e., only bit manipulating instructions: (ANDing, ORing,...

  • Computer Architecture Project Description: farh-to-cel.asm : # Revised and added code taken from Hennesey and Patterson...

    Computer Architecture Project Description: farh-to-cel.asm : # Revised and added code taken from Hennesey and Patterson 5th edition # to work with this simulator. # # Prompts a user to enter a Fahrenheit temperature as a floating point. # Displays the converted temperature in Celcius. # 10/28/2015 .data const5: .float 5.0 # store a floating point constant 5.0 const9: .float 9.0 const32: .float 32.0 .align 2 # align the next string on a word boundary .space 100 prompt: .asciiz "Please...

  • Write a MIPS program that prints(displays) "Hello World" using MMIO (NOT syscall!) Here is a scre...

    Write a MIPS program that prints(displays) "Hello World" using MMIO (NOT syscall!) Here is a screenshot of a MIPS program that prints user input to the screen. And I need something that displays "Hello World" without taking any input. Please help! Thanks. The output should be something like this but without the input .data 7 strl:.asciiz "\nStart entering characters in the MMIO Simulator" .text 10 .globl echo 12 13 14 15 16 17 echo: al Read # single print statement...

  • Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how...

    Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how one can use subroutines (also called procedures, functions, and methods) in MIPS. Because of the importance of subroutines in modern programming, most hardware designers include mechanisms to help programmers. In a high-level language like C or Java, most of the details of subroutine calling are hidden from the programmer. MIPS has special registers to send information to and from a subroutine. The registers $a0,...

  • Write the assembly code that will transform a squared image into a negative print. (HARD-CODED OUTPUT...

    Write the assembly code that will transform a squared image into a negative print. (HARD-CODED OUTPUT WILL RESULT IN ZERO.) That is, every pixel whose unsigned value is 0 should change to 255, 1 should change to 254, 2 should change to 253, ... 255 should change to 0. $a0 contains the address of the input buffer, $a1 contains the address of the output buffer address, and $a2 contains the image dimension. Look at the below image for your reference:...

  • The task will be to write a program in assembler to enter a number and calculate...

    The task will be to write a program in assembler to enter a number and calculate its associated Fibonacci number using a procedure (subroutine) that is called recursively. Factorial and Fibonacci(outline Programs) # MIPS assembly assembly assemblyassemblycode .data n: .word 4 .text main: la $s0,n lw $a0, 0($s0) jal factorial # move what ever is returned into $a0 move $a0, $v0 li $v0,1 syscall b finished factorial: add $sp , $sp , -8 # make room sw $a0, 4($sp )...

  • MIPS Insertion program.........I could really use some help ASAP

    I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort.  Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main:  # la $t0, val # loads val into a register  # li $t1, 0      #keeps track of how many numbers entered  la $a0,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT