Exemple #1
0
 def execute(self, processor):
     if processor.condition_passed():
         if not processor.coproc_accepted(self.cp, processor.this_instr()):
             processor.generate_coprocessor_exception()
         else:
             try:
                 processor.null_check_if_thumbee(self.n)
             except EndOfInstruction:
                 pass
             else:
                 offset_addr = bits_add(processor.registers.get(
                     self.n), self.imm32, 32) if self.add else bits_sub(
                         processor.registers.get(self.n), self.imm32, 32)
                 address = offset_addr if self.index else processor.registers.get(
                     self.n)
                 first_pass = True
                 while first_pass or processor.coproc_done_loading(
                         self.cp, processor.this_instr()):
                     first_pass = False
                     processor.coproc_send_loaded_word(
                         processor.mem_a_get(address, 4), self.cp,
                         processor.this_instr())
                     address = bits_add(address, BitArray(bin="100"), 32)
                 if self.wback:
                     processor.registers.set(self.n, offset_addr)
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset_addr = bits_add(processor.registers.get(
                 self.n), self.imm32, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), self.imm32, 32)
             address = offset_addr if self.index else processor.registers.get(
                 self.n)
             if have_lpae() and lower_chunk(address, 3) == 0b000:
                 if processor.big_endian():
                     data = chain(processor.registers.get(self.t),
                                  processor.registers.get(self.t2), 32)
                 else:
                     data = chain(processor.registers.get(self.t2),
                                  processor.registers.get(self.t), 32)
                 processor.mem_a_set(address, 8, data)
             else:
                 processor.mem_a_set(address, 4,
                                     processor.registers.get(self.t))
                 processor.mem_a_set(bits_add(address, 4, 32), 4,
                                     processor.registers.get(self.t2))
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
Exemple #3
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset_addr = bits_add(processor.registers.get(
                 self.n), self.imm32, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), self.imm32, 32)
             address = offset_addr if self.index else processor.registers.get(
                 self.n)
             if have_lpae() and substring(address, 2, 0) == 0b000:
                 data = processor.mem_a_get(address, 8)
                 if processor.big_endian():
                     processor.registers.set(self.t,
                                             substring(data, 63, 32))
                     processor.registers.set(self.t2,
                                             substring(data, 31, 0))
                 else:
                     processor.registers.set(self.t, substring(data, 31, 0))
                     processor.registers.set(self.t2,
                                             substring(data, 63, 32))
             else:
                 processor.registers.set(self.t,
                                         processor.mem_a_get(address, 4))
                 processor.registers.set(
                     self.t2,
                     processor.mem_a_get(bits_add(address, 4, 32), 4))
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
Exemple #4
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(15)
         except EndOfInstruction:
             pass
         else:
             address = bits_add(align(processor.registers.get_pc(), 4),
                                self.imm32, 32) if self.add else bits_sub(
                                    align(processor.registers.get_pc(), 4),
                                    self.imm32, 32)
             if have_lpae() and address[29:32] == "0b000":
                 data = processor.mem_a_get(address, 8)
                 if processor.big_endian():
                     processor.registers.set(self.t, data[0:32])
                     processor.registers.set(self.t2, data[32:64])
                 else:
                     processor.registers.set(self.t, data[32:64])
                     processor.registers.set(self.t2, data[0:32])
             else:
                 processor.registers.set(self.t,
                                         processor.mem_a_get(address, 4))
                 processor.registers.set(
                     self.t2,
                     processor.mem_a_get(
                         bits_add(address, BitArray(bin="0b100"), 32), 4))
Exemple #5
0
 def execute(self, processor):
     if processor.condition_passed():
         if processor.registers.current_mode_is_hyp():
             print "unpredictable"
         else:
             try:
                 processor.null_check_if_thumbee(self.n)
             except EndOfInstruction:
                 pass
             else:
                 offset = processor.registers.get(
                     self.m) if self.register_form else self.imm32
                 offset_addr = bits_add(processor.registers.get(
                     self.n), offset, 32) if self.add else bits_sub(
                         processor.registers.get(self.n), offset, 32)
                 address = processor.registers.get(
                     self.n) if self.post_index else offset_addr
                 data = processor.mem_u_unpriv_get(address, 2)
                 if self.post_index:
                     processor.registers.set(self.n, offset_addr)
                 if processor.unaligned_support() or not address[31]:
                     processor.registers.set(self.t, sign_extend(data, 32))
                 else:
                     processor.registers.set(self.t,
                                             BitArray(length=32))  # unknown
