esolang

Tueue

Two queues, one accumulator and a goto. Of a queue you only ever see the bottom.

ChuckEsoteric08 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: * ** *** **** ***** ****** ******* ******** ********* **********

The idea

ChuckEsoteric08 made Tueue, a queue language in the style of assembly. There are two queues and an accumulator. One queue is current at a time and SWP switches to the other. A value is read from the bottom of a queue, the end that DEQ takes, so to keep a value you dequeue it and enqueue it again at the back.

Read the story

The specification makes its case for Turing completeness with an interpreter for Bitwise Cyclic Tag. The program bits sit in the first queue with @ after them and go round and round, while the data string lives in the second. As written it drops a program bit each time the program wraps, so program 0 on data 111 never stops.

The machine

InstructionDoes
ENQ x DEQEnqueue x to the current queue; dequeue from it
SWPMake the other queue current
INC x DEC x MUL x DIV xChange the accumulator by x
MOV x yCopy x to y
ADD SUBDequeue a and then b, enqueue a+b or b-a
OUT x ASC xPrint x as a number or as a character
LAB x JMP xMark a line; go there
IQJ x y IAJ x yGo to y when the bottom of the current queue, or the accumulator, is x
IQE xGo to x when the current queue is empty
COM ...A comment

An argument is a number, a word such as @, ACC for the accumulator, or 1QU and 2QU for the bottom of the first and second queue, no matter which one is current.

Example

The looping counter.

The looping counter. The accumulator holds the line number and the first queue holds the count of asterisks on the line, which ENQ 1 and ADD raise by one.

SUB subtracts the first value it takes from the second.

Expected: -7

Further

Ideas it shows

Queue-based

Write your own in Run Convert a program from Tueue

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: tueue.

Command line

shib run tueue -e 'ASC 72
ASC 101
ASC 108
ASC 108
ASC 111
ASC 44
ASC 32
ASC 87
ASC 111
ASC 114
ASC 108
ASC 100
ASC 33'
shib manual tueue

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/tueue.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org