P1eq

From Esolang
Jump to navigation Jump to search

P1eq (plus one and branch if equal) by User:Oleg is a Subleq derivative with an instruction

A B C

and the meaning B=A+1 and jump to C if B does not change.

Hello, world!

Using the Subleq assembly language "Hello, world!" program is straightforward

    # output *p; 
    p a
    a:0 (-1)

    # p++
    p p

    # check if p!=E
    p t
    E t (-1)
    Z Z0 0

. p:H-1 Z:-1 Z0:0 t:0
. H: "Hello, World!\n" E:E-1

Arithmetic sum

The instruction is probably enough to make more complex computation. For example, the following program prints "2" (ASCII value 50) after summing x and y.

    t1 t1
    y y
    t1 t2
    x t2 end
    Z Z0 0
end: y (-1)
    Z Z0 (-1)
. Z:-1 Z0:0 t1:0 t2:0 x:30 y:20

Implementation

Use sqasm.cpp to compile assembly program into the P1eq code. Then sqrun.cpp with the option (-p) to run the compiled code.

See also