Home > Software design >  I can't compare my login password with my registered password. Who can give me a solution to sl
I can't compare my login password with my registered password. Who can give me a solution to sl

Time:09-18

.model

.stack

.data

    fMenu DB 10,13,"************************************"
          DB 10,13,"*****   Welcome TO Our System  *****"
          DB 10,13,"*****   ---------------------  *****"
          DB 10,13,"*****  |     1. Register     | *****"
          DB 10,13,"*****  |     2.  Login       | *****"
          DB 10,13,"*****  |     3.  Exit        | *****"
          DB 10,13,"*****   ---------------------  *****"
          DB 10,13,"************************************"
          DB 10,13,"    Enter Your Selection : $"
    NUM1  DB ?
    ;MSG
    STR3 db 10,13,"Failed to register$"
    STR4 DB 10,13,"SUCCESS to REgister$"
    STR5 DB 10,13,"Not register yet.$"
    STR6 DB 10,13,"Password wrong.$"
    STR7 DB 10,13,"Login successfully.$"    
    ;-----user login and register msg
    STR1  DB 10,13,10,13,10,13,"*****LOGIN PAGE*****$"
    STR2  DB 10,13,10,13,10,13,"*****REGISTER PAGE*****$"
    USER  DB 10,13,"*****USERNAME : $"
    PASS  DB 10,13,"*****PASSWORD : $"
    ;user input
    RUSER DB 13 DUP(?) ;register user
    RPASS DB 10 DUP(?) ;register password
    CPASS DB 10 DUP(?) ;compare register password
    LUSER DB 13 DUP(?) ;login user
    LPASS DB 10 DUP(?) ;login password
.code

main proc

    mov ax,@data
    mov ds,ax
Start:

    mov ah, 09h
    lea dx, fMenu
    int 21h
    
    mov ah,01h ;let user prompt 1 number
    int 21h
    mov NUM1,al
    
    cmp NUM1,'1'
    JE REGISTER
    cmp NUM1,'2'
    JE HI
    cmp NUM1,'3'
    JE BYE
    
REGISTER:

    mov ah,09h
    lea dx,STR2
    int 21h 
    mov ah,09h
    lea dx,USER
    int 21h
    mov ah,3fh
    mov bx,0
    mov cx,13
    lea dx,RUSER
    int 21h
    CMP al,13
    JMP Dispass
BYE:

jmp exit

Hi:

jmp login

DisPass:

    mov ah,09h
    lea dx,Pass
    int 21h
    mov si,0
setpass:
    
    MOV AH,08H
    INT 21H
    CMP AL,0DH
    JE Comfirm
    MOV [RPASS SI],AL
    MOV DL,'*'
    MOV AH,02H
    INT 21H
    INC SI
    Loop setpass

Comfirm:

    mov ah,09h
    lea dx,Pass
    int 21h

    mov si,0
DisC:

    MOV AH,08H
    INT 21H
    CMP AL,0DH
    JE compare
    MOV [CPASS SI],AL
    MOV DL,'*'
    MOV AH,02H
    INT 21H
    INC SI

    JMP disc
    MOV BX,0
    mov cx,0
    
compare:

    mov al,RPASS[bx]
    inc bx
    cmp al,CPASS[bx-1]
    loope compare
    je success
    jne FAIl

LOGIN:

    MOV AH,09H
    LEA DX,STR1
    INT 21H
    MOV AH,09H
    LEA DX,USER
    INT 21H
    mov ah, 3Fh
    MOV CX,13
    MOV BX,0                            
    lea dx, LUSER           
    int 21h 
    MOV CX,13
    MOV BX,0

    ;-----compare user input with register's input
    CHECKU:

        MOV AL,LUSER[BX]
        INC BX
        CMP AL,RUSER[BX-1]
        LOOPE CHECKU
    JE DIPAS
    JNE NOREG
DIPAS:

    mov ah,09h
    lea dx,Pass
    int 21h
    mov si,0
inpass:

    MOV BX,0
    mov cx,0
    MOV AH,08H
    INT 21H
    CMP AL,0DH
    JE CHECKP
    MOV [LPASS SI],AL
    MOV DL,'*'
    MOV AH,02H
    INT 21H
    INC SI

    JMP INPASS

CHECKP:                 ;compare login password with register password

        MOV AL,LPASS[BX]    ;<------ i don't know got what problem
        INC BX
        CMP AL,RPASS[BX-1]
        LOOPE CHECKP
    JE LOSUCCESS
    JNE WroPa
FAIl:

    mov ah,09h
    lea dx,str3
    int 21h
    jmp Start
success:
        
    mov ah,09h
    lea dx,str4
    int 21h
    JMP LOGIN
NOREG:              ;not register yet

    mov ah,09h
    lea dx,str5
    int 21h
    jmp start
WroPa:              ;wrong password

    mov ah,09h
    lea dx,str6
    int 21h
    jmp LOGIN
LOSUCCESS:
    mov ah,09h
    lea dx,str7
    int 21h
exit:
 mov ah,4ch
 int 21h
main endp
end main

CodePudding user response:

CHECKP:                 ;compare login password with register password
    MOV AL,LPASS[BX]    ;<------ i don't know got what problem

You knew how to verify the user name, then why would verifying the password be any different? You need to reset the BX register and load the CX register with the loop count.


Loop setpass

This Loop instruction should become a jmp instruction!


    mov cx,0
compare:

The CX register here needs an initialization, say 10 because that's the length of the password buffers.

  • Related