Advertisement
Redxone

[ASM] ASCII Password Lock! (DOS Compatible!)

Sep 4th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .model small
  2. .stack 100h
  3.  
  4. print macro msg
  5.     mov ah, 9h          ; Call print
  6.     lea dx, msg         ; Store pss to print register
  7.     int 21h             ; Run    
  8. endm    
  9. pchar macro msg
  10.     mov ah, 2h          ; Call char print
  11.     lea al, msg         ; Store pss to print register
  12.     int 21h             ; Run    
  13. endm
  14.  
  15.     .data    
  16. pss db 10,13,'Enter Password: $'  
  17. cor db 10, 13, 'Correct!$'
  18. star db '*$'
  19. line db 10,13,'$'
  20. password db 'test'        
  21. nnum db 0    
  22.     .code
  23. start:
  24. ; LOAD
  25.     mov ax, @data
  26.     mov ds, ax
  27.     mov cx, 4          ; Size of password
  28.     mov di, offset password
  29.     print pss
  30. ; Compare each input with EAX
  31. compare:
  32.     mov dl, [di]  ; Get number in password
  33.     mov ah, 8h      ; Read char
  34.     int 21h         ; Run        
  35.     cmp al, dl     ; Compare input with correct value  
  36.     print star
  37.     je check
  38.     jmp start
  39. check:
  40.    cmp cx, 1  ; Check if last input
  41.    je done     ; Jump to done if last input
  42.    dec cx     ; Dec input counter
  43.    add di, 1     ; Next value
  44.    jmp compare ; Compare new input  
  45. exit:
  46.     mov ah, 4ch; Load DOS
  47.     int 21h    ; Run
  48. done:
  49.     print cor
  50.     jmp exit   ; Exit the program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement