Mic MP
Mic MP
Mic MP
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.
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.
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
Signature
Project Guide
Micro-project Report
1.0 Rationale:
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.
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.
4. Community Support: GUI Turbo assembler benefits from an active user community,
offering tutorials, resources, and updates for continuous improvement.
6. Graphical Interface: GUI Turbo assembler offers a user-friendly GUI, making it more
accessible and intuitive for beginners.
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.
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"
.code
start:
mov ds,ax
mov es,ax
add di,len-1
mov cx,len
mov [di],al
inc si
dec di
loop back
repe cmpsb
jne down
lea dx,msg1
jmp downl
down:lea dx,msg2
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 :
- 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.
- 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.
4. Recursive Approach:
- Use two pointers, one pointing to the start of the string and the other to the end.
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.
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.
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: