Microscript
Jump to navigation
Jump to search
Microscript is an experimental code golfing language designed by User:SuperJedi224. Data is stored as 64-bit signed integers in two registers (both initially 0) and a pair of stacks (both initially empty).
Commands
<any integer literal n not part of another command> -> Increment first register by n "<any sequence of characters>" -> Push the unicode ids of the characters in the string into the stack, in the order they appear in the string a -> Empty the currently selected stack, outputting the values popped as characters, in the order popped c -> Let n be the value currently in the first register when this command is called. Then, zero the first register and repeat the remainder of the program, up to but not including the next "]" character (if one exists, otherwise it goes through the end of the program), n times C -> Copy all items from the selected stack onto the top of the other stack; such that order is preserved d<any integer literal n> -> Decrement first register by n e -> Set the first register to two to the power of its previous value E -> Set the first register to ten to the power of its previous value f -> Reverse the order of elements in the selected stack h -> Halt execution, without outputting register i -> Take a value from the input and write it to the first register I -> Take a string from the input and push the unicode IDs of its characters to the selected stack, from left to right l -> Write the contents of the second register to the first register n -> Print a newline o -> Pop a value off of the currently stack and write it to the first register p -> Print the contents of the first register as a number, followed by a newline (this will also be done automatically when execution is complete, except when halted by the h command) P -> Print the contents of the first register as a Unicode character q -> Works like a, but includes wrapping quotes r<any integer literal n> -> Increment the first register by a random integer on [0,n) s -> Push the contents of the register to the stack t -> Without popping, create a copy of the top value on the stack and write it to the first register v -> Write the contents of the first register to the second register x -> Toggle stack selection z -> Zero the first register Z -> Empty the selected stack + -> Pop a value from the stack and increment the first register by this value - -> Pop a value from the stack and decrement the first register by this value * -> Pop a value from the stack and multiply the first register by this value { -> Repeatedly run the code between this and the matching "}" (if it exists, the end of the program otherwise), exclusive, until the value of the first register is 0. [ -> Run the code between this and the next ] if and only if the selected stack is empty ! -> Set the first register to 1 if its previous value was 0, 0 otherwise % -> Pop a value from the stack and take the first register modulo this value / -> Pop a value from the stack and divide the first register by this value, rounding towards 0 if needed # ->Find the current size of the selected stack and write to the first register $ ->As c, but repeats only the next single symbol '<any one character> -> Write the unicode id of that character to the first register ; -> A separator, currently only necessary for separating integer literals
Example programs
Infinite loop (2 bytes)
1{
Calculate square of input (3 bytes)
is*
Truth-machine (3 bytes)
i{p
Sum of Two Inputs (4 bytes)
isi+
Roll 1,048,576d4 (7 bytes)
20ec1r4
Cat program (9 bytes)
1{I[h]fan
Take an input and print 1, followed by that many zeroes (12 bytes)
is'1Poc'0P]h
Reverse Quine (12 bytes)
"Caxqh"Caxqh
Factorial (13 bytes)
ic1s]z1{[ph]*
Quine (14 bytes)
"fCqxah"fCqxah
Print 1 if input is "heads", -1 if input is "tails" (15 bytes)
Ifod104{zd1ph}1
Hello, world! (18 bytes)
"!dlrow ,olleH"anh
The n
can be omitted if a closing line break is not necessary.
Brainf*** equivalence
It is turing complete by the following Brainf*** equivalence:
+ 1; - d1; < sxo[vzsl]x > xsxo[vzsl] [...] {...}
External resources
- Reference implementation (written in Java)