Question
Must be done in PLP:The Task In this project, you will be adding an interrupt service routine (ISR) to an existing program. The program is
Must be done in PLP:The Task In this project, you will be adding an interrupt service routine (ISR) to an existing program. The program is already fully functional hexadecimal counter that shows the current counter value on the seven-segment display. You will add interrupt handling for two devices: a timer and a button. You should use the timer to generate an interrupt every x cycles (where x can be between 100 and 200 cycles). The button interrupt should be used to reset the counter by setting register $a1 to one (or any non-zero value). Your ISR needs to do the following things: 1. If a timer interrupt was generated, toggle all eight LEDs (i.e. if they are all off, they should all be turned on and vice versa). 2. If a button interrupt was generated, set $a1 to one so that the counter gets reset. 3. Make any changes necessary for future timer and button interrupts. 4. Return from the ISR. No changes should be made to the existing main loop or sseg_display.asm. Code should only be added in between the rows of asterisks (*) following the TODO comments
.org 0x10000000
li $sp, 0x10fffffc # Stack pointer initialization li $s0, sseg_lut # Lookup table address used by sseg_display lui $s1, 0xf070 # Interrupt controller register lui $s2, 0xf0a0 # Seven segment display
# TODO: enable interrupts here: # ************************************************************ # Interrupt Initialization
# ************************************************************
main: jal sseg_display nop addiu $a0, $a0, 1 beq $a1, $0, no_counter_reset nop move $a0, $0 move $a1, $0 no_counter_reset: j main nop
# TODO: add interrupt service routine here: # ************************************************************ # Interrupt Service Routine
# ************************************************************
asm_file_trap: # If your program ends up in this loop then your ISR is not being exited correctly lui $s0, 0xf0a0 li $t0, 0x86afafff # "Err" on seven segment sw $t0, 0($s0) j asm_file_trap nop
sseg_display:
move $t1, $a0 move $t3, $0
# Position 0 andi $t2, $t1, 0xf sll $t2, $t2, 2 addu $t2, $t2, $s0 # Calculate LUT address lw $t2, 0($t2) or $t3, $t3, $t2
# Position 1 andi $t2, $t1, 0xf0 srl $t2, $t2, 2 addu $t2, $t2, $s0 # Calculate LUT address lw $t2, 0($t2) sll $t2, $t2, 8 or $t3, $t3, $t2
# Position 2 andi $t2, $t1, 0xf00 srl $t2, $t2, 6 addu $t2, $t2, $s0 # Calculate LUT address lw $t2, 0($t2) sll $t2, $t2, 16 or $t3, $t3, $t2
# Position 3 andi $t2, $t1, 0xf000 srl $t2, $t2, 10 addu $t2, $t2, $s0 # Calculate LUT address lw $t2, 0($t2) sll $t2, $t2, 24 or $t3, $t3, $t2
# Write to seven segment and increment jr $ra sw $t3, 0($s2)
# Seven segment display lookup table sseg_lut: .word 0xc0 # 0 .word 0xf9 # 1 .word 0xa4 # 2 .word 0xb0 # 3 .word 0x99 # 4 .word 0x92 # 5 .word 0x82 # 6 .word 0xf8 # 7 .word 0x80 # 8 .word 0x90 # 9 .word 0x88 # a .word 0x83 # b .word 0xc6 # c .word 0xa1 # d .word 0x86 # e .word 0x8e # f
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started