Question
Please fill out the blank boxes in the following program so that When KEY 1 is pressed and released, the interrupt subroutine inverts bits 2
Please fill out the blank boxes in the following program so that
When KEY 1 is pressed and released, the interrupt subroutine inverts bits 2 and 3 of the KEY interrupt mask register and turns off all Red LED lights.
When KEY 2 is pressed and released, the ten Red LED lights show binary number 1000000001. That is, LEDR 9 and LEDR 0 are on (i..e, 1), and all other LEDRs are off (i.e., 0.
When KEY 3 is pressed and released, the ten Red LED lights show binary number 0111111110. That is, LEDR 9 and LEDR 0 are off, and all other LEDRs are on.
.section .reset, "ax" movia r2, _start jmp r2 .section .exceptions, "ax" subi sp, sp, 8 stw ra, 0(sp) stw r2, 4(sp) rdctl et, ipending beq et, r0, end_exception check_hardware_interrupts: subi ea, ea, 4 andi r2, et, 0b10 beq r2, r0, end_exception call KEY_Interrupt end_exception: ldw ra, 0(sp) ldw r2, 4(sp) addi sp, sp, 8 eret KEY_Interrupt: subi sp, sp, 16 stw r10, 0(sp) stw r11, 4(sp) stw r2, 8(sp) stw r3, 12(sp) movia r10, 0x10000050 /* KEY base address */ ldwio r2, 0xC(r10) /* read KEY edge capture register */ stwio r0, 0xC(r10) /* clear the register */ movia r11, 0x ( ) /* LEDR base address */ andi r3, r2, 0b10 beq r3, r0, not_KEY1 KEY1: movi r3, 0 stwio r3, 0(r11) ldwio r2, ( ) (r10) xori r2, r2, 0b ( ) stwio r2, ( ) (r10) br end_interrupt not_KEY1: andi r3, r2, 0b ( ) beq r3, r0, KEY3 KEY2: movi r3, 0b ( ) stwio r3, 0(r11) br end_interrupt KEY3: movi r3, 0b ( ) stwio r3, 0(r11) end_interrupt: ldw r10, 0(sp) ldw r11, 4(sp) ldw r2, 8(sp) ldw r3, 12(sp) addi sp, sp, 16 ret .section .text .global _start _start: movia sp, 0x007FFFFC movia r10, 0x10000050 movi r2, 0b01110 stwio r2, 8(r10) movi r2, 0b ( ) wrctl ienable, r2 movi r2, ( ) wrctl status, r2 IDLE: br IDLE .data .end
Once the program runs on your DE1 board, please press KEY3, KEY2, KEY1, KEY3, and KEY2. What are the status of LEDR1 and LEDR0?
LEDR1= (please write either on or off)
LEDR0= (please write either on or off)
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