You are on page 1of 20

Maharashtra State Board of Technical

Education, Mumbai
Year 2022-23

CERTIFICATE
This is to certify that Roll no. of SY CO 22326 ,22336 are of Fourth Semester of Diploma in
Computer Engineering of Institute GOVERNMENT POLYTECHNIC MIRAJ (Inst. Code; 0131)
has completed the Micro-Project satisfactorily in the Subject Microprocessor (22415) for the
academic year 2022-2023 as prescribed in the curriculum by MSBTE Mumbai.

Place : Government Polytechnic, Miraj


Date :

MRs.Supriya Shinde Mr. V.R.Falmari Capt. Mr. Nitin Sonaje

Subject In-Charge Head of Department Principle


Micro-Project Proposal

Title of the Project: “Check Whether String is Palindrome or not”.

1.0 Aims/Benefits of the Micro-Project:

The main idea behind project to perform of this project is to Check String is Palindrome or not

Benefits :-
1) To know Assembly language.
2) To know basic applications of Microprocessor.
3) To learn basic programs of Tasm.

2.0 Course Outcomes Addressed:

1. Configure various devices.


2. Use Assembly language program for the given problem.
3. Develop assembly language program using procedure macros & modular Programming.
4. Use instruction for different code.
5. Analyze the functions functional block of 8086 Microprocessor.

3.0 Proposed Methodology:

1. The topic was decided among us and discussion was done in group..
2. After discussing the topic, the task was listed equally in our group. Consist Of 2 members
3. Information was collected by Sarthak And Both the Annexures made by Vinay
4. The project was done by all the group members
5. An eligible Lead member who will guide the group members and analyzed the data.
6. Eligible match finding the proper information.
7. Soft copy corrections by respective teachers.
8. Completion of the micro project properly.
9. Final copy and submission.
4.0 Action Plan

Sr. No. Details of Activity Start date Finish date Team Members
1. Introduction to Micro-project:
2. Drafting Proposal
3. Proposal submission
4. Micro project Proposal Presentation
5. Executing Micro-Project:
6. Drafting Methodology
7. Drafting Literature Review
8. Drafting Result
9. Micro project Presentation
10. Micro Project final submission

5.0 Resources Required

Sr. No. Name of Resources Specifications

1. Computer System Computer(i3-i7)preferable RAM


minimum 2GB and onwards

2. Operating System Windows-10


3. Printer Canon printer
4. Internet/Websites https://en.wikipedia.org/wiki/4G

6.0 Names of Team Members with Roll No’s:

Roll no. Student Name Enrollment No.


22326 Sarthak C Kamble 2201310195
22336 Vinay S Niranjan 2201310205

Signature
Project Guide
Micro-project Report

Title of micro-project: Check Whether String is Palindrome


or not

1.0 Rationale:

Checking whether a string is a palindrome in assembly language is a task of fundamental


importance due to its efficiency and low-level manipulation capabilities. By directly
accessing hardware resources, assembly language allows for the implementation of efficient
palindrome-checking algorithms, which involve comparing characters from both ends
towards the middle. Such implementations not only serve educational purposes by elucidating
algorithmic concepts at a low level but also find practical applications in embedded systems
and performance-critical environments where optimizing code size and execution speed are
paramount.

2.0 Aims /Benefits of the micro-project:


Some of the Benefits of the micro-project are as follows:

1. Efficiently utilize low-level manipulation capabilities.


2. Enhance understanding of algorithmic principles.
3. Optimize performance for embedded systems.
4. Offer educational insights into assembly language programming.
5. Enable fast and resource-efficient palindrome verification.

3.0 Course outcomes related micro-project:

 Use Assembly language program for the given problem.


 Develop an assembly language program using Assembler
 Develop assembly language program using procedure macros & modular
Programming.

4.0 Literature review:

 Literature highlights efficient palindrome-checking algorithms in assembly language.


 Studies emphasize educational and practical applications.
 Optimization techniques for performance and resource usage are discussed.
 Research underscores the significance of string manipulation techniques.
5.0Actual methodology followed :

 We decided the topic of the micro-project.


 After decision we discussed on the topic of micro-project.
 We distributed sub-points to do by every team member as it claims a team work.
 We looked for our sub- points and collected the information regarding it.
 We prepared our official micro-project .
6.0 Actual Resources Required :

Sr. No. Name of Resources Specifications

1. Computer System Computer(i3-i7)preferable RAM


minimum 2GB and onwards

2. Operating System Windows-10


3. Printer Canon printer
4. Internet/Websites https://en.wikipedia.org/wiki/4G

7.0 Skill developed /learning outcomes :

 The concept of project understood


 The structure and requirement of proposal and report understood
 The necessity of group work is well understood
 How to search information and use of different online tools come to know.
 Practical implementation of queries.

