I need to create a string in assembly that will output the string back, backward
ID: 3829426 • Letter: I
Question
I need to create a string in assembly that will output the string back, backwards. Example "Hello" to "olleH"
This is my code so far:
INCLUDE Irvine32.inc
.data
myString BYTE 80 DUP (?)
MAX = 80
.code
Main PROC
call Clrscr
mov edx,OFFSET myString ;buffer size -1
mov ecx,MAX
call ReadString
call StrLength ;stores string length in eax
xor edx,edx
mov ebx,2
div ebx
mov ecx,eax
L1:
;insert code here
call WriteInt
call Crlf
inc eax
loop L1
mov edx,OFFSET myString
call WriteString
exit
main ENDP
END main
Explanation / Answer
Hi, You Can use below written Assembly Language code to achive your goal. It is a simple assembly program will help you clearing your concepts.
DATA SEGMENT
STR1 DB "HELLO!$"
STR2 DB DUP ('$')
MSG1 DB 10,13,'STORED STRING IN MEMORY IS : $'
MSG2 DB 10,13,'REVERSE STRING IS : $'
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
DISPLAY STR1
LEA SI,STR2
LEA DI,STR1
ADD DI,5
MOV CX,6
REVERSE:
MOV AL,[DI]
MOV [SI],AL
INC SI
DEC DI
LOOP REVERSE
DISPLAY MSG2
DISPLAY STR2
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.