[][src]Struct pir_8_emu::isa::SpecialPurposeRegister

pub struct SpecialPurposeRegister<T: Num + Unsigned + PrimInt> { /* fields omitted */ }

There are some special purpose registers that you cannot directly read/write from, these are used by the CPU for its internal state.

All the registers will start with an initial value of 0.

There are three 16-bit registers for holding significant memory addresses and a single 8-bit register.

NameShortBitsDescription
Program CounterPC16Address of the next instruction to be fetched
Stack PointerSP16Current address of the stack (detailed later)
Memory AddressADR16Address saved for use during certain instructions
InstructionINS8Instruction currently being executed

The address bus is controlled by either PC, SP or ADR.

As the CPU is reading an instruction from system memory, the value of the PC will be used, for some instructions though, such as JUMP or STACK, it is value of ADR or SP (respectively) that is used.

Methods

impl<T: Num + Unsigned + PrimInt> SpecialPurposeRegister<T>[src]

pub fn new(name: &'static str, short: &'static str) -> SpecialPurposeRegister<T>[src]

Create a new, empty register named as specified.

Examples

let pc = SpecialPurposeRegister::<u16>::new("Program Counter", "PC");
assert_eq!(*pc, 0);
assert_eq!(pc.name(), "Program Counter");
assert_eq!(pc.short_name(), "PC");

pub fn name(&self) -> &'static str[src]

The full name of this register

E.g. "Program Counter"

pub fn short_name(&self) -> &'static str[src]

The short/mnemonical name of this register

E.g. "PC"

Trait Implementations

impl<T: Clone + Num + Unsigned + PrimInt> Clone for SpecialPurposeRegister<T>[src]

impl<T: Copy + Num + Unsigned + PrimInt> Copy for SpecialPurposeRegister<T>[src]

impl<T: Debug + Num + Unsigned + PrimInt> Debug for SpecialPurposeRegister<T>[src]

impl<T: Num + Unsigned + PrimInt> Deref for SpecialPurposeRegister<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: Num + Unsigned + PrimInt> DerefMut for SpecialPurposeRegister<T>[src]

impl<T: Num + Unsigned + PrimInt + Display + UpperHex> Display for SpecialPurposeRegister<T>[src]

impl<T: Eq + Num + Unsigned + PrimInt> Eq for SpecialPurposeRegister<T>[src]

impl<T: Hash + Num + Unsigned + PrimInt> Hash for SpecialPurposeRegister<T>[src]

impl<T: Ord + Num + Unsigned + PrimInt> Ord for SpecialPurposeRegister<T>[src]

impl<T: PartialEq + Num + Unsigned + PrimInt> PartialEq<SpecialPurposeRegister<T>> for SpecialPurposeRegister<T>[src]

impl<T: PartialOrd + Num + Unsigned + PrimInt> PartialOrd<SpecialPurposeRegister<T>> for SpecialPurposeRegister<T>[src]

impl<T: Num + Unsigned + PrimInt> ReadWritable for SpecialPurposeRegister<T>[src]

impl<T: Num + Unsigned + PrimInt> StructuralEq for SpecialPurposeRegister<T>[src]

impl<T: Num + Unsigned + PrimInt> StructuralPartialEq for SpecialPurposeRegister<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for SpecialPurposeRegister<T> where
    T: RefUnwindSafe

impl<T> !Send for SpecialPurposeRegister<T>

impl<T> !Sync for SpecialPurposeRegister<T>

impl<T> Unpin for SpecialPurposeRegister<T> where
    T: Unpin

impl<T> UnwindSafe for SpecialPurposeRegister<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.