Compare commits

...

4 commits

5 changed files with 33 additions and 4 deletions

View file

@ -65,6 +65,8 @@ ADD_RESOURCES(embeddedResources
)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
execute_process(COMMAND git describe --tags --always OUTPUT_VARIABLE GIT_REPO_VERSION)
add_executable(rrc-as src/rrcas.cpp ${SOURCE_FILES} ${embeddedResources})

View file

@ -115,8 +115,24 @@
.constant CRM_PERIOD_END, %0x0021FF
.constant CRM_PARAM_START, %0x002200 ;; 64 entries, each one 1 words
.constant CRM_PARAM_END, %0x002240
.constant PLL_PCIE_CTRL, %0x2241
.bitfield PLL_PCIE_CTRL.Nreset 0
.bitfield PLL_PCIE_CTRL.NEnable 1
.bitfield PLL_PCIE_CTRL.Halt 2
.bitfield PLL_PCIE_CTRL.RefDiv 3, 6
.bitfield PLL_PCIE_CTRL.FbDiv4 9
.bitfield PLL_PCIE_CTRL.FbDiv255 10, 8
.bitfield PLL_PCIE_CTRL.OutDiv 18, 6
.bitfield PLL_PCIE_CTRL.OutMuxSel 24, 3
.constant PLL_PCIE_STAT, %0x2242
.bitfield PLL_PCIE_STAT.PllLocked 0
.bitfield PLL_PCIE_STAT.PllFreqChange 1
.bitfield PLL_PCIE_STAT.MiscCtrl.FastCalibrationMode 2
.bitfield PLL_PCIE_STAT.MiscCtrl.AsyncPLLLoadSignal 6
.bitfield PLL_PCIE_STAT.MiscCtrl.InitialCoarseThermalBits 8, 2
.constant SBUS_PCIE_CFG, %0x2243
.constant SBUS_PCIE_COMMAND, %0x2244
.constant SBUS_PCIE_REQUEST, %0x2245

View file

@ -55,7 +55,7 @@
;; Ephemeral registers to be used within functions. These values may not be kept when calling other functions. They can be used when returning values if necessary.
;; Some std functions might restore these values.
.reserve std_EPHEMERAL_REGISTER_0 0x1F0
.constant std_EPHEMERAL_REGISTER_1 0x1F1
.reserve std_EPHEMERAL_REGISTER_1 0x1F1
.reserve std_EPHEMERAL_REGISTER_2 0x1F2
.reserve std_EPHEMERAL_REGISTER_3 0x1F3
.reserve std_EPHEMERAL_REGISTER_4 0x1F4

View file

@ -174,7 +174,7 @@ void Parser::parse() {
break;
case Token::Type::Directive:
if (isDirective(currentValue)) {
if(currentValue == ".constant" || currentValue == ".reserve"){
if(currentValue == ".constant" || currentValue == ".reserve" || currentValue == ".bitfield"){
if (!currentFunction.label.empty()) {
functions.emplace_back(std::move(currentFunction));
currentFunction = Function();
@ -271,6 +271,17 @@ void Parser::parse() {
tokens.push_back(*it);
}
variables[currentDeclaration.tokens.at(1).getTextValue()] = tokens;
}else if (currentDeclaration.tokens.at(0).getTextValue() == ".bitfield") {
auto& fieldName = currentDeclaration.tokens.at(1).getTextValue();
uint32_t fieldBitOffset = currentDeclaration.tokens.at(2).getNumericValue();
uint32_t fieldBitSize = currentDeclaration.tokens.size() > 3 ? currentDeclaration.tokens.at(3).getNumericValue() : 1;
uint32_t fieldBitMask = (1 << fieldBitSize) - 1;
variables[fieldName] = {Token(Token::Type::Immediate, std::to_string(fieldBitMask << fieldBitOffset), fieldBitMask << fieldBitOffset)};
variables[fieldName + ".not"] = {Token(Token::Type::Immediate, std::to_string((~(fieldBitMask << fieldBitOffset)) & 0xFFFFFFFF), (~(fieldBitMask << fieldBitOffset)) & 0xFFFFFFFF)};
variables[fieldName + ".offset"] = {Token(Token::Type::Immediate, std::to_string(fieldBitOffset), fieldBitOffset)};
variables[fieldName + ".size"] = {Token(Token::Type::Immediate, std::to_string(fieldBitSize), fieldBitSize)};
variables[fieldName + ".mask"] = {Token(Token::Type::Immediate, std::to_string(fieldBitMask), fieldBitMask)};
}
currentDeclaration = Declaration();
currentStateIndex = 0;

View file

@ -50,13 +50,13 @@ class Parser {
static std::vector<uint8_t> getAlphaValues() {
return {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_',};
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_', '.',};
}
static std::vector<uint8_t> getAlphanumericValues() {
return {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9'};
}