DE1-SOC COMPUTER SYSTEM WITH NIOS II For Quartus II 15.0
.include "key_codes.s" /* includes .equ for KEY0, KEY1, . .. */
.extern PATTERN /* externally deļ¬ned variables */
.extern KEY_PRESSED
/********************************************************************************
* Pushbutton - Interrupt Service Routine
*
* This routine checks which KEY has been pressed. It writes this value to the global
* variable KEY_PRESSED.
********************************************************************************/
.global PUSHBUTTON_ISR
PUSHBUTTON_ISR:
subi sp, sp, 20 /* reserve space on the stack */
stw ra, 0(sp)
stw r10, 4(sp)
stw r11, 8(sp)
stw r12, 12(sp)
stw r13, 16(sp)
movia r10, 0xFF200050 /* base address of pushbutton KEY parallel port */
ldwio r11, 0xC(r10) /* read edge capture register */
stwio r0, 0xC(r10) /* clear the interrupt */
movia r10, KEY_PRESSED /* global variable to return the result */
CHECK_KEY0:
andi r13, r11, 0b0001 /* check KEY0 */
beq r13, zero, CHECK_KEY1
movi r12, KEY0
stw r12, 0(r10) /* return KEY0 value */
br END_PUSHBUTTON_ISR
CHECK_KEY1:
andi r13, r11, 0b0010 /* check KEY1 */
beq r13, zero, CHECK_KEY2
movi r12, KEY1
stw r12, 0(r10) /* return KEY1 value */
br END_PUSHBUTTON_ISR
CHECK_KEY2:
andi r13, r11, 0b0100 /* check KEY2 */
beq r13, zero, DO_KEY3
movi r12, KEY2
stw r12, 0(r10) /* return KEY2 value */
br END_PUSHBUTTON_ISR
Figure 19. Interrupt service routine for the pushbutton keys (Part a).
22 Altera Corporation - University Program
2015