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

南邮汇编实验2

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

实验要求:输入用户名和密码,输入密码时无回显,当输入用户名及密码与预设用户名、密码相同时,才显示欢迎页面。

.486
DATA SEGMENT USE16
INPUTID DB 'PLEASE INPUT YOUR ID: $'
WRONGINPUT DB 'YOUR INPUT IS WRONG $'
ID DB 'KELLY'    ;your ID
IDLEN EQU $-ID
INPUTPASSWORD DB 'PLEASE INPUT YOUR PASSWORD: $'
PASSWORD DB 'CODING'    ;your PASSWORD
PASSWORDLEN EQU $-PASSWORD
MESG DB 'WELCOME$'
LL EQU $-MESG
BUF DB 100
    DB ?
    DB 100 DUP (?)
DUF DB 100 DUP (?)
DATA ENDS
CODE SEGMENT USE16
     ASSUME CS:CODE,DS:DATA,ES:DATA
BEG: 
     MOV AX,DATA
     MOV DS,AX
     MOV ES,AX
AGAIN: MOV AH,9
       MOV DX,OFFSET INPUTID
       INT 21H
       CALL ENTER
       MOV AH,0AH          ;input ID
       MOV DX,OFFSET BUF
       INT 21H
       CALL ENTER
       MOV BL,BUF+1
       MOV BH,0H
       CMP BL,IDLEN
       JNZ EXIT
       LEA DI,ID    ;compare strings
       LEA SI,BUF+2
       MOV CX,IDLEN
	   CLD
	   REPE CMPSB
	   JNZ EXIT
	   MOV AH,9
	   MOV DX,OFFSET INPUTPASSWORD
	   INT 21H
	   CALL ENTER
	   MOV CX,100
	   LEA SI,DUF
	   MOV DL,0
PSD:   MOV AH,07H           ;input password
       INT 21H
	   CMP AL,0DH
	   JZ COMPARE
	   MOV [SI],AL
	   INC SI
	   INC DL
	   LOOP PSD
COMPARE:   CMP DL,PASSWORDLEN
           JNZ EXIT
           LEA DI,PASSWORD     ;compare strings
	   LEA SI,DUF
	   MOV CX,PASSWORDLEN
	   CLD
	   REPE CMPSB
	   JNZ EXIT
WELCOME:MOV AX,0003H
        INT 10H
        MOV AH,9
	MOV DX,OFFSET MESG
	INT 21H
       MOV AH,4CH
       INT 21H
EXIT PROC 
    MOV AH,9
    MOV DX,OFFSET WRONGINPUT
    INT 21H
    MOV AH,4CH
    INT 21H
    RET
EXIT ENDP
ENTER PROC
         MOV AH,2
	 MOV DL,0DH
	 INT 21H
	 MOV AH,2
	 MOV DL,0AH
	 INT 21H
	 RET
ENTER ENDP
CODE ENDS
     END BEG