Question: . equ LEDS , 0 xf 0 2 0 0 0 0 0 ; address of LED array . equ SWITCH , 0 xf 0

.equ LEDS ,0xf0200000 ; address of LED array
.equ SWITCH ,0xf0100000 ; address of switches
reset:
li t0,0x00 ; initialize pattern to all off
sw t0, LEDS ; display pattern
loop:
lw t1, SWITCH ; read switches
andi t1, t1,0x0f ; keep only lower 4 bits
beq t1, zero, all_on ; if switches are 0, turn all LEDs on
beq t1, t2, loop ; if switches are the same as last time, do nothing
move t2, t1 ; remember last switch value
li t0,0x00 ; initialize pattern to all off
andi t3, t1,0x01 ; check bit 0
beq t3, zero, .odd ; if bit 0 is 0, skip to odd check
.even: ori t0, t0,0xaa ; turn on even LEDs
j .done
.odd: andi t3, t1,0x02 ; check bit 1
beq t3, zero, .other ; if bit 1 is 0, skip to other check
ori t0, t0,0x55 ; turn on odd LEDs
j .done
.other: andi t3, t1,0x08 ; check bit 3
beq t3, zero, .cycle ; if bit 3 is 0, skip to cycle
li t0,0x01 ; initialize pattern to one on
.cycle: sll t4, t1,1 ; shift left to create marquee pattern
or t0, t4
.done: sw t0, LEDS ; display pattern
j loop
all_on: li t0,0xff ; turn all LEDs on
j loop

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!