r/tinycode • • 7h ago

Showcase Blue, minimal colorForth interpreter in 437 bytes

Thumbnail codeberg.org
5 Upvotes

Just stumbled upon this sub and thought this might be of interest (if nothing else once you see where the data stack is stored you may lol a little). It is an interpreter for my colorForth dialect in 172 lines of non code-golfed x86_64 asm. Assembles with fasm to 437 bytes of unsafe as hell fun. Probably could be smaller but I've mainly been focused on the simplicity of the entire system.

In Blue each program starts with a completely clean slate, there are no built in words. So using the colors:

red word: define label

green word: compile call/jmp to word in output

green number: write number to output

blue word: execute word at assemble time

blue number: push number onto the data stack

magenta word: push address of word onto the data stack

You dsl yourself an artisanal binary, brick by brick. Blue source is binary bytecode, so here are some html views of what a program might look like. The first is non typical, but is likely the most minimal Blue program that emits a valid binary. 124 byte version of `/bin/true`:

https://jbirddog.codeberg.page/blue/example/x86_64/true.b.html

However this is more representative of an actual Blue program and shows how one goes from hand jit'ing with green numbers to higher level words, macros, variables and assemble-time execution of user defined words. This yields a 129 byte binary:

https://jbirddog.codeberg.page/blue/example/x86_64/true2.bl.html


r/tinycode • • 11h ago

Showcase Computer Vision on an 8-bit MCU

Thumbnail
github.com
5 Upvotes

TL;DR; 472 bytes of microcontroller's internal EEPROM, are used for the (472 int8-quantized) parameters of a Recurrent Neural Network (RNN) that predicts what a handwritten-digit is with 95% accuracy under 6kb of programmable memmory.

It uses a quite complex but user-friendly Neural-Network library in the background (that I'm working on since 2019). The library itself mostly consists out of macros\preprocessor-directives, boiling down to compactness\tiny-code via user-defined optimization preferences. That said, it still isn't perfect and it still carries some "weakness" from the past I had no time to work on.

This project serves as an "anecdotal"-example or more like a proof-of-concept for what the library is capable for and how small it can get via the optimizations (but I wouldn't say that the project itself is something really practical besides showcasing some kind of a limit for computer vision on 8-bit MCUs). That said it also runs on PCs natively too.

I thought you might find it interesting and therefore I decided to post it here as well. Hope you find it interesting, feel free to ask me anything about it and maybe have fun with it?

idk. I just felt the need to share it. Maybe I wanted to feel noticed again or something. The sure thing is that I'm being genuine with what I'm saying right now or I guess...?

PS. I hope it is relevant to the subreddit too lol