1
0
mirror of https://github.com/ksherlock/x65.git synced 2024-12-28 19:32:25 +00:00

Disassembler local label improvement

- Determination for negative branches to local labels were one off which
meant lots of unnecessary local labels at end of long functions
- struse null/0-length check was reverse causing access to 0
This commit is contained in:
Carl-Henrik Skårstedt 2015-12-12 13:22:23 -08:00
parent 0f740c25bd
commit 3b2b0f7778
2 changed files with 12 additions and 12 deletions

View File

@ -1786,10 +1786,10 @@ void GetReferences(unsigned char *mem, size_t bytes, bool acc_16, bool ind_16, i
} else { // forward check
while (j!=refs.end()) {
++j;
if (j!=refs.end() && !j->local)
skip_global = true;
if (j==refs.end() || trg_addr<j->address)
break;
if (j!=refs.end() && !j->local)
skip_global = true;
}
}
if (skip_global) {
@ -1884,15 +1884,6 @@ bool IsReadOnlyInstruction(MNM_Base op_base)
static const char spacing[] = " ";
void Disassemble(strref filename, unsigned char *mem, size_t bytes, bool acc_16, bool ind_16, int addr, bool ill_wdc, const dismnm *opcodes, bool src, int init_data, strref labels)
{
FILE *f = stdout;
bool opened = false;
if (filename) {
f = fopen(strown<512>(filename).c_str(), "w");
if (!f)
return;
opened = true;
}
const char *spc = src ? "" : spacing;
strref prev_src;
@ -1908,6 +1899,15 @@ void Disassemble(strref filename, unsigned char *mem, size_t bytes, bool acc_16,
bool is_ptrs = is_data && (refs[0].data==DT_PTRS || refs[0].data==DT_PTRS_DATA);
strown<256> out;
FILE *f = stdout;
bool opened = false;
if (filename) {
f = fopen(strown<512>(filename).c_str(), "w");
if (!f)
return;
opened = true;
}
while (bytes) {
// Determine if current address is referenced from somewhere
while (curr_label_index<(int)refs.size() && addr >= refs[curr_label_index].address) {

View File

@ -1500,7 +1500,7 @@ unsigned int strref::ahextoui_skip()
{
const char *scan = string;
strl_t left = length;
while (*scan<=0x20 && left) {
while (left && *scan<=0x20) {
scan++;
left--;
}