The 8051 Microcontroller and Embedded

(lily) #1
Department of Computer Scien

ce and Information Engineering

National Cheng Kung University, TAIWAN
HANEL
INSIDE THE

8051 ADD Instruction


ADD A, source


;ADD the source operand ;to the accumulator


¾The


ADD


instruction tells the CPU to add the source
byte to register A and put the result in register A¾Source operand can be either a register or immediate data, but the destination must always be register Aƒ“

ADD R4, A

”and “

ADD R2, #12H

” are invalid

since A must be the destination of any arithmetic operation
MOV A, #25H ;load 25H into AMOV R2, #34H ;load 34H into R2ADD A, R2 ;add R2 to Accumulator

;(A = A + R2)

MOV A, #25H ;load one operand

;into A (A=25H)
ADD A, #34H ;add the second

;operand 34H to A

There are always many ways to write the same program, depending on the registers used
Free download pdf