[][src]Struct emulator::instruction::Instruction

pub struct Instruction { /* fields omitted */ }

Instruction of the 2i.

Represents a 25 bit wide instruction that the 2i uses. Provides some conveniance methods to extract all different parts.

Methods

impl Instruction[src]

pub fn new(instruction: u32) -> Result<Instruction>[src]

Create a new Instruction from a u32. Fails if more than 25 bits are used.

pub fn new_from_string(string: &str) -> Result<Instruction>[src]

Creat a new Instruction from a binary string (consisting only of ones and zeroes). Failes if more than 25 bits (characters) are used.

pub fn new_looping(address: usize) -> Result<Instruction>[src]

pub fn get_instruction(&self) -> u32[src]

Get the instruction as a 25 bit integer (the first 7 most significant bits of the u32 are always zero)

pub fn should_store_flags(&self) -> bool[src]

MCHFLG

pub fn get_alu_instruction(&self) -> u8[src]

MALUS0-3 (4 bit)

pub fn is_alu_input_b_const(&self) -> bool[src]

MALUIB

pub fn is_alu_input_a_bus(&self) -> bool[src]

MALUIA

pub fn should_write_register(&self) -> bool[src]

MRGWE

pub fn should_write_register_b(&self) -> bool[src]

MRGWS

pub fn get_register_address_b(&self) -> usize[src]

MRGAB0-2 (3 bit)

pub fn get_constant_input(&self) -> u8[src]

MRGAB0-3 (4 bit)

pub fn get_register_address_a(&self) -> usize[src]

MRGAA0-2 (3 bit)

pub fn is_bus_enabled(&self) -> bool[src]

BUSEN

pub fn is_bus_writable(&self) -> bool[src]

BUSWR

pub fn get_next_instruction_address(&self) -> u8[src]

NA0-4 (5 bit)

pub fn get_address_control(&self) -> u8[src]

MAC0-1 (2 bit)

pub fn get_full_address_control(&self) -> u8[src]

MAC1-0 + NA0 (3 bit)

pub fn to_mnemonic(&self, address: Option<usize>) -> String[src]

Create a textual representation of the instruction

Optionally, the address of the instruction inside the program can be passed to simplify the resulting string in many cases.

Examples

use emulator::Instruction;

let inst = Instruction::new(0b00_00001_00_000_0110_01_01_0100_0).unwrap();
assert_eq!("R0 = R0 + 6", &inst.to_mnemonic(Some(0)));

Trait Implementations

impl PartialEq<Instruction> for Instruction[src]

impl Clone for Instruction[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for Instruction[src]

impl Default for Instruction[src]

impl Debug for Instruction[src]

Auto Trait Implementations

impl Send for Instruction

impl Sync for Instruction

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.