mirror of
https://github.com/mrkite/regs.git
synced 2024-11-29 04:49:16 +00:00
supports 32bit labels on pea or ldx/lda pairs
This commit is contained in:
parent
4a4702e301
commit
10615526cd
@ -74,6 +74,8 @@ std::shared_ptr<Inst> Disassembler::decodeInst(Handle f, Entry *entry) {
|
|||||||
uint32_t addr = entry->org;
|
uint32_t addr = entry->org;
|
||||||
entry->flags &= IsFlags; // clear changed flags
|
entry->flags &= IsFlags; // clear changed flags
|
||||||
uint32_t oldFlags = entry->flags;
|
uint32_t oldFlags = entry->flags;
|
||||||
|
inst->prevWord = entry->prevWord;
|
||||||
|
entry->prevWord = 0;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case IMP:
|
case IMP:
|
||||||
inst->operType = Opr::None;
|
inst->operType = Opr::None;
|
||||||
@ -94,6 +96,7 @@ std::shared_ptr<Inst> Disassembler::decodeInst(Handle f, Entry *entry) {
|
|||||||
} else {
|
} else {
|
||||||
inst->oper = f->r16();
|
inst->oper = f->r16();
|
||||||
inst->operType = Opr::Imm16;
|
inst->operType = Opr::Imm16;
|
||||||
|
entry->prevWord = inst->oper;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IMMX:
|
case IMMX:
|
||||||
@ -103,11 +106,13 @@ std::shared_ptr<Inst> Disassembler::decodeInst(Handle f, Entry *entry) {
|
|||||||
} else {
|
} else {
|
||||||
inst->oper = f->r16();
|
inst->oper = f->r16();
|
||||||
inst->operType = Opr::Imm16;
|
inst->operType = Opr::Imm16;
|
||||||
|
entry->prevWord = inst->oper;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IMMS:
|
case IMMS:
|
||||||
inst->oper = f->r16();
|
inst->oper = f->r16();
|
||||||
inst->operType = Opr::Imm16;
|
inst->operType = Opr::Imm16;
|
||||||
|
entry->prevWord = inst->oper;
|
||||||
break;
|
break;
|
||||||
case ABS:
|
case ABS:
|
||||||
inst->oper = f->r16();
|
inst->oper = f->r16();
|
||||||
@ -267,6 +272,9 @@ std::string Disassembler::printInst(std::shared_ptr<Inst> inst) {
|
|||||||
break;
|
break;
|
||||||
case Opr::Imm16:
|
case Opr::Imm16:
|
||||||
args = "#" + hex(inst->oper, 4);
|
args = "#" + hex(inst->oper, 4);
|
||||||
|
if (inst->prevWord && inst->oper) {
|
||||||
|
comment = checkDW(inst->oper, inst->prevWord);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Opr::Abs:
|
case Opr::Abs:
|
||||||
args = hex(inst->oper, 6);
|
args = hex(inst->oper, 6);
|
||||||
@ -377,6 +385,16 @@ std::string Disassembler::lookup(uint16_t val) {
|
|||||||
return symbols[addr];
|
return symbols[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Disassembler::checkDW(uint16_t cur, uint16_t prev) {
|
||||||
|
uint32_t addr = (cur << 16) + prev;
|
||||||
|
std::string ret = symbols[addr];
|
||||||
|
if (ret.empty()) {
|
||||||
|
addr = (prev << 16) + cur;
|
||||||
|
ret = symbols[addr];
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Disassembler::hex(uint32_t val, int width) {
|
std::string Disassembler::hex(uint32_t val, int width) {
|
||||||
static const char *digits = "0123456789abcdef";
|
static const char *digits = "0123456789abcdef";
|
||||||
std::string ret;
|
std::string ret;
|
||||||
|
@ -39,6 +39,7 @@ struct Inst {
|
|||||||
Opr operType;
|
Opr operType;
|
||||||
uint32_t oper;
|
uint32_t oper;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
|
uint16_t prevWord;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Disassembler {
|
class Disassembler {
|
||||||
@ -54,6 +55,7 @@ class Disassembler {
|
|||||||
bool valid(uint32_t address);
|
bool valid(uint32_t address);
|
||||||
std::string hex(uint32_t value, int width);
|
std::string hex(uint32_t value, int width);
|
||||||
std::string lookup(uint16_t value);
|
std::string lookup(uint16_t value);
|
||||||
|
std::string checkDW(uint16_t val, uint16_t prev);
|
||||||
|
|
||||||
std::map<uint32_t, std::string> symbols;
|
std::map<uint32_t, std::string> symbols;
|
||||||
std::shared_ptr<Fingerprints> fingerprints;
|
std::shared_ptr<Fingerprints> fingerprints;
|
||||||
|
Loading…
Reference in New Issue
Block a user