4th on Micro-controllers?

28 views
Skip to first unread message

M Edward Borasky

unread,
Apr 28, 2025, 6:56:01 PMApr 28
to 4tH-compiler
Has anyone gotten 4th to run on a micro-controller? I'm especially interested in the Raspberry Pi Pico and Pico 2, but larger ones will also work.

The Beez

unread,
Apr 29, 2025, 12:08:56 PMApr 29
to 4tH-compiler
Hi!

4tH has run on a multitude of hardware, but always with an underlying OS. I've heard micro-controllers are quite capable nowadays, but personally - I have zero experience with them.
If you want to have a go - I think it's pretty interesting. Of course, if you need any help, I'm always available.

Hans Bezemer

M. Edward (Ed) Borasky

unread,
Apr 30, 2025, 9:07:57 AMApr 30
to 4th-co...@googlegroups.com
I'm experimenting with the Zephyr real-time operating system. It has a
POSIX style user interface and works on a number of micro-controllers
and single-board computers. Once I get past the "make the LEDs blink
and print 'Hello world'" stage I can try to build 4th.
> --
> You received this message because you are subscribed to the Google Groups "4tH-compiler" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to 4th-compiler...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/4th-compiler/b8d0502a-5dc6-4777-be3e-3da82e94f1b5n%40googlegroups.com.



--
AlgoCompSynth by znmeb https://universodon.com/@AlgoCompSynth

I don't have the hand muscles for strongly-typed languages.

The Beez

unread,
Apr 30, 2025, 9:13:00 AMApr 30
to 4tH-compiler
Hi znweb!

Well, that sounds great! I'd be interested to hear from you in more detail when you succeed - because micro processors haven't been a realm I ventured upon! And I think it's fascinating..!
Keep me posted!

Hans Bezemer

The Beez

unread,
May 2, 2025, 3:20:48 AMMay 2
to 4tH-compiler
Hi!

I did a quick dive into the Arduino scene - and most of your "problems" seem associated with input/output. Of course, a micro controller hasn't got a screen or keyboard. It communicates with serial.So, this is what I've come up with to get you started:
1. Only port the library and 4th.c (to begin with. Later - maybe 4tsh.c is fun). Note you need to port the editor sources as well. I dunno whether an Arduino is 16bit, 32bit or 64bit. My guess is 32bit. Note you can use the generated editor.h (or mon.h) from any 32bit platform;
2. 4th.c does most of the stdin/stdout I/O. I/O related members are comp_4th.c (loading 4tH files), dump_4th.c (debugging messages), exec_4th.c (execution I/O), load_4th.c (loading HX files), save_4th.c (saving HX files) and cgen_4th.c (saving C sources). I think for an Arduino port you could drop the three last ones without losing too much functionality;
3. dump_4th.c: vfprintf()
comp_4th.c: fopen(), fseek(), ftell(), fread(), fclose()
exec_4th.c: fseek(), ftell(), fflush(), fputc(), fgetc(), ungetc() (you can forget that last one if you don't wanna read old Apple text files);
4th.c: fgets(), fopen(), fclose(), fflush(), vfprintf()
4. This might be of interest: https://playground.arduino.cc/Main/Printf/
5. The library in question can be found here: https://github.com/avrdudes/avr-libc/tree/main/libc/stdio

Hope this helps!

Hans Bezemer

On Wednesday, April 30, 2025 at 3:07:57 PM UTC+2 zn...@znmeb.net wrote:
Reply all
Reply to author
Forward
0 new messages