Question

Write a MARIE program to implement one round of rock paper scissors game. Your program should...

Write a MARIE program to implement one round of rock paper scissors game. Your program should represent the three moves ‘rock’, ‘paper’ and ‘scissors’ with numbers 1, 2 and 3 respectively. When the program is run, there should be two input prompts, one after the other, to ask for player 1’s and player 2’s moves (a number 1, 2 or 3).

Then the program would compare both numbers and apply the following rules to work out the winner. Paper beats rock, scissors beat paper and rock beats scissors. If both moves are same, the round is drawn. Depending on the results of comparison there will be one of the three outputs: 'P1 Won' or 'P2 Won' or 'Draw'.

Once a result is obtained, the program would take a third input from the user to ask if they want to repeat with another round. User should enter a number 1 to indicate 'yes' and that should repeat the whole process. Any input other than 1 should be treated as 'no' and quit the program.

Use the ‘decimal’ mode for inputs and ‘Unicode’ mode for outputs. To display text on output, you need to print it character by character using their ASCII codes. Insert a line break (ASCII code 10) before starting next round.

Assume that the user will always provide valid numbers as input — do not worry about dealing with invalid input data. Also, write comments within your program so that a reader can understand it easily.

Use the online MARE simulator at this link: https://marie.js.org/

0 0
Add a comment Improve this question Transcribed image text
Answer #1

DOSSEG
.model SMALL
.stack 100h
.data
  
CR db 13,10,'$'
MSG db 'GAME Instruction: Rock=1, Paper= 2, Scissors= 3, $', 0
PL1 db 'Player 1: $', 0
PL2 db 'Player 2: $', 0
PL1_Win db 'Player 1 is the winner! $', 0
PL2_Win db 'Player 2 is the winner! $', 0
PLEQ db 'Player 1 = Player 2 $', 0
.code

BEGIN: MOV AX, @data
MOV DS, AX
MOV ES, AX
  
MOV DX, OFFSET MSG ; Game Instruction
MOV AH, 09h
INT 21h
  
MOV DX, OFFSET CR ; print Carrier Return
MOV AH, 09h
INT 21h
  
MOV DX, OFFSET PL1 ; Prompt of player1
MOV AH, 09h
INT 21h
  
MOV AH,08 ; Function to read a char from keyboard (Input by Player1)
INT 21h ; the char saved in AL
MOV AH,02 ; Function to display a char
MOV BL,AL ; Copy a saved char in AL to BL
MOV DL,AL ; Copy AL to DL to output it
INT 21h
  
MOV DX, OFFSET CR ; print Carrier Return
MOV AH, 09h
INT 21h
  
MOV DX, OFFSET PL2 ; Prompt of player2
MOV AH, 09h
INT 21h
  
MOV AH,08 ; Function to read a char from keyboard (Input by Player2)
INT 21h ; the char saved in AL
MOV AH,02 ; Function to display a char
MOV BH,AL ; Copy a saved char in AL to BH
MOV DL,AL ; Copy AL to DL to output it
INT 21h

MOV DX, OFFSET CR ; print Carrier Return
MOV AH, 09h
INT 21h
  
CMP BL, BH
JE EQUAL
  
;=======================================
CMP BL, '1'
JE EQ1   
CMP BL, '2'
JE EQ2
CMP BL, '3'
JE EQ3
  
EQ1:
CMP BH, '2'
JE P2_Win   
CMP BH, '3'
JE P1_Win   

EQ2:
CMP BH, '1'
JE P1_Win   
CMP BH, '3'
JE P2_Win

EQ3:
CMP BH, '1'
JE P2_Win   
CMP BH, '2'
JE P1_Win

;=======================================

P1_Win: ;Player 1 is winner
MOV DX, OFFSET PL1_Win   
MOV AH, 09h
INT 21h
JMP Final
  
EQUAL: ;Player 1 == Player 2
MOV DX, OFFSET PLEQ   
MOV AH, 09h
INT 21h
JMP Final
  
P2_Win: ;Player 2 is winner
MOV DX, OFFSET PL2_Win   
MOV AH, 09h
INT 21h
JMP Final
;=======================================

Final:   
MOV AH,4Ch ; Function to exit
MOV AL,00 ; Return 00
INT 21h
  
end BEGIN

Add a comment
Know the answer?
Add Answer to:
Write a MARIE program to implement one round of rock paper scissors game. Your program should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember...

    Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember the rules: 1. Rock beats scissors 2. Scissors beats paper 3. Paper beats rock The program should ask the users for their names, then ask them for their picks (rock, paper or scissors). After that, the program should print the winner's name. Note, the players may pick the same thing, in this case the program should say it's tie. when the user input an...

  • Java CSC252   Programming II    Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that...

    Java CSC252   Programming II    Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that allows the user to play "Rock, Paper, Scissors". Write the RPS class. All code should be in one file. main() will be part of the RPS class, fairly small, and contain only a loop that asks the user if they want to play "Rock, Paper, Scissors". If they say yes, it calls the static method play() of the RPS class. If not, the program...

  • JAVA Beginnings of a paper-rock-scissors game. Paper-rock-scissors is a game often used to make decisions. There...

    JAVA Beginnings of a paper-rock-scissors game. Paper-rock-scissors is a game often used to make decisions. There are two players. Each player secretly chooses either, paper, rock or scissors. At the count of three, each player reveals what they have chosen. The winner of the game is determined this way: paper beats rock (because paper covers rock) rock beats scissors (because rock crushes scissors) scissors beat paper (because scissors cut paper) If the two players choose the same item, it is...

  • IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors...

    IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....

  • (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (Java) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. The...

  • C++ Write a program that plays the rock, paper, scissors game. Rock beats scissors; scissors beats...

    C++ Write a program that plays the rock, paper, scissors game. Rock beats scissors; scissors beats paper; paper beats rock. You must use these specific functions in your program. These are the prototypes: char generateP2toss(); int checkThrow(char, char); void printStatistics(int, int, int, int); void finalStatistics(int, int, int, int); void welcome(); Notes on these functions: generateP2toss() will generate the computer's toss (the computer is player2). It returns either an "r", "p", or "s/" checkThrow(char char) will check the throw by passing...

  • (c++ only)Write a program that lets the user play the game of Rock, Paper, Scissors against...

    (c++ only)Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, the user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard using a menu in a function, userChoice, that returns a character. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. If the...

  • This program should be in c++. Rock Paper Scissors: This game is played by children and...

    This program should be in c++. Rock Paper Scissors: This game is played by children and adults and is popular all over the world. Apart from being a game played to pass time, the game is usually played in situations where something has to be chosen. It is similar in that way to other games like flipping the coin, throwing dice or drawing straws. There is no room for cheating or for knowing what the other person is going to...

  • Write a program in python that lets the user play the game Rock, Paper, Scissors against...

    Write a program in python that lets the user play the game Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...

  • C++ You are asked to implement scissors-rock-paper game where the players are a computer and a...

    C++ You are asked to implement scissors-rock-paper game where the players are a computer and a user. The player that wins 3 hands successively is the winner of the game. Your program should prompt the user with a message at the beginning of each hand to enter one of scissors, rock or paper. If the user’s entry is not valid, i.e. entry is neither scissors, rock, nor paper, your program throws a message to the user to enter a valid...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT