esil2reil.c
// General function for operations that take 2 operands
General function for operations that take 2 operands
General function for operations that take 2 operands
static int reil_binop(RAnalEsil *esil, RAnalReilOpcode opcode) {
	RAnalReilInst *ins;
	char tmp_buf[REGBUFSZ];
	ut8 dst_size;
	RAnalReilArg *op2, *op1;
	op2 = reil_pop_arg(esil);
	if (!op2) {
		return false;
	}
	op1 = reil_pop_arg(esil);
	if (!op1) {
		R_FREE (op2);
		return false;
	}
	ins = R_NEW0 (RAnalReilInst);
	if (!ins) {
		R_FREE (op1);
		R_FREE (op2);
		return false;
	}
	ins->opcode = opcode;
	ins->arg[0] = op2;
	ins->arg[1] = op1;
	if (!ins->arg[1]) {
		reil_free_inst (ins);
		return false;
	}
	ins->arg[2] = R_NEW0(RAnalReilArg);
	if (!ins->arg[2])  {
		reil_free_inst (ins);
		return false;
	}
	get_next_temp_reg(esil, tmp_buf);
	reil_make_arg(esil, ins->arg[2], tmp_buf);
	dst_size = ins->arg[0]->size;
	if (dst_size < ins->arg[1]->size) {
		dst_size = ins->arg[1]->size;
	}
	if (opcode == REIL_LT) {
		dst_size = 1;
	}
	ins->arg[2]->size = dst_size;
	reil_print_inst(esil, ins);
	reil_push_arg(esil, ins->arg[2]);
	reil_free_inst(ins);
	return true;
}
static int reil_binop ( RAnalEsil * esil , RAnalReilOpcode opcode ) { RAnalReilInst * ins ; char tmp_buf [ REGBUFSZ ] ; ut8 dst_size ; RAnalReilArg * op2 , * op1 ; op2 = reil_pop_arg ( esil ) ; if ( ! op2 ) { return false ; } op1 = reil_pop_arg ( esil ) ; if ( ! op1 ) { R_FREE ( op2 ) ; return false ; } ins = R_NEW0 ( RAnalReilInst ) ; if ( ! ins ) { R_FREE ( op1 ) ; R_FREE ( op2 ) ; return false ; } ins -> opcode = opcode ; ins -> arg [ 0 ] = op2 ; ins -> arg [ 1 ] = op1 ; if ( ! ins -> arg [ 1 ] ) { reil_free_inst ( ins ) ; return false ; } ins -> arg [ 2 ] = R_NEW0 ( RAnalReilArg ) ; if ( ! ins -> arg [ 2 ] ) { reil_free_inst ( ins ) ; return false ; } get_next_temp_reg ( esil , tmp_buf ) ; reil_make_arg ( esil , ins -> arg [ 2 ] , tmp_buf ) ; dst_size = ins -> arg [ 0 ] -> size ; if ( dst_size < ins -> arg [ 1 ] -> size ) { dst_size = ins -> arg [ 1 ] -> size ; } if ( opcode == REIL_LT ) { dst_size = 1 ; } ins -> arg [ 2 ] -> size = dst_size ; reil_print_inst ( esil , ins ) ; reil_push_arg ( esil , ins -> arg [ 2 ] ) ; reil_free_inst ( ins ) ; return true ; }
General function for operations that take 2 operands
General function for operations that take 2 operands
// Choose the larger of the two sizes as the size of dst // REIL_LT has a dst_size of 1.