[−][src]Struct pir_8_emu::isa::GeneralPurposeRegister
There are eight 8-bit General Purpose registers, each has an internal address for use within the CPU, instructions like MOVE and LOAD can use these addresses.
All the registers will start with an initial value of 0
.
There are eight 8-bit General Purpose registers, each has an internal address for use within the CPU, instructions like MOVE and LOAD can use these addresses. The first five registers have some special functionality, as described, the last three have no special functionality. The last four registers can also be used with the stack.
Address | Letter | Description |
---|---|---|
000 | F | Flag register (can also be used to get a zero value) |
001 | S | Output of the ALU - ALU operations will overwrite any value stored |
010 | X | Input to ALU (Only input for unary operations) |
011 | Y | Second input for ALU |
100 | A | Port number for PORT instruction |
101 | B | |
110 | C | |
111 | D |
Flag register
The flag register can be be read and written to as a general purpose register, though keep in mind that ALU and Compare instructions can effect the value of the flags.
Not all of the bits have a specified role (yet), though the CLRF operation will still clear them.
A value of 1
denotes the flag as 'set', whilst a value of 0
denotes the flag is 'unset'.
Below is a description of what each bit in the flag register denotes.
Bit | Letter | Description |
---|---|---|
0 | Z | Zero flag |
1 | C | Carry flag |
2 | P | Parity (even number of set bits) |
3 | E | Equals flag |
4 | G | Greater than |
5 | ||
6 | ||
7 |
Methods
impl GeneralPurposeRegister
[src]
pub fn new(address: u8, letter: char) -> Option<GeneralPurposeRegister>
[src]
Create a new, empty register named as specified.
Examples
let x = GeneralPurposeRegister::new(0b010, 'X').unwrap(); assert_eq!(*x, 0); assert_eq!(x.address(), 0b010); assert_eq!(x.letter(), 'X'); assert_eq!(GeneralPurposeRegister::new(0b1000, 'Q'), None);
pub fn address(self) -> u8
[src]
The address for this register
Limited to 3 bits' width
pub fn letter(self) -> char
[src]
The letter/mnemonic for this register
E.g. "X"
pub fn relabel(&mut self, to_letter: char) -> Result<(), ()>
[src]
Change this register's letter to the specified one
Will return Err(())
if the letter isn't ASCII
impl GeneralPurposeRegister
[src]
pub fn defaults() -> GeneralPurposeRegisterBank
[src]
Get the default 8 GP registers specified in the ISA
pub fn from_letters(s: &str) -> Result<GeneralPurposeRegisterBank, i8>
[src]
Create a GP register bank from letters contained within the specified string
The string must be 8-ASCII-characters-long.
If it's shorter, Err(-1)
is returned,
if it's longer, Err(8)
is returned,
if character for register at address AAA
is non-ASCII, Err(AAA)
is returned,
Examples
assert_eq!(GeneralPurposeRegister::from_letters("FSXYABCD"), Ok(GeneralPurposeRegister::defaults()));
Trait Implementations
impl Clone for GeneralPurposeRegister
[src]
fn clone(&self) -> GeneralPurposeRegister
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for GeneralPurposeRegister
[src]
impl Debug for GeneralPurposeRegister
[src]
impl Deref for GeneralPurposeRegister
[src]
impl DerefMut for GeneralPurposeRegister
[src]
impl Display for GeneralPurposeRegister
[src]
impl Eq for GeneralPurposeRegister
[src]
impl Hash for GeneralPurposeRegister
[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 Ord for GeneralPurposeRegister
[src]
fn cmp(&self, other: &GeneralPurposeRegister) -> 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 PartialEq<GeneralPurposeRegister> for GeneralPurposeRegister
[src]
fn eq(&self, other: &GeneralPurposeRegister) -> bool
[src]
fn ne(&self, other: &GeneralPurposeRegister) -> bool
[src]
impl PartialOrd<GeneralPurposeRegister> for GeneralPurposeRegister
[src]
fn partial_cmp(&self, other: &GeneralPurposeRegister) -> Option<Ordering>
[src]
fn lt(&self, other: &GeneralPurposeRegister) -> bool
[src]
fn le(&self, other: &GeneralPurposeRegister) -> bool
[src]
fn gt(&self, other: &GeneralPurposeRegister) -> bool
[src]
fn ge(&self, other: &GeneralPurposeRegister) -> bool
[src]
impl ReadWritable for GeneralPurposeRegister
[src]
impl StructuralEq for GeneralPurposeRegister
[src]
impl StructuralPartialEq for GeneralPurposeRegister
[src]
Auto Trait Implementations
impl RefUnwindSafe for GeneralPurposeRegister
impl !Send for GeneralPurposeRegister
impl !Sync for GeneralPurposeRegister
impl Unpin for GeneralPurposeRegister
impl UnwindSafe for GeneralPurposeRegister
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> DowncastSync for T where
T: Send + Sync + Any,
[src]
T: Send + Sync + Any,
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>,