Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly language program to encrypt digits as shown below: Input digit

ID: 3679131 • Letter: W

Question

Write an assembly language program to encrypt digits as shown below:

Input digit :0 1 2 3 4 5 6 7 8 9

Encrypted digit : 4 6 9 5 0 3 1 8 7 2

Briefly discuss whether or not you would use the xlat instruction. your program should accept a string of digit and nondigit characters. the encrypted string should be displayed in which only the digits are affected. then the user should be queried whether he or she wants to terminate the program. if the response is ether 'y' or 'Y' you should terminate the program; otherwise, you should request another input string from the keyboard

the encryption scheme given here has the property that when you encrypt an already encrypted string, you get back the original string. use this property to verify your program

Explanation / Answer

DATA SEGMENT
STR1 DB 10,13,'ENTER STRING HERE :- $'   
STR2 DB 10,13,'ENCRYPTED STRING IS :- $'
MSG3 DB 10,13,'DECPED STRING IS : $'

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 STR1

LEA DX,P1
MOV AH,0AH
INT 21H
  
LEA SI,P11
MOV CL,L1
CALL ENCRYPT

DISPLAY STR2
DISPLAY P11

LEA SI,P11
MOV CL,L1
CALL ENCRYPT

DISPLAY MSG3
DISPLAY P11

MOV AH,4CH
INT 21H
CODE ENDS
ENC PROC NEAR
MOV CH,0   
CHECK1:
CMP [SI],2FH
JB DONE1
CMP [SI],3AH
JB NUM1

CMP [SI],41H
JB DONE1
CMP [SI],5BH
JB UPR1

CMP [SI],61H
JB DONE1
CMP [SI],7BH
JB LWR1

NUM1: CMP [SI],35H
JB LNUM1
SUB [SI],05H
JMP DONE1
LNUM1:
ADD [SI],05H
JMP DONE1   

UPR1: CMP [SI],4EH
JB LUPR1
SUB [SI],0DH
JMP DONE1
LUPR1:
ADD [SI],0DH
JMP DONE1
LWR1: CMP [SI],6EH
JB LLWR1
SUB [SI],0DH
JMP DONE1
LLWR1:
ADD [SI],0DH

DONE1:   
INC SI
LOOP CHECK1
RET
ENC ENDP
DECP PROC NEAR
MOV CH,0   
CHECK2:
CMP [SI],2FH
JB DONE2
CMP [SI],3AH
JB NUM2

CMP [SI],41H
JB DONE2
CMP [SI],5BH
JB UPR2

CMP [SI],61H
JB DONE2
CMP [SI],7BH
JB LWR2

NUM2: CMP [SI],35H
JB LNUM2
ADD [SI],05H
JMP DONE2
LNUM2:
SUB [SI],05H
JMP DONE2   

UPR2: CMP [SI],4EH
JB LUPR2
ADD [SI],0DH
JMP DONE2
LUPR2:
SUB [SI],0DH
JMP DONE2
LWR2: CMP [SI],6EH
JB LLWR2
ADD [SI],0DH
JMP DONE2
LLWR2:
SUB [SI],0DH

DONE2:   
INC SI
LOOP CHECK2
RET
DECP ENDP

END START

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote