ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DisassemblerArm.h
Go to the documentation of this file.
1 /* Disassembly specific to the ARM architecture. */
2 
3 #ifndef ROSE_DISASSEMBLER_ARM_H
4 #define ROSE_DISASSEMBLER_ARM_H
5 
8 public:
10  : decodeUnconditionalInstructions(true), ip(0), insn(0), cond(arm_cond_unknown) {
11  init();
12  }
13 
16  ip(other.ip), insn(other.insn), cond(other.cond) {
17  }
18 
19  virtual ~DisassemblerArm() {}
20 
21  virtual Disassembler *clone() const {
22  return new DisassemblerArm(*this);
23  }
24 
26  virtual bool can_disassemble(SgAsmGenericHeader*) const;
27 
29  virtual SgAsmInstruction *disassembleOne(const MemoryMap *map, rose_addr_t start_va, AddressSet *successors=NULL);
30 
32  virtual void assembleOne(SgAsmInstruction*, SgUnsignedCharList&) {abort();}
33 
35  virtual SgAsmInstruction *make_unknown_instruction(const Exception&);
36 
37 private:
41  class ExceptionArm: public Exception {
42  public:
43  ExceptionArm(const std::string &mesg, const DisassemblerArm *d, size_t bit=0)
44  : Exception(mesg, d->ip) {
45  /* Convert four-byte instruction to little-endian buffer. FIXME: assumes little-endian ARM system */
46  bytes.push_back(d->insn & 0xff);
47  bytes.push_back((d->insn>>8) & 0xff);
48  bytes.push_back((d->insn>>16) & 0xff);
49  bytes.push_back((d->insn>>24) & 0xff);
50  this->bit = bit;
51  }
52  };
53 
54  static SgAsmArmInstruction *makeInstructionWithoutOperands(uint32_t address, const std::string& mnemonic, int condPos,
55  ArmInstructionKind kind, ArmInstructionCondition cond,
56  uint32_t insn);
58  SgAsmArmRegisterReferenceExpression *makePsrFields(bool useSPSR, uint8_t fields) const;
59  SgAsmArmRegisterReferenceExpression *makePsr(bool useSPSR) const;
60 
64  SgAsmExpression* rhsOperand);
73 
75  void init();
76 
78  void startInstruction(rose_addr_t start_va, uint32_t c) {
79  ip = start_va;
80  insn = c;
81  cond = arm_cond_unknown;
82  }
83 
84  /* Per-instruction data members (mostly set by startInstruction()) */
86  uint32_t ip;
87  uint32_t insn;
88  ArmInstructionCondition cond;
89 };
90 
91 #endif