Mic Report
Mic Report
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
The word "palindrome" was coined by the English playwright Ben Jonson in the
17th century from the Greek roots palin and dromos.
Examples:
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
.CODE
MOV DS, AX
;palindrome or not
CALL Palindrome
;interrupt to exit
INT 21H
MAIN ENDP
Palindrome PROC
; load the starting address
; of the string
;the string
LOOP1 :
JE LABEL1
INC SI
JMP LOOP1
LABEL1 :
DEC SI
;or not
LOOP2 :
CMP SI, DI
JL OUTPUT1
MOV AX,[SI]
CMP AL, BL
JNE OUTPUT2
DEC SI
INC DI
JMP LOOP2
OUTPUT1:
LEA DX,STRING1
;loaded in dx
INT 21H
RET
OUTPUT2:
LEA DX,STRING2
; loaded in dx
MOV AH,09H
INT 21H
RET
Palindrome ENDP
END MAIN
OUTPUT