5 ms·
8-bit stack-machine emulated by 200 lines of C
- ilaksh 6y agoIf you are looking for a truly simple virtual machine, check out SUBLEQ. It's ONE instruction and you can do it in like 7 lines of C. Or maybe three if you compress it. gemini://biomimetic.me/subleq.gmi
- howerj 6y agoI managed to port an Forth interpreter to a 16-bit SUBLEQ machine, it's even self hosting, although too slow to use for anything. Getting some of the comparison operators working correctly was more difficult than getting bitwise operators working.
- deleted 6y ago[deleted]
- tromp 6y agoIt's really 3 instructions, SUBLEQ, INPUT, and OUTPUT, where you encode the latter two with bogus values for operands of the first. My idea of a truly simple virtual machine is https://www.ioccc.org/2012/tromp/hint.html https://www.ioccc.org/2012/tromp/hint.html
- howerj 6y agoYour more minimal VM is larger than a minimal SUBLEQ VM! :) I think that is a fair characterization of most SUBLEQ implementations however that did annoy me slightly. You can make ones that use proper memory mapped I/O so they end up being truly single instruction, but they end up being larger.
- rwmj 6y agoWhat am I supposed to do with that URL?
- 1vuio0pswjnm7 6y agoHere's the www URL: https://github.com/runvnc/subleqrun https://github.com/runvnc/subleqrun Accessing gemini sites is relatively easy: echo -e 'gemini://biomimetic.me\r\n'|openssl s_client -connect biomimetic.me:1965 -ign_eof
- flobosg 6y agoConnect to it via a Gemini[1] client or use a web proxy: https://portal.mozz.us/gemini/biomimetic.me/subleq.gmi https://portal.mozz.us/gemini/biomimetic.me/subleq.gmi [1]: https://gemini.circumlunar.space/ https://gemini.circumlunar.space/
- Avshalom 6y agomore about UXN here: https://wiki.xxiivv.com/site/uxn.html https://wiki.xxiivv.com/site/uxn.html
- RodgerTheGreat 6y agoSome similarities to one of my old projects, MakoVM: https://github.com/JohnEarnest/Mako https://github.com/JohnEarnest/Mako It is also Forth-based, and has an ecosystem of interesting little games, programs, and libraries. The CPU, GPU, and other IO facilities fit in a little over 200 lines of Java: https://github.com/JohnEarnest/Mako/blob/master/src/MakoVM.java https://github.com/JohnEarnest/Mako/blob/master/src/MakoVM.j...
- topspin 6y agoIt's actually 8/16 bit in 200 lines of C.
- transfire 6y agoI took a glance. The 16 bit ops appear to be "doubles" -- they are defined in terms of the 8 bit ops.
- deleted 6y ago[deleted]