pub enum Instruction {
Show 19 variants
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
AddImm
AndReg
AndImm
Br
Jmp
Jsr
Fields
offset11: SignedWordJsrr
Ld
Ldi
Ldr
Lea
Not
Ret
Rti
St
Sti
Str
Trap
Implementations§
Source§impl Instruction
impl Instruction
Sourcepub const fn new_add_reg(dr: Reg, sr1: Reg, sr2: Reg) -> Self
pub const fn new_add_reg(dr: Reg, sr1: Reg, sr2: Reg) -> Self
Creates a new ADD instruction (Instruction::AddReg) with two
register sources.
TODO!
println!("{:?}", Instruction::new_add_reg(R0, R1, R2));Sourcepub const fn new_add_imm(dr: Reg, sr1: Reg, imm5: SignedWord) -> Self
pub const fn new_add_imm(dr: Reg, sr1: Reg, imm5: SignedWord) -> Self
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));println!("{:?}", Instruction::new_add_imm(R0, R1, 16));println!("{:?}", Instruction::new_add_imm(R0, R1, -17));Sourcepub const fn new_and_reg(dr: Reg, sr1: Reg, sr2: Reg) -> Self
pub const fn new_and_reg(dr: Reg, sr1: Reg, sr2: Reg) -> Self
Creates a new AND instruction (Instruction::AndReg) with two
register sources.
TODO!
println!("{:?}", Instruction::new_and_reg(R0, R1, R2));Sourcepub const fn new_and_imm(dr: Reg, sr1: Reg, imm5: SignedWord) -> Self
pub const fn new_and_imm(dr: Reg, sr1: Reg, imm5: SignedWord) -> Self
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));println!("{:?}", Instruction::new_and_imm(R0, R1, 16));println!("{:?}", Instruction::new_and_imm(R0, R1, -17));Sourcepub const fn new_br(n: bool, z: bool, p: bool, offset9: SignedWord) -> Self
pub const fn new_br(n: bool, z: bool, p: bool, offset9: SignedWord) -> Self
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));println!("{:?}", Instruction::new_br(true, true, true, 256));println!("{:?}", Instruction::new_br(true, true, true, -257));println!("{:?}", Instruction::new_br(false, false, false, -1));Sourcepub const fn new_jmp(base: Reg) -> Self
pub const fn new_jmp(base: Reg) -> Self
Creates a new ‘JMP’ instruction ([Instruction::JMP]) with the provided
base register.
TODO!
println!("{:?}", Instruction::new_jmp(R7));Sourcepub const fn new_jsr(offset11: SignedWord) -> Self
pub const fn new_jsr(offset11: SignedWord) -> Self
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));println!("{:?}", Instruction::new_jsr(1024));println!("{:?}", Instruction::new_jsr(-1025));Sourcepub const fn new_jsrr(base: Reg) -> Self
pub const fn new_jsrr(base: Reg) -> Self
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
pub const fn new_ldi(dr: Reg, offset9: SignedWord) -> Self
pub const fn new_ldr(dr: Reg, base: Reg, offset6: SignedWord) -> Self
pub const fn new_lea(dr: Reg, offset9: SignedWord) -> Self
pub const fn new_not(dr: Reg, sr: Reg) -> Self
Sourcepub const fn new_rti() -> Self
pub const fn new_rti() -> Self
Creates a new RTI instruction ([Instruction::RTI]).
TODO!
println!("{:?}", Instruction::new_rti());pub const fn new_st(sr: Reg, offset9: SignedWord) -> Self
pub const fn new_sti(sr: Reg, offset9: SignedWord) -> Self
pub const fn new_str(sr: Reg, base: Reg, offset6: SignedWord) -> Self
pub const fn new_trap(trapvec: u8) -> Self
Source§impl Instruction
impl Instruction
pub fn sets_condition_codes(&self) -> bool
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Instruction
impl Debug for Instruction
Source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for Instruction
impl Display for Instruction
Source§impl From<Instruction> for Word
impl From<Instruction> for Word
Source§fn from(ins: Instruction) -> u16
fn from(ins: Instruction) -> u16
Source§impl Hash for Instruction
impl Hash for Instruction
Source§impl PartialEq for Instruction
We use the bit representation of Instruction for equality specifically
so that Jmp { base: R7 } == RET. However, note that BR != BRnzp.
impl PartialEq for Instruction
We use the bit representation of Instruction for equality specifically
so that Jmp { base: R7 } == RET. However, note that BR != BRnzp.