mirror of
https://github.com/mrkite/regs.git
synced 2025-01-02 15:29:39 +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 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.
|
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.
|
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;
|
static std::map<Addressing, int> sizes;
|
||||||
|
|
||||||
Disassembler::Disassembler(std::shared_ptr<Fingerprints> prints,
|
Disassembler::Disassembler(std::shared_ptr<Fingerprints> prints,
|
||||||
std::map<uint32_t, std::string> symbols)
|
std::map<uint32_t, std::string> symbols, uint8_t b)
|
||||||
: symbols(symbols), fingerprints(prints) {
|
: symbols(symbols), fingerprints(prints), b(b) {
|
||||||
for (int i = 0; i < numAddressSizes; i++) {
|
for (int i = 0; i < numAddressSizes; i++) {
|
||||||
sizes[addressSizes[i].mode] = addressSizes[i].length;
|
sizes[addressSizes[i].mode] = addressSizes[i].length;
|
||||||
}
|
}
|
||||||
@ -372,8 +372,9 @@ std::string Disassembler::printInst(std::shared_ptr<Inst> inst) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Disassembler::lookup(uint32_t val) {
|
std::string Disassembler::lookup(uint16_t val) {
|
||||||
return symbols[val];
|
uint32_t addr = (b << 16) + val;
|
||||||
|
return symbols[addr];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Disassembler::hex(uint32_t val, int width) {
|
std::string Disassembler::hex(uint32_t val, int width) {
|
||||||
|
@ -44,7 +44,7 @@ struct Inst {
|
|||||||
class Disassembler {
|
class Disassembler {
|
||||||
public:
|
public:
|
||||||
Disassembler(std::shared_ptr<Fingerprints> prints,
|
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,
|
bool disassemble(std::vector<struct Segment> segments,
|
||||||
std::vector<struct Entry> entries);
|
std::vector<struct Entry> entries);
|
||||||
|
|
||||||
@ -53,8 +53,9 @@ class Disassembler {
|
|||||||
std::shared_ptr<Inst> decodeInst(Handle f, Entry *entry);
|
std::shared_ptr<Inst> decodeInst(Handle f, Entry *entry);
|
||||||
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(uint32_t value);
|
std::string lookup(uint16_t value);
|
||||||
|
|
||||||
std::map<uint32_t, std::string> symbols;
|
std::map<uint32_t, std::string> symbols;
|
||||||
std::shared_ptr<Fingerprints> fingerprints;
|
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());
|
d.disassemble(segments, map.getEntries());
|
||||||
}
|
}
|
||||||
|
16
src/map.cc
16
src/map.cc
@ -5,10 +5,11 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
struct Field {
|
struct Field {
|
||||||
uint32_t org;
|
uint32_t org = 0;
|
||||||
std::string flags;
|
std::string flags;
|
||||||
bool isEntry;
|
bool isEntry = false;
|
||||||
bool isOrg;
|
bool isOrg = false;
|
||||||
|
bool isB = false;
|
||||||
std::string symbol;
|
std::string symbol;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,6 +30,9 @@ Map::Map(const char *filename, uint32_t org) : org(org) {
|
|||||||
this->org = ofs;
|
this->org = ofs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (file.check('*')) {
|
||||||
|
this->b = ofs >> 16;
|
||||||
|
}
|
||||||
if (file.check(':')) {
|
if (file.check(':')) {
|
||||||
Entry entry;
|
Entry entry;
|
||||||
entry.org = ofs;
|
entry.org = ofs;
|
||||||
@ -64,6 +68,9 @@ static bool compareFields(const Field &a, const Field &b) {
|
|||||||
void Map::save() {
|
void Map::save() {
|
||||||
std::map<uint32_t, Field> fields;
|
std::map<uint32_t, Field> fields;
|
||||||
fields[this->org].isOrg = true;
|
fields[this->org].isOrg = true;
|
||||||
|
if (b) {
|
||||||
|
fields[b << 16].isB = true;
|
||||||
|
}
|
||||||
for (auto & entryPoint : entryPoints) {
|
for (auto & entryPoint : entryPoints) {
|
||||||
auto org = entryPoint.org;
|
auto org = entryPoint.org;
|
||||||
fields[org].isEntry = true;
|
fields[org].isEntry = true;
|
||||||
@ -93,6 +100,9 @@ void Map::save() {
|
|||||||
if (field.isOrg) {
|
if (field.isOrg) {
|
||||||
f << "!";
|
f << "!";
|
||||||
}
|
}
|
||||||
|
if (field.isB) {
|
||||||
|
f << "*";
|
||||||
|
}
|
||||||
if (field.isEntry) {
|
if (field.isEntry) {
|
||||||
f << ":";
|
f << ":";
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ class Map {
|
|||||||
void addEntry(uint32_t entry, uint32_t flags);
|
void addEntry(uint32_t entry, uint32_t flags);
|
||||||
void addSymbol(uint32_t org, std::string name);
|
void addSymbol(uint32_t org, std::string name);
|
||||||
uint32_t org;
|
uint32_t org;
|
||||||
|
uint8_t b;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mapname;
|
std::string mapname;
|
||||||
|
Loading…
Reference in New Issue
Block a user