Exemple #6
0
 def execute(self, processor):
     if processor.condition_passed():
         address = bits_add(align(processor.registers.get_pc(), 4),
                            self.imm32, 32) if self.add else bits_sub(
                                align(processor.registers.get_pc(), 4),
                                self.imm32, 32)
         processor.hint_preload_data(address)
Exemple #7
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset = shift(processor.registers.get(self.m), 32,
                            self.shift_t, self.shift_n,
                            processor.registers.cpsr.c)
             offset_addr = bits_add(processor.registers.get(
                 self.n), offset, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), offset, 32)
             address = offset_addr if self.index else processor.registers.get(
                 self.n)
             if self.t == 15:
                 data = processor.registers.pc_store_value()
             else:
                 data = processor.registers.get(self.t)
             if (processor.unaligned_support()
                     or lower_chunk(address, 2) == 0b00
                     or processor.registers.current_instr_set()
                     == InstrSet.ARM):
                 processor.mem_u_set(address, 4, data)
             else:
                 processor.mem_u_set(address, 4, 0x00000000)  # unknown
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset_addr = bits_add(processor.registers.get(
                 self.n), self.imm32, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), self.imm32, 32)
             address = offset_addr if self.index else processor.registers.get(
                 self.n)
             data = processor.mem_u_get(address, 4)
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
             if self.t == 15:
                 if lower_chunk(address, 2) == 0b00:
                     processor.load_write_pc(data)
                 else:
                     print('unpredictable')
             elif processor.unaligned_support() or lower_chunk(address,
                                                               2) == 0b00:
                 processor.registers.set(self.t, data)
             else:
                 processor.registers.set(self.t, 0x00000000)  # unknown
Exemple #9
0
 def execute(self, processor):
     if processor.condition_passed():
         if processor.registers.current_mode_is_hyp():
             print "unpredictable"
         else:
             try:
                 processor.null_check_if_thumbee(self.n)
             except EndOfInstruction:
                 pass
             else:
                 offset = shift(processor.registers.get(
                     self.m), self.shift_t, self.shift_n,
                                processor.registers.cpsr.get_c()
                                ) if self.register_form else self.imm32
                 offset_addr = bits_add(processor.registers.get(
                     self.n), offset, 32) if self.add else bits_sub(
                         processor.registers.get(self.n), offset, 32)
                 address = processor.registers.get(
                     self.n) if self.post_index else offset_addr
                 data = processor.mem_u_unpriv_get(address, 4)
                 if self.post_index:
                     processor.registers.set(self.n, offset_addr)
                 if processor.unaligned_support(
                 ) or address[30:32] == "0b00":
                     processor.registers.set(self.t, data)
                 else:
                     if processor.registers.current_instr_set(
                     ) == InstrSet.InstrSet_ARM:
                         processor.registers.set(
                             self.t, ror(data, 8 * address[30:32].uint))
                     else:
                         processor.registers.set(
                             self.t, BitArray(length=32))  # unknown
Exemple #10
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(15)
         except EndOfInstruction:
             pass
         else:
             base = align(processor.registers.get_pc(), 4)
             address = bits_add(base, self.imm32,
                                32) if self.add else bits_sub(
                                    base, self.imm32, 32)
             data = processor.mem_u_get(address, 4)
             if self.t == 15:
                 if lower_chunk(address, 2) == 0b00:
                     processor.load_write_pc(data)
                 else:
                     print('unpredictable')
             elif processor.unaligned_support() or lower_chunk(address,
                                                               2) == 0b00:
                 processor.registers.set(self.t, data)
             else:
                 if processor.registers.current_instr_set() == InstrSet.ARM:
                     processor.registers.set(
                         self.t, ror(data, 32, 8 * lower_chunk(address, 2)))
                 else:
                     processor.registers.set(self.t, 0x00000000)  # unknown
