This commit is contained in:
Kelvin Sherlock 2017-01-05 00:40:30 -05:00
parent 2cd1ad1ce5
commit 9d937e9c37
3 changed files with 13 additions and 14 deletions

View File

@ -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);
}
}

View File

@ -3,7 +3,6 @@
#include <stdint.h>
#include <string>
#include <functional>
class disassembler {
@ -43,15 +42,8 @@ class disassembler {
void flush();
void set_label_callback(std::function<int32_t(int32_t)> 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<int32_t(int32_t)> _label_callback;
};
#endif

View File

@ -43,6 +43,14 @@ zrdz_disassembler::zrdz_disassembler(std::vector<section> &&sections, 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";