MCA SCE Code

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

D:\all\5th sem\mca\pbl_sce\Simulation_data\Simulation\DigitalDoorLock.

asm
1 ;MCA_PBL
2 ;Title: Password Based Door Lock System with AT89C52
3 ;Group No- B35
4 ;Ketaki Sahastrabuddhe_312059
5 ;Sanjana Kumbhar_312071
6 ;Ankita Lengre_312072
7 ;Janhavi Pawar_312075
8
9
10 ORG 0000H
11 S: MOV P3,#0FFH ;initialization of keypad
12 CLR P3.0 ;clear all port pins _connected to keyboard
13 CLR P3.1
14 CLR P3.2
15 CLR P3.3
16 CLR P2.2
17 CLR P2.3
18
19 MOV R0,#02FH ;Input Password is Stored at 02FH in memory
20 MOV R1,#040H ;Preset Password is Stored at 040H in memory
21 MOV R4,#4 ;4 no password
22 MOV DPTR,#0550H ;load data of location to dptr_password
23 Z: MOV A,#0 ;claer accumulator
24 MOVC A,@A+DPTR
25 MOV @R1,A ;preset value set as original password
26 INC R1
27 INC DPTR
28 DJNZ R4,Z ;decrement and jump if not equal to zero
29
30 MOV A,#38H ;to initialize lcd as 8 bit data length; _4bit_28h_
31 ACALL CMD ;call comd subroutine
32 MOV A,#0EH ;to turn on display, cursor blinking
33 ACALL CMD ;call comd
subroutine

34 MOV A,#01H ;to clear display


35 ACALL CMD ;call comd subroutine
36 MOV A,#080H ;to display content from intial position line 1_cursor at home position
37 ACALL CMD ;call comd subroutine
38 ACALL DEL ;call delay subroutine
39 SJMP PRT ;short jmp to PRT subroutine
40
41 CMD: MOV P1,A
42 CLR P2.0 ;clear Rs=0_for cpommand reg
43 SETB P2.1 ;en =1 for high pulse
44 ACALL DEL2 ;Delay subroutine
45 CLR P2.1 ;en=0 for high to low pulse
46 RET
47
48 DAT: MOV P1,A ;lcd connected to P1
49 SETB P2.0 ;set Rs=1 _data reg
50 SETB P2.1 ;en =1 for high pulse
51 ACALL DEL2 ;Delay subroutine
52 CLR P2.1 ;en=0 for high to low pulse
53 RET
54
55 DEL: MOV R1,#250 ;DELAY SUBROUTINE
56 D2: MOV R2,#250
57 D3: DJNZ R2,D3
58 DJNZ R1,D2
59 RET
60
61
62 DEL2: MOV R1,#10 ;SMALL DELAY
63 D2A: MOV R2,#20
64 D3A: DJNZ R2,D3A
65 DJNZ R1,D2A
66 RET
67
68 DEL3: MOV R1,#200 ;delay subroutine
69 D2B: MOV R2,#200
70 D3B: MOV R3,#20
71 D4B: DJNZ R3,D4B
72 DJNZ R2,D3B
73 DJNZ R1,D2B
74 RET
75

