Write a program in PLP assembly that repeatedly reads the value of the switches (address: 0xf0100000) and displays a pattern on the LED array based on what switches. Each time the switch value is read, the pattern should be displayed (regardless of whether the switch value has changed or not since the last time it was read). The table below indicates the pattern that should be displayed for each possible switch setting. - please use"sw" "li", labels, loops, "beq" and "lw" to create the code. The code is for assambly language and it will be compiled and run on PLPTool version 5.2. I have created the following code it is not completed it. I seem to be stuck here. Please complete it, following the task instructions. # main source file .org 0x10000000 _start: # Initialization li $t0,0xf0100000 # Load address of switches li $t1,0xf0200000 # Load address of LEDs li $t5,1 # Load value of switch 0 address of LEDs li $t6,2 # Load value of switch 1 address of LEDs li $t7,4 # Load value of switch 2 address of LEDs loop: # Read switch value lw $t2, 0($t0) # Load switch value into $t2 # Generate LED pattern based on switch value beq $t2,$t5, switch_0 # Switch 0 pattern beq $t2,$t6, switch_1 # Switch 1 pattern switch_0: li $t3, 0xf # Pattern for switch 0 (LEDs 0-3 on) sw $t3, 0($t1) # Update LEDs with generated pattern j loop # Repeat loop switch_1: li $t3, 0b11110000 # Pattern for switch 1 (LEDs 4-7 on) sw $t3, 0($t1) # Update LEDs with generated pattern j loop # Repeat loop
Write a program in PLP assembly that repeatedly reads the value of the switches (address: 0xf0100000) and displays a pattern on the LED array based on what switches. Each time the switch value is read, the pattern should be displayed (regardless of whether the switch value has changed or not since the last time it was read). The table below indicates the pattern that should be displayed for each possible switch setting. - please use"sw" "li", labels, loops, "beq" and "lw" to create the code. The code is for assambly language and it will be compiled and run on PLPTool version 5.2. I have created the following code it is not completed it. I seem to be stuck here. Please complete it, following the task instructions. # main source file .org 0x10000000 _start: # Initialization li $t0,0xf0100000 # Load address of switches li $t1,0xf0200000 # Load address of LEDs li $t5,1 # Load value of switch 0 address of LEDs li $t6,2 # Load value of switch 1 address of LEDs li $t7,4 # Load value of switch 2 address of LEDs loop: # Read switch value lw $t2, 0($t0) # Load switch value into $t2 # Generate LED pattern based on switch value beq $t2,$t5, switch_0 # Switch 0 pattern beq $t2,$t6, switch_1 # Switch 1 pattern switch_0: li $t3, 0xf # Pattern for switch 0 (LEDs 0-3 on) sw $t3, 0($t1) # Update LEDs with generated pattern j loop # Repeat loop switch_1: li $t3, 0b11110000 # Pattern for switch 1 (LEDs 4-7 on) sw $t3, 0($t1) # Update LEDs with generated pattern j loop # Repeat loop
Chapter8: Arrays
Section: Chapter Questions
Problem 18RQ
Related questions
Question
Write a program in PLP assembly that repeatedly reads the value of the switches (address: 0xf0100000) and
displays a pattern on the LED array based on what switches. Each time the switch value is read, the pattern
should be displayed (regardless of whether the switch value has changed or not since the last time it was read).
The table below indicates the pattern that should be displayed for each possible switch setting.
- please use"sw" "li", labels, loops, "beq" and "lw" to create the code. The code is for assambly language and it will be compiled and run on PLPTool version 5.2.
I have created the following code it is not completed it. I seem to be stuck here. Please complete it, following the task instructions.
# main source file
.org 0x10000000
_start:
# Initialization
li $t0,0xf0100000 # Load address of switches
li $t1,0xf0200000 # Load address of LEDs
li $t5,1 # Load value of switch 0 address of LEDs
li $t6,2 # Load value of switch 1 address of LEDs
li $t7,4 # Load value of switch 2 address of LEDs
loop:
# Read switch value
lw $t2, 0($t0) # Load switch value into $t2
# Generate LED pattern based on switch value
beq $t2,$t5, switch_0 # Switch 0 pattern
beq $t2,$t6, switch_1 # Switch 1 pattern
switch_0:
li $t3, 0xf # Pattern for switch 0 (LEDs 0-3 on)
sw $t3, 0($t1) # Update LEDs with generated pattern
j loop # Repeat loop
switch_1:
li $t3, 0b11110000 # Pattern for switch 1 (LEDs 4-7 on)
sw $t3, 0($t1) # Update LEDs with generated pattern
j loop # Repeat loop
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT