Question
I need help to convert this C program to Assembly using MIPS #include #include #include int boolcheck ( int sumPlayer, int sumDealer, int diceTotal) {
I need help to convert this C program to Assembly using MIPS
#include
#include
#include
int boolcheck(int sumPlayer, int sumDealer, int diceTotal)
{
if(sumPlayer <= diceTotal && sumPlayer > sumDealer)
{
return 0;
}
else if(sumPlayer > diceTotal && sumPlayer > sumDealer && sumDealer <= diceTotal)
{
return 1;
}
else if(sumDealer <= diceTotal && sumDealer > sumPlayer )
{
return 2;
}
else
{
return 3;
}
}
int main() {
printf("Welcome to My Blackjack Game!! ");
printf("Would you like to play? (1 for play, -1 to exit): ");
int input;
scanf("%d", & input);
if (input == 1)
{
printf("...............Lets Start!!............... ");
printf("First You and Dealer will roll the Dice that range between 21 and 26 ");
printf("Your turn (press e to roll the dice) : ");
char prompt;
scanf(" %c", & prompt);
srand(time(NULL));
int random2 = rand()%6 + 20;
printf("you got the number %d from rolling the dice ", random2);
printf("Dealer turn: ");
srand(time(NULL));
int random1 = rand()%6 + 20;
printf("Dealer got the number %d from rolling the dice " , random1);
int diceTotal = random1 + random2;
printf("Dice %d! Get as close to %d without going over! ",diceTotal, diceTotal );
int playerHand[10];
int dealerHand[10];
int sumPlayer;
int sumDealer = 0;
srand(time(NULL));
for(int i= 0; i < 10; i++)
{
playerHand[i] = rand()%10 + 1;
}
for(int i= 0; i < 10; i++)
{
dealerHand[i] = rand()%10 + 1;
sumDealer = sumDealer + dealerHand[i];
}
int count = 0;
do
{
sumPlayer = 0;
printf("Your hand: ");
for(int i= 0; i < 10; i++)
{
printf("%d ", playerHand[i]);
sumPlayer = sumPlayer + playerHand[i];
}
printf(" ");
printf("Which dice would you like to reroll(1, 2, 3, 4, ..., 10)? Or -1 to hold(you have just 5 time to reroll the dices of your hand: ");
int chioce;
scanf("%d", &chioce);
if(chioce <= 10 && chioce >= 1)
{
int p = rand()%10 + 1;
playerHand[chioce - 1] = p;
}
else if(chioce == -1)
break;
else
{
printf("Wrong dice number entered");
}
count++;
printf(" ");
}while(count != 5);
int result;
result = boolcheck(sumPlayer, sumDealer, diceTotal);
if(result == 0)
{
printf("The sum of your hand is: %d ", sumPlayer);
printf("The sum of dealer's hand is: %d ", sumDealer);
printf("you win!!!! ");
}
else if(result == 1)
{
printf("The sum of your hand is: %d ", sumPlayer);
printf("The sum of dealer's hand is: %d ", sumDealer);
printf("You went over %d. Dealer wins. ", diceTotal);
}
else if(result == 2)
{
printf("The sum of your hand is: %d ", sumPlayer);
printf("The sum of dealer's hand is: %d ", sumDealer);
printf("Dealer Wins!!!! ");
}
else
{
printf("The sum of your hand is: %d ", sumPlayer);
printf("The sum of dealer's hand is: %d ", sumDealer);
printf("Ops! Both of you went over %d ", diceTotal);
}
}
printf("Good bye ");
return 0;
}
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