Advertisement
Guest User

Untitled

a guest
May 5th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. IDEAL
  2. MODEL small
  3. STACK 100h
  4. DATASEG
  5. passnum equ 2
  6. password db 16 dup (?)
  7. actualpassword db '123abc'
  8. enterpassword db 'Enter the password and press ENTER to finish.',13,10,'$'
  9. wrongpassword db 13,10,'You have inserted an incorrect password.',13,10,'$'
  10. rightpassword db 13,10,'You have inserted the right password.',13,10,'$'
  11. CODESEG
  12. start:
  13. mov ax, @data
  14. mov ds, ax
  15.  
  16. ;Ask for password
  17. lea dx, [enterpassword]
  18. mov ah, 9h
  19. int 21h
  20.  
  21. Getchar:
  22. xor cx, cx
  23.  
  24. GetcharLoop:
  25.  
  26. ;If user has inserted 16 bytes or more ( 16 characters or more )restart password checking
  27. cmp cx, passnum
  28. jae Getchar
  29.  
  30. mov ah, 1
  31. int 21h
  32. cmp al, 13
  33. je Checkpass
  34. ;If didn't press enter
  35. lea bx, [password]
  36. add bx, cx
  37. mov [bx], al
  38. inc cx
  39. jmp GetcharLoop
  40.  
  41. ;Checking if [password] contains the right password
  42. ;Password will be 123abc
  43. Checkpass:
  44. cmp cx, passnum
  45. jne Fail
  46.  
  47. mov ax, cx; ax = number of times user has inserted a char
  48. xor cx, cx
  49.  
  50. CheckCharLoop:
  51. lea bx, [password]
  52. add bx, cx
  53. mov bl, [bx]
  54.  
  55. lea di, [actualpassword]
  56. add di, cx
  57. mov bh, [di]
  58.  
  59. cmp bl, bh
  60. jne Fail
  61. inc cx
  62. cmp cx, ax
  63. je Success
  64. jmp CheckCharLoop
  65.  
  66. Fail:
  67. lea dx, [wrongpassword]
  68. mov ah, 9h
  69. int 21h
  70. jmp EndPassCheck
  71. Success:
  72. lea dx, [rightpassword]
  73. mov ah, 9h
  74. int 21h
  75. jmp EndPassCheck
  76.  
  77. EndPassCheck:
  78. ;For nothing
  79. mov ah, 1
  80. int 21h
  81. exit:
  82. mov ax, 4c00h
  83. int 21h
  84. END start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement