VD3

From Esolang
Jump to: navigation, search

VD3 is a simple programing language. It has only one command.

Syntax and commands

VD3 syntax is simply:

variable<-X^Y^Z

X, Y and Z can be variables or signed, unbound integers. Variables are as follows:

VD3 variables
Variable Meaning
A Data
B Data
C Data
PC Program counter
IN Input
OUT Output


VD3 2.0 variables
Variable Meaning
A Data
B Data
C Data
D Data
E Data
PC Program counter
IN Input
OUT Output

VD3 expressions

The following example shows how VD3 expressions work:

W<-X^Y^Z

W is now X+Y+Z. In VD3 2.0 it can be too:

...W<-X^Y^Z

... means every empty command position after it (and before next ...) has same command.

Simple adding

A<-1^1^0

A is now 2 (1+1+0).

Using variables

A<-1^2^3
B<-A^1^0

Now A is 6 (1+2+3) and B is 7 (A+1+0).

I/O

OUT<-65^0^0

This program prints the ASCII character 65 (A).

A<-IN^0^0

This program stores an ascii character from input in variable A.

Jumping

PC<-2^0^0
OUT<-65^0^0
OUT<-66^0^0

This program prints only B. It skips the command in position 1 (OUT<-65^0^0). Command position numbering starts from 0.

Haltting

PC<-0^0^-1
OUT<-65^0^0

This program halts and doesn't print A becouse jumpping to negative positions stop the program.

Jump if zero(VD3 2.0 only)

E<-5^0^0
F<-PC^2^0
PC<-7^IN^-48
OUT<-66^0^0
PC<-0^0^-1
OUT<-65^0^0
PC<-0^0^-1
PC<-E^0^0
...PC<-F^0^0

This program ask input. If ascii code of input is 48('0') then jump to 7 and from 7 to 5(saved to E) and print A, if ascii code is greater than 48 jump to >7 and then jump to 3(saved to F) and print B.

Examples

CAT

OUT<-IN^0^0
PC<-0^0^0

Computational class

Computational class of VD3 is unknow, but VD3 2.0 is turing complete becouse it can simulate 3 counter counter machine(E and F need to implement JZ).

INC (Reg):

(Reg)<-(Reg)^1^0

DEC (Reg):

(Reg)<-(Reg)^-1^0

HALT:

PC<-0^0^-1

JZ (Reg) (Destination):

E<-(Destination)^0^0
F<-PC^2^0
PC<-(Jump bank adress)^(Reg)^0

Jump Bank:
PC<-E^0^0
...PC<-F