The (Not so) OISC, or NOISC, is a computer that operates primarily using the subleq instruction. However, unlike a typical OISC, this computer has five instructions. Therefore, it could also be called a FISC (Five Instruction Set Computer).
- Signed 8-bit data and 16-bit address width
- 5 instructions (subleq, set, in, out, hlt)
Each instruction has a variable length, making this computer similar to a CISC architecture. But the only instruction that performs actual computation is subleq, while the other instructions are used to write/read values to/from specific memory addresses or perform operations that would be difficult with just subleq.
-
subleq a, b, c
performb = b - a
, and ifb
<= 0, branch toc
.a
andb
,c
are addressees.c
can either be a label or a 16-bit address, but it is recommended to use labels. 7 Bytes long. -
set addr, value
Sets the value at memory addressaddr
tovalue
. 4 bytes long. -
in addr
Reads input from the user and stores it at memory addressaddr
. 3 bytes long. -
out addr
Prints the value stored at memory addressaddr
. 3 bytes long. -
hlt
Halts the program. 1 byte long.
This code has only been tested in a Linux environment with GCC. However, since the codes are simple, it is likely to work on other compilers or operating systems as well.
If you are using Debian/Ubuntu,
sudo apt update && sudo apt upgrade
sudo apt install python3 gcc git
git clone https://github.com/Aurorasphere/not-so-oisc/
cd not-so-oisc
make
If everything is done correctly, the computer executable will be located in the bin directory.
- Write some assembly code and save.
- type
python src/assembler.py [YOUR CODE'S NAME].s [OUT FILE'S NAME].out
in your terminal.
- type
bin/oiscomputer [OUT FILE'S NAME].out
in your terminal.
Here is an example program that compares two numbers and prints the result:
// Compare A and B,
// If A > B, Print 0.
// If A <= B, Print 1.
in 0x00F0 // Read A, Address of A is 0x00F0
in 0x00F1 // Read B, Address of B is 0x00F1
set 0x00FF 0x00 // Set Bool = 0, Address of Bool value is 0x00FF
subleq 0x00F1 0x00F0 RETURN // If A - B <=0, go to RETURN
out 0x00FF // If not, Print 0
hlt // Stop the Program
RETURN:
set 0x00FF 0x01 // Set Bool = 1
out 0x00FF // Print 1
hlt // Stop the program