Question: . data # constants Multiplier: . word 1 0 7 3 8 0 7 3 5 9 # a sufficiently large prime # You probably
data
# constants
Multiplier: word # a sufficiently large prime
# You probably have enough registers that you won't need variables.
# However, if you do wish to have named variables, do it here.
# Word Variables First
# HalfWord Variables Next
# Byte Variables Last Strings and characters are Byte data
# common strings
minPrompt: asciiz "Enter the smallest number acceptable n:
maxPrompt: asciiz "Enter the biggest number acceptable n :
qtyPrompt: asciiz "How many randoms do you want
rsdPrompt: asciiz "Enter a seed number :
smErr: asciiz "That number is too small, try again:
smErr: asciiz "The max cannot be less than the min, try again:
bgErr: asciiz "That number is too large, try again:
outStr: asciiz "Here is the series of randoms:
newLine: asciiz
text
globl main
#
# The start: entry point from the MIPS file is encompassed in the kernel code
# of the QTSPIM simulator. This version starts with main: which does everything
# in this simple program.
#
main: # start of the main procedure
# prompt for the minimum result and get the value
# this is where you ask the user to tell you the beginning of the
# range of output numbers randoms from to for example
# check that the input number is in the valid range for minimum,
# to and if it isn't, display an error and keep looping
# back until the user enters a good number.
# prompt for the number
# read the integer
# if the integer is go to step
# else print error and return to step
# if the number is go to next input
# else print error and return to step
# prompt for the maximum result and get the value
# just like the minimum result, you keep asking for the input
# until you get a good value. In addition to making sure it
# is in a valid range, you also have to make sure it is
# greater than the minimum entered before.
# prompt for the number
# read the integer
# if the integer is minimum go to step
# else print error and return to step
# if the number is go to next input
# else print error and return to step
# now you ask for how many randoms the user wants
# I arbitrarily chose to as enough to show you are getting
# random numbers without overdoing it Very similar to the last:
# prompt for the number
# read the integer
# if the integer is go to step
# else print error and return to step
# if the number is go to next input
# else print error and return to step
# This one is just as easy, though the boundary values are large. The
reason
# is buried in how the generation algorithm works but you can just
trust me
# that the numbers in this range SHOULD give good random values.
# prompt for the number
# read the integer
# if the integer is go to step
# else print error and return to step
# if the number is go to next input
# else print error and return to step
# Now would be a good time to compute the output range so you don't
have to
# do it each time you generate a new random.
# precalculate the range by subtracting the minimum from the maximum
# then add to the result
# tell the user "here come the randoms" or something similar
# initialize the loop counter with the number of desired randoms
# top of random generator loop
# first generate a random
# multiply the seed by the multiplier
# lo replaces the old seed
# hi is the raw random number
# next range fit the raw random for output
# divide the raw random by the precalculated range
# hi hold the ranged random after division
# add minimum to the ranged random
# print out the result
# print out a newline or to separate the next
# decrement the loop counter
# if loop counter jump back to start of loop
# exit program
li $v
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
