mirror of
https://github.com/ksherlock/wdc-utils.git
synced 2024-12-12 04:29:05 +00:00
disassembler reserved space support.
This commit is contained in:
parent
9d937e9c37
commit
43ac7ba514
@ -498,13 +498,52 @@ void disassembler::flush() {
|
||||
void disassembler::check_labels() {
|
||||
|
||||
if ( _next_label >= 0 && _pc + _st >= _next_label) {
|
||||
//flush();
|
||||
//flush(); // -- too recursive. see above.
|
||||
if (_st) dump();
|
||||
_next_label = next_label(_pc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void disassembler::space(unsigned size) {
|
||||
flush();
|
||||
|
||||
std::string line;
|
||||
|
||||
indent_to(line, kOpcodeTab);
|
||||
line += "ds";
|
||||
indent_to(line, kOperandTab);
|
||||
|
||||
|
||||
while (size) {
|
||||
uint32_t chunk;
|
||||
if (_next_label == -1) chunk = size;
|
||||
else {
|
||||
chunk = _next_label - _pc;
|
||||
chunk = std::min(chunk, size);
|
||||
}
|
||||
|
||||
line.resize(kOperandTab);
|
||||
line += std::to_string(chunk);
|
||||
indent_to(line, kCommentTab);
|
||||
line += "; ";
|
||||
|
||||
line += to_x(_pc, 4);
|
||||
line.push_back(':');
|
||||
line.push_back('\n');
|
||||
fputs(line.c_str(), stdout);
|
||||
|
||||
|
||||
_pc += chunk;
|
||||
size -= chunk;
|
||||
if (_next_label == _pc) _next_label = next_label(_pc);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void disassembler::operator()(const std::string &expr, unsigned size) {
|
||||
|
||||
// todo -- what if label within size?
|
||||
@ -565,6 +604,8 @@ void disassembler::operator()(uint8_t byte) {
|
||||
print();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void disassembler::print_prefix() {
|
||||
|
||||
switch(_mode & 0xf000) {
|
||||
|
@ -19,6 +19,7 @@ class disassembler {
|
||||
template<class T>
|
||||
void operator()(const T &t) { code(std::begin(t), std::end(t)); }
|
||||
|
||||
void space(unsigned bytes);
|
||||
|
||||
bool m() const { return _flags & 0x20; }
|
||||
bool x() const { return _flags & 0x10; }
|
||||
|
@ -244,9 +244,7 @@ bool dump_obj(const char *name, int fd)
|
||||
zrdz_disassembler d(read_sections(section_data), read_symbols(symbol_data));
|
||||
|
||||
uint8_t op = REC_END;
|
||||
unsigned section = SECT_CODE; // default section = CODE
|
||||
unsigned line = 0;
|
||||
std::string file;
|
||||
|
||||
|
||||
d.front_matter(std::string(oname.data()));
|
||||
@ -393,7 +391,7 @@ bool dump_obj(const char *name, int fd)
|
||||
d.emit("", "longi", "off");
|
||||
break;
|
||||
case D_C_FILE: {
|
||||
file = read_cstring(iter);
|
||||
std::string file = read_cstring(iter);
|
||||
line = read_16(iter);
|
||||
std::string tmp = file + ", " + std::to_string(line);
|
||||
d.emit("", ".file", tmp);
|
||||
@ -539,11 +537,8 @@ bool dump_obj(const char *name, int fd)
|
||||
}
|
||||
|
||||
case REC_SPACE: {
|
||||
d.flush();
|
||||
uint16_t count = read_16(iter);
|
||||
// todo -- need to coordinate with label printer/disassembler.
|
||||
d.emit("", "ds", d.to_x(count, 4, '$'));
|
||||
d.set_pc(d.pc() + count);
|
||||
d.space(count);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user