Exemple #11
0
 def execute(self, processor):
     if processor.condition_passed():
         if processor.registers.current_mode_is_hyp():
             print('unpredictable')
         else:
             try:
                 processor.null_check_if_thumbee(self.n)
             except EndOfInstruction:
                 pass
             else:
                 offset = shift(processor.registers.get(self.m), 32, self.shift_t, self.shift_n,
                                processor.registers.cpsr.c) if self.register_form else self.imm32
                 offset_addr = bits_add(processor.registers.get(self.n), offset, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), offset, 32)
                 address = processor.registers.get(self.n) if self.post_index else offset_addr
                 if self.t == 15:
                     data = processor.registers.pc_store_value()
                 else:
                     data = processor.registers.get(self.t)
                 if (processor.unaligned_support() or
                         substring(address, 1, 0) == 0b00 or
                         processor.registers.current_instr_set() == InstrSet.ARM):
                     processor.mem_u_unpriv_set(address, 4, data)
                 else:
                     processor.mem_u_unpriv_set(address, 4, 0x00000000)  # unknown
                 if self.post_index:
                     processor.registers.set(self.n, offset_addr)
Exemple #12
0
 def execute(self, processor):
     if processor.condition_passed():
         address = bits_add(processor.registers.get(self.n), self.imm32, 32) if self.add else bits_sub(
             processor.registers.get(self.n), self.imm32, 32)
         if self.is_pldw:
             processor.hint_preload_data_for_write(address)
         else:
             processor.hint_preload_data(address)
 def execute(self, processor):
     if processor.condition_passed():
         offset_addr = bits_add(processor.registers.get(self.n), self.imm32, 32) if self.add else bits_sub(
             processor.registers.get(self.n), self.imm32, 32)
         address = offset_addr if self.index else processor.registers.get(self.n)
         processor.registers.set(self.t, processor.mem_u_get(address, 1))
         if self.wback:
             processor.registers.set(self.n, offset_addr)
Exemple #14
0
 def execute(self, processor):
     if processor.condition_passed():
         offset = shift(processor.registers.get(self.m), self.shift_t, self.shift_n,
                        processor.registers.cpsr.get_c())
         address = bits_add(processor.registers.get(self.n), offset, 32) if self.add else bits_sub(
                 processor.registers.get(self.n), offset, 32)
         if self.is_pldw:
             processor.hint_preload_data_for_write(address)
         else:
             processor.hint_preload_data(address)
Exemple #15
0
 def execute(self, processor):
     if processor.condition_passed():
         result = bits_add(align(processor.registers.get_pc(), 4),
                           self.imm32, 32) if self.add else bits_sub(
                               align(processor.registers.get_pc(), 4),
                               self.imm32, 32)
         if self.d == 15:
             processor.alu_write_pc(result)
         else:
             processor.registers.set(self.d, result)
 def execute(self, processor):
     if processor.condition_passed():
         offset_addr = bits_add(processor.registers.get(self.n), self.imm32, 32) if self.add else bits_sub(
             processor.registers.get(self.n), self.imm32, 32)
         address = offset_addr if self.index else processor.registers.get(self.n)
         data = processor.mem_u_get(address, 2)
         if self.wback:
             processor.registers.set(self.n, offset_addr)
         if processor.unaligned_support() or not address[31]:
             processor.registers.set(self.t, zero_extend(data, 32))
         else:
             processor.registers.set(self.t, BitArray(length=32))  # unknown
Exemple #17
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(15)
         except EndOfInstruction:
             pass
         else:
             base = align(processor.registers.get_pc(), 4)
             address = bits_add(base, self.imm32,
                                32) if self.add else bits_sub(
                                    base, self.imm32, 32)
             processor.registers.set(
                 self.t, zero_extend(processor.mem_u_get(address, 1), 32))
