- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8085 program to check whether the given 16 bit number is palindrome or not
In this program, we will see how to check a 16-bit number is a palindrome or not.
Write the 8085 Assembly language program to check a 16-bit number is palindrome or not. The number is stored at location 8000H and 8001H.
A number is a palindrome if the number and its reversed sequence is the number itself. For example, 5225 is a palindrome, but ABCD is not a palindrome.
In this problem, we are taking the number and store it into the HL pair. Then we are performing the reverse operation on L content. If the H and updated L value are the same, then the number is a palindrome. To check that we are doing XOR operation on H and L. When the result is 0, it is a palindrome, otherwise, it is not a palindrome.
If the number is palindrome we are storing FFH at location 8050H, and when it is not palindrome the 00H is stored at 8050H.
|F000||2A, 00, 80|| ||LHLD 8000H||Take the 16-bit number from memory to HL pair|
|F003||7D|| ||MOV A,L||Take L to A|
|F004||0F|| ||RRC||Rotate Acc four times|
|F005||0F|| ||RRC|| |
|F006||0F|| ||RRC|| |
|F007||0F|| ||RRC|| |
|F008||AC|| ||XRA H||XOR Acc and H|
|F009||3E, FF|| ||MVI A,FFH||Load FFH into A|
|F00B||CA, 0F, F0|| ||JZ STORE||If Z = 1, jump to store|
|F00E||AF|| ||XRA A||Otherwise load A = 0|
|F00F||32, 50, 80||STORE||STA 8050H||Store result at 8050H|
|F012||67|| ||HLT||Terminate the program|
Kickstart Your Career
Get certified by completing the courseGet Started