2#ifndef ROSE_BinaryAnalysis_Disassembler_M68k_H
3#define ROSE_BinaryAnalysis_Disassembler_M68k_H
4#include <featureTests.h>
5#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/Disassembler/Base.h>
8#include <Rose/BinaryAnalysis/Architecture/BasicTypes.h>
9#include <Rose/BinaryAnalysis/InstructionEnumsM68k.h>
10#include "BitPattern.h"
12#include <boost/serialization/access.hpp>
13#include <boost/serialization/base_object.hpp>
14#include <boost/serialization/export.hpp>
15#include <boost/serialization/split_member.hpp>
18namespace BinaryAnalysis {
19namespace Disassembler {
28 struct State: boost::noncopyable {
51 : name(name), family(family), pattern(pattern) {}
68 typedef std::list<Decoder*> IdisList;
69 typedef std::vector<IdisList> IdisTable;
72#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
74 friend class boost::serialization::access;
77 void serialize_common(S &s,
const unsigned ) {
78 s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
79 s & BOOST_SERIALIZATION_NVP(family);
84 void save(S &s,
const unsigned version)
const {
85 serialize_common(s, version);
89 void load(S &s,
const unsigned version) {
90 serialize_common(s, version);
94 BOOST_SERIALIZATION_SPLIT_MEMBER();
119 typedef std::pair<SgAsmExpression*, SgAsmExpression*> ExpressionPair;
165 size_t bit_offset=0)
const;
249#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
Virtual base class for instruction disassemblers.
Exception thrown by the disassemblers.
Interface for disassembling a single instruction.
Disassembler for Motorola M68k-based instruction set architectures.
SgAsmRegisterReferenceExpression * makeProgramCounter(State &) const
Create a reference to the program counter register.
SgAsmExpression * makeAddress(State &, SgAsmExpression *expr) const
Converts a memory-reference expression to an address.
ExpressionPair makeOffsetWidthPair(State &, unsigned extension_word) const
Create an offset width pair from an extension word.
SgAsmRegisterNames * makeRegistersFromMask(State &, unsigned mask, M68kDataFormat fmt, bool reverse=false) const
Create a list of data and/or address registers.
virtual Base::Ptr clone() const override
Creates a new copy of a disassembler.
SgAsmRegisterReferenceExpression * makeMacRegister(State &, M68kMacRegister) const
Create a MAC register reference expression.
virtual SgAsmInstruction * makeUnknownInstruction(const Exception &) override
Makes an unknown instruction from an exception.
SgAsmIntegerValueExpression * makeImmediateValue(State &, M68kDataFormat fmt, unsigned value) const
Create an integer expression from a specified value.
SgAsmM68kInstruction * makeInstruction(State &, M68kInstructionKind, M68kDataFormat, SgAsmExpression *arg0=NULL, SgAsmExpression *arg1=NULL, SgAsmExpression *arg2=NULL, SgAsmExpression *arg3=NULL, SgAsmExpression *arg4=NULL, SgAsmExpression *arg5=NULL, SgAsmExpression *arg6=NULL) const
Build an instruction.
SgAsmMemoryReferenceExpression * makeAddressRegisterPostIncrement(State &, unsigned regnum, M68kDataFormat fmt) const
Make a memory reference expression using an address register in post-increment mode.
SgAsmRegisterNames * makeFPRegistersFromMask(State &, unsigned mask, M68kDataFormat fmt, bool reverse=false) const
Create a list of floating-point data registers.
SgAsmRegisterReferenceExpression * makeFPRegister(State &, unsigned regnum) const
Create a floating point register.
SgAsmExpression * makeEffectiveAddress(State &, unsigned modreg, M68kDataFormat fmt, size_t ext_offset) const
Create an expression for m68k "<ea>x" or "<ea>y".
SgAsmRegisterReferenceExpression * makeDataRegister(State &, unsigned regnum, M68kDataFormat, size_t bit_offset=0) const
Create a data register reference expression.
virtual SgAsmInstruction * disassembleOne(const MemoryMap::Ptr &, rose_addr_t start_va, AddressSet *successors=nullptr) override
This is the lowest level disassembly function and is implemented in the architecture-specific subclas...
static Ptr instance(const Architecture::BaseConstPtr &, M68kFamily)
Allocating constructor for a specific family.
SgAsmRegisterReferenceExpression * makeMacAccumulatorRegister(State &, unsigned accumIndex) const
Create a MAC accumulator register.
uint16_t instructionWord(State &, size_t n) const
Return the Nth instruction word.
size_t extensionWordsUsed(State &) const
Returns number of instruction words referenced so far in the current instruction.
SgAsmType * makeType(State &, M68kDataFormat) const
Create a ROSE data type for m68k data format.
SgAsmIntegerValueExpression * makeImmediateExtension(State &, M68kDataFormat fmt, size_t ext_word_idx) const
Create an integer expression from extension words.
SgAsmRegisterReferenceExpression * makeStatusRegister(State &) const
Create a reference to the status register.
void insert_idis(Decoder *)
Insert an instruction-specific disassembler.
SgAsmRegisterReferenceExpression * makeColdFireControlRegister(State &, unsigned regnum) const
Create control register for ColdFire cpu.
SgAsmExpression * makeEffectiveAddress(State &, unsigned mode, unsigned reg, M68kDataFormat fmt, size_t ext_offset) const
Create an expression for m68k "<ea>x" or "<ea>y".
SgAsmRegisterReferenceExpression * makeRegister(RegisterDescriptor) const
Generic ways to make a register.
void start_instruction(State &state, const MemoryMap::Ptr &map, rose_addr_t start_va) const
Called by disassembleOne() to initialize the disassembler state for the next instruction.
SgAsmRegisterReferenceExpression * makeConditionCodeRegister(State &) const
Create a reference to the condition code register.
SgAsmMemoryReferenceExpression * makeAddressRegisterPreDecrement(State &, unsigned regnum, M68kDataFormat fmt) const
Make a memory reference expression using an address register in pre-decrement mode.
SgAsmRegisterReferenceExpression * makeDataAddressRegister(State &, unsigned regnum, M68kDataFormat fmt, size_t bit_offset=0) const
Create either a data or address register reference expression.
SgAsmRegisterReferenceExpression * makeAddressRegister(State &, unsigned regnum, M68kDataFormat, size_t bit_offset=0) const
Create an address register reference expression.
Decoder * find_idis(uint16_t *insn_bytes, size_t nbytes) const
Find an instruction-specific disassembler.
M68kFamily get_family() const
Returns ISA family specified in constructor.
Describes (part of) a physical CPU register.
Describes a pattern of bits in a finite number of words.
Reference-counting intrusive smart pointer.
Base class for expressions.
Base class for machine instructions.
Base class for integer values.
Reference to memory locations.
An ordered list of registers.
Base class for references to a machine register.
Base class for binary types.
std::shared_ptr< const Base > BaseConstPtr
Reference counted pointer for Architecture::Base.
uint16_t iwords[11]
Instruction words.
rose_addr_t insn_va
Address of instruction.
MemoryMap::Ptr map
Map from which to read instruction words.
size_t niwords_used
High water number of instruction words used by instructionWord().
size_t niwords
Number of instruction words read.