assembly - 我无法将我的登录密码与我的注册密码进行比较。谁能给我一个解决方案来解决它?
问题描述
.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
解决方案
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,因为这是密码缓冲区的长度。
推荐阅读
- python - 我已经设法在我的 Debian 系统上做了一些事情,而 Python-Cryptography 不允许我安装或删除任何东西
- java - 在java中动态添加类对象到ArrayList
- ruby-on-rails - 带有全局安装 gem 的 rails rake 任务
- python-3.x - 当脚本显示有货时,如何让脚本发送一个通知?
- swift - 初始化泛型类型的占位符空变量
- gcc - ARM 处理器的 GNU 工具链是否提供对 ARM11 等经典处理器的支持?
- c# - 如何从进程名称中获取进程 ID?(C#)
- java - Android:为什么按下按钮时我的活动没有出现?
- reactjs - Console.log 在 React.js 的构造函数和渲染函数中打印两次值
- video - 比较两个视频然后缩小差异