InstrBuilder

Struct InstrBuilder 

Source
pub struct InstrBuilder { /* private fields */ }
Expand description

Builder for microcode.

Implementations§

Source§

impl InstrBuilder

Source

pub fn new() -> Self

Create a new empty builder.

Source

pub fn first(code: impl Into<InstrBuilder>) -> Self

Create a new builder with the given initial instructions.

Source

pub fn yield() -> Self

Create a builder containing just a yield.

Source

pub fn cond( code_if_true: impl Into<InstrBuilder>, code_if_false: impl Into<InstrBuilder>, ) -> Self

Source

pub fn if_true(code_if_true: impl Into<InstrBuilder>) -> Self

Pop a single byte boolean off the microcode stack and run this if it is true.

Source

pub fn if_false(code_if_false: impl Into<InstrBuilder>) -> Self

Pop a single byte boolean off the microcode stack and run this if it is false.

Source

pub fn then_cond( self, code_if_true: impl Into<InstrBuilder>, code_if_false: impl Into<InstrBuilder>, ) -> Self

Chooses between two branches depending on whether the u8 on top of the stack is non-zero.

Source

pub fn then_if_true(self, code_if_true: impl Into<InstrBuilder>) -> Self

Run the given code if the u8 on top of the stack is non-zero.

Source

pub fn then_if_false(self, code_if_false: impl Into<InstrBuilder>) -> Self

Run the given code if the u8 on top of the stack is zero.

Source

pub fn read<R: MicrocodeReadable>(from: R) -> Self

Create a single-step microcode that reads from the specified source.

Source

pub fn write<W: MicrocodeWritable>(to: W) -> Self

Create a single-step microcode that writes to the specified source.

Source

pub fn then(self, code: impl Into<InstrBuilder>) -> Self

Add the given instruction or instructions to the end of this microcode.

Source

pub fn then_yield(self) -> Self

Add a yield to the end of the builder.

Source

pub fn then_read<R: MicrocodeReadable>(self, from: R) -> Self

Add a read to the end of the builder.

Source

pub fn then_write<W: MicrocodeWritable>(self, to: W) -> Self

Add a write to the end of the builder.

Source

pub fn build(self, id: InstrId) -> InstrDef

Build an instruction from this microcode, adding the id for the instruction.

Trait Implementations§

Source§

impl Clone for InstrBuilder

Source§

fn clone(&self) -> InstrBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InstrBuilder

Source§

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

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

impl Default for InstrBuilder

Source§

fn default() -> InstrBuilder

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

impl From<AluOp> for InstrBuilder

Builds the microcode for a single ALU operation. This assumes that the ALU operation’s single u8 arg is already on the stack and handles fetching the accumulator and flags (if needed) and applying the results.

Source§

fn from(op: AluOp) -> Self

Converts to this type from the input type.
Source§

impl From<AluUnaryOp> for InstrBuilder

Builds the microcode for a single ALU unary operation. This handles reading the accumulator and flags as needed, and handles applying the results.

Source§

fn from(value: AluUnaryOp) -> Self

Converts to this type from the input type.
Source§

impl From<HandleHalt> for InstrBuilder

Source§

fn from(_: HandleHalt) -> Self

Converts to this type from the input type.
Source§

impl From<LoadAndExecute> for InstrBuilder

Source§

fn from(_: LoadAndExecute) -> Self

Converts to this type from the input type.
Source§

impl From<Microcode> for InstrBuilder

Source§

fn from(value: Microcode) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<InstrBuilder>> From<Option<T>> for InstrBuilder

Source§

fn from(value: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl From<ServiceInterrupt> for InstrBuilder

Source§

fn from(_: ServiceInterrupt) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.