-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Request for new pseudoinstruction: dec X / dec Y #1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This would have saved me some time today, trying to come up with a dec X/Y solution. Would be really handy to not be bothered with a unique label that can potentially be wrong. |
I've also been thinking recently about a new pseudo instruction like this. |
This fully backward-compatible change (only changes sources, no new emitted instructions) is still a feature worth adding.... |
I think it isn't as simple as it might look like. I think, currently, instructions and symbols use the same namespace. Any program that is using a symbol (or label) So it would require careful changes in the grammar otherwise (see e. g. also #1951 and #2163/#2484). But that would be nice as well… |
I admit I'm having trouble visualizing a well-formed program that, with adding the Could you provide simple example(s) that would cause trouble? (They'd also be useful for tests, since they'd be important edge cases.) |
Let's say you had the following code already:
This currently works fine because |
The current compiler might choose to emit an error for current keywords, when they are used as a label. I not yet seeing where this would be required behavior when parsing the .pio program? At first glance, that appears to be a design choice, and not a hard requirement.Here's what each line must parse as: pico-sdk/tools/pioasm/parser.yy Lines 176 to 185 in ee68c78
Of interest are lines 179-181, which allow a pico-sdk/tools/pioasm/parser.yy Lines 191 to 192 in ee68c78
Meanwhile, each potential pico-sdk/tools/pioasm/parser.yy Lines 251 to 256 in ee68c78
And ... none of the valid pico-sdk/tools/pioasm/parser.yy Lines 259 to 275 in ee68c78
And ... once a line is matching Thus, the context of the current parsing makes it clear whether Example using `dec` as both label and instruction
If I manually parse that, it seems to parse without error? Am I missing a case where there would be ambiguity, or mandatory failure? |
Even where there is a namespace collision, this is not a compatibility problem or caused by a new instruction. The parser functions pico-sdk/tools/pioasm/parser.yy Lines 194 to 195 in ee68c78
But, the conflict is between the define and the label ... not the instruction?
Compare pico-sdk/tools/pioasm/pio_assembler.cpp Lines 38 to 53 in ee68c78
pico-sdk/tools/pioasm/pio_types.h Lines 349 to 352 in ee68c78
pico-sdk/tools/pioasm/pio_assembler.cpp Lines 81 to 97 in ee68c78
|
My point is that it would be easier to do after some internal cleanup (separation of symbols, instructions, operands, directives; proper expressions; conditional assembly; etc.). Requests for |
note also that other things like CircuitPython support parsing the |
I suspect it wouldn't be a problem on CircuitPython's pioasm, though (I think, e. g. |
I have a recommendation for a new pseudoinstruction, and explanation on why it's so useful.
Is this the right depot to file the issue in?
If yes, then I will change the title of the issue to:
Request for new pseudoinstruction:
dec X
/dec Y
Assembler Syntax
dec <target>
, where<target>
is eitherX
orY
For target
X
:0b_000_ddddd_010_aaaaa
ddddd
represents the delay/side-set bitsaaaaa
represents the encoded address to jump toEdge cases
Normally, the
dec <target>
pseudoinstruction encodes to ajmp
to the next instruction in the program.Therefore,
pioasm
would need to handle the following two edges cases:.wrap
directive -- encode thejmp
address to the.wraptarget
jmp
address to the.wraptarget
Why do this?
Two reasons: First, to increase awareness of how to do this. Secondly, to avoid incorrectly written implementations.
When looking for how to modify the data in a register, a user will first look at the
set
andmov
instructions. The impression given is that only negation and reversing the bits are available. However, decrement is a supported atomic operation!There's also the problem of buggy attempts, where a person initially has an unconditional
jmp
, needs to decrement the register at the same time, and converts that to ajmp (x--) label
... thus introducing a bug, because if the register value pre-execution was zero, the jump will not happen. (yes, real world story)The text was updated successfully, but these errors were encountered: