The memory banks of a microcontroller is given below. What will be the final values of the registers A & R1, after the execution of the codes?
MOV A, #07H
MOV 04H, 08H
MOV R1, #03H
ADDC A, R1
SWAP R1
CLR C
ORL A, 0AH
XCH A, 0EH
SETB C
ADD A, R1

Solution: State of Flag register (i.e. PSW),

CYACFORS1RS0OV-P
100100X1

Thus, current value of

  • Carry Flag = 1 [CY]
  • Memory Bank = [RS1 AND RS0]

Memory addresses of:

We need those addresses during the execution of code.

  1. MOV A, #07H Load in register A.
    A =
  2. MOV 04H, 08H Copy the value of memory bank address 08H to address 04H. Currently 08H holds value , which will be copied into address 04H .
  3. MOV R1, #03H Load in R1 register of current selected bank . The address of R1 is 10H.
    R1 =
  4. ADDC A, R1 Add A with R1 and carry CY.
    A = A+R1+CY
    A=
    A =
  5. SWAP R1 Swap the lower nibble with higher nibble of R1. The value of R1 becomes from .
    R1 =
  6. CLR C Clear the value of carry bit.
    CY =
  7. ORL A, 0AH Logical OR between register A and memory bank address0AH. Currently A= and 0AH = .
    A =
    A =
  8. XCH A, 0EH Exchange the value between register A and memory bank address 0EH. Currently A= and 0EH = .
    A =
    0EH =
  9. SETB C Set bit of carry flag.
    CY =
  10. ADD A, R1 Add A with R1.
    A =
    A =

Thus the final values, A = , R1 =