Skip to main content

ProgramCounter

Trait ProgramCounter 

Source
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§

Source

fn get_pc(&self) -> Address

Get the current value of the program counter

Source

fn set_pc( &mut self, memory: &Memory, pc: Address, ) -> Result<ControlFlow<()>, ProgramCounterError<Address, CustomError>>

Set the current value of the program counter

Provided Methods§

Source

fn old_pc(&self, instruction_size: u8) -> Address
where Address: From<u8> + Sub<Output = 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.

Implementors§

Source§

impl<I, Memory, CustomError> ProgramCounter<<<I as Instruction>::Reg as Register>::Type, Memory, CustomError> for BasicInstructionFetcher<I, CustomError>
where I: Instruction, Memory: VirtualMemory,