Go to the documentation of this file.
57 resources_(resourceManager), currentStartAddress_(0),
58 isStartAddressDefined_(
false) {
100 for (
int foundIndex =
sections_.size() - 1;
101 foundIndex >= 0; foundIndex--) {
116 foundSection = §ion;
128 if (foundSection == NULL) {
146 assert(foundSection != NULL);
149 foundSection->
lines.push_back(line);
158 for (
unsigned int i = 0; i <
sections_.size(); i++) {
161 for (
unsigned int j = 0; j < section.
lines.size(); j++) {
162 section.
lines[j]->initData.clear();
163 section.
lines[j]->labels.clear();
164 delete section.
lines[j];
167 section.
lines.clear();
193 std::vector<TPEF::Section*> completed;
196 std::map<std::string, UValue> addressSpaceUsedMAUs;
197 std::vector<std::string> addedLabels;
202 addressSpaceUsedMAUs, addedLabels, labels);
206 for (
unsigned int i = 0; i <
sections_.size(); i++) {
214 newSection = Section::createSection(Section::ST_LEDATA);
216 newSection = Section::createSection(Section::ST_DATA);
219 newSection = Section::createSection(Section::ST_UDATA);
223 completed.push_back(newSection);
250 "Can't write data to instruction memory.");
263 assert(rawSection != NULL);
272 UValue currentMAUIndex = 0;
274 for (
unsigned int j = 0; j < section.
lines.size(); j++) {
277 line, dataSection, labels, currentMAUIndex);
287 for (
unsigned int i = 0; i < addedLabels.size(); i++) {
292 for (
UValue j = 0; j < completed.size(); j++) {
306 for (
UValue i = 0; i < completed.size(); i++) {
325 std::map<std::string, UValue>& addressSpaceUsedMAUs,
326 std::vector<std::string>& addedLabels,
LabelManager& labels) {
330 for (
unsigned int i = 0; i <
sections_.size(); i++) {
341 spaceLastAddress = addressSpaceUsedMAUs[section.
addressSpace];
350 "Can't start data section from address: " +
352 " first unused address in address space: " +
369 for (
unsigned int j = 0; j < section.
lines.size(); j++) {
376 for (
unsigned int k = 0;
377 k < currentLine->
labels.size(); k++) {
382 currentLine->
labels[k], dataLineAddress);
385 addedLabels.push_back(currentLine->
labels[k]);
388 dataLineAddress += currentLine->
width;
393 "Can't write data to instruction memory.");
413 addressSpaceUsedMAUs[section.
addressSpace] = dataLineAddress;
416 std::cerr <<
"Section length: " << section.
length
445 for (
unsigned int k = 0; k < line->
initData.size(); k++) {
449 bool isSigned =
false;
464 if (data.
width != 0) {
465 if (usedMAUs > data.
width) {
469 "Init field contains too long value. Reserved MAUs: " +
479 usedMAUs = data.
width;
483 if (writtenMAUs + usedMAUs > line->
width) {
487 "Data line contains too much init data. Reserved MAUs: " +
489 " Already inited MAUs: " +
500 currentMAUIndex + writtenMAUs,
501 usedMAUs,
static_cast<SValue>(value));
505 currentMAUIndex + writtenMAUs, usedMAUs, value);
513 currentMAUIndex + writtenMAUs));
516 *dataSection, *srcChunk,
518 value, usedMAUs * dataSection->
aSpace()->
MAU());
521 writtenMAUs += usedMAUs;
524 if (writtenMAUs < line->width) {
525 dataSection->
writeValue(currentMAUIndex+writtenMAUs, 1,
526 static_cast<unsigned long>(0));
558 int wordCount =
static_cast<int>(
559 ceil(
static_cast<double>(neededBits) /
560 static_cast<double>(width)));
TPEF::Chunk * stringToChunk(const std::string aStr)
ASpaceElement * aSpace() const
void commitLastRelocations()
bool isInitialized
If section contains initialization data.
void addSection(Section *section)
void setCause(const Exception &cause)
std::vector< InternalSection > sections_
Internal data sections.
std::string label
Name of the label.
MachineResourceManager & resources_
TPEF Resources and strings.
std::string dataSpace
Address space whose MAUs are initialized.
virtual Word MAUsToBytes(Word mauCount) const
static std::string toString(const T &source)
int sizeInWords(UValue value, int MAUWidth, bool isSigned) const
UValue resolveExpressionValue(UValue asmLineNumber, LiteralOrExpression &litOrExpr)
bool fixedStartAddress
Is start address of the section fixed.
#define assert(condition)
UValue width
Number of MAUs that are initialized by the init field.
bool isExpression
Does object contain expression or literal.
UValue currentStartAddress_
Start address of next line (if fixed address).
void addRelocation(TPEF::Section &locationSect, TPEF::SectionElement &location, TPEF::ASpaceElement &dstASpace, UValue destination, UValue bitWidth)
void setCodeFileLineNumber(int lineNum)
DataSectionCreator(MachineResourceManager &resourceManager, AssemblyParserDiagnostic *parent)
UValue startAddress
The start address of the section.
void addLabel(TPEF::ASpaceElement &aSpace, std::string &name, UValue value)
void finalize(TPEF::Binary &tpef, LabelManager &labels, bool littleEndian)
UValue length
Number of MAUs stored in section.
LiteralOrExpression litOrExpr
Initialisation value.
std::vector< InitDataField > initData
Init data fields of data line. Uninitilized data line, if empty.
void removeLabel(std::string &name)
void setName(const ReferenceManager::SafePointer *sectionName)
std::string errorMessage() const
TPEF::ASpaceElement * findDataAddressSpace(std::string name)
void setStartingAddress(AddressImage address)
std::string addressSpace
Address space of the section.
UValue value
If literal, the literal. Otherwise not used.
TPEF::ASpaceElement & aSpaceElement(std::string &labelName)
bool isSigned
Sign of the value.
UValue writeDataLineToTPEF(DataLine *line, TPEF::DataSection *dataSection, LabelManager &labels, UValue currentMAUIndex)
void setAreaStartAddress(UValue address)
UValue asmLineNumber
Line number where in source code this DA line is found.
find Finds info of the inner loops in the false
void setASpace(const ReferenceManager::SafePointer *addrSpace)
virtual void setLengthInMAUs(Word length)
std::vector< std::string > labels
Labels of this data line.
bool isStartAddressDefined_
Is next data line address fixed.
Expression expression
If expression the expression, Otherwise not used.
std::vector< DataLine * > lines
Initialization data of the section. (or uninitialization data;)
virtual Chunk * chunk(SectionOffset offset) const
void addDataLine(const DataLine &origLine)
void clearLastRelocations()
virtual void writeValue(Word index, Word numOfMAUs, unsigned long value)
void resolveDataAreaSizesAndLabelAddresses(std::map< std::string, UValue > &addressSpaceUsedMAUs, std::vector< std::string > &addedLabels, LabelManager &labels)
UValue width
Number of MAUs initialized by this data line.