def execute(self, processor): if processor.condition_passed(): operand1 = to_signed(processor.registers.get(self.n), 32) operand2 = to_signed(processor.registers.get(self.m), 32) addend = to_signed(processor.registers.get(self.a), 32) result = addend - operand2 * operand1 processor.registers.set(self.d, to_unsigned(result, 32))
def execute(self, processor): if processor.condition_passed(): doubled, sat1 = signed_sat_q(2 * to_signed(processor.registers.get(self.n), 32), 32) result, sat2 = signed_sat_q(to_signed(processor.registers.get(self.m), 32) - to_signed(doubled, 32), 32) processor.registers.set(self.d, result) if sat1 or sat2: processor.registers.cpsr.q = 1
def execute(self, processor): if processor.condition_passed(): result = (to_signed(processor.registers.get(self.a), 32) << 32) + to_signed(processor.registers.get( self.n), 32) * to_signed(processor.registers.get(self.m), 32) if self.round: result += 0x80000000 processor.registers.set(self.d, substring(to_unsigned(result, 64), 63, 32))
def execute(self, processor): if processor.condition_passed(): result, sat = signed_sat_q( to_signed(processor.registers.get(self.m), 32) - to_signed(processor.registers.get(self.n), 32), 32) processor.registers.set(self.d, result) if sat: processor.registers.cpsr.q = 1
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) m = processor.registers.get(self.m) diff = to_signed(substring(n, 15, 0), 16) - to_signed(substring(m, 31, 16), 16) sum_ = to_signed(substring(n, 31, 16), 16) + to_signed(substring(m, 15, 0), 16) d = set_substring(0, 15, 0, to_unsigned(diff, 17) >> 1) d = set_substring(d, 31, 16, to_unsigned(sum_, 17) >> 1) processor.registers.set(self.d, d)
def execute(self, processor): if processor.condition_passed(): m = processor.registers.get(self.m) operand2 = substring(m, 31, 16) if self.m_high else substring( m, 15, 0) result = to_signed(processor.registers.get(self.n), 32) * to_signed(operand2, 16) output = substring(to_unsigned(result, 48), 47, 16) processor.registers.set(self.d, output)
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) result1, sat1 = unsigned_sat_q(to_signed(substring(n, 15, 0), 16), self.saturate_to) result2, sat2 = unsigned_sat_q(to_signed(substring(n, 31, 16), 16), self.saturate_to) processor.registers.set(self.d, chain(result2, result1, 16)) if sat1 or sat2: processor.registers.cpsr.q = 1
def execute(self, processor): if processor.condition_passed(): operand2 = ror(processor.registers.get(self.m), 32, 16) if self.m_swap else processor.registers.get(self.m) n = processor.registers.get(self.n) product1 = to_signed(substring(n, 15, 0), 16) * to_signed(substring(operand2, 15, 0), 16) product2 = to_signed(substring(n, 31, 16), 16) * to_signed(substring(operand2, 31, 16), 16) result = product1 + product2 processor.registers.set(self.d, to_unsigned(result, 32)) if result != to_signed(to_unsigned(result, 32), 32): processor.registers.cpsr.q = 1
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) operand1 = substring(n, 31, 16) if self.n_high else substring( n, 15, 0) m = processor.registers.get(self.m) operand2 = substring(m, 31, 16) if self.m_high else substring( m, 15, 0) result = to_signed(operand1, 16) * to_signed(operand2, 16) processor.registers.set(self.d, to_unsigned(result, 32))
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) m = processor.registers.get(self.m) sum1 = to_signed(substring(n, 15, 0), 16) + to_signed( substring(m, 15, 0), 16) sum2 = to_signed(substring(n, 31, 16), 16) + to_signed( substring(m, 31, 16), 16) d = set_substring(0, 15, 0, signed_sat(sum1, 16)) d = set_substring(d, 31, 16, signed_sat(sum2, 16)) processor.registers.set(self.d, d)
def execute(self, processor): if processor.condition_passed(): if to_signed(processor.registers.get(self.m), 32) == 0: if processor.integer_zero_divide_trapping_enabled(): processor.generate_integer_zero_divide() else: result = 0 else: result = int( to_signed(processor.registers.get(self.n), 32) / to_signed(processor.registers.get(self.m), 32)) processor.registers.set(self.d, to_unsigned(result, 32))
def execute(self, processor): if processor.condition_passed(): operand1 = to_signed(processor.registers.get(self.n), 32) operand2 = to_signed(processor.registers.get(self.m), 32) result = operand1 * operand2 f_result = to_unsigned(result, 32) processor.registers.set(self.d, f_result) if self.setflags: processor.registers.cpsr.n = bit_at(result, 31) processor.registers.cpsr.z = 0 if result else 1 if arch_version() == 4: processor.registers.cpsr.c = 0 # unknown
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) m = processor.registers.get(self.m) sum_ = to_signed(substring(n, 15, 0), 16) + to_signed(substring(m, 31, 16), 16) diff = to_signed(substring(n, 31, 16), 16) - to_signed(substring(m, 15, 0), 16) d = set_substring(0, 15, 0, to_unsigned(sum_, 16)) d = set_substring(d, 31, 16, to_unsigned(diff, 16)) processor.registers.set(self.d, d) ge = 0b11 if sum_ >= 0 else 00 ge = set_substring(ge, 3, 2, 0b11 if diff >= 0 else 00) processor.registers.cpsr.ge = ge
def execute(self, processor): if processor.condition_passed(): result = to_signed(processor.registers.get( self.n), 32) * to_signed(processor.registers.get(self.m), 32) f_result = to_unsigned(result, 64) processor.registers.set(self.d_hi, substring(f_result, 63, 32)) processor.registers.set(self.d_lo, substring(f_result, 31, 0)) if self.setflags: processor.registers.cpsr.n = bit_at(f_result, 63) processor.registers.cpsr.z = 0 if f_result else 1 if arch_version() == 4: processor.registers.cpsr.c = 0 # unknown processor.registers.cpsr.v = 0 # unknown
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) operand1 = substring(n, 31, 16) if self.n_high else substring( n, 15, 0) m = processor.registers.get(self.m) operand2 = substring(m, 31, 16) if self.m_high else substring( m, 15, 0) d_total = to_signed( set_substring(processor.registers.get(self.d_lo), 63, 32, processor.registers.get(self.d_hi)), 64) result = to_unsigned( to_signed(operand1, 16) * to_signed(operand2, 16) + d_total, 64) processor.registers.set(self.d_hi, substring(result, 63, 32)) processor.registers.set(self.d_lo, substring(result, 31, 0))
def execute(self, processor): if processor.condition_passed(): operand2 = ror(processor.registers.get(self.m), 32, 16) if self.m_swap else processor.registers.get( self.m) n = processor.registers.get(self.n) product1 = to_signed(substring(n, 15, 0), 16) * to_signed( substring(operand2, 15, 0), 16) product2 = to_signed(substring(n, 31, 16), 16) * to_signed( substring(operand2, 31, 16), 16) d_total = to_signed( set_substring(processor.registers.get(self.d_lo), 63, 32, processor.registers.get(self.d_hi)), 64) result = to_unsigned(product1 - product2 + d_total, 64) processor.registers.set(self.d_hi, substring(result, 63, 32)) processor.registers.set(self.d_lo, substring(result, 31, 0))
def from_bitarray(instr, processor): imm8 = substring(instr, 7, 0) imm32 = to_signed(imm8 * 2, 9) if processor.in_it_block(): print('unpredictable') else: return BT1(instr, imm32=imm32)
def execute(self, processor): if processor.condition_passed(): operand = shift(processor.registers.get(self.n), 32, self.shift_t, self.shift_n, processor.registers.cpsr.c) result, sat = signed_sat_q(to_signed(operand, 32), self.saturate_to) processor.registers.set(self.d, to_unsigned(result, 32)) if sat: processor.registers.cpsr.q = 1
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) m = processor.registers.get(self.m) diff1 = to_signed(substring(n, 7, 0), 8) - to_signed(substring(m, 7, 0), 8) diff2 = to_signed(substring(n, 15, 8), 8) - to_signed(substring(m, 15, 8), 8) diff3 = to_signed(substring(n, 23, 16), 8) - to_signed(substring(m, 23, 16), 8) diff4 = to_signed(substring(n, 31, 24), 8) - to_signed(substring(m, 31, 24), 8) d = set_substring(0, 7, 0, to_unsigned(diff1, 9) >> 1) d = set_substring(d, 15, 8, to_unsigned(diff2, 9) >> 1) d = set_substring(d, 23, 16, to_unsigned(diff3, 9) >> 1) d = set_substring(d, 31, 24, to_unsigned(diff4, 9) >> 1) processor.registers.set(self.d, d)
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) m = processor.registers.get(self.m) sum1 = to_signed(substring(n, 7, 0), 8) + to_signed( substring(m, 7, 0), 8) sum2 = to_signed(substring(n, 15, 8), 8) + to_signed( substring(m, 15, 8), 8) sum3 = to_signed(substring(n, 23, 16), 8) + to_signed( substring(m, 23, 16), 8) sum4 = to_signed(substring(n, 31, 24), 8) + to_signed( substring(m, 31, 24), 8) d = set_substring(0, 7, 0, signed_sat(sum1, 8)) d = set_substring(d, 15, 8, signed_sat(sum2, 8)) d = set_substring(d, 23, 16, signed_sat(sum3, 8)) d = set_substring(d, 31, 24, signed_sat(sum4, 8)) processor.registers.set(self.d, d)
def execute(self, processor): if processor.condition_passed(): n = processor.registers.get(self.n) m = processor.registers.get(self.m) sum1 = to_signed(substring(n, 7, 0), 8) + to_signed(substring(m, 7, 0), 8) sum2 = to_signed(substring(n, 15, 8), 8) + to_signed(substring(m, 15, 8), 8) sum3 = to_signed(substring(n, 23, 16), 8) + to_signed(substring(m, 23, 16), 8) sum4 = to_signed(substring(n, 31, 24), 8) + to_signed(substring(m, 31, 24), 8) d = set_substring(0, 7, 0, to_unsigned(sum1, 8)) d = set_substring(d, 15, 8, to_unsigned(sum2, 8)) d = set_substring(d, 23, 16, to_unsigned(sum3, 8)) d = set_substring(d, 31, 24, to_unsigned(sum4, 8)) processor.registers.set(self.d, d) ge = set_bit_at(0, 0, 0b1 if sum1 >= 0 else 0b0) ge = set_bit_at(ge, 1, 0b1 if sum2 >= 0 else 0b0) ge = set_bit_at(ge, 2, 0b1 if sum3 >= 0 else 0b0) ge = set_bit_at(ge, 3, 0b1 if sum4 >= 0 else 0b0) processor.registers.cpsr.ge = ge