-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.s
More file actions
139 lines (107 loc) · 1.63 KB
/
App.s
File metadata and controls
139 lines (107 loc) · 1.63 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
AREA AsmTemplate, CODE, READONLY
IMPORT main
; (c) Mike Brady, 2011 -- 2019.
EXPORT start
IMPORT ReadKeyPress ;Import subroutine to read keys
IMPORT IO1DIR
IMPORT IO1CLR
IMPORT IO1SET
IMPORT Display
;Main loop
start
LDR R5, =0
LDR R1, =IO1DIR
LDR R2, [R1]
ORR R2, #(2_1111 << 16)
STR R2, [R1]
LDR R1, =IO1SET
LDR R4, =(2_1111 << 16)
STR R4, [R1]
;R2 - state
;R3 - current value
;R4 - total
;R1 - value to display
LDR R2, =0
LDR R3, =0
LDR R4, =0
LDR R1, =0
LPST
BL ReadKeyPress ;Set R0 to +-{20-23}
;State Switch
CMP R2, #2 ;SOFT CLEAR
BEQ CASE0_1
B DEFAULT0
CASE0_1
CMP R0, #0
RSBMI R0, R0, #0
CMP R0, #22
BEQ CASE2_1 ;ADD
CMP R0, #23
BEQ CASE2_2 ;SUB
B EndSwitch2 ;DEFAULT
CASE2_1
LDR R2, =0
B DISPSET
CASE2_2
LDR R2, =1
B DISPSET
DISPSET
LDR R3, =0
MOV R1, R3
EndSwitch2
B EndSwitch0
DEFAULT0
;switch on input
CMP R0, #-22
BEQ CASE1_1 ;SOFT CLEAR
CMP R0, #-23
BEQ start ;RESET
CMP R0, #0
RSBMI R0, R0, #0
CMP R0, #20
BEQ CASE1_2 ;INCREASE
CMP R0, #21
BEQ CASE1_3 ;DECREASE
CMP R0, #22
BEQ CASE1_4 ;ADD
CMP R0, #23
BEQ CASE1_5 ;SUB
B start ;DEFAULT
;R2 - state
;R3 - current value
;R4 - total
;R1 - value to display
;R5 - NEXT STATE
CASE1_1 ;Soft Clear
LDR R3, =0xF
MOV R1, R3
LDR R2, =2
B EndSwitch1
CASE1_2
ADD R3, R3, #1
MOV R1, R3
B EndSwitch1
CASE1_3
SUB R3, R3, #1
MOV R1, R3
B EndSwitch1
CASE1_4
LDR R5, =0
B ADDSUB
CASE1_5
LDR R5, =1
B ADDSUB
ADDSUB
CMP R2, #0
ADDEQ R4, R4, R3
CMP R2, #1
SUBEQ R4, R4, R3
LDR R3, =0
MOV R1, R4
MOV R2, R5
EndSwitch1
EndSwitch0
;Display to LEDs
BL Display
B LPST
END