Question: The starting code is below: .include address_map_arm.s /******************************************************************************** * This program demonstrates use of parallel ports in the Computer System * * It performs the

 The starting code is below: .include "address_map_arm.s" /******************************************************************************** * This program

The starting code is below:

.include "address_map_arm.s"

/******************************************************************************** * This program demonstrates use of parallel ports in the Computer System * * It performs the following: * 1. displays a rotating pattern on the LEDs * 2. if a KEY is pressed, uses SW switches as the pattern ********************************************************************************/ .text /* executable code follows */ .global _start _start:

MOV R0, #31 // used to rotate a bit pattern: 31 positions to the // right is equivalent to 1 position to the left LDR R1, =LED_BASE // base address of LED lights LDR R2, =SW_BASE // base address of SW switches LDR R3, =KEY_BASE // base address of KEY pushbuttons LDR R4, LED_bits

DO_DISPLAY: LDR R5, [R2] // load SW switches

LDR R6, [R3] // load pushbutton keys CMP R6, #0 // check if any key is pressed BEQ NO_BUTTON

MOV R4, R5 // copy SW switch values onto LED displays ROR R5, R5, #8 // the SW values are copied into the upper three // bytes of the pattern register ORR R4, R4, R5 // needed to make pattern consistent as all 32-bits // of a register are rotated ROR R5, R5, #8 // but only the lowest 8-bits are displayed on LEDs ORR R4, R4, R5 ROR R5, R5, #8 ORR R4, R4, R5 WAIT: LDR R6, [R3] // load pushbuttons CMP R6, #0 BNE WAIT // wait for button release

NO_BUTTON: STR R4, [R1] // store pattern to the LED displays ROR R4, R0 // rotate the displayed pattern to the left LDR R6, =50000000 // delay counter DELAY: SUBS R6, R6, #1 BNE DELAY

B DO_DISPLAY

LED_bits: .word 0x0F0F0F0F

.end

1. The supplied program will load a new pattern if any of the pushbuttons are pressed. You are to modify the program so that each pushbutton has its own function, as described below. For the sake of the following discussion, we shall label the rightmost button as button 0 (labelled Key 0 on the circuit board) and the leftmost button as button 3 (Key 3). Modify the program so that the pattern no longer rotates automatically. Instead, the pattern should rotate to the right only when button 0 is pressed, and stop when it is released. Similarly, the pattern should rotate to the left only when button 1 is pressed, and stop when it is released. Pressing button 2 should set the pattern from the switches (as it did initially), while pressing button 3 should reload the original startup pattern stored in memory. 2. Using the getting started.s and/or simple_program.s as reference, you are to write your own program to implement a pattern matching system which operates as follows. The system is to compare the 10-bit value set on the switches to a pattern stored in memory. If the two values match, then this should be indicated in some manner using the LEDs. (You can decide how the LEDs indicate the match.) The system should not be comparing continuously, but should only perform the comparison/check when pushbutton 0 is pressed. The LEDs should not indicate a match before pushbutton 0 is pressed to check for a match. If the switch value does not match the pattern stored in memory, nothing should happen. 3. Modify the program in #2 above to permit the user to change the stored pattern once they have correctly matched the current pattern correctly. The user should use one of the pushbuttons to indicate that a new pattern is to be captured from the switches and used as the new target pattern. This pattern should be stored back into memory to replace the value originally set in the code. Note that the main monitor tool window has a Memory tab at its bottom, which will allow you to view the contents of the system memory. Use this to verify that the new pattern is stored correctly. 1. The supplied program will load a new pattern if any of the pushbuttons are pressed. You are to modify the program so that each pushbutton has its own function, as described below. For the sake of the following discussion, we shall label the rightmost button as button 0 (labelled Key 0 on the circuit board) and the leftmost button as button 3 (Key 3). Modify the program so that the pattern no longer rotates automatically. Instead, the pattern should rotate to the right only when button 0 is pressed, and stop when it is released. Similarly, the pattern should rotate to the left only when button 1 is pressed, and stop when it is released. Pressing button 2 should set the pattern from the switches (as it did initially), while pressing button 3 should reload the original startup pattern stored in memory. 2. Using the getting started.s and/or simple_program.s as reference, you are to write your own program to implement a pattern matching system which operates as follows. The system is to compare the 10-bit value set on the switches to a pattern stored in memory. If the two values match, then this should be indicated in some manner using the LEDs. (You can decide how the LEDs indicate the match.) The system should not be comparing continuously, but should only perform the comparison/check when pushbutton 0 is pressed. The LEDs should not indicate a match before pushbutton 0 is pressed to check for a match. If the switch value does not match the pattern stored in memory, nothing should happen. 3. Modify the program in #2 above to permit the user to change the stored pattern once they have correctly matched the current pattern correctly. The user should use one of the pushbuttons to indicate that a new pattern is to be captured from the switches and used as the new target pattern. This pattern should be stored back into memory to replace the value originally set in the code. Note that the main monitor tool window has a Memory tab at its bottom, which will allow you to view the contents of the system memory. Use this to verify that the new pattern is stored correctly

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!