[−][src]Struct pir_8_emu::isa::SpecialPurposeRegister
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.
Name | Short | Bits | Description |
---|---|---|---|
Program Counter | PC | 16 | Address of the next instruction to be fetched |
Stack Pointer | SP | 16 | Current address of the stack (detailed later) |
Memory Address | ADR | 16 | Address saved for use during certain instructions |
Instruction | INS | 8 | Instruction 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]
fn clone(&self) -> SpecialPurposeRegister<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
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]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Ord + Num + Unsigned + PrimInt> Ord for SpecialPurposeRegister<T>
[src]
fn cmp(&self, other: &SpecialPurposeRegister<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq + Num + Unsigned + PrimInt> PartialEq<SpecialPurposeRegister<T>> for SpecialPurposeRegister<T>
[src]
fn eq(&self, other: &SpecialPurposeRegister<T>) -> bool
[src]
fn ne(&self, other: &SpecialPurposeRegister<T>) -> bool
[src]
impl<T: PartialOrd + Num + Unsigned + PrimInt> PartialOrd<SpecialPurposeRegister<T>> for SpecialPurposeRegister<T>
[src]
fn partial_cmp(&self, other: &SpecialPurposeRegister<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &SpecialPurposeRegister<T>) -> bool
[src]
fn le(&self, other: &SpecialPurposeRegister<T>) -> bool
[src]
fn gt(&self, other: &SpecialPurposeRegister<T>) -> bool
[src]
fn ge(&self, other: &SpecialPurposeRegister<T>) -> bool
[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,
T: RefUnwindSafe,
impl<T> !Send for SpecialPurposeRegister<T>
impl<T> !Sync for SpecialPurposeRegister<T>
impl<T> Unpin for SpecialPurposeRegister<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SpecialPurposeRegister<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
[src]
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
[src]
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
[src]
fn as_any(&self) -> &(dyn Any + 'static)
[src]
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,