So I wrote a ARv6-M assembler in python. #16345
Unanswered
pysselmedheg
asked this question in
Core Development
Replies: 1 comment 6 replies
-
A possible solution to the argument problem would be to write a loader. This would accept a machine code array as created by your assembler and a number of args. The loader would create a machine code preamble to the array, containing instructions to move the args to registers. It would then run the combined file. load(array, arg0, arg1) # Would use *args internally would create machine code to put arg0 in R0, arg1 in R1, followed by the rest of the code. It would then run it. As for running it the only other option apart from the decorator might be a loadable C module. |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think it's really cool that micropython supports inline assembler. The mix of python coding for most stuff, and then assembler for some tight time critical loops tickles my brains. But I got a bit frustrated that there are several missing instructions, and not just the really odd ones.
So I wrote my own assembler decorator. It has the full ARMv6-M instruction set (like in RP2040), and it's not as restrictive as @micropython.asm_thumb regarding use of python variables, or even python code as a preprocessor.
It's still in beta and needs a lot more testing. But so far it looks promising.
Now to the questions.
Right now, I'm generating an array.array('H', [0xabcd, ...]) with the resulting code. The only way I have to actually run it is to send the address of it to a launcher written with @micropython.asm_thumb. That seem like an kludge, and also means I'm down to only two function arguments (Yes, I know that it can be solved with arrays). Does anyone know a way to more directly generate a native code function.
Has anyone seen some kind of test suite for this assembler set. I mean, I can write something myself and just repeat the same mistakes once more, but if it comes from another source than me I'd feel more confident. :-)
And yes, it will end up on github, but I want it to be less unpolished first.
Beta Was this translation helpful? Give feedback.
All reactions