|
|
|
@@ -2,7 +2,11 @@
|
|
|
|
|
|
|
|
|
|
SplitBit is an 8 bit computer that does not exist: a CPU with its own instruction set, split Program and Data memories, an interrupt and vector system, a bus that programs can enumerate, a memory controller that can write code into memory, and a disk. This repository is a C implementation of the machine, an assembler for it, a tool for its disks, and the software that runs on it, which now includes an operating system and an assembler written in SplitBit's own assembly language.
|
|
|
|
|
|
|
|
|
|
**SplitBit assembles SplitBit.** `Programs/CosmOS/Assembler/` runs on the machine, reads source off a SplitBit disk, and writes a boot image or a loadable program back to it with no host involved. It builds the operating system it is running under, and it builds itself, both byte for byte identical to what the C assembler produces from the same source. The test suite then boots the CosmOS that CosmOS built and has *that* one assemble CosmOS again, and the second generation is identical to the first, so the machinery has been through itself. After that the host is a convenience rather than a necessity.
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
*The whole loop in one screen. `Asm.sbx` assembles `hello.asm` into `hello.sbx`; the shell loads that and runs it; then the monitor disassembles what is at 0x2000, which is the program the machine wrote for itself at the top of the screen. No host is involved at any point.*
|
|
|
|
|
|
|
|
|
|
**SplitBit assembles SplitBit.** [`Programs/CosmOS/Assembler/`](Programs/CosmOS/Assembler) runs on the machine, reads source off a SplitBit disk, and writes a boot image or a loadable program back to it with no host involved. It builds the operating system it is running under, and it builds itself, both byte for byte identical to what the C assembler produces from the same source. The test suite then boots the CosmOS that CosmOS built and has *that* one assemble CosmOS again, and the second generation is identical to the first, so the machinery has been through itself. After that the host is a convenience rather than a necessity.
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
> load Asm.sbx
|
|
|
|
@@ -16,15 +20,15 @@ wrote Asm.sbx: program 7533, data 4099, labels 555
|
|
|
|
|
|
|
|
|
|
| Directory | What it holds |
|
|
|
|
|
| --- | --- |
|
|
|
|
|
| `Source/Emulator` | The machine: CPU, memory controller, devices, console, disk |
|
|
|
|
|
| `Source/Assembler` | The assembler that runs on a host |
|
|
|
|
|
| `Source/DiskTool` | SplitDisk, which reads and writes SplitBit's filesystem |
|
|
|
|
|
| `Programs/Examples` | Programs to read: hello, a calculator, Fibonacci, a prime sieve, Life |
|
|
|
|
|
| `Programs/Libraries` | Code included by name rather than linked, since there is no linker |
|
|
|
|
|
| `Programs/Loader` | The standalone loader CosmOS grew out of |
|
|
|
|
|
| `Programs/CosmOS` | The operating system, its applications, and the native assembler |
|
|
|
|
|
| `Programs/testPrograms` | What the test suite drives |
|
|
|
|
|
| `Tests` | The suite: the manifest, the recorded output, and the scripts that check it |
|
|
|
|
|
| [`Source/Emulator`](Source/Emulator) | The machine: CPU, memory controller, devices, console, disk |
|
|
|
|
|
| [`Source/Assembler`](Source/Assembler) | The assembler that runs on a host |
|
|
|
|
|
| [`Source/DiskTool`](Source/DiskTool) | SplitDisk, which reads and writes SplitBit's filesystem |
|
|
|
|
|
| [`Programs/Examples`](Programs/Examples) | Programs to read: hello, a calculator, Fibonacci, a prime sieve, Life |
|
|
|
|
|
| [`Programs/Libraries`](Programs/Libraries) | Code included by name rather than linked, since there is no linker |
|
|
|
|
|
| [`Programs/Loader`](Programs/Loader) | The standalone loader CosmOS grew out of |
|
|
|
|
|
| [`Programs/CosmOS`](Programs/CosmOS) | The operating system, its applications, and the native assembler |
|
|
|
|
|
| [`Programs/testPrograms`](Programs/testPrograms) | What the test suite drives |
|
|
|
|
|
| [`Tests`](Tests) | The suite: the manifest, the recorded output, and the scripts that check it |
|
|
|
|
|
|
|
|
|
|
## The Machine:
|
|
|
|
|
|
|
|
|
@@ -55,6 +59,8 @@ make
|
|
|
|
|
|
|
|
|
|
The sources are ISO C and build clean under `-std=c11 -pedantic` with `-Wall -Wextra`. Beyond ISO C they need POSIX.1-2008, which the makefile asks for by name, and `getopt_long` for the long form of the command line options.
|
|
|
|
|
|
|
|
|
|
Building needs nothing else. **Running the tests needs `bash` and Python 3**, because two of the checking scripts are Python and one of them opens a pseudo-terminal to ask questions a recorded file cannot answer. They also use `stty`, `timeout`, and the usual text utilities: `sed`, `awk`, `grep`, `cmp`, `diff`, `tr`, `sort`, `wc`.
|
|
|
|
|
|
|
|
|
|
Assemble something and run it:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
@@ -174,23 +180,23 @@ because a recorded file cannot answer its question:
|
|
|
|
|
|
|
|
|
|
A cycle count is deliberately **not** part of a recorded result. The last line of the emulator's output has the number taken out before anything is compared, keeping only whether the program stopped on its own or ran into its limit, which is behaviour. Two instructions added to CosmOS used to move that number in six unrelated files at once, so a real difference would have arrived in a crowd of meaningless ones. Anything that wants to measure cycles should say so in a test of its own.
|
|
|
|
|
|
|
|
|
|
To rebuild both tools with the address and undefined behaviour sanitizers and run the suite under them:
|
|
|
|
|
To rebuild all three tools with the address and undefined behaviour sanitizers and run the suite under them:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
make sanitize
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
This catches reads and writes past the end of an array, use after free, leaks, and undefined arithmetic. It also fills fresh allocations with a junk pattern, which turns a read of uninitialised memory from something that quietly works into something the tests notice. It takes about twice as long as `make test`, and puts the ordinary binaries back when it finishes.
|
|
|
|
|
This catches reads and writes past the end of an array, use after free, leaks, and undefined arithmetic. It also fills fresh allocations with a junk pattern, which turns a read of uninitialised memory from something that quietly works into something the tests notice. It runs everything `make test` runs, takes about twice as long, and puts the ordinary binaries back when it finishes.
|
|
|
|
|
|
|
|
|
|
## Documentation:
|
|
|
|
|
|
|
|
|
|
Three documents, divided by what they are about rather than by who reads them.
|
|
|
|
|
|
|
|
|
|
The **SplitBit Programming Manual** describes **the machine**: the instruction set, the registers, the vector table, interrupts, devices, the memory controller, the console, storage, and faults. Everything here is true of any SplitBit, whatever is running on it.
|
|
|
|
|
**[SplitBit Programming Manual](SplitBit%20Programming%20Manual.md)** describes **the machine**: the instruction set, the registers, the vector table, interrupts, devices, the memory controller, the console, storage, and faults. Everything here is true of any SplitBit, whatever is running on it.
|
|
|
|
|
|
|
|
|
|
The **SplitBit Assembler Manual** describes **the language and the file formats**: literal values, labels, segments, the directives, the loadable program header, and the assembler that runs on SplitBit itself.
|
|
|
|
|
**[SplitBit Assembler Manual](SplitBit%20Assembler%20Manual.md)** describes **the language and the file formats**: literal values, labels, segments, the directives, the loadable program header, and the assembler that runs on SplitBit itself.
|
|
|
|
|
|
|
|
|
|
`Programs/CosmOS/README.md` describes **the operating system**: its shell, its applications, what a program may ask it for, and the libraries it owns. A different system on the same machine would answer all of that differently, which is why it is documented with the system rather than with the CPU.
|
|
|
|
|
[Programs/CosmOS/README.md](Programs/CosmOS/README.md) describes **the operating system**: its shell, its applications, what a program may ask it for, and the libraries it owns. A different system on the same machine would answer all of that differently, which is why it is documented with the system rather than with the CPU.
|
|
|
|
|
|
|
|
|
|
## License:
|
|
|
|
|
|
|
|
|
|