3 ms·
Interesting. Only somewhat related; any pointers to articles/document on implementing a stack-based virtual machine?
by joe_the_user 4y ago
Interesting. Only somewhat related; any pointers to articles/document on implementing a stack-based virtual machine?
- bugfix-66 4y agoLook at the Green Arrays F18, the "conclusion" that Forth reached: https://www.greenarraychips.com/home/documents/greg/PB003-110412-F18A.pdf https://www.greenarraychips.com/home/documents/greg/PB003-11... Here's a clear description of what each instruction does: https://colorforth.github.io/forth.html https://colorforth.github.io/forth.html Hilariously, the system has no logical OR, only AND and XOR and NOT, because "Inclusive-or is rarely needed." This system was designed by Chuck Moore, father of Forth. Here is an entertaining video of him explaining the F18A stack machine and programming system: https://youtu.be/0PclgBd6_Zs https://youtu.be/0PclgBd6_Zs This is such a simple machine. I am planning to make a tiny emulator for my site. One could probably write an emulator in 80 lines of Go (one goroutine for each of the 144 cores).
- whatshisface 4y ago>The word */ multiplies by a ratio, with a double-length intermediate product. It eliminates the need for floating-point. Anyone who knows a lot about numeric stuff care to comment on this statement?
- bugfix-66 4y agoIt's just a fixed point instruction. Fixed point multiply: a*m times b*m yields (a*b)*m = a*m * b*m / m In the above, m is the fixed point 1. For example, 65536 for a 16.16 fixed point. The instruction allows you to multiply a*m by b*m and then divide by m, renormalizing your fixed point result. Chuck Moore thinks nobody needs floating point because fixed point is sufficient!
- Someone 4y agoAnd, importantly, the double-length intermediate result prevents the rapid loss of precision, compared to the naive alternatives of : */ * 65536 / : and : */ 65536 / * ;
- spaintech 4y agoThis might have what you need… https://wiki.xxiivv.com/site/uxn.html https://wiki.xxiivv.com/site/uxn.html interesting design and fun little project.
- entaloneralie 4y agoThis talk covers some of the design decisions that lead to the design of the uxn stack machine. https://vimeo.com/771406693#t=85m30s https://vimeo.com/771406693#t=85m30s C source code of the VM, 100 lines. https://git.sr.ht/~rabbits/uxn/tree/main/item/src/uxn.c https://git.sr.ht/~rabbits/uxn/tree/main/item/src/uxn.c An example assembly file for that stack machine https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examples/exercises/fib.tal https://git.sr.ht/~rabbits/uxn/tree/main/item/projects/examp... Another stack machine designed to target FPGA with an elegant design, mentioned in the talk above. https://excamera.com/sphinx/article-j1a-swapforth.html https://excamera.com/sphinx/article-j1a-swapforth.html
- bmitc 4y agoThe virtual machine in nand2tetris (book is *The Elements of Computing Systems) is stack-based. https://www.nand2tetris.org/ https://www.nand2tetris.org/ https://mitpress.mit.edu/9780262539807/the-elements-of-computing-systems/ https://mitpress.mit.edu/9780262539807/the-elements-of-compu... https://www.coursera.org/learn/build-a-computer https://www.coursera.org/learn/build-a-computer
- LAC-Tech 4y agoChapter 3 of this book is pretty useful for that, as each of the instructions have pseudo code descriptions. Worth noting they only pop once for the ADD instruction, not twice!
- gjadi 4y agoWhat about the JVM? :D https://docs.oracle.com/javase/specs/jvms/se7/html/index.html https://docs.oracle.com/javase/specs/jvms/se7/html/index.htm...