When an 8051 is first initialized,
Conditional Branching:
It causes program execution to follow a non-sequential path if a certain condition is true.
For example, JB instruction
Line 1: JB 35h, TEST
Line 2: NOP
Line 3: TEST:…
While executing Line 1, 8051 will analyze the content of bit 35h. If the bit is set, program execution will jump to Line 3 skipping Line 2. If the bit is not set, program execution will be sequential Line 2 and then Line 3.
Conditional branching causes the program to jump within 128 bytes prior to or 127 bytes flowing the address of conditional branch instruction.
Direct Jumps:
It causes program flow to change unconditionally.
For example, LJMP instruction
LJMP TO_THIS_ADDRESS
.
.
.
.
TO_THIS_ADDRESS:…
When the 8051 executes this instruction the PC is loaded with the address of TO_THIS_ADDRESS and program execution continues sequentially from there.
Direct Calls:
Calling a subroutine, instruction like LCALL, causes the program flow to change. When the 8051 executes an LCALL instruction it immediately pushes the current Program Counter onto the stack and then continues executing code at the address indicated by the LCALL instruction.
Return from Routines:
RET instruction causes the program flow to change. When 8051 executes an RET instruction it return to the address that called the given subroutine. 8051 fetch the address from stack and loads it on PC.
Interrupts:
When an interrupt is triggered, event occurs, 8051 temporarily puts on-hold the normal program execution and starts executing interrupt handler mapped to the interrupt. After it finished executing interrupt handler, it resumes normal program execution.
- It resets the PC to 0000h
- 8051 execute instruction sequentially in memory
- Various instructions and Interrupts can modify the program flow
Conditional Branching:
It causes program execution to follow a non-sequential path if a certain condition is true.
For example, JB instruction
Line 1: JB 35h, TEST
Line 2: NOP
Line 3: TEST:…
While executing Line 1, 8051 will analyze the content of bit 35h. If the bit is set, program execution will jump to Line 3 skipping Line 2. If the bit is not set, program execution will be sequential Line 2 and then Line 3.
Conditional branching causes the program to jump within 128 bytes prior to or 127 bytes flowing the address of conditional branch instruction.
Direct Jumps:
It causes program flow to change unconditionally.
For example, LJMP instruction
LJMP TO_THIS_ADDRESS
.
.
.
.
TO_THIS_ADDRESS:…
When the 8051 executes this instruction the PC is loaded with the address of TO_THIS_ADDRESS and program execution continues sequentially from there.
Direct Calls:
Calling a subroutine, instruction like LCALL, causes the program flow to change. When the 8051 executes an LCALL instruction it immediately pushes the current Program Counter onto the stack and then continues executing code at the address indicated by the LCALL instruction.
Return from Routines:
RET instruction causes the program flow to change. When 8051 executes an RET instruction it return to the address that called the given subroutine. 8051 fetch the address from stack and loads it on PC.
Interrupts:
When an interrupt is triggered, event occurs, 8051 temporarily puts on-hold the normal program execution and starts executing interrupt handler mapped to the interrupt. After it finished executing interrupt handler, it resumes normal program execution.
Related topics:
8051 Register Bank and Stack | 8051 Flags Bits | 8051 Timers | 8051 Serial Port | 8051 Interrupts
List of topics: 8051
No comments:
Post a Comment