0% found this document useful (0 votes)
454 views

Program To Copy A String in Reverse Order in Assembly Language Using Visual Studio PDF

This document describes a program that copies a string in reverse order from a source to a target string variable using assembly language and Visual Studio. The program uses a loop and indirect addressing to copy each character from the end of the source string to the beginning of the target string. It includes the assembly code that declares the source and target variables, initializes a loop using ESI and EDI registers to iterate from the end to beginning of the strings, and copies each character using AL before incrementing and decrementing the pointers.

Uploaded by

Dilawar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
454 views

Program To Copy A String in Reverse Order in Assembly Language Using Visual Studio PDF

This document describes a program that copies a string in reverse order from a source to a target string variable using assembly language and Visual Studio. The program uses a loop and indirect addressing to copy each character from the end of the source string to the beginning of the target string. It includes the assembly code that declares the source and target variables, initializes a loop using ESI and EDI registers to iterate from the end to beginning of the strings, and copies each character using AL before incrementing and decrementing the pointers.

Uploaded by

Dilawar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

12/9/2018 7.

Program to Copy a String in Reverse Order in Assembly Language using Visual Studio

Programming Tutorials
SUBSCRIBE

Careem Bike se roz khoob kamao


Jitni rides, utni kamai! Woh bhi apne waqt par, Aaj he Careem Bike ke Captain banein OPE
drive.careem.com

7. Program to Copy a String in Reverse


Order in Assembly Language using Visual
Studio
February 10, 2018

Chapter 3

Assembly Language Fundamentals

Assembly Language Programming Exercise

Problem # 7:

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('#')

Solution:

.386

.model flat,stdcall
.stack 4096

ExitProcess PROTO, dwExitCode:DWORD

.data
source BYTE "This is the source string",0

target BYTE SIZEOF source DUP('#')

.code
main PROC

mov esi,0

mov edi,LENGTHOF source - 1


http://csprogrammingtutorial.blogspot.com/2018/02/program-copy-string-in-reverse-order-in-assembly.html 1/4
12/9/2018 7. Program to Copy a String in Reverse Order in Assembly Language using Visual Studio

mov ecx,SIZEOF source


Programming Tutorials
SUBSCRIBE
L1:

mov eax, 0

mov al,source[esi]
mov target[edi],al

inc esi

dec edi
loop L1

INVOKE ExitProcess,0

main ENDP
END main

Let me know in the comment sec on if you have any ques on.

Previous Post:
Program to Reverse an Array in Assembly Language using Visual Studio

Next Post:

Program to Shifting the Elements in an Array in Assembly Language using Visual

Studio

ASSEMBLY BASICS ASSEMBLY LANGUAGE FOR X86 PROCESSORS CHAPTER 4

COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE COMPUTER SCIENCE

DATA TRANSFERS ADDRESSING AND ARITHMETIC EXERCISE SOLUTION VISUAL STUDIO

Reactions: funny (0) interesting (0) cool (0)

abdoulaye coulibaly 9 October 2018 at 16:20


hi, thank you for this tutorial.

I'd like to know how to display source and target strings.

Hadiqa Amanullah 19 November 2018 at 00:03


You can use WriteString func on from Irvine32 library as
follows:
mov edx,OFFSET source
call WriteString
mov edx,OFFSET target
call WriteString

Please subscribe and share the blog if you like it.

http://csprogrammingtutorial.blogspot.com/2018/02/program-copy-string-in-reverse-order-in-assembly.html 2/4

You might also like