Project < Cohost
Cohost executes COINS, and hosts the Co language. It is a reference implementation of the Core CPU virtual machine which conforms to the COINS specification. It will also provide helper functionality to dynamically load routines into memory while the CPU is running, though this will eventually be baked into a lightweight operating system that runs on the core itself. Cohost is written in Rust.
Design Goals
Coming Soon.
Installation
From Source
To build from source, you must have the Rust toolchain installed on your machine. Given that, you can install with:
$ git clone https://git.sr.ht/~jakintosh/cohost
$ cargo install --path cohost
Download
If you don't mind downloading executable binaries off the internet (or don't have Rust installed), you can download the latest Linux binary below and drop it in a directory on your $PATH.
cohost v0.6.0 (Linux)To do the same from the command line:
$ sudo curl http://coalescent.computer/downloads/cohost -o /usr/local/bin/cohost
$ sudo chmod 755 /usr/local/bin/cohost
To verify:
$ shasum -a 256 `which cohost`
> 3a00c4c35e2aaf5b6f216678a9bf4fd111e38e91eb50fb38ff378b1e4818d129
You can now use the cohost
CLI via the command line. The program binary as of 0.6.0 using Rust 1.74.0 is 518kb on Arch Linux.
Usage
The cohost
CLI has two subcommand branches: run
for executing binaries, and device
for launching and attaching devices.
cohost run
To run the machine, first you need to build a ROM using the co toolchain, or with any other process that produces a valid COINS binary. From there, you can point to that binary file using the command's only required parameter:
$ cohost run <rom-file>
The run
command has three options:
-d/--debug
: shows a step-by-step debug execution visualizer (press ENTER to step)-p/--profile
: shows a profile of the program on completion (program must gracefully end)-t/--terminates
: the CPU will exit when it returns with an empty return stack instead of becoming idle, which is the default behavior
Realistically, --profile
can only be used right now in conjunction with --terminates
, since otherwise the program never gracefully exits to show profiler information. Profile currently only shows the total number of executed instructions.
Two equivalent real-world examples using options:
$ cohost run -dt stack-test.rom
$ cohost run --debug --terminates stack-test.rom
cohost device
The cohost
CLI also includes the ability to launch and attach a console to the running instance.
$ cohost device console
The console allows one to send text data into the running cohost instance, and also display text that is output from the machine.