blackmamba (1)

docx

School

Swinburne University of Technology *

*We aren’t endorsed by this school

Course

345B

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

5

Uploaded by ColonelFrog3642

Report
Name: Nischal Dhungel Student ID: 104483951 Excercise 9.1.1 We're going to build our game up iteratively, and to start with, consider only 1 player.    Lets start with some basic output to tell the player how many matchsticks are left (initially 15).  We want the output to read "15 remaining"   In ARMlite, write the code needed to do this. If you need some further guidance, consider implementing this in the following steps): 1.  create a label for the ASCII text  (i.e., type .ASCIZ) you want to display (i.e, " remaining") 2. initialise  register R0 to 15 3. write the value inside R0 to the output display 4. write the string " remaining" 
Excercise 9.1.2 Now lets consider getting some input from the user.   Recall each player needs to provide a number between 1 and 3 (ie., the number of match sticks to remove).  Building on what you implemented in 9.1.1, write the assembly code required to prompt the user for input using the string "How many do you want to remove (1-3)?", and then read in an integer value and store it in a register of your choice (but not one already being used!) Hint - as in 9.1.1, define  a label to store the string you want to display, and recall from this week's video lectures how numbers can be read in using LDR
Excercise 9.1.3 So now we have the player's input: the number of matchsticks to remove.  We now need to calculate how many matchsticks remain once this number is removed.  Again building on the code you wrote in the previous two exercises, write the code required to calculate the remaining number of matchsticks, and store this number into R0 (which recall, you initialised to 15 in 9.1.1). Once complete, show your tutor the executing program, and take a screen shot showing the code and output, and include in your submission document
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
9.2.1 What happens if you enter a number that takes the number of matchsticks remaining beyond 0 (i.e., into negative values) ? What do you think is going on here ? Hint - take a look at the value in the register! Answer. The register value will be negative and the loop will continue if we input a number that exceeds the zero mark in the number of matchsticks left. Observing the result, the value will rise each time we set the value above zero. Question 9.2.2(a) - What is the condition that needs to be satisifed in order for this loop to occur ?   Write this as a comparison using an inequality (ie., less than, greater than, less than or equal, greater than or equal) Answer The loop will start when the value of the register in R11 is higher than 0. R10<1. Question 9.2.2(b) - What two ARM assembly instructions could be used to create a branch that only occurs under this condition ? Answer To designate a branch that only appears when register R11's value is equal to or less than zero. ARM configuration CMP R10, #3 CMP R10, #1 BGT (if R10>3) BGT (if R10<1) Question 9.2.2(c) - Based on the instructions you outlined in 9.2.2(b), what status bit would be set to 1 if the loop was to repeat ? Answer . The negative status bit would be set to 1 if the loop.
Question 9.2.2(d)   - What are all the modifications needed to the current program to implement this feature ?     Make the required modifications to your program to perform the task. Answer. The program needs to be modified in order to make the loop exit, and to do so, the BLE exit_loop must be added. within the program.