Tueue

From Esolang
Jump to navigation Jump to search

Tueue is a Queue-based esolang designed by User:ChuckEsoteric08. It consists of two queues, as well as one accumulator.

Specification

As said before, Tueue consists of Two queues and one accumulator.

1QU will return bottom of first queue.

2QU will return bottom of second queue.

ACC will return Accumulator.

x and y are arguments.

ENQ x Enqueue x to current queue.
DEQ Dequeue element from current queue
SWP Swap current queue
INC x Increment accumulator by x
DEC x Decrement accumulator by x
MUL x Multiply accumulator by x
DIV x Divide accumulator by x
LAB x Declare label x
JMP x Goto label x
IQJ x y If bottom of current queue is x goto label y
IAJ x y If accumulator is x goto label y
MOV x y copy x to y
OUT x Output x as an integer
ASC x Output x as an ASCII character
ADD Dequeue bottom two elements from queue, and enqueue result of addition of them
SUB Dequeue bottom two elements, a and b and push result of b-a
IQE x If current queue is empty goto x
COM x Comment

Examples

Hello, World!

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

Bitwise Cyclic Tag Interpreter

Because There is no input, you should initialise program and data.

Initialising Program

For 0:

ENQ 0

For 1:

ENQ 1

Initialising Data

After initialising program add this code:

ENQ @
SWP

And then: For 0:

ENQ 0

For 1:

ENQ 1

After initialising data add this command:

SWP

Interpreter itself

LAB SRT

COM Halt if data string is empty.
SWP
IQE END
SWP

MOV 1QU ACC
DEQ
ENQ ACC
IAJ 0 EX0
IAJ 1 EX1
IAJ @ IEM
JMP SRT

LAB EX0
SWP
DEQ
SWP
JMP SRT

LAB EX1
SWP
IQJ 0 SJM
SWP
IQJ @ IF@
SWP
ENQ 1QU
SWP
ENQ 1QU
DEQ
JMP SRT

LAB SJM
SWP
ENQ 1QU
DEQ
JMP SRT

LAB IF@
DEQ
ENQ @
SWP
ENQ 1QU
SWP
ENQ 1QU
DEQ
JMP SRT

LAB IEM
DEQ
ENQ @
IQE END
JMP SRT

LAB END

Looping Counter

This looping counter prints the first ten lines:

COM The accumulator maintains the current line number.
MOV 1 ACC

COM The first queue maintains the line's number of printed asterisks.
ENQ 0

LAB printLine
IAJ 11 haltProgram

LAB printAsterisk
ASC 42
ENQ 1
ADD
IQJ ACC concludeCurrentLine
JMP printAsterisk

LAB concludeCurrentLine
ASC 10
INC 1
DEQ
ENQ 0
JMP printLine

LAB haltProgram

Interpreter

  • Common Lisp implementation of the Tueue programming language.