chapter 3 jump, loop and call instructions
DESCRIPTION
Chapter 3 JUMP, LOOP and CALL Instructions. Outlines. Loop instructions Conditional jump instructions Conditions determining conditional jump Unconditional long & short jumps Calculate target addresses for jumps Subroutines Using stack in subroutines Crystal frequency vs. machine cycle - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/1.jpg)
11
Suranaree UniversitySuranaree UniversityOf TechnologyOf Technologyมทสมทส
2002 Anant Oonsivilai2002 Anant Oonsivilai
Chapter 3Chapter 3JUMP, LOOP and CALL JUMP, LOOP and CALL
InstructionsInstructions
![Page 2: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/2.jpg)
22 2002 Anant Oonsivilai2002 Anant Oonsivilai
OutlinesOutlines
Loop instructionsLoop instructionsConditional jump instructionsConditional jump instructionsConditions determining conditional jumpConditions determining conditional jumpUnconditional long & short jumpsUnconditional long & short jumpsCalculate target addresses for jumpsCalculate target addresses for jumpsSubroutinesSubroutinesUsing stack in subroutinesUsing stack in subroutinesCrystal frequency vs. machine cycleCrystal frequency vs. machine cycleCode programs to generate time delayCode programs to generate time delay
![Page 3: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/3.jpg)
33 2002 Anant Oonsivilai2002 Anant Oonsivilai
LoopingLooping- DJNZ
![Page 4: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/4.jpg)
44 2002 Anant Oonsivilai2002 Anant Oonsivilai
Loop inside a Loop (Nested Loop inside a Loop (Nested Loop)Loop)
![Page 5: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/5.jpg)
55 2002 Anant Oonsivilai2002 Anant Oonsivilai
8051 Conditional Jump Instructions8051 Conditional Jump Instructions
![Page 6: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/6.jpg)
66 2002 Anant Oonsivilai2002 Anant Oonsivilai
Conditional Jump ExampleConditional Jump Example
- JNZ , JNC
![Page 7: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/7.jpg)
77 2002 Anant Oonsivilai2002 Anant Oonsivilai
Conditional Jump ExampleConditional Jump Example
![Page 8: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/8.jpg)
88 2002 Anant Oonsivilai2002 Anant Oonsivilai
Unconditional Jump InstructionsUnconditional Jump Instructions
All conditional jumps are short jumpsAll conditional jumps are short jumps Target address within -128 to +127 of PCTarget address within -128 to +127 of PC
LJMPLJMP (long jump): 3-byte instruction (long jump): 3-byte instruction 2-byte target address: 0000 to FFFFH2-byte target address: 0000 to FFFFH Original 8051 has only 4KB on-chip ROMOriginal 8051 has only 4KB on-chip ROM
SJMPSJMP (short jump): 2-byte instruction (short jump): 2-byte instruction 1-byte relative address: -128 to +1271-byte relative address: -128 to +127
![Page 9: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/9.jpg)
99 2002 Anant Oonsivilai2002 Anant Oonsivilai
Calculating Short Jump AddressesCalculating Short Jump Addresses
![Page 10: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/10.jpg)
1010 2002 Anant Oonsivilai2002 Anant Oonsivilai
Calculating Short Jump AddressesCalculating Short Jump Addresses
![Page 11: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/11.jpg)
1111 2002 Anant Oonsivilai2002 Anant Oonsivilai
Call InstructionsCall Instructions
LCALLLCALL (long call): 3-byte instruction (long call): 3-byte instruction 2-byte address2-byte address Target address within 64K-byte rangeTarget address within 64K-byte range
ACALLACALL (absolute call): 2-byte instruction (absolute call): 2-byte instruction 11-bit address11-bit address Target address within 2K-byte rangeTarget address within 2K-byte range
![Page 12: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/12.jpg)
1212 2002 Anant Oonsivilai2002 Anant Oonsivilai
LCALLLCALL
![Page 13: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/13.jpg)
1313 2002 Anant Oonsivilai2002 Anant Oonsivilai
CALL Instruction & Role of StackCALL Instruction & Role of Stack
![Page 14: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/14.jpg)
1414 2002 Anant Oonsivilai2002 Anant Oonsivilai
CALL Instruction & Role of StackCALL Instruction & Role of Stack
![Page 15: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/15.jpg)
1515 2002 Anant Oonsivilai2002 Anant Oonsivilai
Using PUSH & POP in SubroutinesUsing PUSH & POP in Subroutines
![Page 16: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/16.jpg)
1616 2002 Anant Oonsivilai2002 Anant Oonsivilai
Using PUSH & POP in SubroutinesUsing PUSH & POP in Subroutines
![Page 17: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/17.jpg)
1717 2002 Anant Oonsivilai2002 Anant Oonsivilai
Using PUSH & POP in SubroutinesUsing PUSH & POP in Subroutines
![Page 18: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/18.jpg)
1818 2002 Anant Oonsivilai2002 Anant Oonsivilai
Calling SubroutinesCalling Subroutines
![Page 19: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/19.jpg)
1919 2002 Anant Oonsivilai2002 Anant Oonsivilai
Calling SubroutinesCalling Subroutines
![Page 20: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/20.jpg)
2020 2002 Anant Oonsivilai2002 Anant Oonsivilai
ACALL (absolute call)ACALL (absolute call)
![Page 21: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/21.jpg)
2121 2002 Anant Oonsivilai2002 Anant Oonsivilai
Programming EfficientlyProgramming Efficiently
![Page 22: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/22.jpg)
2222 2002 Anant Oonsivilai2002 Anant Oonsivilai
Time Delay Generation & CalculationTime Delay Generation & Calculation
1 instruction = 1 instruction = nn machine cycle machine cycle
1 machine cycle = 12 clock cycles1 machine cycle = 12 clock cycles
![Page 23: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/23.jpg)
2323 2002 Anant Oonsivilai2002 Anant Oonsivilai
Delay CalculationDelay Calculation
![Page 24: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/24.jpg)
2424 2002 Anant Oonsivilai2002 Anant Oonsivilai
Delay Calculation ExampleDelay Calculation Example
![Page 25: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/25.jpg)
2525 2002 Anant Oonsivilai2002 Anant Oonsivilai
Delay Calculation ExampleDelay Calculation Example
![Page 26: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/26.jpg)
2626 2002 Anant Oonsivilai2002 Anant Oonsivilai
Increasing Delay Using NOPIncreasing Delay Using NOP
![Page 27: Chapter 3 JUMP, LOOP and CALL Instructions](https://reader036.vdocuments.mx/reader036/viewer/2022081418/56813328550346895d9a1499/html5/thumbnails/27.jpg)
2727 2002 Anant Oonsivilai2002 Anant Oonsivilai
Large Delay Using Nested LoopLarge Delay Using Nested Loop