added reading start
This commit is contained in:
parent
5d2a0f867c
commit
d438feb9ee
7 changed files with 128 additions and 4 deletions
61
simulator_SIC_XE/include/loader.h
Normal file
61
simulator_SIC_XE/include/loader.h
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#ifndef LOADER_H
|
||||
#define LOADER_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "file_reader.h"
|
||||
|
||||
class Machine;
|
||||
|
||||
using std::shared_ptr;
|
||||
using std::string;
|
||||
|
||||
|
||||
class Loader {
|
||||
public:
|
||||
Loader( shared_ptr<Machine> machine, string filename) : _machine(machine), _filename(filename) {
|
||||
_file_reader = std::make_shared<FileReader>(filename, std::ios::in);
|
||||
}
|
||||
~Loader();
|
||||
|
||||
|
||||
enum class RecordType {
|
||||
HEADER,
|
||||
TEXT,
|
||||
END,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
struct HeaderMetadata {
|
||||
string program_name;
|
||||
int start_address;
|
||||
int length;
|
||||
};
|
||||
struct TextRecord {
|
||||
int start_address;
|
||||
std::vector<uint8_t> data;
|
||||
};
|
||||
struct EndRecord {
|
||||
int execution_start_address;
|
||||
};
|
||||
|
||||
void load();
|
||||
|
||||
private :
|
||||
|
||||
static RecordType parseRecordType(char c);
|
||||
|
||||
|
||||
shared_ptr<Machine> _machine;
|
||||
string _filename;
|
||||
shared_ptr<FileReader> _file_reader;
|
||||
HeaderMetadata readHeader();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // LOADER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue