esolang

':)'

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

Expected: Hello, World!

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

GroupThenDoes
:) I/O:) :P cPrint cell c as a character or as a number
:] :D cRead a number or a character into cell c
:> nPrint the constant n as a character
:P cells:) c nSet cell c to n
:P a bCopy cell b into cell a
:] :>Move the cell pointer left or right
:D cStore the pointer in cell c
:] arithmetic:) :P :] :> :D a b cSet cell c to the sum, difference, product, quotient or remainder of cells a and b
:D flow:) nMake label n
:P nJump to label n
:] :> n a bJump to n if cell a equals cell b, or is greater
:DHalt
:>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.

Expected: 0

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.

Expected: 5 4 3 2 1

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

Further

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 smileyface

Source

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