Question: I need some help modifying and fixing my code so that I can get Stage 3 results working on the ARMlite simulator. i am encountering

I need some help modifying and fixing my code so that I can get Stage 3 results working on the ARMlite simulator. i am
encountering errors when I try to run my code. Could you please assist me in identifying and resolving these issues? this is my code :
1|; Prompt for player's name
2| MOV R1, #promptName
3| STR R1,.WriteString
4| MOV R2, #nameStorage
5| STR R2,.ReadString
6| STR R2,.WriteString
7| MOV R6, #0x0A ; Load newline character
8| STRB R6,.WriteChar ; Output newline
9|; number of matchsticks
10|playerInput:
11| MOV R3, #promptMatchsticks
12| STR R3,.WriteString
13| LDR R4,.InputNum
14| CMP R4, #10 ; Compare input with lower than 10
15| BLT Error ; If input is less than 10, branch to Error
16| CMP R4, #100
17| BGT Error
18| B counting
19|Error:
20| MOV R8, #errorMsg
21| STR R8,.WriteString
22| B playerInput ; Repeat input process if there's an error
23|counting:
24| STR R4,.WriteUnsignedNum ; Output valid matchstick count
25| MOV R5, #outputName ; Print player's name
26| STR R5,.WriteString
27| STR R2,.WriteString
28| MOV R6, #outputMatchsticks ; Print number of matchsticks
29| STR R6,.WriteString
30| STR R4,.WriteUnsignedNum
31| MOV R8, #Player ; to show results on screen
32| MOV R9, #ThereAre
33| MOV R10, #remaining
34| STR R8,.WriteString
35| STR R2,.WriteString
36| STR R9,.WriteString
37| STR R4,.WriteUnsignedNum
38| STR R10,.WriteString
39|; Prompts the player to enter a number of matchsticks to remove
40|User:
41| STR R8,.WriteString
42| STR R2,.WriteString
43| MOV R11, #Promptq
44| STR R11,.WriteString
45|; Take user's input
46| LDR R12,.InputNum
47| CMP R12, #1 ; check if the input is between 1-7
48| BLT User
49| CMP R12, #7
50| BGT User
51| CMP R12, R4
52| BGT User
53| SUB R4, R4, R12 ; count the remaining matchsticks
54| STR R8,.WriteString
55| STR R2,.WriteString
56| STR R9,.WriteString
57| STR R4,.WriteUnsignedNum
58| STR R10,.WriteString
59|; Check if game is over
60| CMP R4, #0
61| BEQ endGame
62| B computerTurn
63|computerTurn:
64| MOV R1, #compTurnMsg
65| STR R1,.WriteString
66|; Generate random number for computer's turn
67| BL Random ; Call random number generator
68| AND R12, R0, #0x7 ; Mask to range 1-7
69| CMP R12, #0 ; Ensure it's at least 1
70| BNE validRand
71| ADD R12, R12, #1 ; If zero, make it 1
72|validRand:
73| CMP R12, R4 ; Check if random number exceeds remaining matchsticks
74| BLE validCompMove
75| MOV R12, R4 ; If so, use remaining matchsticks
76|validCompMove:
77| SUB R4, R4, R12 ; Computer removes matchsticks
78| STR R8,.WriteString
79| STR R2,.WriteString
80| STR R9,.WriteString
81| STR R4,.WriteUnsignedNum
82| STR R10,.WriteString
83|; Check if game is over
84| CMP R4, #0
85| BEQ endGame
86| B User
87|endGame:
88| CMP R4, #1
89| BEQ declareWinner
90| MOV R1, #drawMsg
Stage 3- Implement Human versus Computer
You have now implemented a program that allows a player to keep removing matchsticks until none
are left. Your task now is to implement a computer player to play against. Specifically, modify your
program from Stage 2 to ensure it satisfies the following:
Alternates turns between the human player and the computer player. The human player
should always go first.
When it is the human player's turn, the same inputs and outputs should be
implemented as per Stage 2.
When it is the computer player's turn, the screen output should read: "Computer
Player's turn".
The computer player's turn should utilise ARMlite's random number generator in order to
select a number between 1 and 7 to remove from the matchsticks count. The number
selected should also not exceed the number of matchsticks remaining. See Lab 8 for
information on random number generation in ARMlite.
Once a valid random number is obtained, this should be used to update the total number of
matchsticks remaining.
Once either player's turn (human or computer) is complete, the total number of matchsticks
should be inspected.
If it is 1, then the player who's turn just occurred is the winner (i.e., they have
forced the other player to pick up a single remaining matchstick).
If the total number of remaining matches is >1, then play continues.
If it is 0, then the game is a draw.
Based on the above conditions, one of the following three messages should be
displayed as appropriate:
"Player (yn)?yn
 I need some help modifying and fixing my code so that

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!