def __execute_sext(self, instr): """Execute SEXT instruction. """ op0_size = instr.operands[0].size op2_size = instr.operands[2].size op0_val = self.read_operand(instr.operands[0]) op0_msb = extract_sign_bit(op0_val, op0_size) op2_mask = (2**op2_size-1) & ~(2**op0_size-1) if op0_msb == 1 else 0x0 op2_val = op0_val | op2_mask self.write_operand(instr.operands[2], op2_val) return None
def __execute_bsh(self, instr): """Execute BSH instruction. """ op0_val = self.read_operand(instr.operands[0]) op1_val = self.read_operand(instr.operands[1]) op1_size = instr.operands[1].size # Check sign bit. if extract_sign_bit(op1_val, op1_size) == 0: op2_val = op0_val << op1_val else: op2_val = op0_val >> twos_complement(op1_val, op1_size) self.write_operand(instr.operands[2], op2_val) return None