XRF
XRF is a stack-based esoteric programming language designed by User:Scoppini in 2015.
Overview
XRF operates on a stack of nonnegative integers of arbitrary size, which is initialized with a single 0 value. XRF programs are divided into 5-command "chunks", which are separated by whitespace. Execution begins with the first chunk. When the end of a chunk is reached, the program moves on to the chunk corresponding to the top value of the stack, where the first chunk corresponds with 0. The commands are:
Command | Description |
---|---|
0 | Push a byte of user input onto the stack |
1 | Output the top value of the stack as an ASCII character, popping it |
2 | Pop the stack |
3 | Duplicate the top of the stack |
4 | Swap the two top values of the stack |
5 | Add one to the top value of the stack |
6 | Subtract one from the top value of the stack |
7 | Replaces the top two values of the stack with their sum |
8 | Ignore the next command if this chunk has not been visited previously |
9 | Send the top element of the stack to the bottom |
A | Jump to the next chunk early ('next' determined by the top value of the stack, as usual) |
B | Terminates the program |
C | Ignore the next command if this chunk has already been visited previously |
D | Randomizes the order of the stack |
E | Replaces the top two values of the stack with the absolute value of their difference (abs(topmost - 2nd_topmost)) |
F | Nop |
All characters other than 0123456789ABCDEF
are not allowed and will cause an error.
Examples
Hello, World! program
53374 54374 54374 545F4 54374 54374 54374 41345 546F4 54374 54374 54374 54374 54554 54554 545F4 54314 54554 54554 54554 545F4 54314 54314 54554 545F4 54314 33745 54664 54664 54664 54664 54314 54664 54664 54664 54664 54664 54664 54314 54934 54554 5454F 54374 5451F 54314 54554 545F4 54314 54664 54664 54664 54314 54664 54664 54664 54664 9151B
Cat program
8B0AF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF 10AFF
Truth-machine
Random generator
A program that generates random output consisting of characters '0' and '1'. Never terminates.
53374 43745 43745 43745 43374 BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB 74235 BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB BBBBB D31AF D31AF
Quine
Here: http://yiap.nfshost.com/esoteric/xrf/quine.xrf This quine is large (~280kb) and extremely slow if run on the original Python interpreter. In fact, a faster interpreter was written in C to allow the program to be run (the quine's author let it run for four hours before understanding that a faster solution was needed).
An alternative interpreter
For running larger, time and memory consuming programs, one might use XRFaster, an interpreter written in C and designed to be fast. However, this particular interpreter does not implement XRF fully; commands 0, 8, C, and D are not implemented because they do not appear in the quine for the sake of which this interpreter was written in the first place. Neither does it perform any error-checking, so your programs need to be perfectly valid.