2019-03-12 03:21 AM
Has anybody implemented a small compiler that runs on an STM32 M3 or M7 to produce code for itself. Must be a compiler, not interpreter, as runtime speed is paramount. Doesn't need to be a complete C++ instruction set, a mini-C or something like that would be fine.
Solved! Go to Solution.
2019-03-12 04:10 AM
There's this interesting project - https://github.com/jserv/amacc
But unfortunately it's for ARMv7-A, not ARMv7-M.
Anyway, you can try to find an interpreter/vm (Lua, Forth, etc.) with a JIT compilation instead of C compiler. [Click Show More]
For example, here's a "Stack" VM implementation with JIT for micro:bit (ARMv6-M) - https://github.com/thomasdenney/microjit
2019-03-12 04:10 AM
There's this interesting project - https://github.com/jserv/amacc
But unfortunately it's for ARMv7-A, not ARMv7-M.
Anyway, you can try to find an interpreter/vm (Lua, Forth, etc.) with a JIT compilation instead of C compiler. [Click Show More]
For example, here's a "Stack" VM implementation with JIT for micro:bit (ARMv6-M) - https://github.com/thomasdenney/microjit
2019-03-12 04:14 AM
JIT is too slow sorry. I'll have a look at the first one and see if can be converted
2019-03-12 04:32 AM
Minding the limited RAM and absence of a MMU on a Cortex M MCU, this does not make sense practically. As exercise, perhaps.
2019-03-12 04:47 AM
I once had perfectly good C and Pascal compilers on an early PC with 256K RAM and floppy discs so I think a 1M RAM H series STM32 with about 1000 times the processing power should be up to the job.
2019-03-12 09:51 AM
And how do you debug?
2019-03-12 10:54 AM
Same as in the 80s - printing to the LCD. This is only a few hundred k of code tops, not the multi-megabyte stuff that obviously needs modern facilities on an attached PC.
2019-03-12 11:33 AM
Where does compiler input come from?
2019-03-12 12:18 PM
A flash card. Main development would be on a PC of course as its more convenient, but I want users to be able to alter a line of code on site without having to find a PC that has the complete ARM development suite on it. The editor of course would also be more simplistic than Visual Studio or whatever, but I have a solution to that. Problem is a small compiler that produces ARM assembly code.
2019-03-12 12:28 PM
What is the intrisic need to generate machine code within the MCU ? Patch FW ?
Most MCU devices don't necessarily have Displays or console connexions. Take a Rice cooker or an e-bike.