8085 program to perform AND operation in nibbles of 8 bit number
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 –
- Load the content of memory location 2050 in A.
- Perform masking of nibbles. Store the lower order nibble in B and higher order nibble in A.
- Perform AND operation between A and B by help of ANA instruction.
- 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.
- LDA 2050: load the content of memory location 2050 in accumulator A.
- ANI 0F: perform AND operation in A and 0F. Store the result in A.
- MOV B, A: moves the content of A in register B.
- LDA 2050: load the content of memory location 2050 in accumulator A.
- ANI F0: perform AND operation in A and F0. Store the result in A.
- RLC: rotate the content of A left by one bit without carry. Use this instruction 4 times to reverse the content of A.
- ANA B: perform AND operation in A and B. Store the result in A.
- STA 3050: store the content of A in memory location 3050.
- HLT: stops executing the program and halts any further execution.
Share your thoughts in the comments
Please Login to comment...