Versert

From Esolang
Jump to navigation Jump to search
This article is a stub, which means that it is not detailed enough and needs to be expanded. Please help us by adding some more information.

Versert is an esoteric programming language inspired by Befunge, invented by Kang Seonghoon in 2005. (Versert is originated in a word "버섯", meaning mushroom in Korean.)Versert is a two-dimensional programming language, like befunge.Versert starts as a problem, what happens if befunge doesn't have a stack.

environment

All code is stored on an infinite two-dimensional plane. Any point on the plane has a coordinate form (column, row), and each character in the code is stored in a cell with integer coordinates. A cell can contain an 8-bit unsigned integer (limited to 0 to 255). The origin (0, 0) corresponds to the leftmost character in the first line of the code.

Before execution, the source code is read as ASCII text and stored in a plane. Suppose all other empty cells contain the space character, 32. Then there is no newline character (that is, 10) in the space, and storing the newline character later in the plane has no effect.

Versert has no stack; Versert has the following variables internally.

Instruction pointer: IP = (x, y) IP points to the instruction that is currently executing. The initial IP is (0, 0). Speed: delta = (DX, Dy) Delta represents the direction of IP. After the instruction pointed to by IP is executed, delta is added to IP to make IP point to the next instruction to be executed. Initially delta was (1,0) - IP eastward. Data pointer: DP = (PX, py) DP points to the target cell that the instruction reads or writes directly. The initial DP is (0, 0). Registers: A, B A and B are only variables that the instruction can change directly. Initially, a and B were zero. Code space is packaged to the extreme like befunge; If the IP goes East, the IP goes back to the original cell from the west, and vice versa. This property is often called Lahey space.

Instruction list

Command Description
0-9 Sets A to given number
+ Adds A to B
- Subtracts A from B.
* Multiplies A to B
~ Swaps A and B
` Swaps A and B if A is greater than B
> Swaps A and B if A is less than B
/ If IP is heading right, turns up; if down, turns left; if left, turns down; if up, turns right
\ If IP is heading right, turns down; if down, turns right; if left, turns up; if up, turns left
@ Terminates the program
# If B is zero, skips one instruction and executes next instruction
. Prints lowermost 8 bits of A to standard output as ASCII character
: Prints A to standard output as integer
, Reads a character and stores its ASCII code to A. When EOF is encountered, A won't be changed
; Reads an integer and stores it to A. When EOF is encountered, A won't be changed
{ Gets an instruction pointed by DP, and stores its ASCII code to B
| Moves DP A cells right, B cells down
} Puts lowermost 8 bits of B to an instruction pointed by DP, as ASCII character.

Examples

This is a famous "Hello, world!" program. Yay, it's cheating ;)

\"Hello, world!" program.
\3+5*0~|}-2+0~|#/{~.00\
     @.~*5+2\#{|1~/

This is same program with no such trick.

6~6*}2*~.{+7-~.~7+~..~3+~.~{8+~.~{4-~.~4*9-~.~8-~.~3+~.~6-~.~8-~.~{3-~.~2~5*~.@

This program does same thing as UNIX's cat program.

#/#.0~1\ 
@\#+,~-/

This program is a quine. (Thanks to mtve)

# #/ 0|   0~4+8*0~|}-0~|#/{~.00\ 
" @\# -2+{|~0*8-4~0.~*5+2\#{|1~/

External resources