Page 1
D:\all\5th sem\mca\pbl_sce\Simulation_data\Simulation\DigitalDoorLock.asm
76
77 PRT:MOV R4,#11 ;enter code _11 letters
78 MOV DPTR,#0500H ;enter code
79 TH: MOV A,#0 ;clear accumulator
80 MOVC A,@A+DPTR
81 ACALL DAT ; lcd data subroutine
82 INC DPTR
83 DJNZ R4,TH ;increment r4_display with respect to contents in dptr
84 MOV A,#0C0H ;to display content from initial position on line2
85 ACALL CMD ;call comand subroutine
86 MOV R4,#4 ;4 input password
87 SJMP M ;short jump to m
88
89 M: ACALL DEL ;delay subrotine
90 JNB P3.4,C1 ;jump if bit is not equal to 1
91 JNB P3.5,C2 ;jump if bit is not equal to 1
92 JNB P3.6,C3 ;jump if bit is not equal to 1
93 JNB P3.7,C4S ;jump if bit is not equal to 1
94 CJNE R4,#0,M ;compare and jump if not equal
95 JMP CHE ;jump on che routine
96 C4S:JMP C4 ;jmp on c4
97
98 C1: DEC R4 ;coloumn 1
99 INC R0 ;Input Password is Stored at 02FH in memory
100 SETB P3.0 ;row 1 initialization
101 JB P3.4,SEVEN ;jmp if bit equal to 1 ,go to seven subroutine_coloumn1 wise
102 SETB P3.1 ;row 2 initialization
103 JB P3.4,FOUR ;jmp if bit equal to 1 ,go to four subroutine__coloumn2 wise
104 SETB P3.2 ;row 3 initialization
105 JB P3.4,ONE ;jmp if bit equal to 1 ,go to one subroutine__coloumn3 wise
106 SETB P3.3 ;row 4 initialization
107 JB P3.4,STAR ;jmp if bit equal to 1 ,go to star subroutine__coloumn4 wise
108
109 C2: DEC R4 ;coloumn 2
110 INC R0 ;Input Password is Stored at 02FH in memory
111 SETB P3.0 ;row 1 initialization
112 JB P3.5,EIGHT ;jmp if bit equal to 1 ,go to eight subroutine_coloumn1 wise
113 SETB P3.1 ;row 2 initialization
114 JB P3.5,FIVE ;jmp if bit equal to 1 ,go to five subroutine_coloumn1 wise
115 SETB P3.2 ;row 3 initialization
116 JB P3.5,TWO ;jmp if bit equal to 1 ,go to two subroutine_coloumn1 wise
117 SETB P3.3 ;row 4 initialization
118 JB P3.5,ZERO ;jmp if bit equal to 1 ,go to Zero subroutine_coloumn1 wise
119
120 SEVEN: MOV A,#'7' ;load 7 value in accumulator
121 ACALL DAT ;call data subroutine
122 ACALL DEL ;call delay
123 MOV @R0,#'7' ;Input Password is Stored if this key is pressed
124 JMP H ;jump on h
125
126 FOUR: MOV A,#'4' ;load 4 value in accumulator
127 ACALL DAT ;all data subroutine
128 ACALL DEL ;call delay
129 MOV @R0,#'4' ;Input Password is Stored if this key is pressed
130 JMP H ;jump on h
131
132 ONE: MOV A,#'1' ;load 1 value in accumulator
133 ACALL DAT ;all data subroutine
134 ACALL DEL ;call delay
135 MOV @R0,#'1' ;Input Password is Stored if this key is pressed
136 JMP H ;jump on h
137
138 STAR: MOV A,#'*'
139 ACALL DAT
140 ACALL DEL
141 MOV @R0,#'*'
142 JMP H
143 C3: DEC R4 ;coloumn 3
144 INC R0
145 SETB P3.0
146 JB P3.6,NINE
147 SETB P3.1
148 JB P3.6,SIX
149 SETB P3.2
150 JB P3.6,THREE
151 SETB P3.3
152 JB P3.6,HASH

