mirror of
https://github.com/mrkite/regs.git
synced 2024-09-07 11:54:25 +00:00
added bank lookups
This commit is contained in:
parent
f3a1293e46
commit
102fa567cc
@ -36,6 +36,9 @@ Each line in this file starts with an address. This address is of the format `$
|
||||
|
||||
If the address is followed by an exclamation point `!`, it means this address is used as the point in memory the executable is loaded at. (OMF files will ignore this). If more than one address is followed by an exclamation point, only the first address encountered will be used.
|
||||
|
||||
If the address is followed by an asterisk `*`, it means this *bank* is used for
|
||||
B address lookups.
|
||||
|
||||
If the address is followed by a colon `:`, it means this address is considered an entrypoint. Disassembly will start at this address. There can be as many entrypoints as you wish. In fact, as you disassemble a file, you may notice that disassembly is halted by indirect jumps. You can add entrypoints to the `.regs` file to continue disassembly at the destination of those jumps.
|
||||
|
||||
After the colon, you can optionally specify "e" "m", "x" or any combination of those characters to force the disassembler state when disassembly starts at that entry point.
|
||||
|
@ -12,8 +12,8 @@ namespace ph = std::placeholders;
|
||||
static std::map<Addressing, int> sizes;
|
||||
|
||||
Disassembler::Disassembler(std::shared_ptr<Fingerprints> prints,
|
||||
std::map<uint32_t, std::string> symbols)
|
||||
: symbols(symbols), fingerprints(prints) {
|
||||
std::map<uint32_t, std::string> symbols, uint8_t b)
|
||||
: symbols(symbols), fingerprints(prints), b(b) {
|
||||
for (int i = 0; i < numAddressSizes; i++) {
|
||||
sizes[addressSizes[i].mode] = addressSizes[i].length;
|
||||
}
|
||||
@ -372,8 +372,9 @@ std::string Disassembler::printInst(std::shared_ptr<Inst> inst) {
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string Disassembler::lookup(uint32_t val) {
|
||||
return symbols[val];
|
||||
std::string Disassembler::lookup(uint16_t val) {
|
||||
uint32_t addr = (b << 16) + val;
|
||||
return symbols[addr];
|
||||
}
|
||||
|
||||
std::string Disassembler::hex(uint32_t val, int width) {
|
||||
|
@ -44,7 +44,7 @@ struct Inst {
|
||||
class Disassembler {
|
||||
public:
|
||||
Disassembler(std::shared_ptr<Fingerprints> prints,
|
||||
std::map<uint32_t, std::string> symbols);
|
||||
std::map<uint32_t, std::string> symbols, uint8_t b);
|
||||
bool disassemble(std::vector<struct Segment> segments,
|
||||
std::vector<struct Entry> entries);
|
||||
|
||||
@ -53,8 +53,9 @@ class Disassembler {
|
||||
std::shared_ptr<Inst> decodeInst(Handle f, Entry *entry);
|
||||
bool valid(uint32_t address);
|
||||
std::string hex(uint32_t value, int width);
|
||||
std::string lookup(uint32_t value);
|
||||
std::string lookup(uint16_t value);
|
||||
|
||||
std::map<uint32_t, std::string> symbols;
|
||||
std::shared_ptr<Fingerprints> fingerprints;
|
||||
uint8_t b;
|
||||
};
|
||||
|
@ -189,6 +189,6 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
Disassembler d(prints, map.getSymbols());
|
||||
Disassembler d(prints, map.getSymbols(), map.b);
|
||||
d.disassemble(segments, map.getEntries());
|
||||
}
|
||||
|
16
src/map.cc
16
src/map.cc
@ -5,10 +5,11 @@
|
||||
#include <algorithm>
|
||||
|
||||
struct Field {
|
||||
uint32_t org;
|
||||
uint32_t org = 0;
|
||||
std::string flags;
|
||||
bool isEntry;
|
||||
bool isOrg;
|
||||
bool isEntry = false;
|
||||
bool isOrg = false;
|
||||
bool isB = false;
|
||||
std::string symbol;
|
||||
};
|
||||
|
||||
@ -29,6 +30,9 @@ Map::Map(const char *filename, uint32_t org) : org(org) {
|
||||
this->org = ofs;
|
||||
}
|
||||
}
|
||||
if (file.check('*')) {
|
||||
this->b = ofs >> 16;
|
||||
}
|
||||
if (file.check(':')) {
|
||||
Entry entry;
|
||||
entry.org = ofs;
|
||||
@ -64,6 +68,9 @@ static bool compareFields(const Field &a, const Field &b) {
|
||||
void Map::save() {
|
||||
std::map<uint32_t, Field> fields;
|
||||
fields[this->org].isOrg = true;
|
||||
if (b) {
|
||||
fields[b << 16].isB = true;
|
||||
}
|
||||
for (auto & entryPoint : entryPoints) {
|
||||
auto org = entryPoint.org;
|
||||
fields[org].isEntry = true;
|
||||
@ -93,6 +100,9 @@ void Map::save() {
|
||||
if (field.isOrg) {
|
||||
f << "!";
|
||||
}
|
||||
if (field.isB) {
|
||||
f << "*";
|
||||
}
|
||||
if (field.isEntry) {
|
||||
f << ":";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user