Question: URGENT!! I Have been working on a Mips program for hours now and no matter what I do I cannot get it to work the
URGENT!!
I Have been working on a Mips program for hours now and no matter what I do I cannot get it to work the I have gotten everything but the draw card function to work this is was was asked by my professor
Write a MIPS assembly language program that takes user input ShuffleDraw and Quit You
can use just the letter or the whole word.
On Shuffle, the deck is copied from the Cards array and the discard array is cleared. Current draw
index will be set to by the main program. Shuffle is available any time.
Draw can only be selected if the deck is not empty the program should start with an empty deck
and current draw index set to Draw removes a value from the bottom of the deck array, adds it
to the discard array, and returns the value to the main program so the main program can print the
card. The main program should decrement the index on each draw until it is after which only
Shuffle or Quit may be selected.
On Quit, the program ends and Quit may be selected at any time.
Here are some tips and requirements:
Use the MIPS syscalls to print out prompts and read in characters. There is an example
program that demonstrates the various syscalls in the Supplemental Material section in
Canvas. Do NOT use syscalls higher than with the exception of in this project.
Do NOT use a routine you found online to generate random numbers or use the system
service to get a random number. You must implement the Linear Congruence algorithm
yourself, modified from Project
Start by calling the shuffle routine from main, having it only copy the Cards array and
modifying my print loop to print your copy.
Once that works, try shuffling the array. If that works, the print loop should show the
shuffled deck.
Next clear the discard deck. You can test that code by copying the shuffled deck to the
discard deck, clearing it and then checking that all the values in the discard deck are
With your shuffle routine working, add the IO loop. When draw is called for, simply call
the draw routine, which should just have a couple of lines of code to print a messages like
Drawing a card... Quit should now work.
Now you can implement the draw subroutine. Make sure the selected value by index from
main is removed from the deck. Then make sure it gets written to the discard array.
Finally, be sure it is returned by the subroutine and main updates the index and prints out the
string pointed to by the returned value.
Build and test your program in incremental stages to avoid being overwhelmed by details.
For example, you might start off writing a loop that prints out the number times. You
might then change it to hardcode a first and last number and then print out every number in
between... and so on
A side note to think about while you are working on the project... was it really necessary to
use a discard array? If you can think of a way to do things without it convince me in your
report. However, I expect to be able to see all the drawn cards in order, so you cant just
delete them from the deck array and forget about it
data
Multiplier: word # a sufficiently large prime
Seed: word
Newline: asciiz
text
globl main
main:
jal initCards # initialize the Cards array
li $t
la $t Cards
li $v
PrintLoop:
blez $t Endit
addiu $t $t
lw $a$t # get address of next string
syscall # and print it
la $a Newline # and then print a new line
syscall
addiu $t $t # get next string pointer address
I cannot send the full code that I have worked on if there is a way I could send it please let me know I need help with this assignment and I cannot figure out how to do it
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
