Fixed problem in DeviceSettings::strParam, returned wrong string
[avr-sim.git] / src / Instruction.h
blob913362373f85d3c57e7c1a1adc7c8bf9ef6b3e4f
1 #ifndef INSTRUCTION_H
2 #define INSTRUCTION_H
4 #include "Exception.h"
5 #include "Format.h"
6 #include "Types.h"
8 namespace avr {
10 class Core;
12 /**
13 * @author Tom Haber
14 * @date Apr 21, 2008
15 * @brief Thrown on illegal instructions
17 * Thrown on illegal instructions, the opcode is available.
19 class IllegalInstruction : public util::Exception {
20 public:
21 IllegalInstruction(word opcode)
22 : Exception( util::format("Illegal Instruction: %x") % opcode ) {}
25 /**
26 * \author Tom Haber
27 * \date Apr 21, 2008
28 * \brief An interface for all instructions on the chip.
30 * An interface for all instructions on the chip.
31 * It has a method for executing instructions on the Core
32 * and tracing (pretty printing) them.
34 class Instruction {
35 public:
36 Instruction() {}
37 virtual ~Instruction() {}
39 public:
40 /**
41 * Executes an instruction on the Core.
43 virtual int operator()(Core *core) const = 0;
45 /**
46 * Pretty prints an instruction
48 virtual int trace(Core *core, std::ostream & ostr) const = 0;
50 /**
51 * Returns whether the instruction has 2 words or just 1.
53 virtual bool is2Word() const { return false; }
58 #endif /*INSTRUCTION_H*/