jimmo wrote: ↑Thu Sep 01, 2022 2:29 am
hippy wrote: ↑Wed Aug 31, 2022 12:52 pm
or at least a very significant rewrite, to allow error checking to prevent things like 'set(x, 255)' and 'mov(x, 255)' mistakes and many others.
Isn't this mostly just a matter of adding more argument checking to the set() and mov() functions? Why does that require a significant rewrite? (I didn't write rp2.py and haven't had much experience with it, so this may be a silly question).
Better argument checking is what's needed, but that requires being able to determine that named constants were used where they should have been used and not where they shouldn't be used. That's hard because, by the time the arguments pass to the code generating functions, they have all been converted to integers so those routines can't tell if they were named or not.
For example 'set(x, null)' and 'mov(x, 3)' are both accepted but neither do what the person writing those presumably expected.
My view is that error checking should catch all mistakes to protect the coder from themselves. To achieve that myself I defined named constants as a class type rather then integer so I could check they were names of registers and then check if valid for the specific command. That wasn't overly complicated but did require quite a number of changes.
Other reasons for rewriting would be to make it single pass with fixups, and to support things like 'dec(x)' and 'inc(x)' which currently require 'jmp' to a following label to be specified. What the SDK assembler accepts has been tightened up but the MicroPython RP2 hasn't kept up so now accepts things the SDK won't.
I got most of this working as proof of concept but it needs completing and a rewrite to make it production quality, and also needs extensive testing to prove correctness and backwards compatibility. I haven't found the time to complete that.