-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIODemo.asm
66 lines (52 loc) · 1.23 KB
/
IODemo.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
; IODemo.asm
; Produces a "bouncing" animation on the LEDs.
; The LED pattern is initialized with the switch state.
ORG 0
; Get and store the switch values
IN Switches
OUT LEDs
STORE Pattern
Left:
; Slow down the loop so humans can watch it.
CALL Delay
; Check if the left place is 1 and if so, switch direction
LOAD Pattern
AND Bit9 ; bit mask
JPOS Right ; bit9 is 1; go right
LOAD Pattern
SHIFT 1
STORE Pattern
OUT LEDs
JUMP Left
Right:
; Slow down the loop so humans can watch it.
CALL Delay
; Check if the right place is 1 and if so, switch direction
LOAD Pattern
AND Bit0 ; bit mask
JPOS Left ; bit0 is 1; go left
LOAD Pattern
SHIFT -1
STORE Pattern
OUT LEDs
JUMP Right
; To make things happen on a human timescale, the timer is
; used to delay for half a second.
Delay:
OUT Timer
WaitingLoop:
IN Timer
ADDI -5
JNEG WaitingLoop
RETURN
; Variables
Pattern: DW 0
; Useful values
Bit0: DW &B0000000001
Bit9: DW &B1000000000
; IO address constants
Switches: EQU 000
LEDs: EQU 001
Timer: EQU 002
Hex0: EQU 004
Hex1: EQU 005