Question: This is using MARS (MIPS Simulation) The 21-card trick is a famous card trick where the performer guesses a card chosen by the spectator. In

This is using MARS (MIPS Simulation)

The 21-card trick is a famous card trick where the performer guesses a card chosen by the spectator. In this project, you will be implementing a small program in MIPS assembly that performs this card trick!

The program will need to interact with a user and manipulate simple data structures in order to perform this trick. To make it simpler, you will be using numbers (1-21) instead of 2 through Ace of clubs/spades/hearts/diamonds.

Create the main loop logic and user interaction:

The tedious part of this program will be to create all the strings, display them to the user, and get user input. It is also the simpler bit.

During the first week, I suggest you focus on creating an application that prints the strings to the user, implements the main loop, and asks the user for input (dont forget to validate the input!).

What I have so far is below and the output is below the code. I need help with printing out the cards as displayed and how to validate the input (column):

.data strIntro: .asciiz "Welcome to the Twenty-One Number trick! " strSecIntro: .asciiz "This program will guess which number you are thinking about! " strThiIntro: .asciiz "Think of a number in the intercal 1-21 and memorise it! " strCont: .asciiz "(Press any key to continue) " strInvalid: .asciiz "The number you input is invalid! " strColumn: .asciiz "In which column is your number (1, 2, 3): " strColumnNumb: .asciiz "Col 1 Col 2 Col 3 " numArray: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 , 12, 13, 14, 15, 16, 17, 18, 19, 20, 21

.text .globl main main: la a0, strIntro # printString(strIntro) li v0, 4 syscall la a0, strSecIntro # printString(strSecIntro) li v0, 4 syscall la a0, strThiIntro # printString(strThiIntro) li v0, 4 syscall la a0, strCont # printString(strCont) li v0, 4 syscall li v0, 10 # exit() - stops the program syscall

cards: #loop to print array of cards by three #loop to validate column input _cardValid:

Welcome to the Twenty-one number trick This program will guess which number you are thinking about! Think of a number in the interval 1-21, and memorize it! (Press any key to continue) Col 1 Col 2 Col 3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 In which column is your number (1, 2, 3): 4 The number you input is invalid! In which column is your number (1, 2, 3): 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!