首页 > 解决方案 > 我无法将我的登录密码与我的注册密码进行比较。谁能给我一个解决方案来解决它?

问题描述

.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

标签: assemblyx86-16

解决方案


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

你知道如何验证用户名,那为什么验证密码会有所不同呢?您需要重置寄存器并使用循环计数BX加载寄存器。CX


Loop setpass

这个Loop指令应该变成jmp指令!


    mov cx,0
compare:

这里的CX寄存器需要初始化,比如 10,因为这是密码缓冲区的长度。


推荐阅读