extractSize can be smaller than the register, generating an LLIL_LOWPART resultSize can be larger than the register, generating sign or zero extension
| 131 | // extractSize can be smaller than the register, generating an LLIL_LOWPART |
| 132 | // resultSize can be larger than the register, generating sign or zero extension |
| 133 | ExprId ExtractRegister(LowLevelILFunction& il, InstructionOperand& operand, size_t regNum, |
| 134 | size_t extractSize, bool signExtend, size_t resultSize) |
| 135 | { |
| 136 | size_t opsz = get_register_size(operand.reg[regNum]); |
| 137 | |
| 138 | if (IS_ZERO_REG(operand.reg[regNum])) |
| 139 | return il.Const(resultSize, 0); |
| 140 | |
| 141 | ExprId res = 0; |
| 142 | |
| 143 | switch (operand.operandClass) |
| 144 | { |
| 145 | case SYS_REG: |
| 146 | res = il.Register(opsz, operand.sysreg); |
| 147 | break; |
| 148 | case REG: |
| 149 | default: |
| 150 | res = il.Register(opsz, operand.reg[regNum]); |
| 151 | break; |
| 152 | } |
| 153 | |
| 154 | if (extractSize < opsz) |
| 155 | res = il.LowPart(extractSize, res); |
| 156 | |
| 157 | if (extractSize < resultSize || opsz < extractSize) |
| 158 | { |
| 159 | if (signExtend) |
| 160 | res = il.SignExtend(resultSize, res); |
| 161 | else |
| 162 | res = il.ZeroExtend(resultSize, res); |
| 163 | } |
| 164 | |
| 165 | return res; |
| 166 | } |
| 167 | |
| 168 | static ExprId GetFloat(LowLevelILFunction& il, InstructionOperand& operand, int float_sz) |
| 169 | { |
no test coverage detected