Exemple #18
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(15)
         except EndOfInstruction:
             pass
         else:
             base = align(processor.registers.get_pc(), 4)
             address = bits_add(base, self.imm32, 32) if self.add else bits_sub(base, self.imm32, 32)
             data = processor.mem_u_get(address, 2)
             if processor.unaligned_support() or not address[31]:
                 processor.registers.set(self.t, sign_extend(data, 32))
             else:
                 processor.registers.set(self.t, BitArray(length=32))  # unkown
 def execute(self, processor):
     if processor.condition_passed():
         offset_addr = bits_add(processor.registers.get(
             self.n), self.imm32, 32) if self.add else bits_sub(
                 processor.registers.get(self.n), self.imm32, 32)
         address = offset_addr if self.index else processor.registers.get(
             self.n)
         data = processor.mem_u_get(address, 2)
         if self.wback:
             processor.registers.set(self.n, offset_addr)
         if processor.unaligned_support() or not bit_at(address, 0):
             processor.registers.set(self.t, data)
         else:
             processor.registers.set(self.t, 0x00000000)  # unknown
Exemple #20
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset = shift(processor.registers.get(self.m), 32, self.shift_t, self.shift_n,
                            processor.registers.cpsr.c)
             offset_addr = bits_add(processor.registers.get(self.n), offset, 32) if self.add else bits_sub(
                 processor.registers.get(self.n), offset, 32)
             address = offset_addr if self.index else processor.registers.get(self.n)
             processor.mem_u_set(address, 1, lower_chunk(processor.registers.get(self.t), 8))
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
Exemple #21
0
 def execute(self, processor):
     if processor.condition_passed():
         offset_addr = bits_add(processor.registers.get(self.n),
                                processor.registers.get(self.m),
                                32) if self.add else bits_sub(
                                    processor.registers.get(self.n),
                                    processor.registers.get(self.m), 32)
         address = offset_addr if self.index else processor.registers.get(
             self.n)
         if have_lpae() and substring(address, 2, 0) == 0b000:
             if processor.big_endian():
                 data = chain(processor.registers.get(self.t),
                              processor.registers.get(self.t2), 32)
             else:
                 data = chain(processor.registers.get(self.t2),
                              processor.registers.get(self.t), 32)
             processor.mem_a_set(address, 8, data)
         else:
             processor.mem_a_set(address, 4,
                                 processor.registers.get(self.t))
             processor.mem_a_set(bits_add(address, 4, 32), 4,
                                 processor.registers.get(self.t2))
         if self.wback:
             processor.registers.set(self.n, offset_addr)
Exemple #22
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(15)
         except EndOfInstruction:
             pass
         else:
             base = align(processor.registers.get_pc(), 4)
             address = bits_add(base, self.imm32,
                                32) if self.add else bits_sub(
                                    base, self.imm32, 32)
             data = processor.mem_u_get(address, 2)
             if processor.unaligned_support() or not bit_at(address, 0):
                 processor.registers.set(self.t, data)
             else:
                 processor.registers.set(self.t, 0x00000000)  # unknown
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset_addr = bits_add(processor.registers.get(
                 self.n), self.imm32, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), self.imm32, 32)
             address = offset_addr if self.index else processor.registers.get(
                 self.n)
             processor.registers.set(
                 self.t, zero_extend(processor.mem_u_get(address, 1), 32))
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
Exemple #24
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset_addr = bits_add(processor.registers.get(self.n), self.imm32, 32) if self.add else bits_sub(
                 processor.registers.get(self.n), self.imm32, 32)
             address = offset_addr if self.index else processor.registers.get(self.n)
             if processor.unaligned_support() or lower_chunk(address, 2) == 0b00:
                 processor.mem_u_set(address, 4, processor.registers.get(self.t))
             else:
                 processor.mem_u_set(address, 4, 0x00000000)
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
Exemple #25
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset_addr = bits_add(processor.registers.get(self.n), self.imm32, 32) if self.add else bits_sub(
                 processor.registers.get(self.n), self.imm32, 32)
             address = offset_addr if self.index else processor.registers.get(self.n)
             data = processor.mem_u_get(address, 2)
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
             if processor.unaligned_support() or address[31:32] == "0b0":
                 processor.registers.set(self.t, zero_extend(data, 32))
             else:
                 processor.registers.set(self.t, BitArray(length=32))  # unknown
