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

• Difficulty Level : Expert
• Last Updated : 20 Jun, 2018

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 –

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.
My Personal Notes arrow_drop_up
Recommended Articles
Page :