Problem – Write an assembly language program in 8085 microprocessor to check whether both the nibbles of 8 bit number are equal or not. If nibbles are equal then store 00 in memory location 3050 otherwise store FF in memory location 3050.
Assumption – Number, to check for similar nibbles is stored at memory location 2050.
- Load the content of memory location 2050 in A.
- Moves the content of A in B.
- Mask the lower nibble and store it in register C.
- Move the content of B in A.
- Mask the higher order nibble and store it in A.
- Reverse the content of A by using RLC instruction 4 times.
- Compare the contents of A and C by help of CMP instruction. Update the flags of 8085.
- Now store FF if ZF = 0 otherwise store 00 if ZF = 1.
- Store the final result in memory location 3050.
|2000||LDA 2050||A <- M|
|2003||MOV B, A||B <- A|
|2004||ANI 0F||A <- A (AND) 0F|
|2006||MOV C, A||C <- A|
|2007||MOV A, B||A <- B|
|2008||ANI F0||A <- A (AND) 0F|
|200A||RLC||Rotate content of A left by one bit without carry|
|200B||RLC||Rotate content of A left by one bit without carry|
|200C||RLC||Rotate content of A left by one bit without carry|
|200D||RLC||Rotate content of A left by one bit without carry|
|200E||CMP C||A – C|
|200F||JZ 2018||Jump if ZF = 1|
|2013||MVI A, FF||A <- FF|
|2015||JMP 201A||Jump to memory location 201A|
|2018||MVI A, 00||A <- 00|
|201A||STA 3050||M <- A|
Explanation – Registers A, B, C are used for general purpose.
- LDA 2050: load the content of memory location 2050 in accumulator A.
- MOV B, A: moves the content of A in register B.
- ANI 0F: performs AND operation in contents of A and 0F. Store the result in A.
- MOV C, A: moves the content of A in register C.
- MOV A, B: moves the content of B in A.
- ANI F0: performs AND operation in contents of A and F0. Store the result in A.
- RLC: rotates content of A left by one bit without carry. Use the instruction 4 times to reverse the number.
- CMP C: compares the content of A and C. Update the flags of 8085 accordingly.
- JZ 2018: jump to memory location 2018 if zero flag is set.
- MVI A, FF: assign FF to A.
- JMP 201A: jump to memory location 201A.
- MVI A, 00: assign 00 to A.
- STA 3050: store the content of A in memory location 3050.
- HLT: stops executing the program and halts any further execution.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- 8085 program to show masking of lower and higher nibbles of 8 bit number
- 8085 program to perform AND operation in nibbles of 8 bit number
- 8085 program to separate (or split) a byte into two nibbles
- 8085 program to check whether the given 16 bit number is palindrome or not
- 8085 program to check whether the given number is even or odd
- 8085 program to convert an 8 bit number into Grey number
- 8085 program to count number of ones in the given 8-bit number
- 8085 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8085 program to find 1’s and 2’s complement of 16-bit number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find square of a 8 bit number
- 8085 program to reverse 16 bit number
- 8085 program to find minimum value of digit in the 8 bit number
- 8085 program to reverse 8 bit number
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to add two 8 bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to add two 16 bit numbers
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.