blob: 4495acb95d70e7d59e3b8e692be0a0d03bee744f [file] [log] [blame]
Greg Clayton64c84432011-01-21 22:02:52 +00001//===-- EmulateInstructionARM.cpp -------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "EmulateInstructionARM.h"
Johnny Chen8584c922011-01-26 01:18:52 +000011#include "ARMDefines.h"
Johnny Chen4baf2e32011-01-24 18:24:53 +000012#include "ARMUtils.h"
Greg Clayton31e2a382011-01-30 20:03:56 +000013#include "lldb/Core/ConstString.h"
Greg Clayton64c84432011-01-21 22:02:52 +000014
15using namespace lldb;
16using namespace lldb_private;
17
18// ARM constants used during decoding
19#define REG_RD 0
20#define LDM_REGLIST 1
21#define PC_REG 15
22#define PC_REGLIST_BIT 0x8000
23
Johnny Chen251af6a2011-01-21 22:47:25 +000024#define ARMv4 (1u << 0)
Greg Clayton64c84432011-01-21 22:02:52 +000025#define ARMv4T (1u << 1)
26#define ARMv5T (1u << 2)
27#define ARMv5TE (1u << 3)
28#define ARMv5TEJ (1u << 4)
Johnny Chen251af6a2011-01-21 22:47:25 +000029#define ARMv6 (1u << 5)
Greg Clayton64c84432011-01-21 22:02:52 +000030#define ARMv6K (1u << 6)
31#define ARMv6T2 (1u << 7)
Johnny Chen251af6a2011-01-21 22:47:25 +000032#define ARMv7 (1u << 8)
Johnny Chen60c0d622011-01-25 23:49:39 +000033#define ARMv8 (1u << 9)
Greg Clayton64c84432011-01-21 22:02:52 +000034#define ARMvAll (0xffffffffu)
35
Johnny Chen7dc60e12011-01-24 19:46:32 +000036typedef enum
Greg Clayton64c84432011-01-21 22:02:52 +000037{
38 eEncodingA1,
39 eEncodingA2,
40 eEncodingA3,
41 eEncodingA4,
42 eEncodingA5,
43 eEncodingT1,
44 eEncodingT2,
45 eEncodingT3,
46 eEncodingT4,
47 eEncodingT5,
48} ARMEncoding;
49
Johnny Chen7dc60e12011-01-24 19:46:32 +000050typedef enum
51{
52 eSize16,
53 eSize32
54} ARMInstrSize;
55
Johnny Chen4baf2e32011-01-24 18:24:53 +000056// Typedef for the callback function used during the emulation.
Johnny Chen3c75c762011-01-22 00:47:08 +000057// Pass along (ARMEncoding)encoding as the callback data.
58typedef bool (*EmulateCallback) (EmulateInstructionARM *emulator, ARMEncoding encoding);
59
Johnny Chen7dc60e12011-01-24 19:46:32 +000060typedef struct
Greg Clayton64c84432011-01-21 22:02:52 +000061{
62 uint32_t mask;
63 uint32_t value;
64 uint32_t variants;
65 ARMEncoding encoding;
Johnny Chen7dc60e12011-01-24 19:46:32 +000066 ARMInstrSize size;
Greg Clayton64c84432011-01-21 22:02:52 +000067 EmulateCallback callback;
Johnny Chen4bee8ce2011-01-22 00:59:07 +000068 const char *name;
Johnny Chen7dc60e12011-01-24 19:46:32 +000069} ARMOpcode;
Greg Clayton64c84432011-01-21 22:02:52 +000070
71static bool
Johnny Chence1ca772011-01-25 01:13:00 +000072emulate_push (EmulateInstructionARM *emulator, ARMEncoding encoding)
Greg Clayton64c84432011-01-21 22:02:52 +000073{
74#if 0
75 // ARM pseudo code...
76 if (ConditionPassed())
77 {
78 EncodingSpecificOperations();
79 NullCheckIfThumbEE(13);
80 address = SP - 4*BitCount(registers);
81
82 for (i = 0 to 14)
83 {
84 if (registers<i> == 1’)
85 {
86 if i == 13 && i != LowestSetBit(registers) // Only possible for encoding A1
87 MemA[address,4] = bits(32) UNKNOWN;
88 else
89 MemA[address,4] = R[i];
90 address = address + 4;
91 }
92 }
93
94 if (registers<15> == 1’) // Only possible for encoding A1 or A2
95 MemA[address,4] = PCStoreValue();
96
97 SP = SP - 4*BitCount(registers);
98 }
99#endif
100
101 bool success = false;
102 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
103 if (!success)
104 return false;
105
106 if (emulator->ConditionPassed())
107 {
108 const uint32_t addr_byte_size = emulator->GetAddressByteSize();
109 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
110 if (!success)
111 return false;
Johnny Chen3c75c762011-01-22 00:47:08 +0000112 uint32_t registers = 0;
Johnny Chen91d99862011-01-25 19:07:04 +0000113 uint32_t Rt; // the source register
Johnny Chen3c75c762011-01-22 00:47:08 +0000114 switch (encoding) {
Johnny Chenaedde1c2011-01-24 20:38:45 +0000115 case eEncodingT1:
Johnny Chen108d5aa2011-01-26 01:00:55 +0000116 registers = Bits32(opcode, 7, 0);
Johnny Chenaedde1c2011-01-24 20:38:45 +0000117 // The M bit represents LR.
Johnny Chen108d5aa2011-01-26 01:00:55 +0000118 if (Bits32(opcode, 8, 8))
Johnny Chenaedde1c2011-01-24 20:38:45 +0000119 registers |= 0x000eu;
120 // if BitCount(registers) < 1 then UNPREDICTABLE;
121 if (BitCount(registers) < 1)
122 return false;
123 break;
Johnny Chen7dc60e12011-01-24 19:46:32 +0000124 case eEncodingT2:
125 // Ignore bits 15 & 13.
Johnny Chen108d5aa2011-01-26 01:00:55 +0000126 registers = Bits32(opcode, 15, 0) & ~0xa000;
Johnny Chen7dc60e12011-01-24 19:46:32 +0000127 // if BitCount(registers) < 2 then UNPREDICTABLE;
128 if (BitCount(registers) < 2)
129 return false;
130 break;
131 case eEncodingT3:
Johnny Chen108d5aa2011-01-26 01:00:55 +0000132 Rt = Bits32(opcode, 15, 12);
Johnny Chen7dc60e12011-01-24 19:46:32 +0000133 // if BadReg(t) then UNPREDICTABLE;
Johnny Chen91d99862011-01-25 19:07:04 +0000134 if (BadReg(Rt))
Johnny Chen7dc60e12011-01-24 19:46:32 +0000135 return false;
Johnny Chen91d99862011-01-25 19:07:04 +0000136 registers = (1u << Rt);
Johnny Chen7dc60e12011-01-24 19:46:32 +0000137 break;
Johnny Chen3c75c762011-01-22 00:47:08 +0000138 case eEncodingA1:
Johnny Chen108d5aa2011-01-26 01:00:55 +0000139 registers = Bits32(opcode, 15, 0);
Johnny Chena33d4842011-01-24 22:25:48 +0000140 // Instead of return false, let's handle the following case as well,
141 // which amounts to pushing one reg onto the full descending stacks.
142 // if BitCount(register_list) < 2 then SEE STMDB / STMFD;
Johnny Chen3c75c762011-01-22 00:47:08 +0000143 break;
144 case eEncodingA2:
Johnny Chen108d5aa2011-01-26 01:00:55 +0000145 Rt = Bits32(opcode, 15, 12);
Johnny Chen7dc60e12011-01-24 19:46:32 +0000146 // if t == 13 then UNPREDICTABLE;
Johnny Chen91d99862011-01-25 19:07:04 +0000147 if (Rt == dwarf_sp)
Johnny Chen3c75c762011-01-22 00:47:08 +0000148 return false;
Johnny Chen91d99862011-01-25 19:07:04 +0000149 registers = (1u << Rt);
Johnny Chen3c75c762011-01-22 00:47:08 +0000150 break;
Johnny Chence1ca772011-01-25 01:13:00 +0000151 default:
152 return false;
Johnny Chen3c75c762011-01-22 00:47:08 +0000153 }
Johnny Chence1ca772011-01-25 01:13:00 +0000154 addr_t sp_offset = addr_byte_size * BitCount (registers);
Greg Clayton64c84432011-01-21 22:02:52 +0000155 addr_t addr = sp - sp_offset;
156 uint32_t i;
157
158 EmulateInstruction::Context context = { EmulateInstruction::eContextPushRegisterOnStack, eRegisterKindDWARF, 0, 0 };
159 for (i=0; i<15; ++i)
160 {
Johnny Chen108d5aa2011-01-26 01:00:55 +0000161 if (BitIsSet (registers, 1u << i))
Greg Clayton64c84432011-01-21 22:02:52 +0000162 {
163 context.arg1 = dwarf_r0 + i; // arg1 in the context is the DWARF register number
164 context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset
165 uint32_t reg_value = emulator->ReadRegisterUnsigned(eRegisterKindDWARF, context.arg1, 0, &success);
166 if (!success)
167 return false;
168 if (!emulator->WriteMemoryUnsigned (context, addr, reg_value, addr_byte_size))
169 return false;
170 addr += addr_byte_size;
171 }
172 }
173
Johnny Chen108d5aa2011-01-26 01:00:55 +0000174 if (BitIsSet (registers, 1u << 15))
Greg Clayton64c84432011-01-21 22:02:52 +0000175 {
176 context.arg1 = dwarf_pc; // arg1 in the context is the DWARF register number
Johnny Chen3c75c762011-01-22 00:47:08 +0000177 context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset
Greg Clayton64c84432011-01-21 22:02:52 +0000178 const uint32_t pc = emulator->ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
179 if (!success)
180 return false;
181 if (!emulator->WriteMemoryUnsigned (context, addr, pc + 8, addr_byte_size))
182 return false;
183 }
184
185 context.type = EmulateInstruction::eContextAdjustStackPointer;
186 context.arg0 = eRegisterKindGeneric;
187 context.arg1 = LLDB_REGNUM_GENERIC_SP;
Johnny Chen5b442b72011-01-27 19:34:30 +0000188 context.arg2 = -sp_offset;
Greg Clayton64c84432011-01-21 22:02:52 +0000189
190 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp - sp_offset))
191 return false;
192 }
193 return true;
194}
195
Johnny Chen5b442b72011-01-27 19:34:30 +0000196// Set r7 or ip to point to saved value residing within the stack.
Johnny Chenbcec3af2011-01-27 01:26:19 +0000197// ADD (SP plus immediate)
198static bool
199emulate_add_rd_sp_imm (EmulateInstructionARM *emulator, ARMEncoding encoding)
200{
201#if 0
202 // ARM pseudo code...
203 if (ConditionPassed())
204 {
205 EncodingSpecificOperations();
206 (result, carry, overflow) = AddWithCarry(SP, imm32, 0’);
207 if d == 15 then
208 ALUWritePC(result); // setflags is always FALSE here
209 else
210 R[d] = result;
211 if setflags then
212 APSR.N = result<31>;
213 APSR.Z = IsZeroBit(result);
214 APSR.C = carry;
215 APSR.V = overflow;
216 }
217#endif
218
219 bool success = false;
220 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
221 if (!success)
222 return false;
223
224 if (emulator->ConditionPassed())
225 {
226 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
227 if (!success)
228 return false;
229 uint32_t Rd; // the destination register
230 uint32_t imm32;
231 switch (encoding) {
232 case eEncodingT1:
233 Rd = 7;
234 imm32 = Bits32(opcode, 7, 0) << 2; // imm32 = ZeroExtend(imm8:'00', 32)
235 break;
236 case eEncodingA1:
237 Rd = Bits32(opcode, 15, 12);
238 imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12)
239 break;
240 default:
241 return false;
242 }
243 addr_t sp_offset = imm32;
244 addr_t addr = sp + sp_offset; // a pointer to the stack area
245
246 EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset,
247 eRegisterKindGeneric,
248 LLDB_REGNUM_GENERIC_SP,
249 sp_offset };
250
251 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, addr))
252 return false;
253 }
254 return true;
255}
256
Johnny Chen2ccad832011-01-28 19:57:25 +0000257// Set r7 or ip to the current stack pointer.
258// MOV (register)
259static bool
260emulate_mov_rd_sp (EmulateInstructionARM *emulator, ARMEncoding encoding)
261{
262#if 0
263 // ARM pseudo code...
264 if (ConditionPassed())
265 {
266 EncodingSpecificOperations();
267 result = R[m];
268 if d == 15 then
269 ALUWritePC(result); // setflags is always FALSE here
270 else
271 R[d] = result;
272 if setflags then
273 APSR.N = result<31>;
274 APSR.Z = IsZeroBit(result);
275 // APSR.C unchanged
276 // APSR.V unchanged
277 }
278#endif
279
280 bool success = false;
Johnny Chen1c13b622011-01-29 00:11:15 +0000281 //const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
282 //if (!success)
283 // return false;
Johnny Chen2ccad832011-01-28 19:57:25 +0000284
285 if (emulator->ConditionPassed())
286 {
287 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
288 if (!success)
289 return false;
290 uint32_t Rd; // the destination register
291 switch (encoding) {
292 case eEncodingT1:
293 Rd = 7;
294 break;
295 case eEncodingA1:
296 Rd = 12;
297 break;
298 default:
299 return false;
300 }
301 EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset,
302 eRegisterKindGeneric,
303 LLDB_REGNUM_GENERIC_SP,
304 0 };
305
306 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, sp))
307 return false;
308 }
309 return true;
310}
311
Johnny Chen1c13b622011-01-29 00:11:15 +0000312// Move from high register (r8-r15) to low register (r0-r7).
313// MOV (register)
314static bool
315emulate_mov_low_high (EmulateInstructionARM *emulator, ARMEncoding encoding)
316{
317#if 0
318 // ARM pseudo code...
319 if (ConditionPassed())
320 {
321 EncodingSpecificOperations();
322 result = R[m];
323 if d == 15 then
324 ALUWritePC(result); // setflags is always FALSE here
325 else
326 R[d] = result;
327 if setflags then
328 APSR.N = result<31>;
329 APSR.Z = IsZeroBit(result);
330 // APSR.C unchanged
331 // APSR.V unchanged
332 }
333#endif
334
335 bool success = false;
336 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
337 if (!success)
338 return false;
339
340 if (emulator->ConditionPassed())
341 {
342 uint32_t Rm; // the source register
343 uint32_t Rd; // the destination register
344 switch (encoding) {
345 case eEncodingT1:
346 Rm = Bits32(opcode, 6, 3);
347 Rd = Bits32(opcode, 2, 1); // bits(7) == 0
348 break;
349 default:
350 return false;
351 }
352 int32_t reg_value = emulator->ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success);
353 if (!success)
354 return false;
355
356 // The context specifies that Rm is to be moved into Rd.
357 EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset,
358 eRegisterKindDWARF,
359 dwarf_r0 + Rm,
360 0 };
361
362 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, reg_value))
363 return false;
364 }
365 return true;
366}
367
Johnny Chen788e0552011-01-27 22:52:23 +0000368// PC relative immediate load into register, possibly followed by ADD (SP plus register).
369// LDR (literal)
370static bool
371emulate_ldr_rd_pc_rel (EmulateInstructionARM *emulator, ARMEncoding encoding)
372{
373#if 0
374 // ARM pseudo code...
375 if (ConditionPassed())
376 {
377 EncodingSpecificOperations(); NullCheckIfThumbEE(15);
378 base = Align(PC,4);
379 address = if add then (base + imm32) else (base - imm32);
380 data = MemU[address,4];
381 if t == 15 then
382 if address<1:0> == 00 then LoadWritePC(data); else UNPREDICTABLE;
383 elsif UnalignedSupport() || address<1:0> = 00 then
384 R[t] = data;
385 else // Can only apply before ARMv7
386 if CurrentInstrSet() == InstrSet_ARM then
387 R[t] = ROR(data, 8*UInt(address<1:0>));
388 else
389 R[t] = bits(32) UNKNOWN;
390 }
391#endif
392
393 bool success = false;
394 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
395 if (!success)
396 return false;
397
398 if (emulator->ConditionPassed())
399 {
400 const uint32_t pc = emulator->ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
401 if (!success)
402 return false;
Johnny Chen809742e2011-01-28 00:32:27 +0000403
404 // PC relative immediate load context
405 EmulateInstruction::Context context = {EmulateInstruction::eContextRegisterPlusOffset,
406 eRegisterKindGeneric,
407 LLDB_REGNUM_GENERIC_PC,
408 0};
Johnny Chen788e0552011-01-27 22:52:23 +0000409 uint32_t Rd; // the destination register
410 uint32_t imm32; // immediate offset from the PC
411 addr_t addr; // the PC relative address
412 uint32_t data; // the literal data value from the PC relative load
413 switch (encoding) {
414 case eEncodingT1:
415 Rd = Bits32(opcode, 10, 8);
416 imm32 = Bits32(opcode, 7, 0) << 2; // imm32 = ZeroExtend(imm8:'00', 32);
417 addr = pc + 4 + imm32;
Johnny Chen809742e2011-01-28 00:32:27 +0000418 context.arg2 = 4 + imm32;
Johnny Chen788e0552011-01-27 22:52:23 +0000419 break;
420 default:
421 return false;
422 }
Johnny Chen809742e2011-01-28 00:32:27 +0000423 data = emulator->ReadMemoryUnsigned(context, addr, 4, 0, &success);
Johnny Chen788e0552011-01-27 22:52:23 +0000424 if (!success)
Johnny Chen809742e2011-01-28 00:32:27 +0000425 return false;
Johnny Chen788e0552011-01-27 22:52:23 +0000426 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + Rd, data))
427 return false;
428 }
429 return true;
430}
431
Johnny Chen5b442b72011-01-27 19:34:30 +0000432// An add operation to adjust the SP.
433// ADD (SP plus register)
434static bool
435emulate_add_sp_rm (EmulateInstructionARM *emulator, ARMEncoding encoding)
436{
437#if 0
438 // ARM pseudo code...
439 if (ConditionPassed())
440 {
441 EncodingSpecificOperations();
442 shifted = Shift(R[m], shift_t, shift_n, APSR.C);
443 (result, carry, overflow) = AddWithCarry(SP, shifted, 0’);
444 if d == 15 then
445 ALUWritePC(result); // setflags is always FALSE here
446 else
447 R[d] = result;
448 if setflags then
449 APSR.N = result<31>;
450 APSR.Z = IsZeroBit(result);
451 APSR.C = carry;
452 APSR.V = overflow;
453 }
454#endif
455
456 bool success = false;
457 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
458 if (!success)
459 return false;
460
461 if (emulator->ConditionPassed())
462 {
463 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
464 if (!success)
465 return false;
466 uint32_t Rm; // the second operand
467 switch (encoding) {
468 case eEncodingT2:
469 Rm = Bits32(opcode, 6, 3);
470 break;
471 default:
472 return false;
473 }
474 int32_t reg_value = emulator->ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + Rm, 0, &success);
475 if (!success)
476 return false;
477
478 addr_t addr = (int32_t)sp + reg_value; // the adjusted stack pointer value
479
480 EmulateInstruction::Context context = { EmulateInstruction::eContextAdjustStackPointer,
481 eRegisterKindGeneric,
482 LLDB_REGNUM_GENERIC_SP,
483 reg_value };
484
485 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, addr))
486 return false;
487 }
488 return true;
489}
490
Johnny Chen0d0148e2011-01-28 02:26:08 +0000491// Set r7 to point to some ip offset.
492// SUB (immediate)
493static bool
494emulate_sub_r7_ip_imm (EmulateInstructionARM *emulator, ARMEncoding encoding)
495{
496#if 0
497 // ARM pseudo code...
498 if (ConditionPassed())
499 {
500 EncodingSpecificOperations();
501 (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), 1’);
502 if d == 15 then // Can only occur for ARM encoding
503 ALUWritePC(result); // setflags is always FALSE here
504 else
505 R[d] = result;
506 if setflags then
507 APSR.N = result<31>;
508 APSR.Z = IsZeroBit(result);
509 APSR.C = carry;
510 APSR.V = overflow;
511 }
512#endif
513
514 bool success = false;
515 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
516 if (!success)
517 return false;
518
519 if (emulator->ConditionPassed())
520 {
521 const addr_t ip = emulator->ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r12, 0, &success);
522 if (!success)
523 return false;
524 uint32_t imm32;
525 switch (encoding) {
526 case eEncodingA1:
527 imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12)
528 break;
529 default:
530 return false;
531 }
532 addr_t ip_offset = imm32;
533 addr_t addr = ip - ip_offset; // the adjusted ip value
534
535 EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset,
536 eRegisterKindDWARF,
537 dwarf_r12,
538 -ip_offset };
539
540 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r7, addr))
541 return false;
542 }
543 return true;
544}
545
546// Set ip to point to some stack offset.
547// SUB (SP minus immediate)
548static bool
549emulate_sub_ip_sp_imm (EmulateInstructionARM *emulator, ARMEncoding encoding)
550{
551#if 0
552 // ARM pseudo code...
553 if (ConditionPassed())
554 {
555 EncodingSpecificOperations();
556 (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), 1’);
557 if d == 15 then // Can only occur for ARM encoding
558 ALUWritePC(result); // setflags is always FALSE here
559 else
560 R[d] = result;
561 if setflags then
562 APSR.N = result<31>;
563 APSR.Z = IsZeroBit(result);
564 APSR.C = carry;
565 APSR.V = overflow;
566 }
567#endif
568
569 bool success = false;
570 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
571 if (!success)
572 return false;
573
574 if (emulator->ConditionPassed())
575 {
576 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
577 if (!success)
578 return false;
579 uint32_t imm32;
580 switch (encoding) {
581 case eEncodingA1:
582 imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12)
583 break;
584 default:
585 return false;
586 }
587 addr_t sp_offset = imm32;
588 addr_t addr = sp - sp_offset; // the adjusted stack pointer value
589
590 EmulateInstruction::Context context = { EmulateInstruction::eContextRegisterPlusOffset,
591 eRegisterKindGeneric,
592 LLDB_REGNUM_GENERIC_SP,
593 -sp_offset };
594
595 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r12, addr))
596 return false;
597 }
598 return true;
599}
600
Johnny Chen4c0e0bc2011-01-25 22:45:28 +0000601// A sub operation to adjust the SP -- allocate space for local storage.
602static bool
603emulate_sub_sp_imm (EmulateInstructionARM *emulator, ARMEncoding encoding)
604{
605#if 0
606 // ARM pseudo code...
607 if (ConditionPassed())
608 {
609 EncodingSpecificOperations();
610 (result, carry, overflow) = AddWithCarry(SP, NOT(imm32), 1’);
611 if d == 15 then // Can only occur for ARM encoding
Johnny Chen799dfd02011-01-26 23:14:33 +0000612 ALUWritePC(result); // setflags is always FALSE here
Johnny Chen4c0e0bc2011-01-25 22:45:28 +0000613 else
614 R[d] = result;
615 if setflags then
616 APSR.N = result<31>;
617 APSR.Z = IsZeroBit(result);
618 APSR.C = carry;
619 APSR.V = overflow;
620 }
621#endif
622
623 bool success = false;
624 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
625 if (!success)
626 return false;
627
628 if (emulator->ConditionPassed())
629 {
630 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
631 if (!success)
632 return false;
633 uint32_t imm32;
634 switch (encoding) {
Johnny Chene4455022011-01-26 00:08:59 +0000635 case eEncodingT1:
636 imm32 = ThumbImmScaled(opcode); // imm32 = ZeroExtend(imm7:'00', 32)
Johnny Chen60c0d622011-01-25 23:49:39 +0000637 case eEncodingT2:
638 imm32 = ThumbExpandImm(opcode); // imm32 = ThumbExpandImm(i:imm3:imm8)
639 break;
640 case eEncodingT3:
641 imm32 = ThumbImm12(opcode); // imm32 = ZeroExtend(i:imm3:imm8, 32)
642 break;
Johnny Chen4c0e0bc2011-01-25 22:45:28 +0000643 case eEncodingA1:
Johnny Chen60c0d622011-01-25 23:49:39 +0000644 imm32 = ARMExpandImm(opcode); // imm32 = ARMExpandImm(imm12)
Johnny Chen4c0e0bc2011-01-25 22:45:28 +0000645 break;
646 default:
647 return false;
648 }
649 addr_t sp_offset = imm32;
650 addr_t addr = sp - sp_offset; // the adjusted stack pointer value
651
652 EmulateInstruction::Context context = { EmulateInstruction::eContextAdjustStackPointer,
653 eRegisterKindGeneric,
654 LLDB_REGNUM_GENERIC_SP,
Johnny Chen5b442b72011-01-27 19:34:30 +0000655 -sp_offset };
Johnny Chen4c0e0bc2011-01-25 22:45:28 +0000656
657 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, addr))
658 return false;
659 }
660 return true;
661}
662
663// A store operation to the stacks that also updates the SP.
Johnny Chence1ca772011-01-25 01:13:00 +0000664static bool
665emulate_str_rt_sp (EmulateInstructionARM *emulator, ARMEncoding encoding)
666{
667#if 0
668 // ARM pseudo code...
669 if (ConditionPassed())
670 {
671 EncodingSpecificOperations();
672 offset_addr = if add then (R[n] + imm32) else (R[n] - imm32);
673 address = if index then offset_addr else R[n];
674 MemU[address,4] = if t == 15 then PCStoreValue() else R[t];
675 if wback then R[n] = offset_addr;
676 }
677#endif
678
679 bool success = false;
680 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
681 if (!success)
682 return false;
683
684 if (emulator->ConditionPassed())
685 {
686 const uint32_t addr_byte_size = emulator->GetAddressByteSize();
687 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
688 if (!success)
689 return false;
Johnny Chen91d99862011-01-25 19:07:04 +0000690 uint32_t Rt; // the source register
Johnny Chence1ca772011-01-25 01:13:00 +0000691 uint32_t imm12;
692 switch (encoding) {
693 case eEncodingA1:
Johnny Chen108d5aa2011-01-26 01:00:55 +0000694 Rt = Bits32(opcode, 15, 12);
695 imm12 = Bits32(opcode, 11, 0);
Johnny Chence1ca772011-01-25 01:13:00 +0000696 break;
697 default:
698 return false;
699 }
700 addr_t sp_offset = imm12;
701 addr_t addr = sp - sp_offset;
702
703 EmulateInstruction::Context context = { EmulateInstruction::eContextPushRegisterOnStack, eRegisterKindDWARF, 0, 0 };
Johnny Chen91d99862011-01-25 19:07:04 +0000704 if (Rt != 15)
Johnny Chence1ca772011-01-25 01:13:00 +0000705 {
Johnny Chen91d99862011-01-25 19:07:04 +0000706 context.arg1 = dwarf_r0 + Rt; // arg1 in the context is the DWARF register number
707 context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset
Johnny Chence1ca772011-01-25 01:13:00 +0000708 uint32_t reg_value = emulator->ReadRegisterUnsigned(eRegisterKindDWARF, context.arg1, 0, &success);
709 if (!success)
710 return false;
711 if (!emulator->WriteMemoryUnsigned (context, addr, reg_value, addr_byte_size))
712 return false;
713 }
714 else
715 {
716 context.arg1 = dwarf_pc; // arg1 in the context is the DWARF register number
717 context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset
718 const uint32_t pc = emulator->ReadRegisterUnsigned(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, 0, &success);
719 if (!success)
720 return false;
721 if (!emulator->WriteMemoryUnsigned (context, addr, pc + 8, addr_byte_size))
722 return false;
723 }
724
725 context.type = EmulateInstruction::eContextAdjustStackPointer;
726 context.arg0 = eRegisterKindGeneric;
727 context.arg1 = LLDB_REGNUM_GENERIC_SP;
Johnny Chen5b442b72011-01-27 19:34:30 +0000728 context.arg2 = -sp_offset;
Johnny Chence1ca772011-01-25 01:13:00 +0000729
730 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp - sp_offset))
731 return false;
732 }
733 return true;
734}
735
Johnny Chen799dfd02011-01-26 23:14:33 +0000736static bool
737emulate_vpush (EmulateInstructionARM *emulator, ARMEncoding encoding)
738{
739#if 0
740 // ARM pseudo code...
741 if (ConditionPassed())
742 {
743 EncodingSpecificOperations(); CheckVFPEnabled(TRUE); NullCheckIfThumbEE(13);
744 address = SP - imm32;
745 SP = SP - imm32;
746 if single_regs then
747 for r = 0 to regs-1
748 MemA[address,4] = S[d+r]; address = address+4;
749 else
750 for r = 0 to regs-1
751 // Store as two word-aligned words in the correct order for current endianness.
752 MemA[address,4] = if BigEndian() then D[d+r]<63:32> else D[d+r]<31:0>;
753 MemA[address+4,4] = if BigEndian() then D[d+r]<31:0> else D[d+r]<63:32>;
754 address = address+8;
755 }
756#endif
757
758 bool success = false;
759 const uint32_t opcode = emulator->OpcodeAsUnsigned (&success);
760 if (!success)
761 return false;
762
763 if (emulator->ConditionPassed())
764 {
765 const uint32_t addr_byte_size = emulator->GetAddressByteSize();
766 const addr_t sp = emulator->ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, 0, &success);
767 if (!success)
768 return false;
769 bool single_regs;
770 uint32_t d; // UInt(Vd:D) starting register
771 uint32_t imm32; // stack offset
772 uint32_t regs; // number of registers
773 switch (encoding) {
774 case eEncodingT1:
775 case eEncodingA1:
776 single_regs = false;
777 d = Bits32(opcode, 15, 12) << 1 | Bits32(opcode, 22, 22);
778 imm32 = Bits32(opcode, 7, 0) * addr_byte_size;
779 // If UInt(imm8) is odd, see "FSTMX".
780 regs = Bits32(opcode, 7, 0) / 2;
781 // if regs == 0 || regs > 16 || (d+regs) > 32 then UNPREDICTABLE;
782 if (regs == 0 || regs > 16 || (d + regs) > 32)
783 return false;
784 break;
785 case eEncodingT2:
786 case eEncodingA2:
787 single_regs = true;
788 d = Bits32(opcode, 15, 12) << 1 | Bits32(opcode, 22, 22);
789 imm32 = Bits32(opcode, 7, 0) * addr_byte_size;
790 regs = Bits32(opcode, 7, 0);
791 // if regs == 0 || regs > 16 || (d+regs) > 32 then UNPREDICTABLE;
792 if (regs == 0 || regs > 16 || (d + regs) > 32)
793 return false;
794 break;
795 default:
796 return false;
797 }
798 uint32_t start_reg = single_regs ? dwarf_s0 : dwarf_d0;
799 uint32_t reg_byte_size = single_regs ? addr_byte_size : addr_byte_size * 2;
800 addr_t sp_offset = imm32;
801 addr_t addr = sp - sp_offset;
802 uint32_t i;
803
804 EmulateInstruction::Context context = { EmulateInstruction::eContextPushRegisterOnStack, eRegisterKindDWARF, 0, 0 };
805 for (i=d; i<regs; ++i)
806 {
807 context.arg1 = start_reg + i; // arg1 in the context is the DWARF register number
808 context.arg2 = addr - sp; // arg2 in the context is the stack pointer offset
809 // uint64_t to accommodate 64-bit registers.
810 uint64_t reg_value = emulator->ReadRegisterUnsigned(eRegisterKindDWARF, context.arg1, 0, &success);
811 if (!success)
812 return false;
813 if (!emulator->WriteMemoryUnsigned (context, addr, reg_value, reg_byte_size))
814 return false;
815 addr += reg_byte_size;
816 }
817
818 context.type = EmulateInstruction::eContextAdjustStackPointer;
819 context.arg0 = eRegisterKindGeneric;
820 context.arg1 = LLDB_REGNUM_GENERIC_SP;
Johnny Chen5b442b72011-01-27 19:34:30 +0000821 context.arg2 = -sp_offset;
Johnny Chen799dfd02011-01-26 23:14:33 +0000822
823 if (!emulator->WriteRegisterUnsigned (context, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp - sp_offset))
824 return false;
825 }
826 return true;
827}
828
Greg Clayton64c84432011-01-21 22:02:52 +0000829static ARMOpcode g_arm_opcodes[] =
830{
Johnny Chene4455022011-01-26 00:08:59 +0000831 // push register(s)
Johnny Chenbcec3af2011-01-27 01:26:19 +0000832 { 0x0fff0000, 0x092d0000, ARMvAll, eEncodingA1, eSize32, emulate_push, "push <registers>" },
833 { 0x0fff0fff, 0x052d0004, ARMvAll, eEncodingA2, eSize32, emulate_push, "push <register>" },
834
Johnny Chen5b442b72011-01-27 19:34:30 +0000835 // set r7 to point to a stack offset
Johnny Chenbcec3af2011-01-27 01:26:19 +0000836 { 0x0ffff000, 0x028d7000, ARMvAll, eEncodingA1, eSize32, emulate_add_rd_sp_imm, "add r7, sp, #<const>" },
Johnny Chen2ccad832011-01-28 19:57:25 +0000837 { 0x0ffff000, 0x024c7000, ARMvAll, eEncodingA1, eSize32, emulate_sub_r7_ip_imm, "sub r7, ip, #<const>"},
Johnny Chen5b442b72011-01-27 19:34:30 +0000838 // set ip to point to a stack offset
Johnny Chen2ccad832011-01-28 19:57:25 +0000839 { 0x0fffffff, 0x01a0c00d, ARMvAll, eEncodingA1, eSize32, emulate_mov_rd_sp, "mov ip, sp" },
Johnny Chenbcec3af2011-01-27 01:26:19 +0000840 { 0x0ffff000, 0x028dc000, ARMvAll, eEncodingA1, eSize32, emulate_add_rd_sp_imm, "add ip, sp, #<const>" },
Johnny Chen2ccad832011-01-28 19:57:25 +0000841 { 0x0ffff000, 0x024dc000, ARMvAll, eEncodingA1, eSize32, emulate_sub_ip_sp_imm, "sub ip, sp, #<const>"},
Johnny Chen4c0e0bc2011-01-25 22:45:28 +0000842
843 // adjust the stack pointer
Johnny Chenbcec3af2011-01-27 01:26:19 +0000844 { 0x0ffff000, 0x024dd000, ARMvAll, eEncodingA1, eSize32, emulate_sub_sp_imm, "sub sp, sp, #<const>"},
Johnny Chence1ca772011-01-25 01:13:00 +0000845
Johnny Chen2ccad832011-01-28 19:57:25 +0000846 // push one register
Johnny Chence1ca772011-01-25 01:13:00 +0000847 // if Rn == '1101' && imm12 == '000000000100' then SEE PUSH;
Johnny Chen788e0552011-01-27 22:52:23 +0000848 { 0x0fff0000, 0x052d0000, ARMvAll, eEncodingA1, eSize32, emulate_str_rt_sp, "str Rt, [sp, #-imm12]!" },
Johnny Chen799dfd02011-01-26 23:14:33 +0000849
850 // vector push consecutive extension register(s)
Johnny Chenbcec3af2011-01-27 01:26:19 +0000851 { 0x0fbf0f00, 0x0d2d0b00, ARMv6T2|ARMv7, eEncodingA1, eSize32, emulate_vpush, "vpush.64 <list>"},
852 { 0x0fbf0f00, 0x0d2d0a00, ARMv6T2|ARMv7, eEncodingA2, eSize32, emulate_vpush, "vpush.32 <list>"}
Greg Clayton64c84432011-01-21 22:02:52 +0000853};
854
Johnny Chen347320d2011-01-24 23:40:59 +0000855static ARMOpcode g_thumb_opcodes[] =
856{
Johnny Chene4455022011-01-26 00:08:59 +0000857 // push register(s)
Johnny Chenbcec3af2011-01-27 01:26:19 +0000858 { 0xfffffe00, 0x0000b400, ARMvAll, eEncodingT1, eSize16, emulate_push, "push <registers>" },
859 { 0xffff0000, 0xe92d0000, ARMv6T2|ARMv7, eEncodingT2, eSize32, emulate_push, "push.w <registers>" },
860 { 0xffff0fff, 0xf84d0d04, ARMv6T2|ARMv7, eEncodingT3, eSize32, emulate_push, "push.w <register>" },
Johnny Chen1c13b622011-01-29 00:11:15 +0000861 // move from high register to low register
862 { 0xffffffc0, 0x00004640, ARMvAll, eEncodingT1, eSize16, emulate_mov_low_high, "mov r0-r7, r8-r15" },
Johnny Chenbcec3af2011-01-27 01:26:19 +0000863
Johnny Chen5b442b72011-01-27 19:34:30 +0000864 // set r7 to point to a stack offset
Johnny Chen2ccad832011-01-28 19:57:25 +0000865 { 0xffffff00, 0x0000af00, ARMvAll, eEncodingT1, eSize16, emulate_add_rd_sp_imm, "add r7, sp, #imm" },
866 { 0xffffffff, 0x0000466f, ARMvAll, eEncodingT1, eSize16, emulate_mov_rd_sp, "mov r7, sp" },
Johnny Chen788e0552011-01-27 22:52:23 +0000867
868 // PC relative load into register (see also emulate_add_sp_rm)
869 { 0xfffff800, 0x00004800, ARMvAll, eEncodingT1, eSize16, emulate_ldr_rd_pc_rel, "ldr <Rd>, [PC, #imm]"},
Johnny Chen60c0d622011-01-25 23:49:39 +0000870
871 // adjust the stack pointer
Johnny Chen5b442b72011-01-27 19:34:30 +0000872 { 0xffffff87, 0x00004485, ARMvAll, eEncodingT2, eSize16, emulate_add_sp_rm, "add sp, <Rm>"},
Johnny Chen788e0552011-01-27 22:52:23 +0000873 { 0xffffff80, 0x0000b080, ARMvAll, eEncodingT1, eSize16, emulate_sub_sp_imm, "add sp, sp, #imm"},
Johnny Chen5b442b72011-01-27 19:34:30 +0000874 { 0xfbef8f00, 0xf1ad0d00, ARMv6T2|ARMv7, eEncodingT2, eSize32, emulate_sub_sp_imm, "sub.w sp, sp, #<const>"},
Johnny Chen788e0552011-01-27 22:52:23 +0000875 { 0xfbff8f00, 0xf2ad0d00, ARMv6T2|ARMv7, eEncodingT3, eSize32, emulate_sub_sp_imm, "subw sp, sp, #imm12"},
Johnny Chen799dfd02011-01-26 23:14:33 +0000876
877 // vector push consecutive extension register(s)
Johnny Chenbcec3af2011-01-27 01:26:19 +0000878 { 0xffbf0f00, 0xed2d0b00, ARMv6T2|ARMv7, eEncodingT1, eSize32, emulate_vpush, "vpush.64 <list>"},
879 { 0xffbf0f00, 0xed2d0a00, ARMv6T2|ARMv7, eEncodingT2, eSize32, emulate_vpush, "vpush.32 <list>"}
Johnny Chen347320d2011-01-24 23:40:59 +0000880};
881
Greg Clayton64c84432011-01-21 22:02:52 +0000882static const size_t k_num_arm_opcodes = sizeof(g_arm_opcodes)/sizeof(ARMOpcode);
Johnny Chen347320d2011-01-24 23:40:59 +0000883static const size_t k_num_thumb_opcodes = sizeof(g_thumb_opcodes)/sizeof(ARMOpcode);
Greg Clayton64c84432011-01-21 22:02:52 +0000884
Greg Clayton31e2a382011-01-30 20:03:56 +0000885bool
886EmulateInstructionARM::SetTargetTriple (const ConstString &triple)
887{
888 m_arm_isa = 0;
889 const char *triple_cstr = triple.GetCString();
890 if (triple_cstr)
891 {
892 const char *dash = ::strchr (triple_cstr, '-');
893 if (dash)
894 {
895 std::string arch (triple_cstr, dash);
896 const char *arch_cstr = arch.c_str();
897 if (strcasecmp(arch_cstr, "armv4t") == 0)
898 m_arm_isa = ARMv4T;
899 else if (strcasecmp(arch_cstr, "armv4") == 0)
900 m_arm_isa = ARMv4;
901 else if (strcasecmp(arch_cstr, "armv5tej") == 0)
902 m_arm_isa = ARMv5TEJ;
903 else if (strcasecmp(arch_cstr, "armv5te") == 0)
904 m_arm_isa = ARMv5TE;
905 else if (strcasecmp(arch_cstr, "armv5t") == 0)
906 m_arm_isa = ARMv5T;
907 else if (strcasecmp(arch_cstr, "armv6k") == 0)
908 m_arm_isa = ARMv6K;
909 else if (strcasecmp(arch_cstr, "armv6") == 0)
910 m_arm_isa = ARMv6;
911 else if (strcasecmp(arch_cstr, "armv6t2") == 0)
912 m_arm_isa = ARMv6T2;
913 else if (strcasecmp(arch_cstr, "armv7") == 0)
914 m_arm_isa = ARMv7;
915 else if (strcasecmp(arch_cstr, "armv8") == 0)
916 m_arm_isa = ARMv8;
917 }
918 }
919 return m_arm_isa != 0;
920}
921
922
Greg Clayton64c84432011-01-21 22:02:52 +0000923bool
924EmulateInstructionARM::ReadInstruction ()
925{
926 bool success = false;
927 m_inst_cpsr = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS, 0, &success);
928 if (success)
929 {
930 addr_t pc = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_ADDRESS, &success);
931 if (success)
932 {
933 Context read_inst_context = {eContextReadOpcode, 0, 0};
934 if (m_inst_cpsr & MASK_CPSR_T)
935 {
936 m_inst_mode = eModeThumb;
937 uint32_t thumb_opcode = ReadMemoryUnsigned(read_inst_context, pc, 2, 0, &success);
938
939 if (success)
940 {
941 if ((m_inst.opcode.inst16 & 0xe000) != 0xe000 || ((m_inst.opcode.inst16 & 0x1800u) == 0))
942 {
943 m_inst.opcode_type = eOpcode16;
944 m_inst.opcode.inst16 = thumb_opcode;
945 }
946 else
947 {
948 m_inst.opcode_type = eOpcode32;
949 m_inst.opcode.inst32 = (thumb_opcode << 16) | ReadMemoryUnsigned(read_inst_context, pc + 2, 2, 0, &success);
950 }
951 }
952 }
953 else
954 {
955 m_inst_mode = eModeARM;
956 m_inst.opcode_type = eOpcode32;
957 m_inst.opcode.inst32 = ReadMemoryUnsigned(read_inst_context, pc, 4, 0, &success);
958 }
959 }
960 }
961 if (!success)
962 {
963 m_inst_mode = eModeInvalid;
964 m_inst_pc = LLDB_INVALID_ADDRESS;
965 }
966 return success;
967}
968
969uint32_t
970EmulateInstructionARM::CurrentCond ()
971{
972 switch (m_inst_mode)
973 {
974 default:
975 case eModeInvalid:
976 break;
977
978 case eModeARM:
979 return UnsignedBits(m_inst.opcode.inst32, 31, 28);
980
981 case eModeThumb:
982 return 0x0000000Eu; // Return always for now, we need to handl IT instructions later
983 }
984 return UINT32_MAX; // Return invalid value
985}
986bool
987EmulateInstructionARM::ConditionPassed ()
988{
989 if (m_inst_cpsr == 0)
990 return false;
991
992 const uint32_t cond = CurrentCond ();
993
994 if (cond == UINT32_MAX)
995 return false;
996
997 bool result = false;
998 switch (UnsignedBits(cond, 3, 1))
999 {
1000 case 0: result = (m_inst_cpsr & MASK_CPSR_Z) != 0; break;
1001 case 1: result = (m_inst_cpsr & MASK_CPSR_C) != 0; break;
1002 case 2: result = (m_inst_cpsr & MASK_CPSR_N) != 0; break;
1003 case 3: result = (m_inst_cpsr & MASK_CPSR_V) != 0; break;
1004 case 4: result = ((m_inst_cpsr & MASK_CPSR_C) != 0) && ((m_inst_cpsr & MASK_CPSR_Z) == 0); break;
1005 case 5:
1006 {
1007 bool n = (m_inst_cpsr & MASK_CPSR_N);
1008 bool v = (m_inst_cpsr & MASK_CPSR_V);
1009 result = n == v;
1010 }
1011 break;
1012 case 6:
1013 {
1014 bool n = (m_inst_cpsr & MASK_CPSR_N);
1015 bool v = (m_inst_cpsr & MASK_CPSR_V);
1016 result = n == v && ((m_inst_cpsr & MASK_CPSR_Z) == 0);
1017 }
1018 break;
1019 case 7:
1020 result = true;
1021 break;
1022 }
1023
1024 if (cond & 1)
1025 result = !result;
1026 return result;
1027}
1028
1029
1030bool
1031EmulateInstructionARM::EvaluateInstruction ()
1032{
1033 return false;
1034}