Exemple #26
0
 def execute(self, processor):
     if processor.condition_passed():
         if processor.registers.current_mode_is_hyp():
             print "unpredictable"
         else:
             try:
                 processor.null_check_if_thumbee(self.n)
             except EndOfInstruction:
                 pass
             else:
                 offset = shift(processor.registers.get(self.m), self.shift_t, self.shift_n,
                                processor.registers.cpsr.get_c()) if self.register_form else self.imm32
                 offset_addr = bits_add(processor.registers.get(self.n), offset, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), offset, 32)
                 address = processor.registers.get(self.n) if self.post_index else offset_addr
                 processor.registers.set(self.t, zero_extend(processor.mem_u_unpriv_get(address, 1), 32))
                 if self.post_index:
                     processor.registers.set(self.n, offset_addr)
Exemple #27
0
 def execute(self, processor):
     if processor.condition_passed():
         try:
             processor.null_check_if_thumbee(self.n)
         except EndOfInstruction:
             pass
         else:
             offset_addr = bits_add(processor.registers.get(
                 self.n), self.imm32, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), self.imm32, 32)
             address = offset_addr if self.index else processor.registers.get(
                 self.n)
             data = processor.mem_u_get(address, 2)
             if self.wback:
                 processor.registers.set(self.n, offset_addr)
             if processor.unaligned_support() or not bit_at(address, 0):
                 processor.registers.set(self.t, sign_extend(data, 16, 32))
             else:
                 processor.registers.set(self.t, 0x00000000)  # unknown
Exemple #28
0
 def execute(self, processor):
     try:
         processor.null_check_if_thumbee(self.n)
     except EndOfInstruction:
         pass
     else:
         offset = shift(processor.registers.get(self.m), self.shift_t,
                        self.shift_n, processor.registers.cpsr.get_c())
         offset_addr = bits_add(processor.registers.get(
             self.n), offset, 32) if self.add else bits_sub(
                 processor.registers.get(self.n), offset, 32)
         address = offset_addr if self.index else processor.registers.get(
             self.n)
         data = processor.mem_u_get(address, 2)
         if self.wback:
             processor.registers.set(self.n, offset_addr)
         if processor.unaligned_support() or not address[31]:
             processor.registers.set(self.t, sign_extend(data, 32))
         else:
             processor.registers.set(self.t, BitArray(length=32))  # unknown
Exemple #29
0
 def execute(self, processor):
     if processor.condition_passed():
         if processor.registers.current_mode_is_hyp():
             print('unpredictable')
         else:
             try:
                 processor.null_check_if_thumbee(self.n)
             except EndOfInstruction:
                 pass
             else:
                 offset = processor.registers.get(self.m) if self.register_form else self.imm32
                 offset_addr = bits_add(processor.registers.get(self.n), offset, 32) if self.add else bits_sub(
                     processor.registers.get(self.n), offset, 32)
                 address = processor.registers.get(self.n) if self.post_index else offset_addr
                 if processor.unaligned_support() or not bit_at(address, 0):
                     processor.mem_u_unpriv_set(address, 2, lower_chunk(processor.registers.get(self.t), 16))
                 else:
                     processor.mem_u_unpriv_set(address, 2, 0x0000)  # unknown
                 if self.post_index:
                     processor.registers.set(self.n, offset_addr)
Exemple #30
0
 def execute(self, processor):
     if processor.condition_passed():
         offset_addr = bits_add(processor.registers.get(
             self.n), self.imm32, 32) if self.add else bits_sub(
                 processor.registers.get(self.n), self.imm32, 32)
         address = offset_addr if self.index else processor.registers.get(
             self.n)
         data = processor.mem_u_get(address, 4)
         if self.wback:
             processor.registers.set(self.n, offset_addr)
         if self.t == 15:
             if address[30:32] == "0b00":
                 processor.load_write_pc(data)
             else:
                 print "unpredictable"
         elif processor.unaligned_support() or address[30:32] == "0b00":
             processor.registers.set(self.t, data)
         else:
             processor.registers.set(self.t,
                                     ror(data, 8 * address[30:32].uint))