SlideShare a Scribd company logo
1 of 39
Download to read offline
BY 
CH. BALAKISHAN 
12MT06PED009
DATA TRANSFER INSTRUCTIONS 
MOV 
MOVC 
MOVX
MOV INSTRUCTION 
The MOV instruction moves data bytes/bits 
between the two specified operands. The byte/bit 
specified by the second operand is copied to the 
location specified by the first operand 
The source data byte/bit is not affected. 
No other register or flag is affected. 
MOV destination, source ;copy source to dest. 
MOV A,#55H ;load value 55H into reg. A
MOV A,#35h; 
moving the 35h to the register A 
MOV 35h,45h; 
moving the content of memory location 45h to 
the memory location 35h, 
Here 
#35h is a data, 
35h is a memory location.
MOV 30h,A; 
moving the content of reg. A to the 
memory location 30h, 
MOV A,30h; 
MOV A,R1; 
moving the content of reg. R1 to the 
reg. A
MOV 3,A; = MOV R3,A; 
MOV A,@R3; 
moving the content of memory 
pointed to by R3 to A; 
MOV @R3,A; 
moving the content of reg. A to the 
memory pointed to by reg.R3
MOV <dest-bit>,<src-bit> 
Function: To move bit data 
One of the operands must be the carry 
flag 
Example: MOV P1.3,C; 
moves the carry bit to 3rd bit of port1 
if C=1; the output of P1.3 is high, 
if C=0; the output of P1.3 is low,
MOV DPTR,16bit data 
Loads the data pointer with 16 bit 
constant, 
This is 3 byte instruction, 
Data stored in 2nd and 3rd bytes of the 
instruction 
MOV DPTR, # 4567H 
DPL=67H;(lower byte) 
DPH=45H;(higher byte)
MOV DPTR, # 4567H; 
MOV DPL,#67H; 
= MOV DPH,#45H; 
MOV R1,R2; it is not possible
MOVC A,@A+ <base-reg> 
these instructions load the accumulator with a 
code byte or constant from program memory 
The address of the byte fetched is the sum 
of the original unsigned 8-bit Accumulator 
contents and the contents of a 16-bit base 
register 
Base register may be either the Data Pointer or 
the PC
Example: 
Look-up table SQUR has the of values between 0 
to 4, 
ORG 100H 
SQUR: DB 0,1,4,9,16 
program to fetch the square value of 4 
ORG 0H 
MOV A,#4H; 
MOV DPTR,100H; 
MOVC A,@A+DPTR; 
END;
MOVX <dest-byte>,<src-byte> 
The MOVX instructions transfer data 
between the Accumulator and a byte of 
external data memory, 
This data space must be connected 
externally 
Address of external memory being 
accessed can be 16-bit or 8-bit 
for 16 bit--- DPTR 
8 bit----R0 or R1
16 Bit address data transfer: 
MOVX @DPTR,A; 
this moves the contents of the 
accumulator to the external memory 
location whose address is pointed to by 
DPTR, 
MOVX A,@DPTR; 
this moves into the accumulator a byte 
from external memory whose address is 
pointed to by DPTR,
8 Bit address data transfer 
MOVX A,@R1; 
This moves to the accumulator to the 
external memory whose 8-bit address is 
pointed to by R0 
MOVX @R1,A; 
This moves a byte from register into 
external memory location whose 8-bit 
address is held by R0
EXAMPLE PROGRAM USING 
MOVX INSTRUCTION.. 
An external ROM uses the 8051 data 
space to store the look-up table (starting 
at 1000H) for DAC data. Write a 
program to read 30 Bytes of these data 
and send it to P1.
Solution: 
MYXDATA EQU 1000H 
COUNT EQU 30 
MOV DPTR, #MYXDATA; 
MOV R2, #COUNT; 
AGAIN: MOVX A,@DPTR; 
MOV P1,A; 
INC DPTR; 
DJNZ R2,AGAIN;
BRANCHING INSTRUCTIONS 
Program branching instructions are used 
to control the flow of actions in program. 
Some instructions provide decision 
making capabilities and transfer control 
to other parts of program. 
eg., Unconditional and conditional 
branches.
SJUMP(short jump): 
2 byte instruction 
1st byte opcode 
2nd byte relative address of target 
location 
relative address range is 00 – FFH, 
All conditional jumps are short jumps 
Ex: SJUMP HERE; 
after executing this instruction it jumps to 
HERE label
LJUMP(long jump): 
Unconditional long jump 
3byte instruction 
1st byte for op-code 
2nd and 3rd byte for 16 bit address of 
target location
CONDITIONAL JUMPS
JZ AND JNZ 
INSTRUCTIONS 
JZ label ; jump if A=0 
Can be used only for register A, not 
any other register. 
flag registers will not be affected 
JNZ label; jump if A is not zero
DJNZ INSTRUCTION 
DJNZ reg, Label; 
The register is decremented. 
If it is not zero, it jumps to the target 
address referred to by the label. 
Prior to the start of loop the register is 
loadel with the counter for the number 
of repetitions. 
Counter can be R0 – R7 or RAM 
location.
Example 
Program to complement the 
accumulator 3 times 
ORG 0H; 
MOV A,0Fh; 
MOV R3,3; 
HERE: CPL A; 
DJNZ R3,HERE; 
END
EXAMPLE: 
Write a program to (a) load the accumulator 
with the value 55H, and (b) complement the 
ACC 700 times. 
MOV A,#55H ;A=55H 
MOV R3,#10 ;R3=10, outer loop count 
NEXT: MOV R2,#70 ;R2=70, inner loop count 
AGAIN: CPL A ;complement A register 
DJNZ R2,AGAIN ;repeat it 70 times 
DJNZ R3,NEXT
JNC INSTRUCTION 
JNC label ;jump if no carry, CY=0 
If CY = 0, the CPU starts to fetch and 
execute instruction from the address of 
the label. 
If CY = 1, it will not jump but will execute 
the next instruction below JNC. 
All conditional jumps are short jumps 
The address of the target must within 
-128 to +127 bytes of the contents of PC
BYTE JUMPS:
CALL instructions 
To call a user defined functions in 
program 
Transfer control to a subroutine 
Flags are not affected 
RET must be the last instruction of 
subroutine 
These are two types 
1) ACALL(absolute call) 
2) LCALL (long call)
ACALL: 
2 byte instruction 
5 bits are used for op-code 
remaining 11 bits are used for 
subroutine target address 
Target address must be within 2K byte 
Ex: ACALL label; 
here label address should be 2K byte 
only
LCALL: 
3 byte instruction 
1st byte for op-code 
2nd and 3rd for target address of the 
subroutine 
Subroutine address located anywhere 
within 64K byte 
Ex: LCALL label;
Program to display 5 and 4 digits in seven 
segment display with delay: 
ORG 0H; 
MOV P1,#05DH; 
ACALL DELAY; 
MOV P1,#026H; 
ACALL DELAY; 
END; 
DELAY: MOV R3,#55; (count=55) 
HERE: DJNZ R3,HERE;(loop) 
RET;
TIME DELAY 
CALCULATIONS 
ž CPU executing an instruction takes a 
certain number of clock cycles. These 
are referred as to as machine cycles. 
ž In original 8051, one machine cycle lasts 
12 oscillator periods. 
ž Find the period of the machine cycle for 
11.0592 MHz crystal frequency?
ž Solution: 
11.0592/12 = 921.6 kHz; 
machine cycle is 1/921.6 kHz = 
1.085μs
PROBLEM: 
ž For 8051 system of 11.0592 
MHz, find how long it takes to 
execute each instruction. 
(a) MOV R3,#55 (b) DEC R3 (c) 
DJNZ R2 target 
(d) LJMP (e) SJMP (f) NOP (g) 
MUL AB
Solution:
Find the size of the delay in following program, 
if the crystal frequency is 11.0592MHz. 
MACHINE CYCLE 
DELAY: MOV R3,#250 1 
HERE: NOP 1 
NOP 1 
NOP 1 
NOP 1 
DJNZ R3,HERE 2 
RET 2
SOLUTION 
ž The time delay inside HERE 
loop is [250(1+1+1+1+2)]x1.085μs 
= 1627.5μs. Adding the two 
instructions outside loop we 
have 1627.5μs + 3 x 1.085μs = 
1630.755μs.
Https  _doc-0o-c4-apps-viewer.googleusercontent

