Write an Assembly Language procedure that encodes an original string using the f
ID: 3771209 • Letter: W
Question
Write an Assembly Language procedure that encodes an original string using the following arrays
Code1 BYTE “SHO5FUP3IK8EZG9XC0NQLDB1WVY4TR7AM6J2”
Code2 BYTE “abcdefghijklmnopqrstuvwxyz0123456789”
The encoding works as follows: Each uppercase letter occurs somewhere in Code1. The procedure searches the array for the letter, notes the index of the array in which the letter occurs, and then uses this index in array Code2 to find the corresponding lowercase letter that encodes the uppercase one. For Example, suppose that the original string contains the letter H. Because H is stored at index 1 in Code1, H is encoded as b, because it is the character stored at index 1 in Code2. Characters in the original string that are not found in the array Code1 are unchanged.
Your procedure should accept three parameters in registers ESI, EDI and ECX as follows:
Offset address of the original string in ESI register.
Offset address of the encoded string in EDI register.
Length of the original string in ECX register.
An example of a dialogue with the user is as follows:
Enter a string (Max. 60 characters): Good Morning Oman
Your encoded string is: nccv 6c3sisn c65s
.data
OLDSTR BYTE 61 DUP(0); assume maximum string size of 60
NEWSTR BYTE 61 DUP(0) ;add any needed data definitions
.code
main PROC
; write your main procedure here
main ENDP
; add the Other procedures here
END main
Explanation / Answer
NAME DISPLAY_OF_LOWERSTRING_UPPERSTRING
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
ORG 1000H
CODE1 DB 'SHO5FUP3IK8EZG9XC0NQLDB1WVY4TR7AM6J2'
CODE2 DB 'abcdefghijklmnopqrstuvwxyz0123456789'
COUNT DW 17
SEARCH DB 'H'
FOUND DB 'STRING FOUND$'
NOT FOUND DB 'STRING NOT FOUND$'
DATA ENDS
CODE SEGMENT
ORG 2000H
START: MOV AX,DATA
MOV DS,AX
MOV CX,COUNT
MOV DI,OFFSET CODE1
MOV AL,SEARCH
REPNE SCASB
JZ YES
MOV DX,OFFSET NOT FOUND
MOV AH,09
INT 21H
JMP OVER
MOV SI,DI
YES: MOV SI,OFFSET CODE2
MOV AL,SI
MOV DX,OFFSET FOUND
MOV AH,09
INT 21h
OVER: MOV AH,4CH
INT 21H
CODE ENDS
END START
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.