
DE1-S
O
C C
OMPUTER
S
YSTEM WITH
N
IOS
II
For Quartus II 15.0
stw
r8, 16(sp)
stw
r10, 20(sp)
stw
r20, 24(sp)
stw
r21, 28(sp)
stw
r22, 32(sp)
stw
r23, 36(sp)
movia
r10, 0xFF202000
/* interval timer base address */
sthio
r0, 0(r10)
/* clear the interrupt */
movia
r20, 0xFF200020
/* HEX3_HEX0 base address */
movia
r21, PATTERN
/* set up a pointer to the pattern for HEX displays */
movia
r22, KEY_PRESSED
/* set up a pointer to the key pressed */
movia
r23, SHIFT_DIR
/* set up a pointer to the shift direction variable */
ldw
r6, 0(r21)
/* load pattern for HEX displays */
stwio
r6, 0(r20)
/* store to HEX3 ... HEX0 */
ldw
r4, 0(r22)
/* check which key has been pressed */
CHK_KEY0:
movi
r8, KEY0
/* code to check for KEY1 */
bne
r4, r8, CHK_KEY1
movia
r20, SLIDER_SWITCH_BASE
ldw
r6, 0(r20)
/* load a new pattern from the SW switches */
br
SHIFT
CHK_KEY1:
movi
r8, KEY1
/* code to check for KEY1 */
bne
r4, r8, CHK_KEY2
movi
r5, RIGHT
/* KEY1 sets rotation direction to the right */
stw
r5, 0(r23)
br
SHIFT
CHK_KEY2:
movi
r8, KEY2
/* code to check for KEY2 */
bne
r4, r8, CHK_KEY3
movi
r5, LEFT
/* KEY2 sets rotation direction to the left */
stw
r5, 0(r23)
br
SHIFT
Figure
18
. Interrupt service routine for the interval timer (Part
b
).
20
Altera Corporation - University Program
2015