MASM assembly language Make a program that takes the string as input from the us
ID: 3903015 • Letter: M
Question
MASM assembly language
Make a program that takes the string as input from the user and prints the reversed string as output. There are several conditions for conversion: uppercase should be students should make at least one user-defined procedure to read a string and to print the string in reverse order. An example for your program is shown in below box. NOTE: 1. The string length does not exceed 40 characters. 2. 'Enter' character () is not counted in string length. 3. If input string is larger than 40 characters, ignore the string and get input again. 4. You can freely define procedures in your convenience. 5. Input 'Enter character () to finish the program C:W>s171234J Type A_String_To_Reverse: I like MUSIC.J Reversed_String:.cisum EKIL i Type_A_String_To_Reverse: I like ASSEMBLY PROGRAMMING. Reversed_String: gnimmargorp ylbmessa EKIL i Type A_String_To_Reverse: I like BOTH Assembly programming and dATA STRUCTURE.J Type_A_String_To_Reverse:J Bye! C:W>Explanation / Answer
Please find the MASM code to reverse a string:-
.MODEL SMALL
.STACK 32
.DATA
STR1 DB 0DH,0AH, 'ENTER THE STRING :- $'
STR2 DB 0DH,0AH, 'YOUR REVERSED STRING IS :- $'
nl db 0dh,0ah,'$'
.CODE
START:
MOV AX,@DATA
MOV DS,AX
DISP:
LEA DX,STR1
MOV AH,09H
INT 21H
MOV CL,00
MOV AH,01H
READ:
INT 21H
MOV BL,AL
PUSH BX
inc cx
CMP AL,0DH
JZ DISPLAY
JMP READ
DISPLAY:
LEA DX,STR2
MOV AH,09H
INT 21H
lea dx, nl
mov ah,09h
int 21h
ANS:
MOV AH,02H
POP BX
MOV DL,BL
INT 21H
LOOP ANS
.EXIT
END START
Please let me know in case of any clarifications required. Thanks!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.