-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnegativeTest.txt
157 lines (139 loc) · 3.37 KB
/
negativeTest.txt
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <reg932.inc>
cseg at 0
mov P2M1,#0 ; set Port 2 to bi-directional
mov P1M1,#0 ; set Port 1 to bi-directional
mov P0M1,#0 ; set Port 0 to bi-directional
setb P2.0 ; Set Switch 2 to not pressed
setb P2.3 ; Set Switch 3 to not pressed
NOT_PRESSED:
jnb p0.1, NOT_PRESSED ;Make sure it isn't held down
jnb p2.3, NOT_PRESSED
DELAY: ;100ms delay for input
MOV R0, 0x91
DLOOP:
MOV R1, 0xFF
DLOOP2:
DJNZ R1, DLOOP2
DJNZ R0, DLOOP
acall WAIT_INPUT
WAIT_INPUT:
jnb P0.1, INCREMENT ;Check for Increment button, Sw2
jnb P2.3, DECREMENT ;Check for Decrement button, Sw3
acall WAIT_INPUT ;will continue to loop here until Sw1 is pressed
INCREMENT:
JNB p0.4, DECREMENT ;This port being 0 indicates negative
;Will increment by 1 0=ON and 1=OFF
setb c ;set carry to 1 which will be used to increment
L1: ;All of these loops are used to increment
JC LED1
L2:
JC LED2
L3:
JC LED3
L4:
JC LED4
DONE:
acall NOT_PRESSED ;jumps up to delay input
LED1:
JB p2.4, LED1_ISOFF
JNB p2.4, LED1_ISON
LED1_ISON:
setb p2.4 ;Turning LED off
acall L2
LED1_ISOFF:
clr p2.4 ;Turning LED on
clr c
acall L2
;LED 2
LED2:
JB p0.5, LED2_ISOFF
JNB p0.5, LED2_ISON
LED2_ISON:
setb p0.5
acall L3 ;Turning LED off
LED2_ISOFF:
clr p0.5 ;Turning LED on
clr c
acall L3
;LED 3
LED3:
JB p2.7, LED3_ISOFF
JNB p2.7, LED3_ISON
LED3_ISON:
setb p2.7
acall L4 ;Turning LED off
LED3_ISOFF:
clr p2.7 ;Turning LED on
clr c
acall L4
;LED 4
LED4:
JB p0.6, LED4_ISOFF
JNB p0.6, LED4_ISON
LED4_ISON:
setb p0.6 ;Clears all the LED's because over 15
setb p2.4
setb p0.5
setb p2.7
setb p0.6
setb p0.4 ;rollover always turns off negative light
;ACALL BEEP_UP
acall DONE
LED4_ISOFF:
clr p0.6 ;Turning LED on
clr c
acall DONE
DECREMENT:
JNB p0.4, INCREMENT ;This port being 0 indicates negative
JNB p2.4, NOT_0 ;this chunk checks for the exception
JNB p0.5, NOT_0 ;where we would be going from -1 to 0
JNB p2.7, NOT_0
JNB p0.6, NOT_0
CLR p2.4
CLR p0.4
;NOT_0:
JNB p2.4, D_L1ON
CLR p2.4 ;p2.4 = 0, light is on
ACALL D_L2 ;check light 2
D_L1ON:
SETB p2.4
ACALL DONE ;ACALL DOWN_SOUND ; Play a sound when exiting
D_L2:
JNB p0.5, D_L2ON
CLR p0.5 ;p.05 = 0, light is on
ACALL D_L3 ;check light 3
D_L2ON:
SETB p0.5
ACALL DONE ;ACALL DOWN_SOUND ; Play a sound when exiting
D_L3:
JNB p2.7, D_L3ON
CLR p2.7 ;p2.7 = 0, light is on
ACALL D_L4 ;check light 4
D_L3ON:
SETB p2.7
ACALL DONE ;ACALL DOWN_SOUND ; Play a sound when exiting
D_L4:
JNB p0.6, D_L4ON
CLR p0.6 ;p0.6 = 0, light is on
ACALL DONE ;ACALL DOWN_SOUND ; Play a sound when exiting
D_L4ON:
SETB p0.6
SETB p0.4 ; Rollover always goes to 0
ACALL DONE ; ACALL DOWN_SOUND ; Play a sound when exiting
;SOUND1: ; label used to call the subroutine
; mov R3, #0xF2
; mov R4, #0x3D
; acall stall ; this calls a second (nested) subroutine
; ret ; return to previous program location
;stall:
; loop0:
; mov R1, #85 ; The values entered into R1
; loop1: ; and R2 control the tempo of the
; mov R2, #255 ; song. Smaller values make the
; loop2: ; song play faster.
; nop
; djnz R2, loop2
; djnz R1, loop1
; djnz R0, loop0
; ret
END