Page 2
D:\all\5th sem\mca\pbl_sce\Simulation_data\Simulation\DigitalDoorLock.asm
153
154 EIGHT: MOV A,#'8'
155 ACALL DAT
156 ACALL DEL
157 MOV @R0,#'8'
158 JMP H
159
160 FIVE: MOV A,#'5'
161 ACALL DAT
162 ACALL DEL
163 MOV @R0,#'5'
164 SJMP H
165
166 TWO: MOV A,#'2'
167 ACALL DAT
168 ACALL DEL
169 MOV @R0,#'2'
170 SJMP H
171
172 ZERO: MOV A,#'0'
173 ACALL DAT
174 ACALL DEL
175 MOV @R0,#'0'
176 SJMP H
177
178 C4: DEC R4 ;coloumn 4
179 INC R0
180 SETB P3.0
181 JB P3.7,AA
182 SETB P3.1
183 JB P3.7,BB
184 SETB P3.2
185 JB P3.7,CC
186 SETB P3.3
187 JB P3.7,DD
188
189 NINE: MOV A,#'9'
190 ACALL DAT
191 ACALL DEL
192 MOV @R0,#'9'
193 SJMP H
194
195 SIX: MOV A,#'6'
196 ACALL DAT
197 ACALL DEL
198 MOV @R0,#'6'
199 SJMP H
200
201 THREE: MOV A,#'3'
202 ACALL DAT
203 ACALL DEL
204 MOV @R0,#'3'
205 SJMP H
206
207 HASH: MOV A,#'#'
208 ACALL DAT
209 ACALL DEL
210 MOV @R0,#'#'
211 SJMP H
212
213 AA: MOV A,#'A'
214 ACALL DAT
215 ACALL DEL
216 MOV @R0,#'A'
217 SJMP H
218
219 BB: MOV A,#'B'
220 ACALL DAT
221 ACALL DEL
222 MOV @R0,#'B'
223 SJMP H
224
225 CC: MOV A,#'C'
226 ACALL DAT
227 ACALL DEL
228 MOV @R0,#'C'
229 SJMP H

Page 3
D:\all\5th sem\mca\pbl_sce\Simulation_data\Simulation\DigitalDoorLock.asm
230
231 DD: MOV A,#'D'
232 ACALL DAT
233 ACALL DEL
234 MOV @R0,#'D'
235 SJMP H
236
237
238 H: CLR P3.0 ;clear port pins
239 CLR P3.1
240 CLR P3.2
241 CLR P3.3
242 JMP M
243
244
245 CHE:MOV A,#01H ;check subrotine_clear display
246 ACALL CMD ;cmd of lcd
247 MOV A,#080H ;to display content from initial position on line 1
248 ACALL CMD ;cmd subroutine of lcd
249 ACALL DEL ;delay subroutine
250 MOV R0,#02FH ;Input Password is Stored at 02FH in memory
251 MOV R1,#04FH ;Preset Password is Stored at 040H in memor
252 MOV R4,#4
253
254 CH: INC R0 ;inc R0 for input password
255 INC R1 ;inc R1 for preset password
256 MOV A,@R0
257 MOV B,@R1
258 CJNE A,B,FA ;cmpare enter password and orginal password if not equal then jmp to FA
259 DJNZ R4,CH
260 MOV R4,#7 ;success msg consist of 7 character
261 MOV DPTR,#0600H ;success match password
262 TH2:MOV A,#0 ;accumulator 0
263 MOVC A,@A+DPTR ;load a with dptr+a content_sucess msg
264 ACALL DAT ;call lcd data subroutine
265 INC DPTR ;inc dptr
266 DJNZ R4,TH2 ;dec jump if not equal to zero then jmp on TH2
267
268 H2:CLR P2.2 ;stepper motor pin 1 clkwise________01
269 SETB P2.3 ;stepper motor pin 1 _anti clockwise_open door
270 ACALL DEL3
271 CLR P2.3 ;wait
272 CLR P2.2 ;stop motor
273 ACALL DEL3
274 SETB P2.2 ; rotate clkwise________10
275 CLR P2.3
276 ACALL DEL3
277 JMP S ;initial line
278
279 FA: MOV R4,#7 ;7 character
280 MOV DPTR,#0650H ;failure
281 TH3:MOV A,#0
282 MOVC A,@A+DPTR
283 ACALL DAT
284 INC DPTR
285 DJNZ R4,TH3
286 MOV R4,#0
287 WA: ACALL DEL
288 DJNZ R4,WA
289 JMP S ;initial line
290
291
292
293 ORG 0500H
294 DB "ENTER CODE:"
295
296 ORG 0550H ;password
297 DB "1234"
298
299 ORG 0600H
300 DB "SUCCESS:"
301
302 ORG 0650H
303 DB "FAILURE:"
304
305 END

Page 4

You might also like