Programming Microcontrollers

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.

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
Share
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.

View Comments

Recent Posts

Rigid-Flex PCBs: Enhancing Durability and Flexibility in Electronic Devices

The world of electronics is constantly evolving, allowing designers and manufacturers to push the boundaries…

2 months ago

Key Features of PIC16X84 Family of Microcontrollers

PIC microcontrollers are fabricated by Microchip Technology. PIC16C84 and PIC16F84 are the two microcontrollers in…

9 months ago

ADD Instruction in Intel 8051 (MCS-51) Microcontroller

The ADD instruction tells the microcontroller’s CPU to add the source byte to register A…

9 months ago

Main Features of Intel 8086 Microprocessor

8-bit microprocessors are limited in their speed (the number of instructions that can be executed…

9 months ago

Basic Features of 68HC11 Family of Microcontrollers

The 68HC11 (also abbreviated as 6811 or HC11) is an 8-bit microcontroller that was introduced…

9 months ago

Process Synchronization using Semaphores

Mutual exclusion typically imposes some conditions on access to a given resource by two or…

9 months ago