Usage:Looping counter

From Esolang
Jump to navigation Jump to search

Usage:Looping counter is an esoteric programming language based on looping counters invented by User:A.

Syntax

A Usage:Looping counter program consists of registers. A register can only preserve an eighth of a byte(i.e. one base-4 digit), and all commands consist of also an eighth of a byte. The virtual machine halts when all of the registers are 0.

// This does not work in this language. These are just non-comments merely for documenting the language.
1 2 + 1 // Create a register (i.e. register #1). When its zero-trigger is activated, increment register 2 by 1.
2 1 + 1 // Create a register (i.e. register #2). When its zero-trigger is activated, increment register 1 by 1.

In every looping counter program, register pairs are executed, and the pairs are simply every possible 2-register combination in a list of registers.

In every register pair, if the number of executions of a pair is even, decrement the register in the left of the memory and increment the register in the right of the memory until one of them is already zero. Then, their 0-triggers are triggered. If the number of executions of a pair is odd, then vice versa.

The first example is an infinite loop. This is the process of executing this program:

Assume that register 1 is 5, and register 2 is 4.
   5 4
-> 0 9 <- 0-trigger!
-> 0 10
-> 10 0 <- 0-trigger!
-> 11 0
...

Bytecode

The bytecode for this language is simple:

+   = 00
-   = 01 This is vise versa of +.
*   = 02 This command is a placeholder for a 0-trigger.
.   = 03 This command is for debugging; it outputs all of the registers.

Integer-constant = corresponding constant