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...

  • 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...

  • 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...

  • 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...

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

    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 entry...

  • Rock, Paper, Scissors (also known by several other names, see http://en.wikipedia.org/wiki/Rock p...

    Help needed in Perl language program! Note : Perl Language Rock, Paper, Scissors (also known by several other names, see http://en.wikipedia.org/wiki/Rock paper scissors) is an extremely popular hand game most often played by children. Often, it is used as a method of selection similar to flipping a coin or throwing dice to randomly select a person for some purpose. Of course, this game is not truly random since a skilled player can often recognize and exploit the non-random behavior of...

  • In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play...

    In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play the game of Rock, Paper, Scissors against the computer.Your program should have the following: •Make the name of the project RockPaperScissors•Write a method that generates a random number in the range of 1 through 3. The randomly generated number will determine if the computer chooses rock, paper, or scissors. If the number is 1, then the computer has chosen rock. If the number is...

  • It's writing a simple rock paper scissors game strictly following the instructions. INSTRUCTIONS: If the user...

    It's writing a simple rock paper scissors game strictly following the instructions. INSTRUCTIONS: If the user selects 'p': 1. First the program should call a function named getComputerChoice to get the computer's choice in the game. The getComputerChoice function should generate a random number between 1 and 3. If the random number is 1 the computer has chosen Rock, if the random number is 2 the user has chosen Paper, and if the random number is 3 the computer has...

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
ADVERTISEMENT