
DE1-S
O
C C
OMPUTER
S
YSTEM WITH
N
IOS
II
For Quartus II 15.0
/********************************************************************************
* This program demonstrates the use of parallel ports in the DE1-SoC Computer:
*
1. displays the SW switch values on the red LEDR
*
2. displays a rotating pattern on the HEX displays
*
3. if KEY[3..0] is pressed, uses the SW switches as the pattern
********************************************************************************/
.
text
/* executable code follows */
.
global
_start
_start:
/* initialize base addresses of parallel ports */
movia
r15, 0xFF200040
/* SW slider switch base address */
movia
r16, 0xFF200000
/* red LED base address */
movia
r17, 0xFF200050
/* pushbutton KEY base address */
movia
r20, 0xFF200020
/* HEX3_HEX0 base address */
movia
r19, HEX_bits
ldwio
r6, 0(r19)
/* load pattern for HEX displays */
DO_DISPLAY:
ldwio
r4, 0(r15)
/* load input from slider switches */
stwio
r4, 0(r16)
/* write to red LEDs */
ldwio
r5, 0(r17)
/* load input from pushbuttons */
beq
r5, r0, NO_BUTTON
mov
r6, r4
/* copy SW switch values onto HEX displays */
WAIT:
ldwio
r5, 0(r17)
/* load input from pushbuttons */
bne
r5, r0, WAIT
/* wait for button release */
NO_BUTTON:
stwio
r6, 0(r20)
/* store to HEX3 ... HEX0 */
roli
r6, r6, 1
/* rotate the displayed pattern */
movia
r7, 500000
/* delay counter */
DELAY:
subi
r7, r7, 1
bne
r7, r0, DELAY
br
DO_DISPLAY
.
data
/* data follows */
HEX_bits:
.
word
0x0000000F
.
end
Figure 8. An example of assembly language code that uses parallel ports.
Altera Corporation - University Program
2015
7