pub trait ProgramCounter<Address, Memory, CustomError = CustomErrorPlaceholder> {
// Required methods
fn get_pc(&self) -> Address;
fn set_pc(
&mut self,
memory: &Memory,
pc: Address,
) -> Result<ControlFlow<()>, ProgramCounterError<Address, CustomError>>;
// Provided method
fn old_pc(&self, instruction_size: u8) -> Address
where Address: From<u8> + Sub<Output = Address> { ... }
}Expand description
Generic program counter
Required Methods§
Sourcefn set_pc(
&mut self,
memory: &Memory,
pc: Address,
) -> Result<ControlFlow<()>, ProgramCounterError<Address, CustomError>>
fn set_pc( &mut self, memory: &Memory, pc: Address, ) -> Result<ControlFlow<()>, ProgramCounterError<Address, CustomError>>
Set the current value of the program counter
Provided Methods§
Sourcefn old_pc(&self, instruction_size: u8) -> Address
fn old_pc(&self, instruction_size: u8) -> Address
Get the previous value of the program counter before executing an instruction.
This is usually called from under instruction execution when the program counter is already
advanced during instruction fetching. As such, pc - instruction_size is expected to never
underflow.