0% found this document useful (0 votes)
74 views15 pages

MIC Micro2024

The document describes an assembly language program that checks if a given string is a palindrome or not. It explains the program development steps which include the problem statement, algorithm, flowchart, initialization and explanation of instructions used, the program written in a proper format along with comments, and sample inputs and outputs. The program utilizes efficient string manipulation techniques in assembly language to compare characters from both ends of the input string and determine if it is a palindrome.

Uploaded by

Piush Gogi
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)
74 views15 pages

MIC Micro2024

The document describes an assembly language program that checks if a given string is a palindrome or not. It explains the program development steps which include the problem statement, algorithm, flowchart, initialization and explanation of instructions used, the program written in a proper format along with comments, and sample inputs and outputs. The program utilizes efficient string manipulation techniques in assembly language to compare characters from both ends of the input string and determine if it is a palindrome.

Uploaded by

Piush Gogi
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/ 15

Maharashtra Board of Technical Education, Mumbai

Certified that this Micro-Project Report

“ALP to check the given string is palindrome or not”


Is the work of
Roll Enrollment No. Student Name
No.
05 2200150130 Ravikiran Tirgule

29 2200150154 Yogesh Yemul

71 2200150203 Piush Gogi

The student of Semester four Subject Name-Microprocessor (22415) Diploma in


Computer Technology , 2023-24.

This report is a partial fulfilment of subject MIC(22415) for the award of the
Diploma in Computer Technology , By MSBTE, Mumbai.

Guide Name - Mr. Tarange

A.L. Date & Sign –

HOD PRINCIPAL

1
INDEX

Sr.No. Title Page No


1. Abstract 3
2. Introduction 4
3. program development steps.
3.1 problem statement
3.2 algorithm
3.3 flowchart
3.4 initialisation and
explanation of
instructions used. 5-12
3.5 write a neat program
in proper format along
with comments.
3.6 write 5 set of inputs
and the respective output.

4. Conclusion : write summary


13
of topic u covered
5. Acknowledgement 14
6 References: write
reference web links u used 15
in proper sequence.

2
ABSTRACT

In this Micro-project we have developed assembly language program designed to

determine whether a given string is a palindrome or not. A palindrome is a sequence of

characters that reads the same backward as forward. The program utilizes efficient string

manipulation techniques to compare characters from both ends of the string, checking for

equality iteratively until the midpoint is reached. If all characters match, the string is confirmed

as a palindrome; otherwise, it is deemed non-palindromic.

The program employs appropriate logic and control flow to handle various string

lengths and edge cases effectively. Additionally, it leverages assembly language's low-level

capabilities to optimize performance and minimize resource usage. Through thorough testing

and validation, the program ensures reliable and accurate identification of palindromic strings,

contributing to the broader field of string manipulation algorithms in assembly language

programming..

3
INTRODUCTION

The assembly language program described in this paper serves the purpose of

determining whether a given string is a palindrome or not. A palindrome is a sequence of

characters that reads the same backward as forward, such as "radar" or "level". This program

employs low-level string manipulation techniques to efficiently compare characters from both

ends of the string, ultimately providing a verdict on whether the input string meets the

palindrome criterion.

By leveraging the power of assembly language, this program aims to provide a simple

yet effective solution to this classic problem in computer science.

4
PROGRAM DEVELOPMENT STEPS

3.1 PROGRAM STATEMENT:

ALP to determine A given String is palindrome or not.

3.2 Algorithm:

1. Start

2. Read a String From User.

3. Reverse the string.

4. Compare the reversed string with original string.

5. If both are equal then go to next step otherwise go to 7th step.

6. Display “String is palindrome”.

7. Display “String is not Palindrome”

8. Stop

5
3.3 Flowchart:

6
3.4 Initialisation and explanation of instructions used:

1. Setting Up Data Segment:


MOV AX, DATA: This instruction loads the starting address of the data segment into the AX
register.
MOV DS, AX: It sets the data segment register (DS) to the value in AX, pointing DS to the
beginning of the data segment.
2. Displaying Prompt to Enter a String:
LEA DX, MSG1: This loads the offset address of the string "ENTER THE STRING: $" into
the DX register.
MOV AH, 09H: It sets the AH register to 09H, which is the function number for displaying a
string using the DOS interrupt 21H.
INT 21H: This software interrupt triggers a DOS function call to display the string stored in
DX.
3. Initializing Source and Destination Pointers:
LEA SI, STR1: This loads the offset address of the string buffer STR1 into the SI register,
initializing it as the source pointer for string manipulation.
LEA DI, STR1: Similarly, this loads the offset address of STR1 into the DI register,
initializing it as the destination pointer for string manipulation.
4. Initializing for Reading Characters:
MOV AH, 01H: This sets the AH register to 01H, which is the function number for reading
a character from standard input using DOS interrupt 21H.

7
Instructions Used:

1. MOV: This instruction moves data from one location to another. In this code, it's used
to initialize registers and store characters read from input into memory.
2. LEA: Load Effective Address instruction computes and loads the effective address of a
memory operand into a register. It's used here to load the address of strings and
variables into registers.
3. INT: This instruction generates a software interrupt. In this code, it's used to invoke
DOS functions for input/output operations and program termination.
4. CMP: Compare instruction compares two operands and sets the status flags in the CPU
accordingly. It's used for comparing characters to determine if the string is a
palindrome.
5. JE: Jump if Equal instruction jumps to a specified location if the Zero Flag (ZF) is set.
In this code, it's used to check if the Enter key was pressed to terminate the input string.
6. INC: Increment instruction increases the value of the operand by 1. It's used here to move to
the next memory location when storing characters in memory.
7. DEC: Decrement instruction decreases the value of the operand by 1. It's used to move
backward through memory when comparing characters for palindrome checking.
8. JMP: Jump instruction unconditionally jumps to a specified location. It's used here for
loops and to control program flow.

