':)'
An assembly language in which every word is a smiley.
Martsadas · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Martsadas made :), a language that uses only six smileys. :O ends an instruction and :> separates arguments. The other four smileys are the digits of base 4, so :) is 0, :P is 1, :] is 2 and :D is 3. The letter H, 72, is written :P :) :] :).
Read the story
Like Whitespace, every instruction starts with a smiley that picks a group. The second smiley picks the instruction in that group. The same five smileys mean different things in each place.
The machine
| Group | Then | Does |
|---|---|---|
:) I/O | :) :P c | Print cell c as a character or as a number |
:] :D c | Read a number or a character into cell c | |
:> n | Print the constant n as a character | |
:P cells | :) c n | Set cell c to n |
:P a b | Copy cell b into cell a | |
:] :> | Move the cell pointer left or right | |
:D c | Store the pointer in cell c | |
:] arithmetic | :) :P :] :> :D a b c | Set cell c to the sum, difference, product, quotient or remainder of cells a and b |
:D flow | :) n | Make label n |
:P n | Jump to label n | |
:] :> n a b | Jump to n if cell a equals cell b, or is greater | |
:D | Halt | |
:> | Use the group of the instruction before |
Cell 0 is the cell under the pointer, which starts at 1 and cannot go left of it. A ; starts a comment. Cells hold whole numbers of any size, so :) is a counter machine and Turing complete.
Example
The Hello World prints one constant per line.
The Hello World prints one constant per line.
The truth machine reads a number into cell 3 and sets cell 1 to 1. It prints cell 3 and jumps back to label 2 while the two are equal.
A countdown. Cell 1 starts at 5 (:P :P), and the loop prints it and a space (32 is :] :) :)), takes 1 off and jumps back while cell 1 is greater than the empty cell 3.
The specification also has 99 bottles of beer, 185 instructions on 206 lines. One loop prints the verses from 99 down to 2, and the verse for 1 is spelled out letter by letter.
Patterns it teaches
- Encoding tricks: numbers in base 4, written with four faces.
- Counter machines: cells, arithmetic and conditional jumps.
- Camouflage: a program reads like a chat full of smileys.
Further
See also
Cell-based
Write your own in Run Convert a program from ':)'
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: smileyface.
Command line
shib run smileyface -e ':) :] :D :O ; Get input
:P :) :P :> :P :O ; Set another cell to 1
:D :) :] :O ; Make a new label
:) :P :D :O ; Print the input
:D :] :] :> :D :> :P :O ; Jump to the label if the input is equal to 1
:D :D :O ; Halt the program' --input '0'shib manual smileyfaceSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/smileyface.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org