Open In App

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 –

  1. Load the content of memory location 2050 in accumulator A.
  2. Move the content of A in register B.
  3. Perform AND operation of A with 0F and store the result in memory location 3050.
  4. Move the content of B in A.
  5. Perform AND operation of A with F0 and reverse the result by using RLC instruction 4 times.
  6. 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 F0 A <- A (AND) F0
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:

  1. LDA 2050: load the content of memory location 2050 in accumulator A.
  2. MOV B, A: moves the content of A to B.
  3. ANI 0F: perform AND operation of A with 0F and store the result back to A.
  4. STA 3050: store content of A in memory location 3050.
  5. MOV A, B: moves the content of B in A.
  6. ANI F0: perform AND operation of A with F0 and store the result back to A.
  7. RLC: rotate content of A left by 1 bit without carry. Use this instruction 4 times to reverse the content of A.
  8. STA 3051: store the content of A in memory location 3051.
  9. HLT: stops executing the program and halts any further execution.

Advantages:

Disadvantages:

Article Tags :