Module-2 CP notes
Module-2 CP notes
INSTRUCTION SET
instruction.
• Eg. MOV A,#30H
ADD A, #83
• # Symbol indicates the data is immediate.
2. Register addressing
• In this addressing mode the register will hold
the data.
• One of the eight general registers (R0 to R7)
• ADD A,R6
LCALL DELAY
9. Bit Inherent Addressing
• In this addressing, the address of the flag
space
SETB 07H ; Sets the bit 7 of 20H RAM space
II. DATA TRANSFER
INSTRUCTIONS-8051
• Definition
• Examples
• Description
a. Move the contents of a register Rn to A
i. MOV A,R2
ii. MOV A,R7
Eg.
MOV A,#45H ;[A]=45H
MOV B,#0F5H ;[B]=F5H
MUL AB ;[A] x [B] = 45 x F5 = 4209
[A]=09H, [B]=42H
Division
DIV AB:
This instruction divides the 8 bit unsigned number
which is stored in A by the 8 bit unsigned number
which is stored in B register. After division the result
will be stored in accumulator and remainder will be
stored in B register.
Eg.
MOV A,#45H ;[A]=0E8H
MOV B,#0F5H ;[B]=1BH
DIV AB ;[A] / [B] = E8 /1B = 08 H with
remainder 10H
Eg 1:
MOV A,#23H
MOV R1,#55H
ADD A,R1 // [A]=78
DA A // [A]=78 no changes in the accumulator after DA A
Eg 2:
MOV A,#53H
MOV R1,#58H
ADD A,R1 // [A]=ABH
DA A // [A]=11, C=1 . ANSWER IS 111. Accumulator data is
changed after DA A
Increment
Increments the operand by one.
INC A
INC Rn
INC DIRECT
INC @Ri
INC DPTR
The Carry Flag is not set when the value "rolls over" from 255
to 0.
ANL A,#DATA
ANL A, Rn
ANL A,DIRECT
ANL A,@Ri
ANL DIRECT,A
ANL DIRECT, #DATA
Logical OR
• ORL destination, source:
ORL does a bitwise "OR" operation between source and
destination, leaving the resulting value in destination.
ORL A,#DATA
ORL A, Rn
ORL A,DIRECT
ORL A,@Ri
ORL DIRECT,A
ORL DIRECT, #DATA
Logical Ex-OR
• XRL destination, source:
XRL does a bitwise "EX-OR" operation between source and
destination, leaving the resulting value in destination.
• " XRL " instruction logically EX-OR the bits of source and
destination.
XRL A,#DATA
XRL A,Rn
XRL A,DIRECT
XRL A,@Ri
XRL DIRECT,A
XRL DIRECT, #DATA
Logical NOT
• CPL complements operand, leaving the result
in operand. If operand is a single bit then the
state of the bit will be reversed.
a. During execution of LCALL, [PC] = [PC]+3; (if address where LCALL resides is
say, 0x3254; during execution of this instruction [PC] = 3254h + 3h = 3257h
a. During execution of SCALL, [PC] = [PC]+2; (if address where LCALL resides is
say, 0x8549; during execution of this instruction [PC] = 8549h + 2h = 854Bh