fn emit_skip_if(&mut self, reg: X86Register, cc: ConditionCode, value: Operand) {
        // We'll use `di` as a scratch register for PC. Start by loading `self.pc + 2` into `di`
        // (assuming the test succeeds and we need to skip), then perform the comparison and cond.
        // branch over code that loads `self.pc` into `di` (in case the branch condition is not
        // fullfilled we'll load the non-skipping PC).

        // `mov di, <PC+2>`
        self.emit_raw(&[0x66, 0xBF]);
        self.code_buffer.write_u16::<LittleEndian>(self.pc + 2).unwrap();

        // `cmp <REG>, <VAL>`
        self.emit_op(reg, AluOp::Cmp, value);

        // Skip the `self.pc` load if the given `ConditionCode` is fullfilled.
        // `jX +<DIST>`
        let dist = 4;
        self.emit_raw(&[0x0F, 0x80 | cc as u8]);
        self.code_buffer.write_i32::<LittleEndian>(dist).unwrap();

        // Load `self.pc` into `di`
        // `mov di, <PC>`
        self.emit_raw(&[0x66, 0xBF]);
        self.code_buffer.write_u16::<LittleEndian>(self.pc).unwrap();

        // Store PC in `ChipState`
        let offset = self.calc_offset(|state| &state.pc);
        // `mov [rsi + <OFFSET>], di`
        self.emit_raw(&[0x66, 0x89, 0xBE]);
        // FIXME check offset validity
        self.code_buffer.write_i32::<LittleEndian>(offset.bytes as i32).unwrap();
    }
/// Emits code to compare `reg` against `value` and load PC with `self.pc` or `self.pc + 2`
/// depending on a `ConditionCode`.
///
/// This should only be used for terminating instructions.


This should only be used for terminating instructions.
This should only be used for terminating instructions .
fn emit_skip_if(&mut self, reg: X86Register, cc: ConditionCode, value: Operand) {
        // We'll use `di` as a scratch register for PC. Start by loading `self.pc + 2` into `di`
        // (assuming the test succeeds and we need to skip), then perform the comparison and cond.
        // branch over code that loads `self.pc` into `di` (in case the branch condition is not
        // fullfilled we'll load the non-skipping PC).
        // `mov di, <PC+2>`
        self.emit_raw(&[0x66, 0xBF]);
        self.code_buffer.write_u16::<LittleEndian>(self.pc + 2).unwrap();
        // `cmp <REG>, <VAL>`
        self.emit_op(reg, AluOp::Cmp, value);
        // Skip the `self.pc` load if the given `ConditionCode` is fullfilled.
        // `jX +<DIST>`
        let dist = 4;
        self.emit_raw(&[0x0F, 0x80 | cc as u8]);
        self.code_buffer.write_i32::<LittleEndian>(dist).unwrap();
        // Load `self.pc` into `di`
        // `mov di, <PC>`
        self.emit_raw(&[0x66, 0xBF]);
        self.code_buffer.write_u16::<LittleEndian>(self.pc).unwrap();
        // Store PC in `ChipState`
        let offset = self.calc_offset(|state| &state.pc);
        // `mov [rsi + <OFFSET>], di`
        self.emit_raw(&[0x66, 0x89, 0xBE]);
        // FIXME check offset validity
        self.code_buffer.write_i32::<LittleEndian>(offset.bytes as i32).unwrap();
    }
fn emit_skip_if ( & mut self , reg : X86Register , cc : ConditionCode , value : Operand ) { // We'll use `di` as a scratch register for PC. Start by loading `self.pc + 2` into `di` // (assuming the test succeeds and we need to skip), then perform the comparison and cond. // branch over code that loads `self.pc` into `di` (in case the branch condition is not // fullfilled we'll load the non-skipping PC). // `mov di, <PC+2>` self . emit_raw ( & [ 0x66 , 0xBF ] ) ; self . code_buffer . write_u16 :: < LittleEndian > ( self . pc + 2 ) . unwrap ( ) ; // `cmp <REG>, <VAL>` self . emit_op ( reg , AluOp :: Cmp , value ) ; // Skip the `self.pc` load if the given `ConditionCode` is fullfilled. // `jX +<DIST>` let dist = 4 ; self . emit_raw ( & [ 0x0F , 0x80 | cc as u8 ] ) ; self . code_buffer . write_i32 :: < LittleEndian > ( dist ) . unwrap ( ) ; // Load `self.pc` into `di` // `mov di, <PC>` self . emit_raw ( & [ 0x66 , 0xBF ] ) ; self . code_buffer . write_u16 :: < LittleEndian > ( self . pc ) . unwrap ( ) ; // Store PC in `ChipState` let offset = self . calc_offset ( | state | & state . pc ) ; // `mov [rsi + <OFFSET>], di` self . emit_raw ( & [ 0x66 , 0x89 , 0xBE ] ) ; // FIXME check offset validity self . code_buffer . write_i32 :: < LittleEndian > ( offset . bytes as i32 ) . unwrap ( ) ; }
Emits code to compare `reg` against `value` and load PC with `self.pc` or `self.pc + 2`
depending on a `ConditionCode`.
Emits code to compare ` reg ` against ` value ` and load PC with ` self . pc ` or ` self . pc + 2 ` depending on a ` ConditionCode ` .
&mut self
reg
X86Register
cc
ConditionCode
value
Operand
&mut self
reg
X86Register
cc
ConditionCode
value
Operand