# VD3

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

## Contents

## 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:

Variable | Meaning |
---|---|

A | Data |

B | Data |

C | Data |

PC | Program counter |

IN | Input |

OUT | Output |

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.

### Halting

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

This program halts and doesn't print A because jumping to negative positions stops 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

VD3 2.0 is Turing-complete. To show this, we will implement any 2-counter machine with instructions INC, DEC, and JZ. Let *X* be the position of the current command, and let *L* be the total number of commands excluding the postfix. Let

denote *R*`A`

or `B`

, and let

denote a jump destination position. Then, each instruction can be implemented:
*Z*

INC(*R*):

R<-R^1^0

DEC(*R*):

R<-R^-1^0

JZ(*R*, *Z*):

C<-X^0^0 PC<-R^(L+1)^0 PC<-Z^0^0

Postfix:

PC<--1^0^0 PC<-C^2^0 ...PC<-C^3^0

The computational class of VD3 without VD3 2.0 features is unknown.