-
Notifications
You must be signed in to change notification settings - Fork 0
/
passwordbased.asm
192 lines (159 loc) · 2.14 KB
/
passwordbased.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
org 0h
MAIN:
ACALL LCD_INIT
MOV DPTR,#MYDATA
ACALL SEND_DAT
ACALL DELAY
ACALL READ_KEYPRESS
ACALL DELAY
ACALL CHECK_PASSWORD
Stay_here:SJMP Stay_here
READ_KEYPRESS:
MOV R0,#5D
MOV R1,#160D
ROTATE:ACALL KEY_SCAN
MOV @R1,A
ACALL DATAWRT
ACALL DELAY2
INC R1
DJNZ R0,ROTATE
RET
CHECK_PASSWORD:MOV R0,#5D
MOV R1,#160D
MOV DPTR,#PASSWORD
RPT:CLR A
MOVC A,@A+DPTR
XRL A,@R1
JNZ FAIL
INC R1
INC DPTR
DJNZ R0,RPT
ACALL LCD_INIT
MOV DPTR,#TEXT_S1
ACALL SEND_DAT
ACALL DELAY
SETB P2.3
CLR P2.4
SJMP GOBACK
FAIL:ACALL LCD_INIT
MOV DPTR,#TEXT_F1
ACALL SEND_DAT
ACALL DELAY
CLR P2.3
CLR P2.4
ACALL MAIN
GOBACK:RET
LCD_INIT:MOV DPTR,#MYCOM
C1:CLR A
MOVC A,@A+DPTR
ACALL COMNWRT
ACALL DELAY
INC DPTR
JZ DAT
SJMP C1
DAT:RET
SEND_DAT:
CLR A
MOVC A,@A+DPTR
ACALL DATAWRT
ACALL DELAY
INC DPTR
JZ AGAIN
SJMP SEND_DAT
AGAIN: RET
KEY_SCAN:MOV P1,#11111111B
CLR P1.0
JB P1.4, NEXT1
MOV A,#55D
RET
NEXT1:JB P1.5,NEXT2
MOV A,#56D
RET
NEXT2: JB P1.6,NEXT3
MOV A,#57D
RET
NEXT3: JB P1.7,NEXT4
MOV A,#47D
RET
NEXT4:SETB P1.0
CLR P1.1
JB P1.4, NEXT5
MOV A,#52D
RET
NEXT5:JB P1.5,NEXT6
MOV A,#53D
RET
NEXT6: JB P1.6,NEXT7
MOV A,#54D
RET
NEXT7: JB P1.7,NEXT8
MOV A,#42D
RET
NEXT8:SETB P1.1
CLR P1.2
JB P1.4, NEXT9
MOV A,#49D
RET
NEXT9:JB P1.5,NEXT10
MOV A,#50D
RET
NEXT10: JB P1.6,NEXT11
MOV A,#51D
RET
NEXT11: JB P1.7,NEXT12
MOV A,#45D
RET
NEXT12:SETB P1.2
CLR P1.3
JB P1.4, NEXT13
MOV A,#67D
RET
NEXT13:JB P1.5,NEXT14
MOV A,#48D
RET
NEXT14: JB P1.6,NEXT15
MOV A,#61D
RET
NEXT15: JB P1.7,NEXT16
MOV A,#43D
RET
NEXT16:LJMP KEY_SCAN
COMNWRT:MOV P3,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DATAWRT: MOV P3,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DELAY: MOV R3,#50
HERE2: MOV R4,#255
HERE: DJNZ R4,HERE
DJNZ R3,HERE2
RET
DELAY2: MOV R3,#250D
MOV TMOD,#01
BACK2: MOV TH0,#0FCH
MOV TL0,#018H
SETB TR0
HERE5: JNB TF0,HERE5
CLR TR0
CLR TF0
DJNZ R3,BACK2
RET
CLRSCR: MOV A,#01H
ACALL COMNWRT
RET
ORG 500H
MYCOM: DB 38H,0EH,01,06,80H,0
MYDATA: DB "Password-",0
PASSWORD:DB 49D,50D,51D,52D,53D,0
TEXT_F1: DB "INCORRECT",0
TEXT_S1: DB "CORRECT",0
END