[][src]Enum lc3_isa::Instruction

pub enum Instruction {
    AddReg {
        dr: Reg,
        sr1: Reg,
        sr2: Reg,
    },
    AddImm {
        dr: Reg,
        sr1: Reg,
        imm5: SignedWord,
    },
    AndReg {
        dr: Reg,
        sr1: Reg,
        sr2: Reg,
    },
    AndImm {
        dr: Reg,
        sr1: Reg,
        imm5: SignedWord,
    },
    Br {
        n: bool,
        z: bool,
        p: bool,
        offset9: SignedWord,
    },
    Jmp {
        base: Reg,
    },
    Jsr {
        offset11: SignedWord,
    },
    Jsrr {
        base: Reg,
    },
    Ld {
        dr: Reg,
        offset9: SignedWord,
    },
    Ldi {
        dr: Reg,
        offset9: SignedWord,
    },
    Ldr {
        dr: Reg,
        base: Reg,
        offset6: SignedWord,
    },
    Lea {
        dr: Reg,
        offset9: SignedWord,
    },
    Not {
        dr: Reg,
        sr: Reg,
    },
    Ret,
    Rti,
    St {
        sr: Reg,
        offset9: SignedWord,
    },
    Sti {
        sr: Reg,
        offset9: SignedWord,
    },
    Str {
        sr: Reg,
        base: Reg,
        offset6: SignedWord,
    },
    Trap {
        trapvec: u8,
    },
}

Variants

AddReg

Fields of AddReg

dr: Regsr1: Regsr2: Reg
AddImm

Fields of AddImm

dr: Regsr1: Regimm5: SignedWord
AndReg

Fields of AndReg

dr: Regsr1: Regsr2: Reg
AndImm

Fields of AndImm

dr: Regsr1: Regimm5: SignedWord
Br

Fields of Br

n: boolz: boolp: booloffset9: SignedWord
Jmp

Fields of Jmp

base: Reg
Jsr

Fields of Jsr

offset11: SignedWord
Jsrr

Fields of Jsrr

base: Reg
Ld

Fields of Ld

dr: Regoffset9: SignedWord
Ldi

Fields of Ldi

dr: Regoffset9: SignedWord
Ldr

Fields of Ldr

dr: Regbase: Regoffset6: SignedWord
Lea

Fields of Lea

dr: Regoffset9: SignedWord
Not

Fields of Not

dr: Regsr: Reg
Ret
Rti
St

Fields of St

sr: Regoffset9: SignedWord
Sti

Fields of Sti

sr: Regoffset9: SignedWord
Str

Fields of Str

sr: Regbase: Regoffset6: SignedWord
Trap

Fields of Trap

trapvec: u8

Implementations

impl Instruction[src]

pub const fn new_add_reg(dr: Reg, sr1: Reg, sr2: Reg) -> Self[src]

Creates a new ADD instruction (Instruction::AddReg) with two register sources. TODO!

println!("{:?}", Instruction::new_add_reg(R0, R1, R2));

pub const fn new_add_imm(dr: Reg, sr1: Reg, imm5: SignedWord) -> Self[src]

Creates a new ADD instruction (Instruction::AddImm) with a register source and a 5 bit signed immediate source ([-16, 16)).

This function will panic at compile time if it is invoked with an immediate value that isn't in bounds (and if the invocation is in a const context and the resulting value is used). TODO!

println!("{:?}", Instruction::new_add_imm(R0, R1, -16));
println!("{:?}", Instruction::new_add_imm(R0, R1, 15));
This example panics
println!("{:?}", Instruction::new_add_imm(R0, R1, 16));
This example panics
println!("{:?}", Instruction::new_add_imm(R0, R1, -17));

pub const fn new_and_reg(dr: Reg, sr1: Reg, sr2: Reg) -> Self[src]

Creates a new AND instruction (Instruction::AndReg) with two register sources. TODO!

println!("{:?}", Instruction::new_and_reg(R0, R1, R2));

pub const fn new_and_imm(dr: Reg, sr1: Reg, imm5: SignedWord) -> Self[src]

