From Esolang
Jump to: navigation, search

SMITHb (or in other words, "SMITH FLAT") is an esoteric programming language invented by User:Zzo38. There is no GOTO or loops or such things as that. The program consists of a sequence of integers (of any size, positive, negative, or zero) and nulls (which are represented by *). The program executes only forward, repeatedly executing and deleting the command indicated by the first 2 elements of the sequence (which is one command). It can also act as a stack with the top of the stack at the end of the program.

There are sixteen different commands:

* * Stop program.
0 * Pop one number from top of stack, and output it.
* 0 Input a number and push to stack.
0 0 Change top element of stack, positive to negative, negative to positive, null to zero, zero to null
- - If X is less than Y then duplicate elements from X to Y onto the top of the stack. (The X and Y values are -1 for the top, -2 for one below the top, -3 for two below the top, and so on.) If X is greater than Y then duplicate elements from Y to X onto the top of the stack in reverse order.
- + Push result of element X of stack divided by Y, rounded toward zero (null if element X is null).
+ - Swap element X after the command in the program (1= next element after current command, 2=next one after that, etc) with element Y of stack.
+ + Execute command which is element X in program followed by element Y in program.
+ 0 Delete X elements from the top of the stack.
- 0 Delete element X from the stack.
+ * Remove the top X elements of the stack, add them together and push the sum, if any terms are nulls then the answer is also null.
- * Swap element X of the stack with the top element of the stack.
0 + Duplicate the top element of the stack Y times.
0 - If element Y of stack is zero or null then reverse the entire stack (after the current command is removed).
* + Delete the next Y elements of the program.
* - Reverse the order of the elements from Y to the top of the stack.

You are allowed to define macros name(value) and include them by typing name. You can include Unicode numbers for characters by putting them in quotation marks. You can also repeat by typing the number of times to repeat followed by the stuff to repeat in parentheses. Comments are a semicolon and all of the text until the end of the line.


Hello world program:

12(0 *) * *
"!" "d" "l" "r" "o" "W" 32 "o" "l" "l" "e" "H"

Cat program:

2(* 0 0 * -6 -1)

Computational class

SMITHb is Turing-complete. It is possible to convert brainfuck programs into SMITHb.

Interpreters and translators