#include<stdio.h>
#includ<conio.h>

Int main()
{
int ch;
float F,C,R,K;
char chs;
printf(“Choose Input Value\n1.F\n2.C\n3.R\n4.K\n”);
scanf(“%d”,&ch);
switch(ch)
{
 Case1:
  F=input(“Fahrenheit value”);
  C=(5/9)*(F-32);
  K=C+273.15;
  R(9/5)*K;

 Case2:
  C=input(“Celsius value”);
  F=(9/5)*(F-32);
  K=C+273.15;
  R=(9/5)*K;

 Case3:
  R=input(“Rankine value”);
  F=R-459.67;
  C=(5/9)*(F-32);
  K=C+273.15;

 Case4:
  K=input(“Kelvin value”);
  R=(9/5)*K;
  F=R-459.67;
  C=(5/9)*(F-32);

  default: printf(“Invalid Input”) 
}
fflush(stdin);
printf(“Print final value F=%0.3f R=0.3f C=%0.3f K=%0.3K”,F,R,C,K);
}

Given the following relationships write a MIPS program to convert a user input temperature in any of the four scales, and then converting to the other three scales. Identify the original temperature scale and value as well as the other three as output. If the scale entered is not F,C,R,or K, output an error message with the input for value displayed as part of the message.
I would like to change the C language to MIPS. I have not learned the MIPS language yet, so I have no idea. Can someone please help me? I would be happy to write the MIPS code.

From here on down, it doesn't matter.
have no relation
System calls are a set of services provided from the operating system. To use a system call, a call code is needed to be put to $v0 register for the needed operation. If a system call has arguments, those are put at the $a0-$a2 registers. Here are all the system calls.

li (load immediate) is a pseudo-instruction (we'll talk about that later) that instantly loads a register with a value. la (load address) is also a pseudo-instruction that loads an address to a register. With li $v0, 4 the $v0 register has now 4 as value, while la $a0, str loads the string of str to the $a0 register.

A word is (as much as we are talking about MIPS) a 32 bits sequence, with bit 31 being the Most Significant Bit and bit 0 being the Least Significant Bit.

lw (load word) transfers from the memory to a register, while sw (store word) transfers from a register to the memory. With the lw $s1, 0($t0) command, we loaded to $s1 register the value that was at the LSB of the $t0 register (thats what the 0 symbolizes here, the offset of the word), aka 256. $t0 here has the address, while $s1 has the value. sw $t2, 0($t0) does just the opposite job.

MARS uses the Little Endian, meaning that the LSB of a word is stored to the smallest byte address of the memory.

MIPS uses byte addresses, so an address is apart of its previous and next by 4.

By assembling the code from before, we can further understand how memory and registers exchange, disabling "Hexadecimal Values" from the Data SegmentYou may have noticed that MARS has a Tools menu. The capabilities provided through this menu really catapult MARS into a different league of computer science educational software.
We call each of the items in the Tools menu a MARS Tool. A MARS Tool is best described as a pop-up application that observes MIPS memory and/or register activity during MIPS program execution then communicates that activity to the tool user to serve a particular purpose. This is best seen by example.

I've been on a few embedded MIPS dev teams. We used a C compiler. What little we did in assembly was to account for changes from the supplied BSP (board support package) to accommodate our custom board.

It's possible you are posting homework here and didn't tell so I'll take this as an honest question and share how we compiled C code to run on our MIPS boards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.