Creates a new AND instruction (Instruction::AndImm) with a register source and a 5 bit signed immediate source ([-16, 16)).

This function will panic at compile time if it is invoked with an immediate value that isn't in bounds (and if the invocation is in a const context and the resulting value is used). TODO!

println!("{:?}", Instruction::new_and_imm(R0, R1, -16));
println!("{:?}", Instruction::new_and_imm(R0, R1, 15));
This example panics
println!("{:?}", Instruction::new_and_imm(R0, R1, 16));
This example panics
println!("{:?}", Instruction::new_and_imm(R0, R1, -17));

pub const fn new_br(n: bool, z: bool, p: bool, offset9: SignedWord) -> Self[src]

Creates a new BR instruction (Instruction::Br) with the condition codes to branch on and a 9 bit signed PC-relative offset ([-256, 256)).

This function will panic at compile time if it is invoked with an offset value that isn't in bounds (and if the invocation is in a const context and the resulting value is used). TODO!

println!("{:?}", Instruction::new_br(true, true, true, 255));
println!("{:?}", Instruction::new_br(true, true, true, -256));
This example panics
println!("{:?}", Instruction::new_br(true, true, true, 256));
This example panics
println!("{:?}", Instruction::new_br(true, true, true, -257));
This example panics
println!("{:?}", Instruction::new_br(false, false, false, -1));

pub const fn new_jmp(base: Reg) -> Self[src]

Creates a new 'JMP' instruction ([Instruction::JMP]) with the provided base register. TODO!

println!("{:?}", Instruction::new_jmp(R7));

pub const fn new_jsr(offset11: SignedWord) -> Self[src]

Creates a new JSR instruction ([Instruction::JSR]) with the provided 11 bit signed PC-relative offset ([-1024, 1024)). TODO!

println!("{:?}", Instruction::new_jsr(1023));
println!("{:?}", Instruction::new_jsr(-1024));
This example panics
println!("{:?}", Instruction::new_jsr(1024));
This example panics
println!("{:?}", Instruction::new_jsr(-1025));

pub const fn new_jsrr(base: Reg) -> Self[src]

Creates a new 'JSRR' instruction ([Instruction::JSRR]) with the provided base register. TODO!

println!("{:?}", Instruction::new_jsrr(R6));

pub const fn new_ld(dr: Reg, offset9: SignedWord) -> Self[src]

pub const fn new_ldi(dr: Reg, offset9: SignedWord) -> Self[src]

pub const fn new_ldr(dr: Reg, base: Reg, offset6: SignedWord) -> Self[src]

pub const fn new_lea(dr: Reg, offset9: SignedWord) -> Self[src]

pub const fn new_not(dr: Reg, sr: Reg) -> Self[src]

pub const fn new_ret() -> Self[src]

Creates a new RET instruction ([Instruction::RET]) (equivalent to a JMP R7). TODO!

println!("{:?}", Instruction::new_ret());

pub const fn new_rti() -> Self[src]

Creates a new RTI instruction ([Instruction::RTI]). TODO!

println!("{:?}", Instruction::new_rti());

pub const fn new_st(sr: Reg, offset9: SignedWord) -> Self[src]

pub const fn new_sti(sr: Reg, offset9: SignedWord) -> Self[src]

pub const fn new_str(sr: Reg, base: Reg, offset6: SignedWord) -> Self[src]

pub const fn new_trap(trapvec: u8) -> Self[src]

impl Instruction[src]

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

impl Instruction[src]

pub fn to_word(&self) -> u16[src]

Trait Implementations

impl Clone for Instruction[src]

impl Copy for Instruction[src]

impl Debug for Instruction[src]

impl<'de> Deserialize<'de> for Instruction[src]

impl Display for Instruction[src]

impl Eq for Instruction[src]

impl From<Instruction> for Word[src]

impl Hash for Instruction[src]

impl PartialEq<Instruction> for Instruction[src]

We use the bit representation of Instruction for equality specifically so that Jmp { base: R7 } == RET. However, note that BR != BRnzp.

impl Serialize for Instruction[src]

impl TryFrom<u16> for Instruction[src]

type Error = Word

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.