Home » Microcontrollers » Programming Microcontrollers » ADD Instruction in Intel 8051 (MCS-51) Microcontroller

ADD Instruction in Intel 8051 (MCS-51) Microcontroller

The ADD instruction tells the microcontroller’s CPU to add the source byte to register A and put the result in register A. Recall, A is the accumulator register typically used for all arithmetic and logic instructions.

ADD Instruction in Intel 8051 (MCS-51) Microcontroller

The ADD instruction is usually in the following form:

ADD A, source   ; ADD the source operand to the accumulator

The source operand can be either a register or immediate data, but the destination register must always be register A.

Example of ADD instruction:

MOV A, #23H   ; load 23H i.e. in hexadecimal into register A

MOV R2, #28H   ; load 28H into register R2

ADD A, R2   ; add contents of R2 to A thus, A = A + R2

The following instructions aren’t allowed:

ADD R2, A   ; Not allowed as A must always be the destination register

ADD R2, #25  ; Not allowed as destination register is not A
Please follow us and share:

Comments

Leave a Reply

Currently trending: