mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-08-07 17:02:52 +03:00
small pioasm improvements (#2224)
- fix disassembly of `wait jmppin` - fix incorrect error message - make python output emit `word(x)` for all unsupported instructions
This commit is contained in:
@@ -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) {
|
void program::set_clock_div(const yy::location &l, float clock_div) {
|
||||||
if (clock_div < 1.0f || clock_div >= 65536.0f) {
|
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;
|
clock_div_int = (uint16_t)clock_div;
|
||||||
if (clock_div_int == 0) {
|
if (clock_div_int == 0) {
|
||||||
|
@@ -56,7 +56,9 @@ std::string disassemble(uint inst, uint sideset_bits_including_opt, bool sideset
|
|||||||
if (arg2 & 0x1cu) {
|
if (arg2 & 0x1cu) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
} else if (arg2) {
|
} else if (arg2) {
|
||||||
guts = "jmppin " + std::to_string(arg2 & 3u);
|
guts = "jmppin + " + std::to_string(arg2 & 3u);
|
||||||
|
} else {
|
||||||
|
guts = "jmppin";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -131,7 +133,7 @@ std::string disassemble(uint inst, uint sideset_bits_including_opt, bool sideset
|
|||||||
op("mov");
|
op("mov");
|
||||||
std::string guts = dest + ", ";
|
std::string guts = dest + ", ";
|
||||||
if (operation == 1) {
|
if (operation == 1) {
|
||||||
guts += "!";
|
guts += "~";
|
||||||
} else if (operation == 2) {
|
} else if (operation == 2) {
|
||||||
guts += "::";
|
guts += "::";
|
||||||
}
|
}
|
||||||
@@ -193,6 +195,9 @@ std::string disassemble(uint inst, uint sideset_bits_including_opt, bool sideset
|
|||||||
}
|
}
|
||||||
delay &= ((1u << (5 - sideset_bits_including_opt)) - 1u);
|
delay &= ((1u << (5 - sideset_bits_including_opt)) - 1u);
|
||||||
ss << std::left << std::setw(4) << (delay ? ("[" + std::to_string(delay) + "]") : "");
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -204,6 +204,9 @@ struct python_output : public output_format {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
invalid = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
guts = ((arg1 & 4u) ? "1, " : "0, ") + guts;
|
guts = ((arg1 & 4u) ? "1, " : "0, ") + guts;
|
||||||
@@ -254,7 +257,7 @@ struct python_output : public output_format {
|
|||||||
uint operation = arg2 >> 3u;
|
uint operation = arg2 >> 3u;
|
||||||
if (source.empty() || dest.empty() || operation == 3) {
|
if (source.empty() || dest.empty() || operation == 3) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
} else {
|
||||||
if (dest == source && (arg1 == 1 || arg2 == 2) && operation == 0) {
|
if (dest == source && (arg1 == 1 || arg2 == 2) && operation == 0) {
|
||||||
op("nop");
|
op("nop");
|
||||||
op_guts("");
|
op_guts("");
|
||||||
@@ -272,6 +275,7 @@ struct python_output : public output_format {
|
|||||||
}
|
}
|
||||||
op_guts(guts);
|
op_guts(guts);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0b110: {
|
case 0b110: {
|
||||||
@@ -310,7 +314,9 @@ struct python_output : public output_format {
|
|||||||
if (invalid) {
|
if (invalid) {
|
||||||
op("word");
|
op("word");
|
||||||
ss << std::hex;
|
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;
|
uint delay = ((uint) inst >> 8u) & 0x1f;
|
||||||
ss << std::left << std::setw(9);
|
ss << std::left << std::setw(9);
|
||||||
|
@@ -44,3 +44,10 @@ wait gpio 40
|
|||||||
.pio_version 1
|
.pio_version 1
|
||||||
.mov_status txfifo < 12
|
.mov_status txfifo < 12
|
||||||
.mov_status irq next set 3
|
.mov_status irq next set 3
|
||||||
|
|
||||||
|
.program python
|
||||||
|
.pio_version 1
|
||||||
|
wait 0 jmppin
|
||||||
|
wait 0 jmppin + 3
|
||||||
|
mov x, !x
|
||||||
|
.word 0x1234
|
Reference in New Issue
Block a user