Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

PLP Tool 5.2: In this project, you will be adding an interrupt service routine (ISR) to an existing program. The program is already fully functional

PLP Tool 5.2:

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 use the timer to generate an interrupt every x cycles (where x can be between 100 and 200 cycles). Your ISR needs to do the following things:

1. Toggle all eight LEDs (i.e. if they are all off, they should all be turned on and if they are already on, turn them off)

2. Perform any tasks necessary to allow another timer interrupt within 100 to 200 cycles.

No changes should be made to the existing main loop or sseg_display.asm. Code should only be added following the TODO comments. Thank you for your help!

Editable Code:

main.asm:

.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 below # ****************************

# NOTE: Do not add or modify any code within this main loop main: jal sseg_display nop addiu $a0, $a0, 1 j main nop

# **************************************** # TODO: add interrupt service routine below # ****************************************

image text in transcribed

sseg_display.asm:

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

image text in transcribedimage text in transcribedimage text in transcribed

org 0x10000000 2 3 lui $sp, 0x10fffffc # Stack pointer initialization |li $s0, sseg-Lut 5 lui $s1, 0xf070 6 ui $s2, 0xf0a0 # Lookup table address used by sseg-display # Interrupt controller register # Seven segment display 10 |# TODO: enable interrupts below 11 |# 12 13 15 16 |# NOTE: Do not add or modify any code within this main loop 17 main: 18 19 20 21 jal sseg_display nop addiu $a0, $a0, 1 j main nop 23 24 25 |# 26 |# TODO: add interrupt service routine below 27 # 1 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 2 6 9 sseg display: 10 move $t1, $a0 move $t3, $0 12 13 14 15 16 17 18 19 20 21 # Position 0 andi $t2, $t1, 0xf sll $t2, $t2, 2 addu $t2, st2, $50 # Calculate LUT address lw $t2, 0($t2) or $t3, $t3, $t2 23 24 25 26 27 # Position 1 andi $t2, $t1, 0xf0 srl $t2, $t2, 2 addu $t2, st2, $50 # Calculate LUT address lw $t2, 0($t2) sll $t2, $t2, 8 or $t3, $t3, $t2 29 39 31 32 # Position 2 andi $t2, $t1, 0xf00 srl $t2, $t2, 6 addu $t2, $t2, $50 # Calculate LUT address lw $t2, 0 ($t2) sll $t2, $t2, 16 or $t3, $t3, $t2 35 36 37 38 39 40 41 42 43 # Position 3 andi $t2, $t1, 0xf000 srl $t2, $t2, 10 addu $t2, $t2, $50 # Calculate LUT address lw $t2, 0 ($t2) sll $t2, $t2, 24 or $t3, $t3, $t2 45 46 47 48 49 # write to seven segment and increment r $ra sw $t3, 0 ($s2) 50 |# Seven segment display lookup table 51 sseg_lut: 52 53 54 #0 word word word 0xc0 Oxf9 Oxa4 3.4 5 6 7 8 9 abcdef 0922800836-6e b998f8988ca8 5678901234567 5555566666666 org 0x10000000 2 3 lui $sp, 0x10fffffc # Stack pointer initialization |li $s0, sseg-Lut 5 lui $s1, 0xf070 6 ui $s2, 0xf0a0 # Lookup table address used by sseg-display # Interrupt controller register # Seven segment display 10 |# TODO: enable interrupts below 11 |# 12 13 15 16 |# NOTE: Do not add or modify any code within this main loop 17 main: 18 19 20 21 jal sseg_display nop addiu $a0, $a0, 1 j main nop 23 24 25 |# 26 |# TODO: add interrupt service routine below 27 # 1 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 2 6 9 sseg display: 10 move $t1, $a0 move $t3, $0 12 13 14 15 16 17 18 19 20 21 # Position 0 andi $t2, $t1, 0xf sll $t2, $t2, 2 addu $t2, st2, $50 # Calculate LUT address lw $t2, 0($t2) or $t3, $t3, $t2 23 24 25 26 27 # Position 1 andi $t2, $t1, 0xf0 srl $t2, $t2, 2 addu $t2, st2, $50 # Calculate LUT address lw $t2, 0($t2) sll $t2, $t2, 8 or $t3, $t3, $t2 29 39 31 32 # Position 2 andi $t2, $t1, 0xf00 srl $t2, $t2, 6 addu $t2, $t2, $50 # Calculate LUT address lw $t2, 0 ($t2) sll $t2, $t2, 16 or $t3, $t3, $t2 35 36 37 38 39 40 41 42 43 # Position 3 andi $t2, $t1, 0xf000 srl $t2, $t2, 10 addu $t2, $t2, $50 # Calculate LUT address lw $t2, 0 ($t2) sll $t2, $t2, 24 or $t3, $t3, $t2 45 46 47 48 49 # write to seven segment and increment r $ra sw $t3, 0 ($s2) 50 |# Seven segment display lookup table 51 sseg_lut: 52 53 54 #0 word word word 0xc0 Oxf9 Oxa4 3.4 5 6 7 8 9 abcdef 0922800836-6e b998f8988ca8 5678901234567 5555566666666

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students explore these related Databases questions