Question
// **************************************************************** // LoveCS.java // // Use a while loop to print many messages declaring your // passion for computer science // **************************************************************** public class
// ****************************************************************
// LoveCS.java
//
// Use a while loop to print many messages declaring your
// passion for computer science
// ****************************************************************
public class LoveCS
{
public static void main(String[] args)
{
final int LIMIT = 10;
int count = 1;
while (count <= LIMIT)
{
System.out.println("I love Computer
Science!!");
count++;
}
}
}
I need this java code converted to MIPS language which is an assembly language used in the compiler in mars.
Below is some code we worked on in class and he said we could reference this.
.data
str1: .asciiz "x is bigger than y "
str2: .asciiz "x is smaller than y "
xprompt: .asciiz "Enter a value for X:"
yprompt: .asciiz "Enter a value for Y:"
again: .asciiz "Repeat? (0=No, 1=Yes):"
.text
start:
#Prompt for X
li $v0, 4 #Function 4 is print string
la $a0, xprompt #Get address of string to be printed
syscall
#Read in user response...
li $v0, 5 #Read in an integer
syscall #User's response will in $v0
move $t0, $v0 # $t0=$v0; copy value in $v0 to $t0
#Prompt for Y
li $v0, 4 #Function 4 is print string
la $a0, yprompt #Get address of string to be printed
syscall
#Read in user response...
li $v0, 5 #Read in an integer
syscall #User's response will in $v0
move $t1, $v0 # $t1=$v0; copy value in $v0 to $t0
#--------------------------------------------
#li $t0, 30 #We'll use $t0 to represent "x" x=3
#li $t1, 40 #We'll use $t0 to represent "y" y=4
bgt $t0, $t1,xGreat # if ($t0 > $t1) goto xGreat
ble $t0, $t1,xSmall # if ($t0 <= $t1) goto xSmall
xGreat:
#print string $v0=4 $a0 = address of null-terminated string to print
li $v0, 4 # $v0=4
la $a0, str1 # Load address str1 into $a0
syscall
b endIF
xSmall:
#print string $v0=4 $a0 = address of null-terminated string to print
li $v0, 4 # $v0=4
la $a0, str2 # Load address str2 into $a0
syscall
endIF:
#Prompt to repeat
li $v0, 4 #Function 4 is print string
la $a0, again #Get address of string to be printed
syscall
#get Response
li $v0, 5 #Read in an integer
syscall #Users response is in $v0
#Jump back to top if user responds with "1"
beq $v0,1,start
li $v0, 10 #Return control back to the operating system
syscall
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started