Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN
HANEL
INSIDE THE8051 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 invalidsince 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 AThere are always many ways to write the same program, depending on the registers used