diff --git a/disassembler.cpp b/disassembler.cpp index 2f5d5ae..cf433fc 100644 --- a/disassembler.cpp +++ b/disassembler.cpp @@ -497,9 +497,10 @@ void disassembler::flush() { void disassembler::check_labels() { - if ( _label_callback && _next_label >= 0 && _pc + _st >= _next_label) { - flush(); - _next_label = _label_callback(_pc); + if ( _next_label >= 0 && _pc + _st >= _next_label) { + //flush(); + if (_st) dump(); + _next_label = next_label(_pc); } } diff --git a/disassembler.h b/disassembler.h index 28c7726..9ed7c16 100644 --- a/disassembler.h +++ b/disassembler.h @@ -3,7 +3,6 @@ #include #include -#include class disassembler { @@ -43,15 +42,8 @@ class disassembler { void flush(); - void set_label_callback(std::function callback) { - _label_callback = callback; - _next_label = -1; - if (_label_callback) _next_label = _label_callback(-1); - } - void recalc_next_label() { - if (_label_callback) _next_label = _label_callback(-1); - else _next_label = -1; + _next_label = next_label(-1); } static std::string to_x(uint32_t value, unsigned bytes, char prefix = 0); @@ -98,8 +90,6 @@ class disassembler { int32_t _next_label = -1; void check_labels(); - - std::function _label_callback; }; #endif diff --git a/zrdz_disassembler.cpp b/zrdz_disassembler.cpp index e39a816..6c1fdeb 100644 --- a/zrdz_disassembler.cpp +++ b/zrdz_disassembler.cpp @@ -43,6 +43,14 @@ zrdz_disassembler::zrdz_disassembler(std::vector
&§ions, std::vecto e.symbols.emplace_back(s); } + // sort labels... + for (auto &e : _sections) { + if (e.symbols.empty()) continue; + std::sort(e.symbols.begin(), e.symbols.end(), [](const symbol &a, const symbol &b) { + return a.offset > b.offset; + }); + } + if (_sections.size() < 5) _sections.resize(5); _sections[SECT_PAGE0].name = "page0"; _sections[SECT_CODE].name = "code";