aboutsummaryrefslogblamecommitdiffhomepage
path: root/src/insn.rs
blob: 8351c5419473c3166dc04265a8409aec5a5df13a (plain) (tree)
1
2
3
4
5
6
7
8
9

        

        
        



                     
                                



                                      
                                     

                              
 
                  
                                               



                              
                                                               


                             
                     
                                 

                                      

                      



                                                                                              

                                       
mod add;
mod dec;
mod jmp;
mod jz;
mod mov;
mod ret;
mod test;

pub trait Add<T, U> {
    /// Emit an add instruction.
    fn add(&mut self, op1: T, op2: U);
}

pub trait Dec<T> {
    /// Emit a decrement instruction.
    fn dec(&mut self, op1: T);
}

pub trait Jmp<T> {
    /// Emit an unconditional jump instruction.
    fn jmp(&mut self, op1: T);
}

pub trait Jz<T> {
    /// Emit a conditional jump if zero instruction (`ZF = 1`).
    fn jz(&mut self, op1: T);
}

pub trait Mov<T, U> {
    /// Emit an move instruction.
    fn mov(&mut self, op1: T, op2: U);
}

pub trait Test<T, U> {
    /// Emit a logical compare instruction.
    ///
    /// Computes the bit-wise logical AND of first operand and the second operand and sets the
    /// `SF`, `ZF`, and `PF` status flags, the result is discarded.
    fn test(&mut self, op1: T, op2: U);
}