This implementation is a runtime / VM / interpreter that parses and runs an extension of the programming language featured in Zachtronics' Shenzhen I/O.
Write your code in a .sio file:
$x0 # What's this?
# - It's a way to declare your own registers, if you need them.
# This one refers to an XBus channel x0.
$dat # This is another register.
# Registers that don't start with p or x are considered *plain registers*.
# Registers that start with p refer to *power channels*,
# XBus- and Power channels can be used to send data between SIO-files (nodes).
#run this once
@mov 100 acc
mov acc stdout
# - stdout is a register that you can use to write to stdout :)
# What does it write?
# - whatever you give it. It can be string or it can be a number.
# It's kinda like the stdout you know from C.
sub 1
mov "\n" stdout # A string literal!
tlt acc 1
+ mov "done\n" stdout
+ end # End the program.
slp 1
I was looking for something novel that I can implement my solutions for the next advent of code in. I wanted to work with something as annoying and crazy as Shenzhen I/O! Luckily, I found this kotlin project in a dumpster outside a chinese-themed grill.
- Dynamically typed values (yes, the language is now worse), store types such as integers, floating point numbers and char strings! wow
- Cast values between the types using the
cst Tinstruction. It operates on theaccregister. - All the
acc-related instructions such asacc,add,sub&mulapply to all the types, try them out! - Test-instructions are also applicable.
- Cast values between the types using the
- Declare your own registers at the beginning of a file by writing
$name. Use these to store values. XBus and simple I/O registers are used for passing values between multiple nodes, so the prefixesxandpshould be for those types of registers only. You still have to declare them and the order of the declarations determine the identity of each port. - Memory! Declare sequences of memory as special registers.
- Comes in a sized variant (
*name[10]makes a memory register, 10 values long) and an unsized, infinite, variant (*name). - Change the element referenced by
mov'ing to the accompanying&-register, (&namefor both previous examples).
- Comes in a sized variant (
- Use the new built-in registers!
- Set a clock-speed in Hz by
moving to theclk-register.mov -1 clkto enable overclocking (makes it go faster🔥🔥🔥) - Read from
stdinby requestingncharacters bymoving to thestdinregister. Then, you can access the values bymoving from the register.- Read until a specific pattern by
moving the pattern string into stdin. Useful for reading line-by-line.
- Read until a specific pattern by
- Write to
stdoutbymoving to thestdoutregister. Read back what you wrote by moving from stdout (???) - Write to
stderrbymoving to thestderrregister. - Write to
rngto seed a random generator.movfrom the register to get a value! Try different types to get different results! - Use the
xsz,ysz,gfxandpxlregisters to render simple raster graphics.- Use the
kb0emulated PowerChannel to consume keyboard codes (sent from the raster-window).
- Use the
- Set a clock-speed in Hz by
- End your program with the new
endinstruction.
Unfortunately a lot of the documentation was in Zealandic(???) so I don't really know how everything works yet.
First, download a release from the releases page. The project is in Kotlin, so it compiles to a .jar file. You need at least Java 8 to run it.
Once you have it, you can run it like:
java -jar sio.jar <your .sio scripts>
That's right, you can run multiple .sio files at the same time. Commmunicating between those files is what the channels are for.
There's also a native version for amd64 linux. This has been compiled with Graalvm so maybe it's faster?
However, It's uncertain if graphical sio applications work with the native build.
I found a raster-graphics-extension for SIO on a now-defunct meme forum, one of the users was using it as the background for their avatar. It's interesting to play with, so I've merged it into the existing code. It's using the state-of-the-art Java Abstract Window Toolkit (AWT) to render graphics, so it should be available for graphics-enabled Java installations.
I wrote an example application (viewed above).
Check out the test-resources folder for more examples used in testing.
Press backspace on your keyboard to go back in your browser-history. If that doesn't work, you are probably forced to either type a new URL into the URL-field at the top or close the tab. If that doesn't work, you can press CTRL+W to close the tab. In the most dire cases you can probably get away from this page by pressing ALT+F4, but only do this if you are prepared to close the entire browser.
If that doesn't work for you, maybe you can leave the page open until the next time you restart or something. I've added some tasteful art so that the window at least stays decorative.

