diff options
author | Oxore <oxore@protonmail.com> | 2023-04-23 00:27:58 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-04-23 00:35:30 +0300 |
commit | 771b675f2ec83c1b6b2d41d236fc4bd3c368b1cd (patch) | |
tree | 14d83b3b84b1edc218018c8eea9a49fefe15282d /disasm.h | |
parent | 8b874f105d52a461942bbb8960d0f729c0865507 (diff) |
Pass settings everywhere, impl cross references
Diffstat (limited to 'disasm.h')
-rw-r--r-- | disasm.h | 41 |
1 files changed, 32 insertions, 9 deletions
@@ -11,16 +11,39 @@ enum class TracedNodeType { kData, }; -constexpr size_t kMnemonicBufferSize{10}; -constexpr size_t kArgsBufferSize{50}; +constexpr size_t kRefsCountPerBuffer = 10; + +constexpr size_t kMnemonicBufferSize = 8; +constexpr size_t kArgsBufferSize = 64; +constexpr size_t kMarkBufferSize = 64; + +struct ReferenceNode { + ReferenceNode *next{}; + uint32_t refs[kRefsCountPerBuffer]; + uint32_t refs_count{}; +}; struct DisasmNode { - TracedNodeType type{}; - uint32_t offset{}; - size_t size{kInstructionSizeStepBytes}; // Instruction size in bytes + const TracedNodeType type{}; + /// Absolute offset of the instruction (PC value basically) + const uint32_t offset{}; + /// Instruction size in bytes + size_t size{kInstructionSizeStepBytes}; + /// Indicates whether `branch_addr` should be interpreted bool has_branch_addr{}; - uint32_t branch_addr{}; // Absolute address of where to branch to - char mnemonic[kMnemonicBufferSize]{}; // Mnemonic of the instruction at the current offset - char arguments[kArgsBufferSize]{}; // Formatted arguments of the instruction - void Disasm(const DataBuffer &code); + /// Absolute address of where to branch to + uint32_t branch_addr{}; + /// Mnemonic of the instruction at the current offset + char mnemonic[kMnemonicBufferSize]{}; + /// Formatted arguments of the instruction; + char arguments[kArgsBufferSize]{}; + /// Additional instruction specific info to put in a comment + char additional[kArgsBufferSize]{}; + /// Additional instruction specific info to put in a comment + ReferenceNode *ref_by{}; + ReferenceNode *last_ref_by{}; + void Disasm(const DataBuffer &code, const Settings&); + void AddReferencedBy(uint32_t offset); + ~DisasmNode(); +private: }; |