-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPASSWD.ASM
80 lines (67 loc) · 2.22 KB
/
PASSWD.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
; password protect program in TASM asembler
; coded by Falsedeer(gamer.com.tw)
.model small
.CODE
ORG 100h
start:
mov ah, 09h
mov dx, OFFSET msg
int 21h
xor di, di
xor al, al
mov bx, OFFSET buff
firstchar:
mov ah, 01h ;moving the first letter into buff manually
int 21h
cmp al, 0dh ;check if the first char is enter
mov byte PTR [bx+di], al
jnz input ;if not enter, jnz to input to read the rest
jmp done ;exit now if the first char is enter
input:
xor al, al ;reset al to hold entered letter
mov ah, 01h ;read input
int 21h
inc di ;increase di by 1, mark the total input byte
mov byte PTR [bx+di], al ;save the char to var:input
cmp al, 0dh ;check if it's a CRLF
jnz input ;loop if doesn't equal.
jmp markup
markup: ;overwrite the last byte to markup the end
mov byte PTR [bx+di], 0 ;adding a terminate zero, overwrite CRFL
inc di ;index starts from zero, so inc di to correct the value.
mov si, di ;save the length in si register
xor di, di
mov cx, OFFSET len_passwd
mov bx, OFFSET buff
mov bp, OFFSET passwd
verify_char:
xor ax, ax
mov al, byte PTR [bp+di]
cmp byte PTR [bx+di], al
jnz reject ;if doent match, jump to error
inc di
cmp cx, di
jnz verify_char
verify_len:
cmp cx, si
jnz reject
accept:
mov ah, 09h
mov dx, OFFSET msg2
int 21h
jmp done
reject:
mov ah, 09h
mov dx, OFFSET msg3
int 21h
jmp done
done:
mov ah, 4ch
int 21h
msg db "Please enter password: $"
msg2 db "Welcome!$"
msg3 db "Error Occured!$"
buff db 10 dup(0) ;buffer area for input data
passwd db "miraix",0
len_passwd EQU $ - passwd ;length of passwd
end start