Question
The following program is to be written using ASSEMBLY LANGUAGE. USE ONLY MARS # If $t0 > $t1, branch to t0_bigger, bgt $t0, $t1, t0_bigger
The following program is to be written using ASSEMBLY LANGUAGE.
USE ONLY MARS
# If $t0 > $t1, branch to t0_bigger,
bgt $t0, $t1, t0_bigger
move $t2, $t1 # otherwise, copy $t1 into $t2.
b endif # and then branch to endif
t0_bigger: move $t2, $t0 # copy $t0 into $t2 endif:
Using what you have in this tutorial write a program that reads in two numbers from the user and then prints out the larger one. (Only have this execute once, ignore error checking etc.)
Step 2 . Loops A loop is a piece of code that is executed multiple times. A loop needs some sort of counter or condition that should be modified each step through the loop so it doesnt try and run forever. (E.g. for a loop that runs 10 times, you have, in C, for (int i=0; i< 10; i++){ some code} each time through the loop i is incremented by 1, and when it reaches 10 the loop doesnt execute and execution continues after the loop)
Modify the program from the previous step to use a loop that keeps running until the two user inputs are equal here is a simple loop (this is more of a while loop than a for loop)
loop:
beq $t2, $t3, endloop # if $t2 == $t3, exit endloop: done
Now modify your program so that the loop only executes 5 times and prints out the larger number each time. (Use a temporary variable, add 1 to it each time, and then if it equals 5 times endloop).
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