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

Write a program with a loop and indirect addressing that copies a string from so

ID: 3753475 • Letter: W

Question

Write a program with a loop and indirect addressing that copies a string from source to target, reversing the character order in the process. Use the following variables:
source BYTE "This is the source string",0
target BYTE SIZEOF source DUP('#')

Make the source string the phrase “I am CPEN 3710 student John Doe.”,0 (note: replace the ‘John Doe’ portion with your own name) and reserve sufficient space for the target string, which will be the original string written backwards. (The “null byte” containing zero at the end of the string is not part of the reversal; it should still be at the end, not the beginning, of the reversed string.) After you have finished reverse-copying the string, in addition to calling DumpMem to display the area of memory containing the two strings, also call Irvine’s WriteString procedure (see page 169) twice, to display the original string and the reversed string to the screen as characters. Assemble and link your program as usual, run it, and capture and print out a screen shot showing the displayed results.

Explanation / Answer

INCLUDE Irvine32.inc

WriteString PROTO

.data

source BYTE "This is the source string",0

target BYTE SIZEOF source DUP('#')

.code

main PROC

mov esi,0

mov edi,LENGTHOF source - 2

mov ecx,SIZEOF source

L1:

mov al,source[esi]

mov target[edi],al

inc esi

dec edi

loop L1

mov edx, OFFSET target

call WriteString

exit

main ENDP

END main

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