More Related Content

What's hot

Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineTechnogroovy
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copymkazree
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessorhepzijustin
 
Computer network
Computer networkComputer network
Computer networkDeepikaT13
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086techbed
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiMuhammad Abdullah
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Jay Patel
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutinemilandhara
 
8085 branching instruction
8085 branching instruction8085 branching instruction
8085 branching instructionprashant1271
 
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd Technogroovy India
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4Motaz Saad
 
8085:branching and logical instruction
8085:branching and logical instruction8085:branching and logical instruction
8085:branching and logical instructionNemish Bhojani
 
Data transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorData transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorvishalgohel12195
 

What's hot (20)

Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects Online
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Binary to bcd
Binary to bcdBinary to bcd
Binary to bcd
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copy
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessor
 
Computer network
Computer networkComputer network
Computer network
 
1344 Alp Of 8086
1344 Alp Of 80861344 Alp Of 8086
1344 Alp Of 8086
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidi
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
8085 branching instruction
8085 branching instruction8085 branching instruction
8085 branching instruction
 
Arm chap 3 last
Arm chap 3 lastArm chap 3 last
Arm chap 3 last
 
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
Embedded Systems Training & Live Projects @Technogroovy Systems India Pvt Ltd
 
8086 alp
8086 alp8086 alp
8086 alp
 