8.0 CONCLUSION
In conclusion, the endeavor of implementing a palindrome-checking algorithm in assembly
language offers valuable insights into low-level programming principles and their practical
applications. Through efficient string manipulation and comparison techniques, the project not only
enhances understanding of algorithmic concepts but also underscores the importance of optimizing
performance and resource usage, particularly in embedded systems. Existing literature showcases
various efficient algorithms tailored for assembly language, highlighting the significance of such
projects in both educational and real-world contexts. By delving into the intricacies of palindrome
verification at a low level, this project not only serves as a learning tool but also contributes to the
broader body of knowledge in computer science and assembly language programming.
1.Descripition of The Project
Title: "String Palindrome Assembly Language Program "

The assembly language program for palindrome detection typically involves a step-by-step
process of analyzing each character of the input string to determine whether it forms a
palindrome. Here's a breakdown of the key components and functionalities of such a
program:

1. Input Handling: The program begins by prompting the user to input a string, which is
stored in memory. In assembly language, this involves setting up appropriate input/output
procedures or system calls to receive user input.

2. String Length Calculation: Next, the program calculates the length of the input string. This
step is crucial for defining the boundaries within which the palindrome check will be
performed. The length calculation often involves traversing the string until a null terminator
('\0') is encountered.

3. Palindrome Checking Algorithm: The core of the program lies in the palindrome checking
algorithm. Using assembly language instructions, the program compares characters from both
ends of the string iteratively until the middle is reached. Any deviation in character values
between corresponding positions indicates a non-palindromic sequence.

4. Output Display: Upon completing the palindrome check, the program displays a message
indicating whether the input string is a palindrome or not. This output serves as feedback to
the user.

5. Error Handling: Additionally, the program may include error handling routines to deal with
invalid inputs or unexpected behavior gracefully. This could involve checking for edge cases
such as empty strings or strings with only one character.

6. Optimization: Depending on the complexity of the palindrome detection algorithm,


optimization techniques may be applied to enhance the program's efficiency. This could
involve minimizing redundant computations or streamlining memory access patterns.

7. Documentation and Comments: To aid understanding and maintainability, the program


should be well-documented with comments explaining the purpose of each section and
relevant assembly instructions used.

8.Testing and Debugging: Prior to deployment, the program should undergo thorough testing
and debugging to ensure its correctness and reliability across various input scenarios.
We have use GUI Turbo assembler over TASM due to the following advantages:

1. More Directives: GUI Turbo assembler offers a wider range of directives than TASM,
allowing for greater flexibility and control in programming tasks

2. Integrated Tools: GUI Turbo assembler includes features like syntax highlighting, code
completion, and debugging tools, streamlining the development process.

3. Cross-Platform Compatibility: Some versions of GUI Turbo assembler support multiple


operating systems, providing flexibility in the development environment.

4. Community Support: GUI Turbo assembler benefits from an active user community,
offering tutorials, resources, and updates for continuous improvement.

5. Documentation: GUI Turbo assembler provides comprehensive documentation and


learning resources, aiding newcomers in mastering assembly language programming
efficiently.

6. Graphical Interface: GUI Turbo assembler offers a user-friendly GUI, making it more
accessible and intuitive for beginners.

In summary, GUI Turbo assembler’s GUI, integrated tools, cross-platform support,


community backing, and extensive documentation make it a preferred choice for many
programmers over TASM.
2.Flowchart of String Palindrome
3.Algorithm of String Palindrome
1.Create a string and a reverse 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

20.If all the characters match print string is palindrome else print not palindrome
4.List of Assembly Directives used:
1).model small Directive: This line specifies the memory model to be used for the program.
In this case, it's "small", which typically means that the program is small enough to fit within
a single segment of 64 KB.

2) .stack Directive: This line is used to define a stack segment for the program. It's where
local variables, return addresses, and other data related to function calls are stored.

3) .data Directive: This line indicates the start of the data section, where initialized data is
declared.

4) db Directive: This line declares a variable and initializes it with the characters.

5)len equ $-str Directive: This line calculates the length of the string str by subtracting the
current location counter ($) from the address of str

6) db 20 dup (0) Directive: This line declares a buffer capable of holding 20 characters,
initialized with zeros.

7) .code Directive: This line indicates the start of the code section where the main program
logic resides marks the beginning of the code execution.

8) end Directive: This line indicates the end of the code section and specifies the entry point
of the program

These directives and instructions collectively perform the task of copying a string in reverse
order, comparing it with the original string to determine if it is a palindrome, and displaying
the appropriate message to the user.
5.Descripition of all the statements:
Let's break down and explain each line of the provided assembly language code:

1) .model small: This directive specifies the memory model to be used by the program.
"Small" model indicates that the program assumes it will fit into a single segment of 64KB.

