Struct PSR

Source
pub struct PSR(/* private fields */);
Expand description

A wrapper over u16 in order to faciliate the PSR.

The word is encoded as the following:

  • PSR[15..16]: Privilege mode (0 = supervisor, 1 = user)
  • PSR[8..11]: Interrupt priority
  • PSR[0..3]: Condition codes
        privilege
        |     interrupt priority
        |     |         condition codes
        |     |         |
        V     V         V
0x8002: 1000 0000 0000 0010
        ~     ~~~       ~~~

Each of these are exposed as the PSR::privileged, PSR::priority, and PSR::cc values.

Implementations§

Source§

impl PSR

Source

pub fn new() -> Self

Creates a PSR with a default value (user mode, z condition code).

Source

pub fn privileged(&self) -> bool

Checks whether the simulator is in privileged mode.

  • true = supervisor mode
  • false = user mode
Source

pub fn priority(&self) -> u8

Checks the current interrupt priority of the simulator.

Source

pub fn cc(&self) -> u8

Checks the condition code of the simulator.

Source

pub fn is_n(&self) -> bool

Checks the condition code of the simulator is n.

Source

pub fn is_z(&self) -> bool

Checks the condition code of the simulator is z.

Source

pub fn is_p(&self) -> bool

Checks the condition code of the simulator is p.

Source

pub fn get(&self) -> u16

Gets the bit-representation of the PSR.

Source

pub fn set(&mut self, data: u16)

Sets the PSR to the provided data value.

Source

pub fn set_privileged(&mut self, privl: bool)

Sets whether the simulator is in privileged mode.

Source

pub fn set_priority(&mut self, prio: u8)

Sets the current interrupt priority of the simulator.

Source

pub fn set_cc(&mut self, cc: u8)

Sets the condition code of the simulator.

Source

pub fn set_cc_n(&mut self)

Sets the condition code of the simulator to n.

Source

pub fn set_cc_z(&mut self)

Sets the condition code of the simulator to z.

Source

pub fn set_cc_p(&mut self)

Sets the condition code of the simulator to p.

Trait Implementations§

Source§

impl Debug for PSR

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PSR

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for PSR

§

impl RefUnwindSafe for PSR

§

impl Send for PSR

§

impl Sync for PSR

§

impl Unpin for PSR

§

impl UnwindSafe for PSR

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V