欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

南邮汇编实验——汇编语言实现用户的登录,不回显密码

程序员文章站 2022-06-20 20:24:36
...

用汇编语言实现用户的登录,不回显密码

代码:

.586
DATA SEGMENT USE16
STRWELCOME DB 'WELCOME,INPUT YOUR ID$'
STRINPUTPASS DB 'Please input your password$'
STRWID DB 'Your id is wrong$'
STRWPASS DB 'Your password is wrong$'
STRRIGHT DB 'Login successfully$'
HC DB 0DH,0AH,'$'
XXX DB '*$'
IDIN DB 100
 DB ?
 DB 100 DUP(?)


PASSIN DB 100 DUP(?)
 

DATA ENDS
EXTRA SEGMENT USE16
IDC DB 'GOOD'
IDLENG EQU $-IDC
PASSC DB 'GOOD123'
PASSLENG EQU $-PASSC
EXTRA ENDS

CODE SEGMENT USE16
  ASSUME CS:CODE,DS:DATA,ES:EXTRA
BEG:MOV AX,DATA
 MOV DS,AX
 MOV AX,EXTRA
 MOV ES,AX
 MOV AH,9
 MOV DX,OFFSET STRWELCOME
 INT 21H
 CALL HUICHE
 MOV AH,0AH
 MOV DX,OFFSET IDIN
 INT 21H
 MOV CL,IDIN+1    ;TRY IDIN[1]
 MOV CH,0
 CMP CX,IDLENG
 JNZ WID
 MOV SI,OFFSET IDIN+2
 MOV DI,OFFSET IDC
 CLD     ;?
 REPE CMPSB
 JNZ WID
 CALL HUICHE
 MOV AH,9
 MOV DX,OFFSET STRINPUTPASS
 INT 21H
 CALL HUICHE
 MOV SI,0
 MOV BX,OFFSET PASSIN
NOC:MOV AH,8
 INT 21H
 CMP AL,13
 JZ STA
 MOV  [BX+SI],AL
 INC SI
 CALL XIN
 JMP NOC
 
STA:MOV CX,SI
 CMP CX,PASSLENG
 JNZ WPA
 MOV SI,OFFSET PASSIN
 MOV DI,OFFSET PASSC
 CLD     ;?
 REPE CMPSB
 JNZ WPA
 CALL HUICHE
 MOV AH,9
 MOV DX,OFFSET STRRIGHT
 INT 21H
 JMP EXIT
 
WID:CALL HUICHE
 MOV AH,9
 MOV DX,OFFSET STRWID
 INT 21H
 JMP EXIT
WPA:CALL HUICHE
 MOV AH,9
 MOV DX,OFFSET STRWPASS
 INT 21H
 JMP EXIT
 
EXIT:MOV AH,4CH
 INT 21H

 
HUICHE PROC
 MOV AH,9
 MOV DX,OFFSET HC
 INT 21H
 RET
HUICHE ENDP

XIN PROC 
 MOV AH,9
 MOV DX,OFFSET XXX
 INT 21H
 RET
XIN ENDP

CODE ENDS
 END BEG