Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/pioasm/pio_assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void program::set_pio_version(const yy::location &l, int version) {

void program::set_clock_div(const yy::location &l, float clock_div) {
if (clock_div < 1.0f || clock_div >= 65536.0f) {
throw syntax_error(l, "clock divider must be between 1 and 65546");
throw syntax_error(l, "clock divider must be between 1 and 65535");
}
clock_div_int = (uint16_t)clock_div;
if (clock_div_int == 0) {
Expand Down
11 changes: 8 additions & 3 deletions tools/pioasm/pio_disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ std::string disassemble(uint inst, uint sideset_bits_including_opt, bool sideset
if (arg2 & 0x1cu) {
invalid = true;
} else if (arg2) {
guts = "jmppin " + std::to_string(arg2 & 3u);
guts = "jmppin + " + std::to_string(arg2 & 3u);
} else {
guts = "jmppin";
}
break;
}
Expand Down Expand Up @@ -131,7 +133,7 @@ std::string disassemble(uint inst, uint sideset_bits_including_opt, bool sideset
op("mov");
std::string guts = dest + ", ";
if (operation == 1) {
guts += "!";
guts += "~";
} else if (operation == 2) {
guts += "::";
}
Expand Down Expand Up @@ -193,6 +195,9 @@ std::string disassemble(uint inst, uint sideset_bits_including_opt, bool sideset
}
delay &= ((1u << (5 - sideset_bits_including_opt)) - 1u);
ss << std::left << std::setw(4) << (delay ? ("[" + std::to_string(delay) + "]") : "");
return ss.str();
// remove trailing spaces
auto str = ss.str();
str.erase(str.find_last_not_of(' ')+1);
return str;
}

38 changes: 22 additions & 16 deletions tools/pioasm/python_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ struct python_output : public output_format {
}
}
break;
default:
invalid = true;
break;
}
if (!invalid) {
guts = ((arg1 & 4u) ? "1, " : "0, ") + guts;
Expand Down Expand Up @@ -254,23 +257,24 @@ struct python_output : public output_format {
uint operation = arg2 >> 3u;
if (source.empty() || dest.empty() || operation == 3) {
invalid = true;
}
if (dest == source && (arg1 == 1 || arg2 == 2) && operation == 0) {
op("nop");
op_guts("");
} else {
op("mov");
std::string guts = dest + ", ";
if (operation == 1) {
guts += "invert(";
} else if (operation == 2) {
guts += "reverse(";
}
guts += source;
if (operation == 1 || operation == 2) {
guts += ")";
if (dest == source && (arg1 == 1 || arg2 == 2) && operation == 0) {
op("nop");
op_guts("");
} else {
op("mov");
std::string guts = dest + ", ";
if (operation == 1) {
guts += "invert(";
} else if (operation == 2) {
guts += "reverse(";
}
guts += source;
if (operation == 1 || operation == 2) {
guts += ")";
}
op_guts(guts);
}
op_guts(guts);
}
break;
}
Expand Down Expand Up @@ -310,7 +314,9 @@ struct python_output : public output_format {
if (invalid) {
op("word");
ss << std::hex;
op_guts(std::to_string(inst));
std::stringstream guts;
guts << std::hex << std::showbase << std::setfill('0') << std::setw(4) << inst;
op_guts(guts.str());
}
uint delay = ((uint) inst >> 8u) & 0x1f;
ss << std::left << std::setw(9);
Expand Down
7 changes: 7 additions & 0 deletions tools/pioasm/test/amethyst.pio
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ wait gpio 40
.pio_version 1
.mov_status txfifo < 12
.mov_status irq next set 3

.program python
.pio_version 1
wait 0 jmppin
wait 0 jmppin + 3
mov x, !x
.word 0x1234
Loading