• SUBLEQ and Eforth

    From anthk@21:1/5 to All on Wed May 14 07:49:07 2025
    SUBLEQ from this author it's a 16 bit virtual machine
    with just one instruction:

    https://github.com/howerj/sublec

    subtract 'a' from 'b', store it under 'b' and if it's equal or less
    than 0, jump to whatever address it's being pointed at 'c'.

    https://en.wikipedia.org/wiki/One-instruction_set_computer

    The programmer wrote an Eforth image runnable under Subleq.

    This is a whole subleq program in C:

    #include <stdio.h>
    int main
    (int x, char **v) {
    FILE *f = fopen(v[1], "r");
    short p = 0, m[1 << 16], *i = m;
    while (fscanf(f, "%hd", i++) > 0);
    for (; p >= 0;) {
    int a = m[p++], b = m[p++], c = m[p++];
    a < 0 ? m[b] =
    getchar() : b < 0 ? putchar(m[a]) : (m[b] -= m[a]) <= 0 ? p = c : 0;
    }
    }

    Here's the subleq image:

    https://raw.githubusercontent.com/howerj/subleq/master/subleq.dec

    Run it as ./subleq ./subleq.dec

    It you want speed, there's muxleq, which runs a lot faster than subleq.
    Muxleq multiplexes instructions. Again:

    https://github.com/howerj/muxleq

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)