Question: Write a program in assembly that reads a 3-bit desired light pattern from the 3 input switches connected to pins P2.3-P2.5 and displays the patter

Write a program in assembly that reads a 3-bit desired light pattern from the 3 input switches connected to pins P2.3-P2.5 and displays the patter on the 8 LEDs with some rotation options based on the other 3 switches.

; Main loop here

mov.b #00000000b,&P1OUT mov.b #11111111b,&P1DIR mov.b #00000000b,&P2DIR

InfLoop mov.b &P2IN, R5 ; get a fresh copy of all inputs and keep in R5 bit.b #BIT0, R5 ; test BIT0 jnz rotate ; if 1, go to rotate mode read mov.b R5, R6 ; if 0, read the new pattern form by copying switches value to R6 and.b #00111000b,R6 ; mask desired LED patterd from P2 pins 3-5 mov.b R6, &P1OUT ; display the patern on P1 jmp InfLoop

rotate inv.b R6 ; replace with your rotation code, left or right based pin P2.1

patout mov.b R6, &P1OUT ; display the roated pattern call #Delay ; call subroutine delay jmp InfLoop

Delay mov.w #50000, R7 ; modify your delay to have slow and fast bassed on pin P2.2

dloop dec.w R7 jnz dloop ret

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!