0% found this document useful (0 votes)
7 views4 pages

Expt 9

Uploaded by

pottivasanthi
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)
7 views4 pages

Expt 9

Uploaded by

pottivasanthi
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/ 4

ECE DEPARTMENT

MICRO PROCESSORS & MICROCONTROLERS LAB

EXP.No: 09 Date:

PALINDROME
Aim:

To write an Assembly Language program to given word is palindrome or not and


Display the Result

APPARATUS:

 MASM software
 Personal computer

Register used: DX=Offset Address,AH=Function code, CX=Count

Portsused: None

Flags Effected: CF,ZF

Algorithm:

1. Start
2. Initialize the segments used
3. Initialize the Input & Output variables in the Data segment
4. End the data segment
5. Start the code segment
6. Initialize the data segment on code segment
7. Clear the CX Register
8. Assign the Given word to the SI Register
9. Count is assigned to the CX register and count moved to BX register
10. Store the 1st letter of the word in AL register from SI register
11. Store the last letter of the word in AH register from BX register
12. Compare the both letters
13. If both letters are Equal then go to next letters otherwise display the message “GIVEN
WORD IS NOT PALINDROME”.
14. Increment the SI and Decrement the count
15. Again compare the letters till the count is zero.
16. After comparing the all letters, if comparison is equal then display the message
“GIVEN WORD IS NOT PALINDROME”
17. Stop

PRAGATI ENGINEERING COLLEGE, SURAMPALEM Page 1


ECE DEPARTMENT
MICRO PROCESSORS & MICROCONTROLERS LAB

PROGRAM:

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
PALIN DB "RADER","$"
MSG1 DB "GIVEN WORD IS PALINDROME","$"
MSG2 DB "GIVEN WORD IS NOT PALINDROME","$"
COUNT EQU 04H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
XOR CX,CX
LEA SI,PALIN
MOV CL,COUNT
BACK: MOV CL,[SI]
MOV BX,CX
MOV AH,[BX]
CMP AL,AH
JE OK
LEA DX,MSG2
MOV AH,09H
INT 21H
JMP OVER
OK: INC SI
DEC CL
JNZ BACK
LEA DX,MSG1
MOV AH,09H
INT 21H
OVER: MOV AH,4CH
INT 21H
CODE ENDS
END START

CODE TABLE:

Physical Address Hex code Label Mnemonic Operands Comments

Segment Offset
Base Address
Address
0B52 0000 B84E0B MOV AX,0B4E Initialization of Data
0B52 0003 8ED8 MOV DS,AX segment

PRAGATI ENGINEERING COLLEGE, SURAMPALEM Page 2


ECE DEPARTMENT
MICRO PROCESSORS & MICROCONTROLERS LAB

0B52 0005 33C9 XOR CX,CX Clear the CX register


0B52 0007 8D36000 LEA SI, Assign word to the SI
0 [0000] register
0B52 000B B104 MOV CL,04 Count moved to CL
register
0B52 000D 8A0C MOV AL,[SI] 1st letter of the word
moved to AL
0B52 000F 8BD9 MOV BX,CX Count is moved to BX
0B52 0011 8A27 MOV AH,[BX] Last Letter moved to AH
0B52 0013 3AC4 CMP AL,AH Compare AL & AH
0B52 0015 740B 0022 JZ Jump to Specified
location if both are
Equal
0B52 0017 8D161F0 LEA DX, Display meg 1 “GIVEN
0 [001F] WORD IS NOT
0B52 001B B409 MOV AH,09 PALINDROME”
0B52 001D CD21 INT21
0B52 001F EB0E JMP 002F Jump to Specified
location to end the
program
0B52 0021 90 NOP No operation
0B52 0022 46 INC SI Increment SI for next
letter in forward direction
0B52 0023 FEC9 DEC CL Decrement CL for next
letter in reverse direction
0B52 0025 75E6 000D JNZ Jump to specified
location if Count is zero
0B52 0027 8D16060 LEA DX, Display msg2 “GIVEN
0 [0006] WORD IS
0B52 002B B409 MOV AH,09 PALINDROME”
0B52 002D CD21 INT21
0B52 002F B44C MOV AH,4C End of the program
0B52 0031 CD21 INT21

Procedure:

1. Type MASM filename.ASM and press enter on the command prompt.

2. If any errors are present rectify that errors and go to step3.

3. Type LINK filename.OBJ and press enter.

4. Type DEBUG filename.EXE and press enter.

5. Press G command to see the result.

Result:Check the given word is PALINDROM or not and results are observed using MASM

PRAGATI ENGINEERING COLLEGE, SURAMPALEM Page 3


ECE DEPARTMENT
MICRO PROCESSORS & MICROCONTROLERS LAB

PRAGATI ENGINEERING COLLEGE, SURAMPALEM Page 4

You might also like