blob: 0a2dddeeb8416776361a6cfe148448d7d4d777b1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# tonkobali
Rust project for the [Programming with Rust](https://2024.fmi.rust-lang.bg/) elective at FMI.
This is a small [SUBLEQ](https://en.wikipedia.org/wiki/One-instruction_set_computer#Subtract_and_branch_if_less_than_or_equal_to_zero)-based virtual machine and assembler for it.
More information can be found in the READMEs of the appropriate crates.
Some example programs are provided in `examples`.
## Detailed demo

## Usage
Install `cargo` on your system.
For Nix-capable machines you may get an environment with everything you need with:
```sh
nix develop
```
To assemble and then execute the `math.s` program just execute:
```sh
cargo run --bin assembler -- ./examples/math.s
cargo run --bin vm -- ./program.bin
```
Wait until you see a prompt with `HALTED` with red background to the left of your cursor.
You're now in the interface of the virtual machine.
Then enter `1000.1001`, you should get the following output:
```
1000: 55 1
```
To exit the vm enter `quit`.
## Resources
- [Wikipedia on SUBLEQ](https://en.wikipedia.org/wiki/One-instruction_set_computer#Subtract_and_branch_if_less_than_or_equal_to_zero)
- [masswerk's 6502 instruction set](https://www.masswerk.at/6502/6502_instruction_set.html#AND)
- [rmac's source format](https://rmac.is-slick.com/manual/manual/#source-format)
- [sbprojects on wozmon](https://www.sbprojects.net/projects/apple1/wozmon.php)
## Name
The name of this project has some logic behind it.
"SUBLEQ" can be shortened to "SL".
"SL" also stands for [Sierra Leone](https://en.wikipedia.org/wiki/Sierra_Leone), a small african country.
Sierra Leone is divided into [16 districts](https://en.wikipedia.org/wiki/Districts_of_Sierra_Leone), the two center-most being "Tonkolili" and "Bombali".
Therefore, "tonkobali" represents the composition of the two central components inside SL.
Before, the vm crate was called "tonkolili" and assembler - "bombali".
These names were dropped because they were confusing.
|