Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Meet and Greet (http://www.go4expert.com/community/meet-and-greet/)
-   -   password program were cmp not working (http://www.go4expert.com/community/password-program-cmp-t28014/)

panthera 13Mar2012 22:55

password program were cmp not working
 
Code:

data segment
msg1  db 0ah,0dh,'Enter the password : $',0ah,0dh
msg2  db 0ah,0dh,'Re-enter password : $',0ah,0dh
msg3  db 0ah,0dh,'Logging Successful $',0ah,0dh
msg4  db 0ah,0dh,'Password wrong $',0ah,0dh
msg5  db 0ah,0dh,'Password wrongc $',0ah,0dh
a db 10 (?)
b db 10 (?)
countz db ?
data ends

assume cs:code,ds:data

code segment
start:

mov ax,data
mov ds,ax

mov ah,09h
mov dx,offset msg1
int 21h

mov di,offset a
mov si,offset b

loop1: mov ah,08h
            int 21h
            cmp al,0dh
            je loop2
            mov [di],al
            inc di
            inc cl
            jmp loop1
loop2: mov ah,09h
            mov dx,offset msg2
            int 21h
            jmp loop3
loop3: mov ah,08h
            int 21h
            cmp al,0dh
            je check0
            mov [si],al
            inc si
            inc ch
            jmp loop3
check0: mov di,offset a
              mov si,offset b
              ;mov bl,di
              ;mov al,si
                mov countz,ch
              cmp cl,countz
              je check
              ;mov cl,ch
              jmp fail1
check : mov cl,ch
              jmp check1

check1: cmp cl,0dh
              jge pass
              mov bl,[di]
              mov bh,[si]
              cmp bl,bh
              jne fail1
              inc di
              inc si
              dec cl
              jmp check1

pass: mov ah,09h
          mov dx,offset msg3
          int 21h
          jmp last

fail: mov ah,09h
          mov dx,offset msg4
          int 21h
          jmp last

fail1: mov ah,09h
          mov dx,offset msg5
          int 21h
          jmp last

last: mov ah,4ch
        int 21h
        code ends
        end start



All times are GMT +5.5. The time now is 06:00.