use crate::data::{ Wr, Rd, literal::Label, literal::RoutineName, literal::DebugMsg, }; use crate::instr::{Cond}; /// A higher level simple opration #[derive(Clone, Debug, Eq, PartialEq)] pub enum HLOp { /// Mark a jump target. Label(Label), /// Jump to a label Jump(Label), /// Jump to a label if a flag is set JumpIf(Cond, Label), /// Low level op L(Op), } /// A low level instruction #[derive(Clone, Debug, Eq, PartialEq)] pub enum Op { /// Do nothing Nop, /// Mark a far jump target (can be jumped to from another routine). /// This label is preserved in optimized code. FarLabel(Label), /// Jump to a label that can be in another function FarJump(Label), /// Call a routine with arguments. /// The arguments are passed as argX. Return values are stored in resX registers. Call(RoutineName, Vec), /// Exit the current routine with return values Ret(Vec), /// Mark a routine entry point (call target). /// Kept in the low level instruction file for position-independent code Routine(RoutineName), /// Skip backward or forward Skip(Rd), /// Skip if a flag is set SkipIf(Cond, Rd), /// Deny jumps, skips and run across this address, producing a run-time fault with a message. Barrier(Option), /// Generate a run-time fault with a debugger message Fault(Option), /* Arithmetic */ /// Copy a value Mov(Wr, Rd), /// Compare two values and set conditional flags. /// If the values are identical, evaluate if they are zero, positive, or negative (the "tst" op) Cmp(Rd, Rd), // Increment a value Inc(Wr), // Decrement a value Dec(Wr), // TODO arithmetics, bit manipulation, byte operations } /// Make "into" work impl From for HLOp { fn from(op: Op) -> Self { HLOp::L(op) } }