regs/src/map.h

50 lines
995 B
C
Raw Normal View History

2020-02-15 00:08:27 +00:00
/** @copyright 2020 Sean Kasun */
#pragma once
#include <cstdint>
2020-02-17 23:58:22 +00:00
#include <map>
#include <vector>
#include <string>
2020-02-15 00:08:27 +00:00
#include "disasm.h"
2020-02-17 23:58:22 +00:00
class File {
public:
File(const std::string &filename);
bool is_open() const;
bool eof();
uint32_t hex();
bool check(uint8_t ch);
char oneOf(const std::string &str);
std::string until(uint8_t ch);
void error(const char *msg);
private:
uint8_t *data, *p, *end;
int curLine;
std::string filename;
void ws();
};
struct Entry {
uint32_t org;
uint32_t flags;
};
2020-02-15 00:08:27 +00:00
class Map {
public:
2020-02-21 23:57:11 +00:00
Map(const char *filename, uint32_t org);
void save();
2020-02-19 00:03:29 +00:00
bool needsEntry();
std::vector<Entry> getEntries();
2020-02-20 03:23:23 +00:00
std::map<uint32_t, std::string> getSymbols();
2020-02-19 00:03:29 +00:00
void addEntry(uint32_t entry, uint32_t flags);
2020-02-21 23:57:11 +00:00
void addSymbol(uint32_t org, std::string name);
2020-02-17 23:58:22 +00:00
uint32_t org;
private:
2020-02-21 23:57:11 +00:00
std::string mapname;
bool usedMap;
2020-02-17 23:58:22 +00:00
std::vector<Entry> entryPoints;
std::map<uint32_t, std::string> symbols;
2020-02-21 23:57:11 +00:00
std::string toAddress(uint32_t val);
2020-02-15 00:08:27 +00:00
};