8
3.5 Write a neat program in proper format along with comments:

ASSUME CS:code, DS:data ; Set up segment registers

data SEGMENT

MSG1 DB 10,13,'ENTER THE STRING: $' ; Message to prompt user to enter a string
MSG2 DB 10,13,'STRING IS PALINDROME$' ; Message displayed if the string is a
palindrome
MSG3 DB 10,13,'STRING IS NOT PALINDROME$' ; Message displayed if the string
is not a palindrome
STR1 DB 50 DUP(0) ; Buffer to store the input string

data ENDS

code SEGMENT

START:

MOV AX, DATA ; Load the starting address of the data segment into
AX MOV DS, AX ; Set DS to point to the data segment

LEA DX, MSG1 ; Load the address of the prompt message into DX
MOV AH, 09H ; Set AH to display string function
INT 21H ; Display the prompt message

LEA SI, STR1 ; Initialize SI to point to the input buffer


LEA DI, STR1 ; Initialize DI to point to the input buffer
MOV AH, 01H ; Set AH to read character function

NEXT:

INT 21H ; Read a character from standard input


CMP AL, 0DH ; Compare the character with carriage return (Enter key)
JE TERMINATE ; If Enter is pressed, jump to termination

MOV [DI], AL ; Store the character in the buffer


INC DI ; Move to the next position in the
buffer
JMP NEXT ; Repeat the process for the next

character TERMINATE:

MOV AL, '$' ; Store '$' at the end of the string

9
MOV [DI], AL

DOTHIS:

DEC DI ; Move DI back to the last valid character in the string


MOV AL, [SI] ; Load a character from the beginning of the string
CMP [DI], AL ; Compare it with the corresponding character from the end
JNE NOTPALINDROME ; If they don't match, the string is not a
palindrome INC SI ; Move to the next character in the beginning of the
string
CMP SI, DI ; Compare the pointers to check if all characters have been checked
JL DOTHIS ; If there are more characters to check, repeat the process

PALINDROME:

MOV AH, 09H ; Set AH to display string function


LEA DX, MSG2 ; Load the address of the palindrome message into DX
INT 21H ; Display the palindrome message

JMP EXIT ; Jump to the exit

NOTPALINDROME:

MOV AH, 09H ; Set AH to display string function


LEA DX, MSG3 ; Load the address of the non-palindrome message into DX
INT 21H ; Display the non-palindrome message

EXIT:

MOV AH, 4CH ; Set AH to exit program function


INT 21H ; Terminate program execution

code ENDS

END START

10
3.6 write 5 set of inputs and the respective output:

1. Input: "madam"
a. Output: "STRING IS PALINDROME"
2. Input: "racecar"
a. Output: "STRING IS PALINDROME"
3. Input: "hello"
a. Output: "STRING IS NOT PALINDROME"
4. Input: "level"
a. : "STRING IS
PALINDROME" 5. Input: "12321"
a. Output: "STRING IS PALINDROME"

Image 1.1

Image 1.2

11
Image 1.3

Image 1.4

Image 1.5

12
4 Conclusion:

In conclusion, this assembly language project effectively demonstrates the


implementation of a palindrome checker. The program prompts the user to input a
string, reads the input, and then checks whether the entered string is a palindrome or not.

Throughout the code, appropriate comments are provided to enhance readability and
understanding of the logic behind each instruction. The program efficiently utilizes the
8086 assembly language instructions to manipulate data, compare characters, and display
messages to the user using DOS interrupt calls.

By breaking down the process into clear steps, from inputting the string to determining its
palindrome status, this project serves as a valuable educational resource for understanding
low-level programming concepts. It highlights the importance of memory management,
character manipulation, and conditional branching in assembly language programming.

Overall, this project offers a practical example of how assembly language can be used to
solve real-world problems, showcasing the power and versatility of low-level programming
languages.

13
5 Acknowledgement:

We would like to express our sincere gratitude to all those who have contributed to
the completion of this assembly language project on palindrome checking.

First and foremost, we extend our heartfelt appreciation to our mentor A.L. Tarange Sir
for their invaluable guidance and support throughout the development of this project.
Their encouragement have been important in shaping the project and enhancing its
quality.

Furthermore, we are grateful to Government Polytechnic, Solapur and CM Department for


providing the necessary resources and environment conducive to conducting this project.

Last but not least, we extend our appreciation to our family and friends for their
unwavering support and encouragement throughout this endeavor.

Thank you all for your contributions and encouragement. Without your support, this
project would not have been possible.

14
6 References:

https://www.cs.ubbcluj.ro/~forest/teaching/os/laboratory/lab4/docs/interrupts.html
https://www.tutorialspoint.com/assembly_programming/index.htm
https://www.cs.virginia.edu/~evans/cs216/guides/x86.htm
https://en.wikibooks.org/wiki/X86_Assembly/Interfacing_with_DOS
https://www.mathsisfun.com/numbers/palindrome.html

15

You might also like