8085 program to show masking of lower and higher nibbles of 8 bit number
Problem – Write an assembly language program in 8085 microprocessor to show masking of lower and higher nibble of 8 bit number.
Example –
Assumption – 8 bit number is stored at memory location 2050. After masking of nibbles, lower order nibble is stored at memory location 3050 and higher order nibble is stored at memory location 3051.
Algorithm –
- Load the content of memory location 2050 in accumulator A.
- Move the content of A in register B.
- Perform AND operation of A with 0F and store the result in memory location 3050.
- Move the content of B in A.
- Perform AND operation of A with 0F and reverse the result by using RLC instruction 4 times.
- Store the result in memory location 3051.
Program –
MEMORY ADDRESS | MNEMONICS | COMMENT |
---|---|---|
2000 | LDA 2050 | A <- M[2050] |
2003 | MOV B, A | B <- A |
2004 | ANI 0F | A <- A (AND) 0F |
2006 | STA 3050 | M[3050] <- A |
2009 | MOV A, B | A <- B |
200A | ANI 0F | A <- A (AND) 0F |
200C | RLC | rotate content of A left by 1 bit without carry |
200D | RLC | rotate content of A left by 1 bit without carry |
200E | RLC | rotate content of A left by 1 bit without carry |
200F | RLC | rotate content of A left by 1 bit without carry |
2010 | STA 3051 | M[3051] <- A |
2013 | HLT | END |
Explanation – Registers A, B are used:
- LDA 2050: load the content of memory location 2050 in accumulator A.
- MOV B, A: moves the content of A to B.
- ANI 0F: perform AND operation of A with 0F and store the result back to A.
- STA 3050: store content of A in memory location 3050.
- MOV A, B: moves the content of B in A.
- ANI 0F: perform AND operation of A with 0F and store the result back to A.
- RLC: rotate content of A left by 1 bit without carry. Use this instruction 4 times to reverse the content of A.
- STA 3051: store the content of A in memory location 3051.
- HLT: stops executing the program and halts any further execution.