rust opcodes

This commit is contained in:
tali 2023-12-17 16:01:18 -05:00
parent d65bef661e
commit 509ccc132d
1 changed files with 16 additions and 16 deletions

View File

@ -1,6 +1,6 @@
use std::fmt; use std::fmt;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[repr(transparent)] #[repr(transparent)]
pub struct Reg(pub u16); pub struct Reg(pub u16);
@ -16,11 +16,11 @@ pub struct ConstIdx(pub u16);
impl fmt::Display for ConstIdx { impl fmt::Display for ConstIdx {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({})", self.0) write!(f, "K{}", self.0)
} }
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum ArgV { pub enum ArgV {
R(Reg), R(Reg),
K(ConstIdx), K(ConstIdx),
@ -35,7 +35,7 @@ impl fmt::Display for ArgV {
} }
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum ArgL { pub enum ArgL {
SubI(Reg, i16), SubI(Reg, i16),
SubR(Reg, Reg), SubR(Reg, Reg),
@ -50,11 +50,11 @@ impl fmt::Display for ArgL {
} }
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum Ins { pub enum Ins {
O(InsO, i32),
V(InsV, ArgV), V(InsV, ArgV),
RV(InsRV, Reg, ArgV), RV(InsRV, Reg, ArgV),
O(InsO, i32),
RL(InsRL, Reg, ArgL), RL(InsRL, Reg, ArgL),
LV(InsLV, ArgL, ArgV), LV(InsLV, ArgL, ArgV),
RRK(InsRRK, Reg, Reg, ConstIdx), RRK(InsRRK, Reg, Reg, ConstIdx),
@ -77,40 +77,40 @@ impl fmt::Display for Ins {
} }
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum InsV { pub enum InsV {
RET, RET,
BTR, BTR,
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum InsRV { pub enum InsRV {
Op(Opr), Op(Opr),
Br(Cmp), Br(Cmp),
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum InsO {
JMP,
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum InsRL { pub enum InsRL {
Get(Opr), Get(Opr),
CAL(u16), CAL(u16),
RETCAL(u16), RETCAL(u16),
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum InsLV { pub enum InsLV {
Set(Opr), Set(Opr),
} }
#[derive(Copy, Clone, Eq, PartialEq)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum InsRRK { pub enum InsRRK {
LOC, LOC,
} }
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum InsO {
JMP,
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub enum Opr { pub enum Opr {
MOV, MOV,