Program to check for palindrome in 8085 Microprocessor

8085MicrocontrollerMicroprocessor

Here we will see one 8085 Microprocessor program, that can check whether a number is palindrome or not.

Problem Statement 

Write an 8085 Assembly language program to check whether a bit pattern is palindrome or not.

Discussion 

In this program we are taking the number from location 8000H. The program will return 00H if the number is not palindrome, otherwise it will return FFH.

Let the Input is 18H so the binary value is (0001 1000) this is a palindrome. The number 52H (0101 0010) it is not a palindrome.

In this problem we are taking the first number into accumulator, then shifting it to the left. When it is left shifted the MSb will be placed at LSb and also in the carry flag. This carry flag is inserted into the D register by right shifting. Thus the bit pattern will be reversed, now by checking the values of actual number and the reversed number we can determine it is palindrome or not.

Input

first input

Address
Data


8000
BD



second input

Address
Data


8000
52


third input

Address
Data


8000
18


Flow Diagram

Program

Address
HEX Codes
Labels
Mnemonics
Comments
F000
3A, 00, 80
 
LDA 8000H  
Load the number into A
F003
67
 
MOV H,A
Move Acc to H
F004
0E, 08
 
MVI C,08H  
Initialize Counter
F006
7C
LOOP
MOV A,H
Load H to Acc
F007
07
 
RLC
Rotate Left
F008
67
 
MOV H,A
Get back Acc to H
F009
7A
 
MOV A,D
Load D content into Acc
F00A
1F
 
RAR
Rotate Right through carry
F00B
57
 
MOV D,A
Get back Acc to D
F00C
0D
 
DCR C  
Decrease C
F00D
C2, 06, F0
 
JNZ LOOP  
Jump to LOOP if Z = 0
F010
7C
 
MOV A,H
Load H data to Acc
F011
BA
 
CMP D  
Compare D with Acc
F012
CA, 1A, F0
 
JZ TRUE
If both are same, it is palindrome
F015
3E, 00
 
MVI A, 00H
Load 00H into A
F017
C3, 1C, F0
 
JMP EXIT  
Jump to Exit
F01A
3E, FF
TRUE
MVI A,FFH  
Load FFH into A
F01C
32, 50, 80
EXIT
STA 8050H  
Store the result into memory
F01F
76
 
HLT
Terminate the program

 

Output

first output

Address
Data


8050
FF


Second Output

Address
Data


8050
00


 third output

Address
Data


8050
FF


 

raja
Published on 04-Oct-2019 12:35:36
Advertisements