Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
crsn/csn_asm/src/instr/op.rs

66 lines
1.7 KiB

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 {
/// 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<Rd>),
/// Exit the current routine with return values
Ret(Vec<Rd>),
/// 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<DebugMsg>),
/// Generate a run-time fault with a debugger message
Fault(Option<DebugMsg>),
/* Arithmetic */
/// Copy a value
Mov(Wr, Rd),
/// Compare two values and set conditional flags
Cmp(Rd, Rd),
// Increment a value
Inc(Wr),
// Decrement a value
Dec(Wr),
// TODO arithmetics, bit manipulation, byte operations
}
/// Make "into" work
impl From<Op> for HLOp {
fn from(op: Op) -> Self {
HLOp::L(op)
}
}