forked from techcompliant/DASM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.h
78 lines (53 loc) · 3.42 KB
/
Program.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef PROGRAM_H
#define PROGRAM_H
#include <iomanip>
#include "DAsm.h"
namespace DAsm{
class Instruction;
class ProgramChunk;
struct error_entry{
std::string message;
unsigned int line;
Instruction* source;
};
class Program{
public:
Program();
virtual ~Program();
bool LoadSource(std::string source, bool ingnoreEmptyLines = true);
void AddExpressionTarget(std::string nExpression,word* nTarget);
void AddDefineOnlyTarget(std::string nExpression,word* nTarget);
void AddIncrementTarget(std::string nExpression,word* nTarget);
void AddLabelValue(std::string nLabel, word nValue);
void AddDefine(std::string nLabel, int nValue);
std::string GlobalizeLabels(std::string nExpression);
unsigned int GetLength();
unsigned int mLength;
int Evaluate(std::string expression, bool* errorFlag=nullptr);
bool IsMacro(std::string keyword);
std::string DoMacro(std::string keyword, std::list<std::string> args);
void AddMacro(std::string nMacro);
std::list<macro> mMacros;
std::string ToHex(std::string firstWordSeparator = "0x", std::string wordSeparator = " 0x", std::string instructionSeparator = "\n", bool littleEndian = true, bool ignoreEmptyIntructions = true);
word* ToBlock(unsigned long maxSize = DCPU_RAM_SIZE, bool little_endian = true);
word* ToBlock(unsigned long maxSize, unsigned long& programSize, bool little_endian = true);
void Error(std::string message, Instruction* source = nullptr);
void Error(std::string message, unsigned int line_number);
void updateError(error_entry &entry);
std::list<error_entry> mErrors;
std::list<ProgramChunk> mChunks;
std::list<ProgramChunk*> mOrdered;
std::string mGlobalLabel;
std::list<label_value> mDefineValues;
std::list<expression_target> mDefineOnlyTargets;
std::list<expression_target> mExpressionTargets;
std::list<expression_target> mIncrementTargets;
std::list<Instruction>* mInstructions;
ProgramChunk* mCurChunk;
bool mStrictDefineCommas;
bool mStrictDirectiveDots;
bool mIgnoreLabelCase; //When true, all labels are converted to uppercase
bool mArrangeChunks;//When true, .orgs control actual position of code in output
};
}
#endif