Ch2 arm-1
Ch2 arm-1Ch2 arm-1
Ch2 arm-1
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
Lecture6
Lecture6Lecture6
Lecture6
 
8085:branching and logical instruction
8085:branching and logical instruction8085:branching and logical instruction
8085:branching and logical instruction
 
Data transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processorData transfer instruction set of 8085 micro processor
Data transfer instruction set of 8085 micro processor
 
Shift rotate
Shift rotateShift rotate
Shift rotate
 

Viewers also liked

Interrupt programming
Interrupt programming Interrupt programming
Interrupt programming vijaydeepakg
 
Construction
ConstructionConstruction
ConstructionLD7
 
Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)REEJASHA
 
Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor vijaydeepakg
 
Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)REEJASHA
 
Timer programming
Timer programming Timer programming
Timer programming vijaydeepakg
 
Task 5 + 6
Task 5 + 6Task 5 + 6
Task 5 + 6LD7
 
Dizee rascal analysis
Dizee rascal analysisDizee rascal analysis
Dizee rascal analysisLD7
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051) vijaydeepakg
 
Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 vijaydeepakg
 
Acls bolsillo 2010
Acls bolsillo 2010Acls bolsillo 2010
Acls bolsillo 2010nvklnd
 
Deploy django apps using docker
Deploy django apps using dockerDeploy django apps using docker
Deploy django apps using dockerThomas Kremmel
 
Cinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur FacebookCinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur FacebookBenjamin Martin
 
Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)Philippe Watrelot
 
Brand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnantBrand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnantLabCom
 

Viewers also liked (20)

Interrupt programming
Interrupt programming Interrupt programming
Interrupt programming
 
Construction
ConstructionConstruction
Construction
 
Lp 30
Lp 30Lp 30
Lp 30
 
Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)
 
Keypad and dc motor
Keypad and dc motor Keypad and dc motor
Keypad and dc motor
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)
 
Timer programming
Timer programming Timer programming
Timer programming
 
12 mt06ped001
12 mt06ped001 12 mt06ped001
12 mt06ped001
 
12 mt06ped007
12 mt06ped007 12 mt06ped007
12 mt06ped007
 
Task 5 + 6
Task 5 + 6Task 5 + 6
Task 5 + 6
 
Dizee rascal analysis
Dizee rascal analysisDizee rascal analysis
Dizee rascal analysis
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
Jp
Jp Jp
Jp
 
Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 Sudhir tms 320 f 2812
Sudhir tms 320 f 2812
 
Acls bolsillo 2010
Acls bolsillo 2010Acls bolsillo 2010
Acls bolsillo 2010
 
Deploy django apps using docker
Deploy django apps using dockerDeploy django apps using docker
Deploy django apps using docker
 
Cinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur FacebookCinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
 
Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)
 
Brand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnantBrand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnant
 

Similar to Https _doc-0o-c4-apps-viewer.googleusercontent

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.pptsteffydean
 
Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01cairo university
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxAmoghR3
 
Instruction set summary
Instruction set summary Instruction set summary
Instruction set summary janicetiong
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerchirag patil
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)Pratheesh Pala
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontrollerjokersclown57
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentationJiMs ChAcko
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Vijay Kumar
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)AmitPaliwal20
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction setStefan Oprea
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing ModesMayank Garg
 
The 8051 microcontroller
The 8051 microcontrollerThe 8051 microcontroller
The 8051 microcontrollerPallaviHailkar
 

Similar to Https _doc-0o-c4-apps-viewer.googleusercontent (20)

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01Lecture 4 (8051 instruction set) rv01
Lecture 4 (8051 instruction set) rv01
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptx
 
Instruction set summary
Instruction set summary Instruction set summary
Instruction set summary
 
MES_MODULE 2.pptx
MES_MODULE 2.pptxMES_MODULE 2.pptx
MES_MODULE 2.pptx
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Micro controller(pratheesh)
Micro controller(pratheesh)Micro controller(pratheesh)
Micro controller(pratheesh)
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
8085 paper-presentation
8085 paper-presentation8085 paper-presentation
8085 paper-presentation
 
6.pptx
6.pptx6.pptx
6.pptx
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
Addressing Modes
Addressing ModesAddressing Modes
Addressing Modes
 
Micro task1
Micro task1Micro task1
Micro task1
 
The 8051 microcontroller
The 8051 microcontrollerThe 8051 microcontroller
The 8051 microcontroller
 
UNIT II.pptx
UNIT II.pptxUNIT II.pptx
UNIT II.pptx
 
Microcontroller .pptx
Microcontroller .pptxMicrocontroller .pptx
Microcontroller .pptx
 

Https _doc-0o-c4-apps-viewer.googleusercontent

  • 1. BY CH. BALAKISHAN 12MT06PED009
  • 3. MOV INSTRUCTION The MOV instruction moves data bytes/bits between the two specified operands. The byte/bit specified by the second operand is copied to the location specified by the first operand The source data byte/bit is not affected. No other register or flag is affected. MOV destination, source ;copy source to dest. MOV A,#55H ;load value 55H into reg. A
  • 4. MOV A,#35h; moving the 35h to the register A MOV 35h,45h; moving the content of memory location 45h to the memory location 35h, Here #35h is a data, 35h is a memory location.
  • 5. MOV 30h,A; moving the content of reg. A to the memory location 30h, MOV A,30h; MOV A,R1; moving the content of reg. R1 to the reg. A
  • 6. MOV 3,A; = MOV R3,A; MOV A,@R3; moving the content of memory pointed to by R3 to A; MOV @R3,A; moving the content of reg. A to the memory pointed to by reg.R3
  • 7. MOV <dest-bit>,<src-bit> Function: To move bit data One of the operands must be the carry flag Example: MOV P1.3,C; moves the carry bit to 3rd bit of port1 if C=1; the output of P1.3 is high, if C=0; the output of P1.3 is low,
  • 8. MOV DPTR,16bit data Loads the data pointer with 16 bit constant, This is 3 byte instruction, Data stored in 2nd and 3rd bytes of the instruction MOV DPTR, # 4567H DPL=67H;(lower byte) DPH=45H;(higher byte)
  • 9. MOV DPTR, # 4567H; MOV DPL,#67H; = MOV DPH,#45H; MOV R1,R2; it is not possible
  • 10. MOVC A,@A+ <base-reg> these instructions load the accumulator with a code byte or constant from program memory The address of the byte fetched is the sum of the original unsigned 8-bit Accumulator contents and the contents of a 16-bit base register Base register may be either the Data Pointer or the PC
  • 11. Example: Look-up table SQUR has the of values between 0 to 4, ORG 100H SQUR: DB 0,1,4,9,16 program to fetch the square value of 4 ORG 0H MOV A,#4H; MOV DPTR,100H; MOVC A,@A+DPTR; END;
  • 12. MOVX <dest-byte>,<src-byte> The MOVX instructions transfer data between the Accumulator and a byte of external data memory, This data space must be connected externally Address of external memory being accessed can be 16-bit or 8-bit for 16 bit--- DPTR 8 bit----R0 or R1
  • 13. 16 Bit address data transfer: MOVX @DPTR,A; this moves the contents of the accumulator to the external memory location whose address is pointed to by DPTR, MOVX A,@DPTR; this moves into the accumulator a byte from external memory whose address is pointed to by DPTR,
  • 14. 8 Bit address data transfer MOVX A,@R1; This moves to the accumulator to the external memory whose 8-bit address is pointed to by R0 MOVX @R1,A; This moves a byte from register into external memory location whose 8-bit address is held by R0
  • 15. EXAMPLE PROGRAM USING MOVX INSTRUCTION.. An external ROM uses the 8051 data space to store the look-up table (starting at 1000H) for DAC data. Write a program to read 30 Bytes of these data and send it to P1.
  • 16. Solution: MYXDATA EQU 1000H COUNT EQU 30 MOV DPTR, #MYXDATA; MOV R2, #COUNT; AGAIN: MOVX A,@DPTR; MOV P1,A; INC DPTR; DJNZ R2,AGAIN;
  • 17. BRANCHING INSTRUCTIONS Program branching instructions are used to control the flow of actions in program. Some instructions provide decision making capabilities and transfer control to other parts of program. eg., Unconditional and conditional branches.
  • 18. SJUMP(short jump): 2 byte instruction 1st byte opcode 2nd byte relative address of target location relative address range is 00 – FFH, All conditional jumps are short jumps Ex: SJUMP HERE; after executing this instruction it jumps to HERE label
  • 19.
  • 20. LJUMP(long jump): Unconditional long jump 3byte instruction 1st byte for op-code 2nd and 3rd byte for 16 bit address of target location
  • 22. JZ AND JNZ INSTRUCTIONS JZ label ; jump if A=0 Can be used only for register A, not any other register. flag registers will not be affected JNZ label; jump if A is not zero
  • 23. DJNZ INSTRUCTION DJNZ reg, Label; The register is decremented. If it is not zero, it jumps to the target address referred to by the label. Prior to the start of loop the register is loadel with the counter for the number of repetitions. Counter can be R0 – R7 or RAM location.
  • 24. Example Program to complement the accumulator 3 times ORG 0H; MOV A,0Fh; MOV R3,3; HERE: CPL A; DJNZ R3,HERE; END
  • 25. EXAMPLE: Write a program to (a) load the accumulator with the value 55H, and (b) complement the ACC 700 times. MOV A,#55H ;A=55H MOV R3,#10 ;R3=10, outer loop count NEXT: MOV R2,#70 ;R2=70, inner loop count AGAIN: CPL A ;complement A register DJNZ R2,AGAIN ;repeat it 70 times DJNZ R3,NEXT
  • 26. JNC INSTRUCTION JNC label ;jump if no carry, CY=0 If CY = 0, the CPU starts to fetch and execute instruction from the address of the label. If CY = 1, it will not jump but will execute the next instruction below JNC. All conditional jumps are short jumps The address of the target must within -128 to +127 bytes of the contents of PC
  • 28. CALL instructions To call a user defined functions in program Transfer control to a subroutine Flags are not affected RET must be the last instruction of subroutine These are two types 1) ACALL(absolute call) 2) LCALL (long call)
  • 29. ACALL: 2 byte instruction 5 bits are used for op-code remaining 11 bits are used for subroutine target address Target address must be within 2K byte Ex: ACALL label; here label address should be 2K byte only
  • 30. LCALL: 3 byte instruction 1st byte for op-code 2nd and 3rd for target address of the subroutine Subroutine address located anywhere within 64K byte Ex: LCALL label;
  • 31.
  • 32. Program to display 5 and 4 digits in seven segment display with delay: ORG 0H; MOV P1,#05DH; ACALL DELAY; MOV P1,#026H; ACALL DELAY; END; DELAY: MOV R3,#55; (count=55) HERE: DJNZ R3,HERE;(loop) RET;
  • 33. TIME DELAY CALCULATIONS ž CPU executing an instruction takes a certain number of clock cycles. These are referred as to as machine cycles. ž In original 8051, one machine cycle lasts 12 oscillator periods. ž Find the period of the machine cycle for 11.0592 MHz crystal frequency?
  • 34. ž Solution: 11.0592/12 = 921.6 kHz; machine cycle is 1/921.6 kHz = 1.085μs
  • 35. PROBLEM: ž For 8051 system of 11.0592 MHz, find how long it takes to execute each instruction. (a) MOV R3,#55 (b) DEC R3 (c) DJNZ R2 target (d) LJMP (e) SJMP (f) NOP (g) MUL AB
  • 37. Find the size of the delay in following program, if the crystal frequency is 11.0592MHz. MACHINE CYCLE DELAY: MOV R3,#250 1 HERE: NOP 1 NOP 1 NOP 1 NOP 1 DJNZ R3,HERE 2 RET 2
  • 38. SOLUTION ž The time delay inside HERE loop is [250(1+1+1+1+2)]x1.085μs = 1627.5μs. Adding the two instructions outside loop we have 1627.5μs + 3 x 1.085μs = 1630.755μs.