2).stack: This directive reserves space for the program's stack. However, it doesn't specify the
size of the stack, so it will use the default size provided by the assembler.

3).data: This directive marks the beginning of the data section where static variables are
declared and initialized.

4).str db "MOM": This line declares a string variable named "str" and initializes it with the
characters "MOM". "db" stands for "define byte", indicating that each character is a single
byte.

5)len equ $-str: This line defines a symbolic constant "len" using the equ directive. It
calculates the length of the string "str" by subtracting the current address ($) from the address
of the start of "str".

6)rstr db 20 dup (0): This line declares another string variable named "rstr" with a size of 20
bytes, initialized with zeros using the "dup" directive.

7)msg1 db 10,13, "It is a palindrome$": This line declares a string variable "msg1" containing
the message "It is a palindrome" followed by carriage return (13) and line feed (10)
characters, and terminated with a dollar sign ($) to mark the end of the string.

8)msg2 db 10,13, "It is not a palindrome$": Similar to msg1, this line declares another string
variable "msg2" containing the message "It is not a palindrome".

9).code: This directive marks the beginning of the code section where the executable
instructions of the program are defined.

10). start: This label marks the entry point of the program.

11)mov ax, @data: This instruction loads the address of the data segment into the AX
register.

12)mov ds, ax: This instruction moves the content of the AX register into the DS register,
setting up the data segment register to point to the beginning of the data segment.

13)mov es, ax: Similar to the above, this instruction sets up the extra segment register (ES) to
point to the beginning of the data segment.

14)mov si, offset str: This instruction loads the offset (memory address) of the "str" variable
into the SI register, preparing to copy the string.
15)mov di, offset rstr: Similar to the above, this instruction loads the offset of the "rstr"
variable into the DI register, setting up the destination for the copied string.

16) add di, len-1: This instruction calculates the destination address for the end of the
reversed string by adding the length of the string minus one to the current address in the DI
register.

17)mov cx, len: This instruction loads the length of the string into the CX register, specifying
the number of characters to be copied.

18)back: This label marks the beginning of a loop to copy the string in reverse order.

19)mov al, [si]: This instruction loads a byte from the source string into the AL register.

20)mov [di], al: This instruction stores the byte from AL into the destination string.

21)inc si: This instruction increments the source index register (SI), moving to the next
character in the source string.

22)dec di: This instruction decrements the destination index register (DI), moving to the
previous position in the destination string.

23)loop back: This instruction decrements the CX register and loops back to the "back" label
as long as CX is not zero, allowing the copying process to continue until all characters are
copied.

24)mov si, offset str: This instruction reloads the offset of the original string into the SI
register for comparison.

25)mov di, offset rstr: This instruction reloads the offset of the reversed string into the DI
register for comparison.

26)mov cx, len: This instruction reloads the length of the string into the CX register for
comparison.

27)cld: This instruction clears the direction flag, ensuring that string comparison operations
will proceed from the source to the destination.

28)repe cmpsb: This instruction compares bytes in the strings pointed to by the SI and DI
registers until either a mismatch is found or the CX register reaches zero. The "repe" prefix
specifies that the comparison should continue as long as bytes are equal (repeating while
equal).

29)jne down: This instruction jumps to the "down" label if the comparison does not result in
equality (i.e., the strings are not palindromes).

30)lea dx, msg1: This instruction loads the offset of the "msg1" string into the DX register,
preparing to display the message indicating that it is a palindrome.
31)jmp downl: This instruction jumps to the "downl" label to display the message if the
comparison indicates a palindrome.

32)down: This label marks the section of the code to be executed if the comparison indicates
that the strings are not palindromes.

33)lea dx, msg2: This instruction loads the offset of the "msg2" string into the DX register,
preparing to display the message indicating that it is not a palindrome.

34)downl: This label marks the end of the program execution.

This assembly program copies a string in reverse order, compares it with the original string to
determine if it is a palindrome, and displays the appropriate message accordingly.
6.ALP
.model small

.stack

.data

str db "MOM"

len equ $-str

rstr db 20 dup (0)

msg1 db 10,13, "It is a palindrome$"

msg2 db 10,13, "It is not a palindrome$"

.code

start:

mov ax, @data

mov ds,ax

mov es,ax

mov si,offset str

mov di,offset rstr

add di,len-1

mov cx,len

back: mov al, [si]

mov [di],al

inc si

dec di

loop back

mov si,offset str

mov di,offset rstr

mov cx, len


cld

repe cmpsb

jne down

lea dx,msg1

jmp downl

down:lea dx,msg2

downl:mov ah, 09h

int 21h

mov ah,4ch

int 21h

