The MOV Instruction in Intel 8051 (MCS-51) Microcontroller

The MOV Instruction in Intel 8051 (MCS-51) Microcontroller

The MOV instruction tells the CPU to move (in actual fact COPY) the source operand to the destination operand.

MOV destination, source   ; copy source to destination

Programming in assembly language requires that at least you understand the architecture of the microprocessor or microcontroller you are working with; this means that we need to be well-versed with things like registers in that specific microprocessor or microcontroller. For the Intel 8051 also referred to as MCS-51, the mostly widely used registers include: A (Accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, Program Counter, and so forth.

Register sets for 8050-8051
Fig: Register sets for 8050-8051

The following examples illustrate the MOV instruction showing how the operands are moved into different registers.

MOV A, #40H   ; load value 40H into register A, #indicates it is a number
MOV R0, A     ; copy contents of A into register R0, thus (A=R0=40H)
MOV R1, A     ; copy contents of A into register R1 (A=R1=40H)
MOV R2, #60H  ; load value 60H into R3 hence (R3=60H)
MOV A, R2   ; copy contents of R2 into A, as a result (A=R2=60H)

Key points to note:

  • The values i.e. number (preceded with #) can be loaded directly to registers A, B, or R0-R7.
  • If the value is not preceded with #, it implies to load from a memory location.
  • Moving a value that is too big into a register will cause an error. For example:
MOV A, #7D0H   ; Not allowed, as 7DO in binary is greater 8 bits
  • Take note of the following:
MOV R4, #0F6H ;Add 0 to indicate that the value F is a Hex & not a letter
  • If values 0 to F are moved into an 8-bit register, the rest of the bits are presumed to be all zeros e.g.
MOV A, #7 ; the result will be A = 07 i.e. A = 00000111
Please follow us and share:

Author: John Mulindi

John Mulindi has a background in a technical field and he writes on topics ranging from automation, computer systems, embedded systems, mechatronics to measurement and control.

One thought on “The MOV Instruction in Intel 8051 (MCS-51) Microcontroller”

Leave a Reply