forked from shoaib30/Microprocessor-Lab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPASSWORD.asm
More file actions
82 lines (74 loc) · 1.07 KB
/
PASSWORD.asm
File metadata and controls
82 lines (74 loc) · 1.07 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
;PASSWORD.asm
;shoaib ahmed
;18.05.15
;password check
assume cs:code,ds:data
data segment
pwd db "hello"
len1 db (len1-pwd)
epwd db 10 dup(?)
len2 db (len1-pwd)
msg1 db 0ah,0dh,"Enter the password: $"
msg2 db 0ah,0dh,"Password Match$"
msg3 db 0ah,0dh,"Password does not match$"
msg4 db 0ah,0dh,"Exceeded 3 attempts$"
data ends
DISP MACRO msg
LEA dx,msg
MOV ah,9
INT 21h
ENDM
code segment
START: MOV ax,data
MOV ds,ax
MOV es,ax
MOV cl,0
RPT: PUSH cx
CALL ENTPWD
CALL MATCH
POP cx
INC cl
CMP cl,3
JB RPT
DISP msg4
MOV ah,4ch
INT 21h
ENTPWD PROC near
MOV si,offset epwd
DISP msg1
MOV bl,0
AGAIN: MOV ah,8
INT 21h
CMP al,0dh
JE FIN
MOV [si],al
INC si
INC bl
MOV dl,"*"
MOV ah,2
INT 21h
JMP AGAIN
FIN: MOV len2,bl
RET
ENTPWD ENDP
MATCH PROC near
MOV bl,len1
CMP bl,len2
JNE DNMAT
LEA si,pwd
LEA di,epwd
CLD
;PUSH cx
MOV ch,0
MOV cl,len1
REP CMPSB
JNZ DNMAT
;POP cx
DISP msg2
MOV ah,4ch
INT 21h
DNMAT: DISP msg3
RET
MATCH ENDP
code ends
end START