A program in 8086 assembly language that checks an input string against a password string stored in memory. 7m Jun2006

By | February 8, 2015

Write a program in 8086 assembly language that checks an input string against a password string stored in the memory and outputs an appropriate message if the strings are not equal.       7m Jun2006

DATA SEGMENT
MSG1 DB 10,13,’ENTERED PASSWORD : $’
MSG2 DB 10,13,’YOU HAVE ENTERED WRONG PASSWORD !!! $’
MSG3 DB 10,13,’YOU HAVE ENTERED CORRECT PASSWORD ! $’
MSG4 DB 10,13,’PASSWORD LENGTH IS NOT EQUAL $’

STR1 DB “NITIN”

P1 LABEL BYTE
M1 DB 0FFH
L1 DB ?
P11 DB 0FFH DUP (‘$’)
DATA ENDS

DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX

DISPLAY MSG1

LEA DX,P1
MOV AH,0AH
INT 21H

CMP L1,5
JNE NOTEQUAL

LEA SI,STR1
LEA DI,P11

MOV CX,5
CHECK:
MOV AL,[SI]
CMP [DI],AL
JNE NOPASWD
INC SI
INC DI
LOOP CHECK

DISPLAY MSG3
JMP EXIT

NOTEQUAL:
DISPLAY MSG4

NOPASWD:
DISPLAY MSG2
JMP EXIT

EXIT: MOV AH,4CH
INT 21H
CODE ENDS
END START

Program code: -

DATA SEGMENT
MSG1 DB 10,13,'ENTERED PASSWORD : $'
MSG2 DB 10,13,'YOU HAVE ENTERED WRONG PASSWORD !!! $'
MSG3 DB 10,13,'YOU HAVE ENTERED CORRECT PASSWORD ! $'
MSG4 DB 10,13,'PASSWORD LENGTH IS NOT EQUAL $'
STR1 DB "NITIN"
P1 LABEL BYTE
M1 DB 0FFH
L1 DB ?
P11 DB 0FFH DUP ('$')
DATA ENDS
DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
DISPLAY MSG1
LEA DX,P1
MOV AH,0AH
INT 21H
CMP L1,5
JNE NOTEQUAL
LEA SI,STR1
LEA DI,P11
MOV CX,5
CHECK:
MOV AL,[SI]
CMP [DI],AL
JNE NOPASWD
INC SI
INC DI
LOOP CHECK
DISPLAY MSG3
JMP EXIT
NOTEQUAL:
DISPLAY MSG4
NOPASWD:
DISPLAY MSG2
JMP EXIT
EXIT: MOV AH,4CH
INT 21H
CODE ENDS
 
END START

Screen shots: -

Asm_program_Check_Password

After Execution: -

Asm_program_Check_Password_Output