The only supported instruction is called subleq. It works like this:
instruction subleq(a, b: Address; c: Label) =
Mem[b] = Mem[b] - Mem[a]
if Mem[b] ≤ 0: goto c
Surprisingly for many, this instruction set is Turing complete and all important operations can easily be mapped to subleq.
For example ADD a, b can be implemented as:
subleq a, Z
subleq Z, b
subleq Z, Z
where Z is mapped to a location that is always zero.
An MOV a, b can be implemented as:
subleq b, b
subleq a, Z
subleq Z, b
subleq Z, Z
Now if you worry that producing more instructions for every realistic program cannot be good for performance and the hardware caches, we will prove you wrong. ;-)
A high performance RISC 6 implementation can use instruction coalescing and combine up to 128 instructions of specialized patterns into a single internal operation. This is very easy to do because we know that every instruction uses the subleq opcode; there is no other available.
In order to do coalescing the CPU has to prove that the 128 memory locations that these 128 instructions would touch are not observable afterwards. Admittedly that is a hard problem, but we think that the simplicity of the instruction set does compensate for it. Simple is better.
So which patterns are specialized? That depends on the CPU model, the simplest model does not do any specialization and is an ideal model for universities. Numerous studies have shown that the average IQ of university students is constantly declining; RISC 6 is simple enough that even the biggest fool can understand it.
That I now work for SiSix implies many good things for Nim:
I'd like to announce that my new employer, "Rockstar Open Foundation Ltd."®, joins forces with SiSix in their next big endeavour: Rockstar Intermediate Representation Initiative™.
To facilitate faster growth of the new RISC 6 ecosystem, ROFL® is aiming to develop a set of modern tooling which will allow everyone to leverage resources of their respected technology platforms and capture and consolidate team efforts across multiple programming languages. The main core of the new toolset is the ultramodern RIRI™ Code Processing Compiler which transpiles· input in the easy to generate code in RockstarLang (called lyricode) to the RISC 6 instruction set. The other main component is Common Rockstar Runtime Abstract Processor, which is blazing-fast and stable VM, allowing running RIR-compiled lyricode on a widest set of legacy and obsolete architectures, such as AMD64 or AArch64.
In the next 6 month the Foundations plans to come to mutual agreements with most of the independent programming language teams to prioritize the work on integrating the Rockstar Intermediate Representation into their code generation process. I personally salute the Nim programming language developers for being the trailblazers of this process.
All this innovative work on RIRI™ CoPro Compiler and RIRI™ CRRAP will surely instigate agile practices in compiler development for every language joining the Initiative and as RISC 6 products dominate the market all the participants of the Initiative will be able to utilize the synergy of the newly developed joint ecosystem to bring us the new technological future we all deserve and want to make money in.
Btw can you please pick a shorter mnemonic than subleq, since it would be typed frequently? I think cmov would be a good alternative.
The name was chosen after a long-winded process and is unlikely to change. Advantages:
Disadvantages:
Really don't get it this ultimate risc being really Turing complete, how then to do decision operation e.g.
cmp eax, ebx
jz [0700]
cmp eax, $0101
ja [0700]
https://wiki.xxiivv.com/site/subleq.html has a few examples, you can also give https://esolangs.org/wiki/Subleq a look :)
P.S.: Check the date of the post :P
subleq a, Z
subleq Z, b
subleq Z, Z
, a head that can read or write
Mem[b] = Mem[b] - Mem[a]
or move
if Mem[b] ≤ 0: goto c
, some instructions to follow
instruction subleq(a, b: Address; c: Label) =
Mem[b] = Mem[b] - Mem[a]
if Mem[b] ≤ 0: goto c
, some states and a final state (in which it should stop). I think it enters the final state after
subleq Z, Z
So it's Turing-complete.