A SUBLEQ Virtual Machine for the Commodore VIC-20. This VM uses 16-bit words.
SUBLEQ is a computer architecture that has only one instruction: SUBLEQ. The instruction stands for SUbtract and Branch if Less than or EQual to zero. Because there is only one instruction, only the operands are specified, which consist of 3 memory addresses that are acted on as follows:
SUBLEQ a, b, c
Mem[b] := Mem[b] - Mem[a]
if (Mem[b] ≤ 0) goto c
To find out more, have a look at the article: SUBLEQ - A One Instruction Set Computer (OISC) and its accompanying video.
The SUBLEQ virtual machine is contained in the file 'subleq.a65' which can be included into the file you want to run it from. You need to define SL_MEM
as a constant to point to where the program is in memory and then use jsr SL_run
to start the VM.
There is a script, sqtoword.tcl, which can be used to convert the output of a SUBLEQ assembler into .word
entries. There are also skeleton scripts for unexpanded and 8k+ systems to append these .word
entries to.
There are number of example assembler files in examples/
. These were created using the sblasm assembler and the original SUBLEQ source files can be found in its repo. They can be assembled using the XA assembler from within examples/
:
$ xa -I .. -o fizzbuzz.prg fizzbuzz.a65
- echo.a65
- Echos user input back to display. Requires: Unexpanded Vic
- hello.a65
- Displays "HELLO, WORLD!". Requires: Unexpanded Vic
- fizzbuzz.a65
- Plays Fizz Buzz up to 100. Requires: Unexpanded Vic
- rock_paper_scissors.a65
- Play Rock, Paper, Scissors against the Vic. Requires: 8k+
- sble.test.a65
- Tests the VM using the
sble
(SUBLEQ) instruction. Requires: Unexpanded Vic - standard.test.a65
- Tests standard routines. Requires: 16k+
Each program is prefixed with a basic stub so you can just load them and type run
to start.
Copyright (C) 2020 Lawrence Woodman lwoodman@vlifesystems.com
This software is licensed under an MIT Licence. Please see the file, LICENCE.md, for details.