Title: Chapter 3 JUMP, LOOP and CALL Instructions
1Chapter 3JUMP, LOOP and CALL Instructions
2Outlines
- 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
- Code programs to generate time delay
3Looping
- DJNZ
4Loop inside a Loop (Nested Loop)
58051 Conditional Jump Instructions
6Conditional Jump Example
- JNZ , JNC
7Conditional Jump Example
8Unconditional Jump Instructions
- All conditional jumps are short jumps
- Target address within -128 to 127 of PC
- LJMP (long jump) 3-byte instruction
- 2-byte target address 0000 to FFFFH
- Original 8051 has only 4KB on-chip ROM
- SJMP (short jump) 2-byte instruction
- 1-byte relative address -128 to 127
9Calculating Short Jump Addresses
10Calculating Short Jump Addresses
11Call Instructions
- LCALL (long call) 3-byte instruction
- 2-byte address
- Target address within 64K-byte range
- ACALL (absolute call) 2-byte instruction
- 11-bit address
- Target address within 2K-byte range
12LCALL
13CALL Instruction Role of Stack
14CALL Instruction Role of Stack
15Using PUSH POP in Subroutines
16Using PUSH POP in Subroutines
17Using PUSH POP in Subroutines
18Calling Subroutines
19Calling Subroutines
20ACALL (absolute call)
21Programming Efficiently
22Time Delay Generation Calculation
- 1 instruction n ? machine cycle
- 1 machine cycle 12 clock cycles
23Delay Calculation
24Delay Calculation Example
25Delay Calculation Example
26Increasing Delay Using NOP
27Large Delay Using Nested Loop