0% found this document useful (0 votes)
603 views2 pages

Reverse A String

The document describes an assembly language program that reverses a string. The program uses registers AX, SI, and DI to iterate through the string stored in the DATA segment and swap each character with the character at the opposite end of the string. The result is that the original string "MPI LAB" is reversed to "BAM IPM". The program demonstrates reversing a string in assembly language using basic operations like MOV, XCHG, INC, DEC, and LOOP.

Uploaded by

api-26685949
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
603 views2 pages

Reverse A String

The document describes an assembly language program that reverses a string. The program uses registers AX, SI, and DI to iterate through the string stored in the DATA segment and swap each character with the character at the opposite end of the string. The result is that the original string "MPI LAB" is reversed to "BAM IPM". The program demonstrates reversing a string in assembly language using basic operations like MOV, XCHG, INC, DEC, and LOOP.

Uploaded by

api-26685949
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Adam’s Engineering College, Paloncha

ECE Department –MPI LAB

Experiment No.: 14 Year : III/IV B.Tech II Semester Page 1 of 2

REVERSE A STRING

Aim: - To write an assembly language program to reverse


the given string.

Registers: - AX

Description: - Reversing the given string and the result is


stored in the pointer.

Ports:- None.

DATA SEGMENT

A DB ‘MPI LAB’
DATA ENDS

CODE SEGMENT

ASSUME CS: CODE, DS: DATA, ES: DATA

START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV CL, 03
LEA SI, A
MOV AX, 04
ADD DI, AX
L1: MOV AL, [SI]
XCHG AL, [DI]
MOV [SI], AL

Lab in-charge HOD, ECE


Adam’s Engineering College, Paloncha
ECE Department –MPI LAB

Experiment No.: 14 Year : III/IV B.Tech II Semester Page 2 of 2

INC SI
DEC DI
LOOP L1

CODE ENDS
END START

Result: The given string is reversed.

Lab in-charge HOD, ECE

You might also like