Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | anthk <anthk@openbsd.home> |
| Newsgroups | comp.misc |
| Subject | SUBLEQ and Eforth |
| Followup-To | comp.lang.forth |
| Date | Wed, 14 May 2025 07:49:07 -0000 (UTC) |
| Organization | A noiseless patient Spider |
| Lines | 40 |
| Message-ID | <slrn1028in7.2c2c.anthk@openbsd.home.localhost> (permalink) |
| Injection-Date | Wed, 14 May 2025 09:49:08 +0200 (CEST) |
| Injection-Info | dont-email.me; posting-host="7e32319b20dfb1e254981a76c7bf64c1"; logging-data="2523782"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HJKbXbirmGmmxagzZFKp0" |
| User-Agent | slrn/1.0.3 (OpenBSD) |
| Cancel-Lock | sha1:VcXXIOJTHVdMFKK7/++CGQk5kos= |
| Xref | csiph.com comp.misc:27378 |
Followups directed to: comp.lang.forth
Show key headers only | View raw
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
Back to comp.misc | Previous | Next | Find similar
SUBLEQ and Eforth anthk <anthk@openbsd.home> - 2025-05-14 07:49 +0000
csiph-web