end start
7.Different ways to write the program
Here are different approaches to implement a string palindrome program in assembly
language :

1.Compare Characters Approach:

- Start by comparing the first character with the last character of the string.

- Move inward by incrementing the start pointer and decrementing the end pointer.

- Continue comparing characters until they meet in the middle.

- If at any point characters don't match, it's not a palindrome.

- Otherwise, if all characters match, it's a palindrome.

2. Reverse String Approach:

- Reverse the input string.

- Compare the original string with the reversed string.

- If they are identical, it's a palindrome.

- Otherwise, it's not.

3. Using Stack Approach:

- Push characters onto a stack as you read them from the string.

- Then pop characters off the stack and compare them with characters in the string.

- If all characters match, it's a palindrome.

- Otherwise, it's not.

4. Recursive Approach:

- Recursively compare the first and last characters of the string.

- If they match, recursively compare the remaining substring.

- If the substring has one or no characters left, it's a palindrome.

- If any comparison fails, it's not a palindrome.


5. Using Pointers Approach:

- Use two pointers, one pointing to the start of the string and the other to the end.

- Compare characters pointed by these pointers.

- Move the pointers towards each other until they meet.

- If characters at corresponding positions match throughout the traversal, it's a palindrome.

Each of these approaches has its advantages and disadvantages in terms of efficiency, ease of
implementation, and memory usage. Depending on the specific requirements and constraints
of your assembly language program, you can choose the most suitable approach.
8.Practical application :
A practical application of a string palindrome detection program in assembly
language could be in the development of text processing tools, especially those dealing with
data validation or error checking. Here's how it could be applied:

1.Data Validation in User Input: When users input data into a system, such as passwords,
usernames, or other textual information, a palindrome detection routine can be used to ensure
that the input is not easily guessable or insecure. For example, passwords should ideally not
be palindromes as they could be vulnerable to simple attacks.

2. File Parsing and Analysis: In applications that involve parsing or analyzing text files,
detecting palindromes within the text could serve as a form of data quality check. If certain
sections of the text are expected to be coherent phrases or sentences, identifying palindromes
can highlight anomalies or errors in the data.

3.Text Filtering and Processing: Palindrome detection can be integrated into text filtering or
processing algorithms. For instance, in natural language processing tasks, identifying and
removing palindromic words or phrases from text corpora can help improve the accuracy of
subsequent analyses or applications, such as sentiment analysis or language modeling.

4. Network Security: In network security applications, palindrome detection can be employed


to detect patterns or anomalies in network traffic or transmitted data. For example, detecting
palindromic sequences within network packets could signal potential security threats or
attempts at data exfiltration through covert channels.

5. String Compression and Encoding: Palindrome detection algorithms can also be utilized in
compression or encoding schemes, where repetitive patterns are identified and represented
more efficiently. By detecting and encoding palindromic substrings within larger strings,
compression algorithms can achieve higher compression ratios, leading to more efficient data
storage or transmission.

6. Genomic Sequence Analysis: In bioinformatics applications, palindrome detection


algorithms play a crucial role in analyzing genomic sequences. Palindromic sequences within
DNA or RNA strands can have significant biological implications, such as in the recognition
sites for restriction enzymes or the formation of secondary DNA structures.

7. Cryptography and Cryptanalysis: Palindrome detection can be relevant in cryptographic


systems for generating or analyzing cryptographic keys. Identifying palindromic patterns
within key sequences can help assess their randomness or susceptibility to certain types of
cryptographic attacks, such as those exploiting weak key structures.

Overall, the practical application of a string palindrome detection program in assembly


language extends across various domains, including data validation, text processing, network
security, bioinformatics, and cryptography.
9.Procedure to run the program
To run the provided assembly language program in GUI Turbo Assembler (GTASM), you
can follow these steps:

1. Open GUI Turbo Assembler (GTASM) on your computer.

2. Create a new assembly source file by selecting "File" > "New".

3. Copy and paste the provided assembly code into the editor window.

4. Save the file with a suitable name and ".asm" extension (e.g., "palindrome.asm").

5. To assemble the code, select "Run" > "Assemble" or press F9. This will compile the code
and generate the corresponding machine code.

6. If there are any errors during assembly, they will be displayed in the output window at the
bottom of the screen. You'll need to correct any errors before proceeding.

7. Once the code is successfully assembled, you can run the program by selecting "Run" >
"Execute" or pressing Ctrl + F9.

8. If the program execution requires input, such as entering data for palindrome detection,
follow the prompts in the console window or any other input/output interface provided by
GTASM.

9. After the program completes execution, you should see the output displayed in the console
window or any other output interface specified in the code.

10. To exit GTASM, simply close the application window or select "File" > "Exit".
10.Output:
When given string is a palindrome:

When given string is not a palindrome:

You might also like