You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, it could be convenient when set x, -1 could also generate mov x, ~null (especially when -1 is a calculated value like (n-1 << 25 >> 25)). Not for pins and pindirs (different pin mappings) but for x and y:
diff --git tools/pioasm/pio_assembler.cpp tools/pioasm/pio_assembler.cpp
index a36854b2..5de3d972 100644
--- tools/pioasm/pio_assembler.cpp+++ tools/pioasm/pio_assembler.cpp@@ -385,8 +385,12 @@ raw_encoding instr_out::raw_encode(program& program) {
raw_encoding instr_set::raw_encode(program& program) {
int v = value->resolve(program);
+ if (v == ~0 && (dest == in_out_set::in_out_set_x || dest == in_out_set::in_out_set_y)) {+ return {inst_type::mov, (uint) dest, (uint) mov::null | ((uint) mov_op::invert << 3u)};+ }+
if (v < 0 || v > 31) {
- throw syntax_error(value->location, "'set' bit count must be >= 0 and <= 31");+ throw syntax_error(value->location, "'set' value must be >= 0 and <= 31 (or -1 for x and y)");
}
return {inst_type::set, (uint) dest, (uint) v};
}
I think this can work as an explicit pioasm pseudo-instruction, but it is worth being precise that the assembler would be lowering:
set x, -1
to a different hardware instruction:
mov x, ~null
rather than encoding a special SET value.
For x and y the resulting register value is equivalent. pins and pindirs should continue to reject -1.
The current instruction::encode() adds delay and side-set after raw_encode(), so those fields should remain preserved even if instr_set::raw_encode() returns a MOV encoding.
Before landing it I'd cover:
set x, -1
set y, -1
an expression that resolves to -1
rejection for pins
rejection for pindirs
generated instruction/disassembly reflecting the actual MOV encoding
Also, if -1 becomes a supported value, the existing error should probably say set value rather than set bit count.
Activity
magy00 commentedon Sep 22, 2026
An ugly workaround could be:
kvnloo commentedon Sep 29, 2026
I think this can work as an explicit pioasm pseudo-instruction, but it is worth being precise that the assembler would be lowering:
set x, -1to a different hardware instruction:
mov x, ~nullrather than encoding a special
SETvalue.For
xandythe resulting register value is equivalent.pinsandpindirsshould continue to reject-1.The current
instruction::encode()adds delay and side-set afterraw_encode(), so those fields should remain preserved even ifinstr_set::raw_encode()returns aMOVencoding.Before landing it I'd cover:
set x, -1set y, -1-1pinspindirsMOVencodingAlso, if
-1becomes a supported value, the existing error should probably sayset valuerather thanset bit count.