Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IDEAL
- MODEL small
- STACK 100h
- DATASEG
- passnum equ 2
- password db 16 dup (?)
- actualpassword db '123abc'
- enterpassword db 'Enter the password and press ENTER to finish.',13,10,'$'
- wrongpassword db 13,10,'You have inserted an incorrect password.',13,10,'$'
- rightpassword db 13,10,'You have inserted the right password.',13,10,'$'
- CODESEG
- start:
- mov ax, @data
- mov ds, ax
- ;Ask for password
- lea dx, [enterpassword]
- mov ah, 9h
- int 21h
- Getchar:
- xor cx, cx
- GetcharLoop:
- ;If user has inserted 16 bytes or more ( 16 characters or more )restart password checking
- cmp cx, passnum
- jae Getchar
- mov ah, 1
- int 21h
- cmp al, 13
- je Checkpass
- ;If didn't press enter
- lea bx, [password]
- add bx, cx
- mov [bx], al
- inc cx
- jmp GetcharLoop
- ;Checking if [password] contains the right password
- ;Password will be 123abc
- Checkpass:
- cmp cx, passnum
- jne Fail
- mov ax, cx; ax = number of times user has inserted a char
- xor cx, cx
- CheckCharLoop:
- lea bx, [password]
- add bx, cx
- mov bl, [bx]
- lea di, [actualpassword]
- add di, cx
- mov bh, [di]
- cmp bl, bh
- jne Fail
- inc cx
- cmp cx, ax
- je Success
- jmp CheckCharLoop
- Fail:
- lea dx, [wrongpassword]
- mov ah, 9h
- int 21h
- jmp EndPassCheck
- Success:
- lea dx, [rightpassword]
- mov ah, 9h
- int 21h
- jmp EndPassCheck
- EndPassCheck:
- ;For nothing
- mov ah, 1
- int 21h
- exit:
- mov ax, 4c00h
- int 21h
- END start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement