
source code:
jmp start
mess2 db 10,13," Enter Password: $"
passframe1 db 10,13," ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»$"
invalid db 10,13," º Invalid password (hit) any key º$"
valid db 10,13," º Valid password º$"
timeout db 10,13," º Time is up! you are allowed 3 tries º$"
passframe2 db 10,13," ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ$"
bSpace db 8,"$"
choice db 0
pass_word db 100 dup 0 ;comment: "user input"
aces_word db 'p','o','w','e','r' ;comment: "pre-define password"
aces_cnt dw 5 ;comment: "pre-define number of characters in the password"
word_cnt dw 0
try dw 1 ;comment: "Counts the number of invalid"
newLine db 10,13,"$"
space db " $"
cont_mess db 10,13," Do you want to continue (y/n) :$"
start:
mov try,1
password:
mov ax,3
int 10h
mov word_cnt,0
lea dx,mess2
mov ah,9
int 21h
mov bx,0
input:
mov ah,8
int 21h
cmp al,13
je safety
cmp al,8
je backspace
mov pass_word[bx],al
inc bx
mov dl,'*'
mov ah,2
int 21h
jmp safetyzone
backspace:
cmp bx,0
je input
lea dx,bSpace
mov ah,9
int 21h
mov dl,' '
mov ah,2
int 21h
lea dx,bSpace
mov ah,9
int 21h
dec bx
safetyzone:
jmp input
safety:
mov word_cnt,bx
mov ax,aces_cnt
cmp ax,bx
jne mismatch
mov bx,word_cnt
mov cx,bx
mov bx,0
checking:
mov al,pass_word[bx]
mov ah,aces_word[bx]
cmp al,ah
jne mismatch
inc bx
loop checking
call ok_message
call exit
mismatch:
mov ax,try
cmp ax,3
je timesup
inc try
call error
mov ah,1
int 21h
call password
timesup:
call timesup_message
exit:
call continue
error:
lea dx,passframe1
mov ah,9
int 21h
lea dx,invalid
mov ah,9
int 21h
lea dx,passframe2
mov ah,9
int 21h
ret
ok_message:
lea dx,passframe1
mov ah,9
int 21h
lea dx,valid
mov ah,9
int 21h
lea dx,passframe2
mov ah,9
int 21h
ret
timesup_message:
lea dx,passframe1
mov ah,9
int 21h
lea dx,timeout
mov ah,9
int 21h
lea dx,passframe2
mov ah,9
int 21h
ret
new_Line:
lea dx,newLine
mov ah,9
int 21h
ret
clear:
xor ax,ax
xor bx,bx
ret
spacer:
lea dx,space
mov ah,9
int 21h
ret
continue:
call new_Line
xor dx,dx
lea dx,cont_mess
mov ah,9
int 21h
mov ah,1
int 21h
cmp al,'y'
je start_bridge
cmp al,'n'
je con_quit
jmp continue
start_bridge:
call start
con_quit:
int 20h
fullclear:
xor ax,ax
xor bx,bx
xor cx,cx
xor dx,dx
ret
No comments:
Post a Comment