mirror of
https://github.com/ksherlock/wdc-utils.git
synced 2024-12-12 04:29:05 +00:00
improved label placement.
This commit is contained in:
parent
d991eabdfd
commit
fbd4fad488
36
dumpobj.cpp
36
dumpobj.cpp
@ -182,6 +182,19 @@ symbol find_symbol(const std::vector<symbol> &symbols, unsigned section, unsigne
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void place_labels(std::vector<symbol> &labels, uint32_t pc) {
|
||||||
|
while (!labels.empty()) {
|
||||||
|
auto &label = labels.back();
|
||||||
|
if (label.offset > pc) return;
|
||||||
|
if (label.offset == pc) {
|
||||||
|
printf("%s:\n", label.name.c_str());
|
||||||
|
} else {
|
||||||
|
warnx("Unable to place label %s (offset $%04x)", label.name.c_str(), label.offset);
|
||||||
|
}
|
||||||
|
labels.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dump_obj(const char *name, int fd)
|
void dump_obj(const char *name, int fd)
|
||||||
{
|
{
|
||||||
static const char *sections[] = { "PAGE0", "CODE", "KDATA", "DATA", "UDATA" };
|
static const char *sections[] = { "PAGE0", "CODE", "KDATA", "DATA", "UDATA" };
|
||||||
@ -249,7 +262,7 @@ void dump_obj(const char *name, int fd)
|
|||||||
|
|
||||||
unsigned section = 1; // default section = CODE.
|
unsigned section = 1; // default section = CODE.
|
||||||
std::vector<symbol> labels = labels_for_section(symbols, section);
|
std::vector<symbol> labels = labels_for_section(symbols, section);
|
||||||
|
//uint32_t label_pc = labels.empty() ? 0xffff : labels.back().offset;
|
||||||
|
|
||||||
uint8_t op = REC_END;
|
uint8_t op = REC_END;
|
||||||
|
|
||||||
@ -258,16 +271,16 @@ void dump_obj(const char *name, int fd)
|
|||||||
auto iter = data.begin();
|
auto iter = data.begin();
|
||||||
while (iter != data.end()) {
|
while (iter != data.end()) {
|
||||||
|
|
||||||
while (!labels.empty() && labels.back().offset == d.pc()) {
|
place_labels(labels, d.pc());
|
||||||
printf("%s:\n", labels.back().name.c_str());
|
|
||||||
labels.pop_back();
|
|
||||||
}
|
|
||||||
|
|
||||||
op = read_8(iter);
|
op = read_8(iter);
|
||||||
if (op == 0) break;
|
if (op == 0) break;
|
||||||
if (op < 0xf0) {
|
if (op < 0xf0) {
|
||||||
d.process(iter, iter + op);
|
auto end = iter + op;
|
||||||
iter += op;
|
while (iter != end) {
|
||||||
|
d.process(*iter++);
|
||||||
|
place_labels(labels, d.pc());
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,6 +463,15 @@ void dump_obj(const char *name, int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
place_labels(labels, d.pc());
|
||||||
|
|
||||||
|
|
||||||
|
for(auto &label : labels) {
|
||||||
|
warnx("Unable to place label %s (offset $%04x)", label.name.c_str(), label.offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (iter != data.end() || op != REC_END) errx(EX_DATAERR, "%s records ended early", name);
|
if (iter != data.end() || op != REC_END) errx(EX_DATAERR, "%s records ended early", name);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user