8085 Program to check for palindrome

MicrocontrollerMicroprocessor8085

Now let us see a program of Intel 8085 Microprocessor. This program will convert ASCII to binary values.

Problem Statement

Write 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

AddressData
.
.
.
.
.
.
8000BD
.
.
.
.
.
.

second input

AddressData
.
.
.
.
.
.
800052
.
.
.
.
.
.

third input

AddressData
.
.
.
.
.
.
800018
.
.
.
.
.
.

Flow Diagram

Program

AddressHEX CodesLabelsMnemonicsComments
F0003A, 00, 80
LDA 8000H   Load the number into A
F00367
MOV H, AMove Acc to H
F0040E, 08
MVI C,08H   InitializeCounter
F0067CLOOPMOV A, HLoad H to Acc
F00707
RLCRotate Left
F00867
MOV H, AGet back Accto H
F0097A
MOV A, DLoad D content into Acc
F00A1F
RARRotate Right through carry
F00B57
MOV D, AGet back Acc to D
F00C0D
DCR C   Decrease C
F00DC2, 06, F0
JNZ LOOP    Jump to LOOPif Z = 0
F0107C
MOV A, HLoad H data to Acc
F011BA
CMP D   Compare D with Acc
F012CA, 1A, F0
JZ TRUEIf both are same, it is palindrome
F0153E, 00
MVI A, 00H  Load 00H intoA
F017C3, 1C, F0
JMP EXIT    Jump to Exit
F01A3E, FFTRUEMVI A, FFH   Load FFH into A
F01C32, 50, 80EXITSTA 8050H   Store the result into memory
F01F76
HLTTerminate the program


Output

first output

AddressData
.
.
.
.
.
.
8050FF
.
.
.
.
.
.

second output

AddressData
.
.
.
.
.
.
805000
.
.
.
.
.
.

third output

AddressData
.
.
.
.
.
.
8050FF
.
.
.
.
.
.
raja
Published on 21-Jan-2019 10:49:40
Advertisements