Program flow Flashcards
What happens to the Program Counter (PC) during normal execution
The PC is incremented after each instruction enabling pipelining by overlapping instruction fetch and execution
What is pipelining in microprocessors
Pipelining overlaps the fetch and execute stages of instructions improving processing speed
What is an unconditional branch
A branch instruction that always changes the PC such as GOTO in PIC16F84A
How does a conditional branch work
It checks status bits and branches only if specific conditions are met allowing loops like for or while
What is an example of data-dependent branching
An if/else structure such as turning off a kettle if the temperature exceeds 100°C
What is absolute addressing
The destination address is directly specified in the instruction but may be limited by instruction size
How does relative addressing benefit program flow
It uses small offsets making code relocatable and more memory-efficient
What are skip instructions
They skip the next instruction if a condition is met without changing the PC directly
How does a subroutine call work
The current address is saved and the PC jumps to the subroutine address After execution the saved address is restored
What instructions manage subroutine calls in PIC16F84A
CALL saves return address and RETURN restores return address
What is the purpose of the stack in subroutine calls
To store return addresses registers and function arguments
What is an interrupt
An external or internal event that stops the main program triggering an interrupt service routine ISR
How does interrupt-driven I/O differ from program-controlled I/O
Interrupt-driven I/O responds immediately while program-controlled I/O continuously checks for events
What must be saved during an interrupt
The PC and register contents must be saved to the stack to ensure the main program resumes correctly
What is an exception in a microprocessor
An unexpected error that triggers an exception handler such as division by zero or memory access failures