Write an assembly language (MIPS) program to encrypt digits as shown below: Inpu
ID: 3691455 • Letter: W
Question
Write an assembly language (MIPS) 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 Your program should accept a string consisting of digit and non-digit characters. The encrypt string should be displayed in which only the digits are affected. Then, the user should be queried whether he of she wants to terminate the program. If the response is either '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. Sample output Please input phrase to code/decode (14 character limit) Let123 Let655 would you Like to terminate the program? N Please input phrase to code/decode (16 character limi) Let693 Let123 would you Like to terminates the program? li Sr0,4 la Sa0, [str_addr] a string address syscall Read character from keyboard Li Sr0, 12 Syscall character is read in Sr0 Read using from keyboard Li Sr0, 8 La Sa0, [addr] Sload address to S20 Li Sa1, len load string length in Sal Refer to the link below for more information. Lab Assignment: Provide comments throughout your code. Write a report, which includes: MIPS Code for each program Output screen shot for registers' console for each program. Conclusion. Write a survey report on the latest MIPS 64 bit warrior class processor's architecture and features. (Font size 12, single space lines).Explanation / Answer
###ASSEMBLY LANGUAGE PROGRAM###
DATA SEGMENT #data segment starting here
STR1 DB 10,13,'ENTER STRING HERE :- $' #declare string 1
STR2 DB 10,13,'ENCRYPTED STRING IS :- $'#declare string 2
MSG3 DB 10,13,'DECPED STRING IS : $'
P1 LABEL BYTE
M1 DB 0FFH
L1 DB ?
P11 DB 0FFH DUP ('$')
DATA ENDS #here the data segment can be end
DISPLAY MACRO MSG # this displays Macro message
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA #copying Data in to AX register
MOV DS,AX #copying AX in to DS
DISPLAY STR1
LEA DX,P1
MOV AH,0AH
INT 21H
LEA SI,P11
MOV CL,L1 #transfer the content of L1 register to the content #of CL register
CALL ENCRYPT
DISPLAY STR2 #Displaying String2
DISPLAY P11 #Displaying P11
LEA SI,P11
MOV CL,L1 #transfer the content of L1 reg to the content of #CL reg
CALL ENCRYPT
DISPLAY MSG3 #display MSG3
DISPLAY P11 #display P11
MOV AH,4CH #transfer 4CH to AH
INT 21H
CODE ENDS
ENC PROC NEAR
MOV CH,0
CHECK1: #Check process starting here
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 #Adding 05H to [SI]
JMP DONE1
UPR1: CMP [SI],4EH
JB LUPR1
SUB [SI],0DH
JMP DONE1
LUPR1:
ADD [SI],0DH #Adding 0DH to the register[SI]
JMP DONE1
LWR1: CMP [SI],6EH
JB LLWR1
SUB [SI],0DH
JMP DONE1
LLWR1:
ADD [SI],0DH
DONE1:
INC SI
LOOP CHECK1 #Loop checking process
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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.