Question: 3. Write an assembly code to light up alternate LEDs continuously starting with LED1. Use the given Delay routine.
LED1 LED2 LED3 ON OFF OFF Delay OFF ON OFF Delay OFF OFF ON Delay ON OFF OFF …
My Assembly Code:
Main: LDI R16,0x80; OUT DDRD,R16; LDI R16,0x28; OUT DDRB,R16; Start: SBI PORTD,7; CBI PORTB,3; CBI PORTB,5; CALL Delay CBI PORTD,7; SBI PORTB,3; CBI PORTB,5; CALL Delay CBI PORTD,7; CBI PORTB,3; SBI PORTB,5; CALL Delay RJMP Start Delay: LDI R19,0; LDI R20,0xFF; Loop: LDI R21,0xFF; Loop1; DEC R21; CPSE R21,R19; RJMP Loop1; DEC R20; CPSE R20,R19; RJMP Loop RET;