Minecraft CarpetMod standalone turing-complete vanilla command-block array-based CPU generator
The generator is written in scarpet using CarpetMod
Assembly is written in JSON so maybe one day, with enough instructions, it would be possible to transpile LUA's bytecode to it. Which would be the ultimate goal of this project
The assembly language is array-based and it provides
- basic stack manipulation instructions (
pushandpopinstructions) - primitive usage of "variables" (
getandsetinstructions) - basic arithmetics (
addandsubinstructions) - conditional jumps
- subroutines
The ALU (Arithmetic Logic Unit) in action
The first 10 fibonacci numbers - Video Showcase
jmp main
lbl loop
pop //get 0
add
get 0 //10
push 1
sub
set 0
pop
pop
jnz loop
lbl main
push 10
push 1
push 1
push 69 //dummy for 1st pop in :loop
jmp loopnumber—[0-9]+char—'.'name—[_a-zA-Z][_a-zA-Z0-9]*value— Eithernumber,charorname(constant)idx—value, 0-based index from the bottom of the stack[...]- optional argument, if not present, taken from the stackA- top value on the stackB- second-top value on the stack
| Instruction | Description |
|---|---|
push value |
Push value onto the top of the stack |
| pop | Discard the top element of the stack 📝 No other instruction can pop a value off the stack |
get [idx] |
Push element at idx onto the top of the stack |
set [idx] [value] |
Set element at idx to value |
| Instruction | Description |
|---|---|
lbl name |
Define a new label of ID name |
call name |
Call the subroutine at label name |
| ret | Return from the current subroutine |
jmp name |
Jump to label name |
je name |
Jump to label name if A == B |
jne name |
Jump to label name if A != B |
jg name |
Jump to label name if A > B |
jge name |
Jump to label name if A >= B |
jl name |
Jump to label name if A < B |
jle name |
Jump to label name if A <= B |
jz name |
Jump to label name if A == 0 |
jnz name |
Jump to label name if A != 0 |
| Instruction | Description |
|---|---|
| add | Push A + B |
| sub | Push A - B |
- Clean up the scarpet code
- Clean up this readme
- Actually handle
charcuz I don't think it's working - Make conditional jumps pop off their
As andBs - Create a
constinstruction for setting constants - Create an
idxinstruction that pushes the top index - Create
mulanddivinstructions for multiplication and division - Perhaps create a
delinstruction that would remove an element at a specified index - Perhaps create a
putinstruction that would place a specified block at the givenx y zcoordinates (good luck with that)