summaryrefslogtreecommitdiff
path: root/disasm.h
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-05-14 22:43:54 +0300
committerOxore <oxore@protonmail.com>2023-05-14 22:51:08 +0300
commita8e2bf904ebe7a2c668fbad50ab7433a427607c6 (patch)
tree25666b992276d04d89d0fe10d4780ad5ac971da6 /disasm.h
parentd9ba2fbbf1fe7b7543258f8698081f0f4509e46c (diff)
Move instruction related data into separate Op struct
Diffstat (limited to 'disasm.h')
-rw-r--r--disasm.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/disasm.h b/disasm.h
index cac0bea..6eaf48b 100644
--- a/disasm.h
+++ b/disasm.h
@@ -331,6 +331,19 @@ struct Op {
Condition condition{Condition::kT}; ///< For Scc, Bcc and Dbcc
Arg arg1{}; ///< First argument, optional
Arg arg2{}; ///< Second argument, optional, cannot be set if arg1 is not set
+ static constexpr auto Typical(
+ const OpCode opcode = OpCode::kNone,
+ const OpSize opsize = OpSize::kNone,
+ const Arg arg1 = Arg{},
+ const Arg arg2 = Arg{})
+ {
+ return Op{opcode, opsize, Condition::kT, arg1, arg2};
+ }
+ static constexpr auto Raw(const uint16_t instr)
+ {
+ return Op::Typical(OpCode::kRaw, OpSize::kNone, Arg::Raw(instr));
+ }
+ int FPrint(FILE*, const Settings&) const;
};
struct DisasmNode {
@@ -348,18 +361,12 @@ struct DisasmNode {
bool is_call{};
ReferenceNode *ref_by{};
ReferenceNode *last_ref_by{};
- OpCode opcode{OpCode::kNone}; ///< Identifies instruction (mnemonic)
- /// Size specifier, the suffix `b`, `w` or `l`
- OpSize size_spec{OpSize::kNone};
- Condition condition{Condition::kT}; ///< For Scc, Bcc and Dbcc
- Arg arg1{}, arg2{}; ///< Argument specifiers (in order as in asm listing)
Op op{};
/*! Disassembles instruction with arguments
* returns size of whole instruction with arguments in bytes
*/
size_t Disasm(const DataBuffer &code);
- int FPrint(FILE*, const Settings&) const;
void AddReferencedBy(uint32_t offset, ReferenceType);
~DisasmNode();
private: