summaryrefslogtreecommitdiff
path: root/disasm.h
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-04-23 19:17:01 +0300
committerOxore <oxore@protonmail.com>2023-04-23 19:17:01 +0300
commite8bc35a6297da6bea1eed833ac25cfebe1fee355 (patch)
tree2bf1b5826036bdc51023181ea8ab70a6fb7e0a8e /disasm.h
parent771b675f2ec83c1b6b2d41d236fc4bd3c368b1cd (diff)
Impl separate xref types call and branch
Diffstat (limited to 'disasm.h')
-rw-r--r--disasm.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/disasm.h b/disasm.h
index f8820ef..7fb38db 100644
--- a/disasm.h
+++ b/disasm.h
@@ -17,9 +17,20 @@ constexpr size_t kMnemonicBufferSize = 8;
constexpr size_t kArgsBufferSize = 64;
constexpr size_t kMarkBufferSize = 64;
+enum class ReferenceType {
+ kUnknown = 0,
+ kBranch,
+ kCall,
+};
+
+struct ReferenceRecord {
+ ReferenceType type{};
+ uint32_t address{};
+};
+
struct ReferenceNode {
ReferenceNode *next{};
- uint32_t refs[kRefsCountPerBuffer];
+ ReferenceRecord refs[kRefsCountPerBuffer];
uint32_t refs_count{};
};
@@ -33,6 +44,9 @@ struct DisasmNode {
bool has_branch_addr{};
/// Absolute address of where to branch to
uint32_t branch_addr{};
+ /// Indicates whether instruction is a call (BSR, JSR) or just a branch
+ /// (Bcc, JMP) if `has_branch_addr` is set
+ bool is_call{};
/// Mnemonic of the instruction at the current offset
char mnemonic[kMnemonicBufferSize]{};
/// Formatted arguments of the instruction;
@@ -43,7 +57,7 @@ struct DisasmNode {
ReferenceNode *ref_by{};
ReferenceNode *last_ref_by{};
void Disasm(const DataBuffer &code, const Settings&);
- void AddReferencedBy(uint32_t offset);
+ void AddReferencedBy(uint32_t offset, ReferenceType);
~DisasmNode();
private:
};