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

Mic Report

This document describes an 8086 assembly language program to check if a given string is a palindrome. It provides the theory of strings and palindromes, outlines the algorithm to compare the first and last characters and work inward, and includes the source code with comments. The program takes a string as input, traverses to the end, loads the start and end pointers, compares characters, decrements one pointer and increments the other on each pass, and outputs whether the string is or is not a palindrome.

Uploaded by

Asmit Suragond
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
289 views

Mic Report

This document describes an 8086 assembly language program to check if a given string is a palindrome. It provides the theory of strings and palindromes, outlines the algorithm to compare the first and last characters and work inward, and includes the source code with comments. The program takes a string as input, traverses to the end, loads the start and end pointers, compares characters, decrements one pointer and increments the other on each pass, and outputs whether the string is or is not a palindrome.

Uploaded by

Asmit Suragond
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Introduction

AIM:
TO CHECK WHETHER THE GIVEN STRING IS PALINDROME
USING 8086 ASSEMBLY LANGUAGE PROGRAME.

SOFTWARE REQUIRED:

1. PC WITH WINDOWS

2. TASM SOFTWARE

THEORY:
String:
A string is traditionally a sequence of characters, either as a literal constant or as
some kind of variable. The latter may allow its elements to be mutated and the
length changed, or it may be fixed (after creation). A string is generally considered
a data type and is often implemented as an array data

structure of bytes (or words) that stores a sequence of elements, typically


characters, using some character encoding. String may also denote more general
arrays or other sequence (or list) data types and structures.

Depending on programming language and precise data type used, a variable


declared to be a string may either cause storage in memory to be statically
allocated for a predetermined maximum length or employ dynamic allocation to
allow it to hold a variable number of elements.

When a string appears literally in source code, it is known as a string literal or an


anonymous string.
Palindrome:

A palindrome is a word, number, phrase, or other sequence of characters which


reads the same backward as forward, such

as madam or racecar or the number 10201. Sentence-length palindromes may be


written when allowances are made for adjustments to capital letters, punctuation,
and word dividers, such as "A man, a plan, a canal, Panama!", "Was it a car or a
cat I saw?" or "No 'x' in Nixon".

Composing literature in palindromes is an example of constrained writing.

The word "palindrome" was coined by the English playwright Ben Jonson in the
17th century from the Greek roots palin and dromos.

Problem: Write an 8086 program to check whether a given string is palindrome or


not.

Examples:

Input String: "MAM"

Output: String is palindrome

Input String: "VVP"

Output: String is not palindrome

Explanation:
Algorithm

1. Create a string
2. Traverse to the end of the string
3. Get the address of the end of the string, DI
4. Load the starting address of the string, SI
5. Compare the value stored at the address
6. Increment the pointer, SI
7. Decrements the pointer, DI
8. Compare again the value stored at si and di
9. Repeat the steps until SI<=DI
10. If all the characters match print string is palindrome else print not
palindrome
SOURCE CODE

.MODEL SMALL

.STACK 100H

.DATA

; The string to be printed

STRING DB 'mic', '$'

STRING1 DB 'String is palindrome', '$'

STRING2 DB 'String is not palindrome', '$'

.CODE

MAIN PROC FAR

MOV AX, @DATA

MOV DS, AX

; check if the string is;

;palindrome or not

CALL Palindrome

;interrupt to exit

MOV AH, 4CH

INT 21H

MAIN ENDP

Palindrome PROC
; load the starting address

; of the string

MOV SI,OFFSET STRING

; traverse to the end of;

;the string

LOOP1 :

MOV AX, [SI]

CMP AL, '$'

JE LABEL1

INC SI

JMP LOOP1

;load the starting address;

;of the string

LABEL1 :

MOV DI,OFFSET STRING

DEC SI

; check if the string is plaindrome;

;or not

LOOP2 :

CMP SI, DI

JL OUTPUT1
MOV AX,[SI]

MOV BX, [DI]

CMP AL, BL

JNE OUTPUT2

DEC SI

INC DI

JMP LOOP2

OUTPUT1:

;load address of the string

LEA DX,STRING1

; output the string;

;loaded in dx

MOV AH, 09H

INT 21H

RET

OUTPUT2:

;load address of the string

LEA DX,STRING2

; output the string

; loaded in dx
MOV AH,09H

INT 21H

RET

Palindrome ENDP

END MAIN
OUTPUT

RESULT AND CONCLUSION:

AN ASSEMBLY LANGUAGE PROGRAM TO CHECK WHETHER THE GIVEN STRING IS


PALINDROME USING 8086 IS PERFORMED.

You might also like