8085 program to perform AND operation in nibbles of 8 bit number

Problem – Write an assembly language program in 8085 microprocessor to perform AND operation between lower and higher order nibble of 8 bit number.

Example –

Assumption – 8 bit number is stored at memory location 2050. Final result is stored at memory location 3050.

Algorithm –



  1. Load the content of memory location 2050 in A.
  2. Perform masking of nibbles. Store the lower order nibble in B and higher order nibble in A.
  3. Perform AND operation between A and B by help of ANA instruction.
  4. Store the final result in memory location 3050.

Program –

MEMORY ADDRESS MNEMONICS COMMENT
2000 LDA 2050 A <- M[2050]
2003 ANI 0F A <- A (AND) 0F
2005 MOV B, A B <- A
2006 LDA 2050 A <- M[2050]
2009 ANI F0 A <- A (AND) F0
200B RLC Rotate accumulator left by one bit without carry
200C RLC Rotate accumulator left by one bit without carry
200D RLC Rotate accumulator left by one bit without carry
200E RLC Rotate accumulator left by one bit without carry
200F ANA B A <- A (AND) B
2010 STA 3050 M[3050] <- A
2013 HLT END

Explanation – Registers A, B are used for general purpose.

  1. LDA 2050: load the content of memory location 2050 in accumulator A.
  2. ANI 0F: perform AND operation in A and 0F. Store the result in A.
  3. MOV B, A: moves the content of A in register B.
  4. LDA 2050: load the content of memory location 2050 in accumulator A.
  5. ANI F0: perform AND operation in A and F0. Store the result in A.
  6. RLC: rotate the content of A left by one bit without carry. Use this instruction 4 times to reverse the content of A.
  7. ANA B: perform AND operation in A and B. Store the result in A.
  8. STA 3050: store the content of A in memory location 3050.
  9. 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.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.