Data Transfer and Branch Instructions
Data Transfer and Branch Instructions
S.No. Instruction
Symbolicrepresentation Explanation
MOV A,Rn (A)- (Rn) The content of register Rn is movd to the accUmulator (A-register).
The Rn can be any one of the &régisters of the currently selected bank.
MOV A,direct, direct = 8-bit address of The content of internal RAMISÉR (whose address is specified
internal RAM/SFR directly in the instruction) is rgoved to accumulator (A-register).
(A) (RAM/SFR)
MOV A,@Ri/ (Ri)= Internal RAM address The content of internal RAM memory (whose address is specified by
(A) - (RAM) the Ri-registeris movgd to the accumulator (A-register). The
register Ri can be either R0 or R1or the currently selected register bank.
MOV A,#data (A) data The data given in the instruction is moved to the accumulator (A-register).
5. MOV Rn,A (Rn) (A) The content of the accumulator is moved to register Rn, where Rn is any
one of the 8 registers of the currently selected register bank.
8. MOV Rn,direct direçe = 8-bit address of The content of internal RAM/SFR (whose address is directly specified
intfnal RAM/SFR in the instruction) is moved to register Rn, where Rn is any one of the
(Bh) (RAM/SFR) 8 registers of the currently selected register bank.
t7. MOV Rn,#data Rn)- data The immediate data given in the instruction is moved to register Rn,
where Rn is any one of the 8 registers of the currently selected register
bank.
8 MOV direct,A direct = 8-bit address of internal The content of the accumulator is moved to internal RAM/SFR M1crop
RAM/SFR (RAM/SFR) (A) whose address is directly specified in the instruction.
|MOV direct, Rn direct = 8-bit address of internal The content of register Rn is moved to internal RAM/SFR
RAM/SFR (RAM/SFR) (Rn) whose address is directly specified in the instruction.
10 MOV direct,direct direct = 8-bit address of internal The content of one internal RAM/SFR is moved to another
RAM/SFR internal RAM/SFR. The address of the source and destination
(RAM/SFR)(RAMWSFR) are directly specified in the instruction.
11. MOV direct, @Ri (Ri) = Internal RAM address The content of internal RAM whose address is specified by Ri
of source operand is moved to another internal RAM/SFR whose address is
direct = Internal RAM/SFR directly specified in the instruction. The register Ri can be nrollcrs
address of destination operand either RO or R1.
(RAM/SFR) (RAM)
Table 4.11: continued...
Instruction
Symbolic representation
The immediate data given in the
Explanation
instruction is mnoved to the
thapter
S.No.
MOV direct,#data direct= Address of internal RAM/SF whose address is directly specified in the
4-
12. internal RAM/SFR,
Microcontrol er
(RAM/SFR) data
instruction.
moved to an internal RAM
The content of the accumulator is
(Ri) =Internal RAM address Ri-register. The
13. MOV @Ri,A location whose address is specified by the
(RAM) (A) register Rican be either R0 or R1.
whose address is directly
direct = Internal RAM/SFR address The content of the internal RAM/SFR
14. MOV @Ri,direct specified in the instruction is moved to another internal RAM
of source operand Ri-register. The
location whose address is specified by the
(Ri)= Internal RAM address of
destination operand. register Rican be either RO or R1.
(RAM) (RAM/SFR)
moved to an
The immediate data given in the instruction is
15. MOV @Ri,#data (Ri) =Internal RAM address address is specified by the
(RAM)+ data internal RAM location, whose
Ri-register. The register Ri can be RO or R1.
moved
16. MOV DPTR,#data16|(DPTR) - data16 The 16-bit constant (data16) given in the instruction is
(The content of the DPTR is used as address of
to the DPTR.
external data memory in the subsequent instruction.)
17. MOVC A,@A+DPTR (A) + (DPTR) = Address of program This instruction will copy a byte from the codelprogram memory
memory to the accumulator. The address of the program memory is given
(A) + (program memory) by the sum of the content of the DPTR and accumulator before
the move operation.
18. MOVC A,@A+PC (PC) - (PC)+1 This instruction will copy a byte from the codelprogram memory
(A) + (PC) =Address of program tothe accumulator. The address of the program memory is given
memory by the sum of the PC and the accumulator. Here, the content of
(A)+ (program memory) the PC is incremented before adding to A to get the address of
the code memory.
19. MOVX A,@Ri (Ri) =8-bit address external The content of external data RAM is moved to the accumulator.
data RAM The content of register Riis the 8-bit address of the
(A) - (RAM) external memory. The register Ri can be either RO or R1 of the
currently selected register bank.
20. MOVX A,@DPTR (DPTR)= 16-bit address of external The content of external data RAM is moved to the acCCumulator.
data RAM (A) 4 (RAM) The content of DPTR is the 16-bit address of the external RAM.
Table 4.11: continued. 24
4.
S.No. Instruction
21.
Symbolic representation Explanation
MOVX @Ri,A (Ri) = 8-bit address of external data RAM
The coritent of the accurnulator is moved to the external
(RAM) (A) data RAM. The content of the Ri is the 8-bit address of
external RAM. The register Rican be either RO or R1
22.
of the currehtly selected register bank.
MOVX @DPTR,A (DPTR) =16-bit address of external data RAM The coniént of the accumulator is moved to the external
(RAM) < (A) data RAM. The content of the DPTRis the 16-bit address
of he external RAM.
23. PUSH direct (SP) (SP) + 1 The stack pointer is incremented by one. The content of
direct = 8-bit address of internal RAM/SFR the internal RAMISFR (whose address is directly specified
((SP)) (RAM/SFR) in the instruction)is moved to the intermal RAM memory
pointed by the SP.
24. POP direct direct = 8-bit address of internal RAM/^FR The content of the internal RAM memory pointed by the
(RAM/SFR}-(SP) SP is moved to the internal RAM/SFR (whose address
(SP) (SP) 1 isdirectly specified in the instruction). Then the stack
pointer is decremented by one.
25. XCH A,Rn (A)Z (Rn) The content of register Rn is exchanged with the
accumulator. The register Rn can be any one of the eight
registers of the currently selected register bank.
26. XCH A,direct direct = 8-bit address of internal RAM/SFR The content of the internal RAM /SFR whose address
(A) (RAMISFR) is directly specified in the instruction is exchanged with
the accumulator.
27. XCH A,@Ri (Ri) =8-bit address of internal RAM The content of the internal RAM whose address is specified
(A) (RAM) by the Ri-register is exchanged with the accumulator.
The register Ri can be either RO or R1 of the currently
selected register bank.
28. XCHD A,@Ri (Ri) =&-bit address of internal RAM The lower nibble of the internal RAM addressed by Ri
(A)a0 (RAM),o register is exchanged with the lower nibble of the
accumulator. The content of the upper nibble of RAM
and accumulator are not altered. The Register Rican
be either RO or R1 of the currently selected register
bank.
WAP A
(Ao The higher nibble of the accumulator is exchanged with the
lower nibble of the acCumulator.
4.7.4 PROGRAM BRANCHING INSTRUCTIONS
Nomally, aprogram is executed sequentially and the PC(ProgramCounter) keeps track of the address of the instructions and it
is incremented appropriately after each fetch operation. The program branching instructions will modify the content of the PCso that,
the program control branches to a new address. The program branching instructions of 805I includes conditional and unconditional
olers
branching instruction. Inconditional branching instructions, the content of the PC is modified, only ifthe condition
instrucions like
instruction, the PC is always modifcd. The MICrocontroller
hapter-
instruction is true, whereas in unconditional
branching
modifying the PC. The program branching instructions
enecifed in the
previous value of thePC in thestack before
ACALL and LCALL willsave the explanationabout each instruction.
4.14 with a brief
of 805Iare listed in Table
PROGRAM BRANCHING INSTRUCTIONS
TABLE 4.14:
Explanation
S.No. Instruction Symbolic representation unconditionally call a subroutine which resides within
This instruction is used to
ACALL addr11 (PC)(PC) + 2
of the program memory in which the instruction following ACALL
78.
(SP) -(SP)+1 the same 2k block increments the PCby two, to point to the
is stored. This instruction first incremented
(SP) (PCh Next, the content of the SP is
address of the instruction next to ACALL. SP.
(SP) - (SP) +1 saved in the stack memory pointed by
by one and the low byte of PC is saved in
(SP)) -(PC)15-8
content of the SP is incremented by one and then, high byte of PCis
Again,
(PC)pa - addr11 Then, the 11-bit address given in the
the stack memory pointed by the SP. thePC. (The 11- bit address is the
instruction is moved to the lower 11-bit position of opcode.) Now, the controller
of the
second byte of the instruction and upper 3 bits
address.
starts fetching the instructions from this new
instruction is used to unconditionally call a subroutine anywhere in the 64 k
This
79.LCALL addr16 (PC) - (PC) +3 three to point to the next instruction.
(SP) - (SP) +1 space. First, the PC is incremented by the PC is saved in the stack memory
of
Next, the SP is incremented and the content
(SP) + (PCh given in the instruction is moved
(SP) - (SP) +1 pointed by the SP. Then, the 16-bit address address.
fetching the instruction from this new
(SP) (PChs8 to the PC and so the controller
(PC) - addr16 starts
this
terminate a subroutine. On execution of
(PC),., + (SP) This instruction is used to is moved
80. RET the stack memory pointed by the SP
instruction, the content of
(SP) -(SP)-1
high byte of PC and SP is decremented by one. Then, the content of the
(PC),, 4-(SP) tothe
the low byte of PCand again
(SP) - (SP)- 1 stack memory pointed by SP is moved to
the SP is decremented by one.
This
terminate an interrupt service subroutine.
(PC),- (SP) This RETI instruction is used to to that of RET instruction
81.RETI top of the stack to the PC similar tho
Table 4.14: continued.
|s.No Instruction Symbolic representation Explanation
memory iocation wthin
82. AJMP addr11 (PC) (PC) +2 This instruction is used to unconditionally /urno to a
which the instruction
(PC),,n f- addr11 the same 2k block of progran memory in
by two to point to the
following AJMP is stored. First, the PCis incrernented
instruction and then the 11-bit address given in the instrucion
address of next address is the second
11-bit position of the PC.The 11-ot
is moved to the lower
byte of the instruction and upper 3 bits of opcode
to any location in the 64 k
LJMP addr16 (PC) addr16 This instruction is used to unConditionally jump
83. instruction,the 16-bit address given
memory space. Upon execution of this controller starts fetching the
instruction is moved to the PC, and so the
in the
instruction from this new address.
CINEAdiredfset (PC)
diret
(PC) 3 First, trhe PCis irirornerted ty threes tr
Address of internal RAM/SERontent f the accurnulator ard thie internal PAMISFR (whose
f (A) (RAMISFR) then
(PC) 4 (PC)+ offset
If (A) <(RAMISFR) then, CF 1
|If (A) > (RAMISFR) then, CF 4 0
addrgss is dirertty speified in the instrurtion) are ompared. Kthe
contents are not 9qual then the prograrn onrol is transferred to a
new address. The new address is the un of the PC and otset grven
ordMro ntro
irt , thereni n t n . The
94 NOP (PC) + (PC) + 1 This instruction will not perform any operation. Sxcet hat he PCis
incremented by one to point to the next instruction. EAecutton of NOP
will produce a delay ofone machine cycle time and so, his instruction
can be used to create smalldelaysin multiplies of machine cycde time.