8051 instruction — moving the value from Port 3 to register R2 Which instruction correctly transfers the current value present at Port 3 into general-purpose register R2?

Difficulty: Easy

Correct Answer: MOV R2, P3

Explanation:


Introduction / Context:
8051 supports register-to-direct, direct-to-register, and accumulator-based data moves. Knowing valid addressing forms helps avoid assembler errors and unintended side effects.


Given Data / Assumptions:

  • We need to read a port's latch/pin value (Port 3) into a CPU register.
  • Direct addressing of SFR P3 is permitted.
  • Target register is R2 (in the current active register bank).


Concept / Approach:
The instruction format MOV Rn, direct is valid: it copies the byte at a direct address (such as SFR P3) into a working register Rn. Thus MOV R2, P3 transfers the Port 3 value into R2 in a single instruction.


Step-by-Step Solution:

1) Determine source operand: SFR P3 (direct address).2) Determine destination: R2 (register in current bank).3) Use MOV R2, P3 to perform direct-to-register transfer.4) Assemble and verify addressing mode is supported.


Verification / Alternative check:
Referencing the 8051 instruction set shows opcodes MOV Rn, direct (A8–AF opcodes) are legal and execute in 2 bytes, 2 machine cycles on many variants.


Why Other Options Are Wrong:

  • MOV P2, R3: writes R3 to Port 2, wrong direction and wrong port.
  • MOV R3, P2: reads Port 2, not Port 3, and puts it in R3, not R2.
  • MOV 3P, R2: invalid mnemonic/syntax.


Common Pitfalls:
Forgetting that ports are SFRs and can be accessed via direct addressing; mixing up source/destination order in MOV.


Final Answer:
MOV R2, P3

More Questions from The 8051 Microcontroller

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion