Neb's Art

From Esolang
Jump to navigation Jump to search

Neb's Art is an assembly-like esoteric programming language where you draw the output, created by User:HecknTarnation. The program's data is a grid of tiles that all store integers. When the program ends, the grid is printed to the screen.

All data is either stored in the grid, the stack, or the register.

Grid

The grid is an NxN-sized grid of signed 16-bit numbers. The pointer starts in the top left and can be moved around and 'point at' any tile.

Register

The register is a single 16-bit value that can be read from and written to.

The Data Stack

The data stack, just called 'the stack', is a stack of signed 16-bit numbers. This should not be confused with the execution stack.

Execution Stack

A stack of places in your code used to return from jump instructions.

The Compare (comp) Flag

This boolean flag is used for certain instructions. It is set during comparison instructions if they pass, but will not be unset if they fail.

Instructions

Op Codes Description
# [A:#] [B:#] Sets the size of the grid to A tall, B long. This must be the first instruction. It can be rerun, but doing so will clear the grid.
? [num/ascii] Sets the output mode of the grid. The default is 'num', or as numbers.
+ - * / % [#] Performs the given operation to/from the current tile. If no parameter is provided, it pops and uses the top value of the stack.
&< [#] Loads the number given, or the value from the tile being pointed at, into the register.
<& Loads the value from the register into the tile being pointed at.
=& Takes in a number as input from the user, and stores it into the stack.
` [#] Fills the grid with the given number.
< > ^ v [#] Moves the pointer the given number of times, or 1 if no parameter is given, in the given direction on the grid. If the pointer cannot move that amount, because it would go over the bounds of the grid, it will move as much as it can before stopping.
'(' ')' [X:#]/[Y:#] Sets the X or Y positions of the pointer, respectively. If combined, '()' it will do both, which means you have to specify both X and Y.
.( or .) [X:#]/[Y:#] Compares the current X or Y position, respectively, with the given one. Like the last instruction, they can be combined into '.() [X:#] [Y:#]' to compare both. If the comparison passes, meaning the X/Y position is equal to the one(s) given, the comp flag will be set.
.= Compares the register's value to the tile being pointed at. Sets the comp flag if equal, doesn't pop the stack.
.& Sets the comp flag if there are any numbers on the stack.
-. Skips all instructions, except for '.!', while the comp flag is set.
.! Unsets the comp flag.
@ [text] Creates a label. This instruction doesn't have to be executed for the label to be used.
-> [label] Jumps to a given label, pushing the current execution position to the execution stack.
->* [label] Same as previous, but does not push to the execution stack.
->= [label] [#] [*] Jump if the tile being pointed at's value is equal to the given value. If [*] is placed, the execution stack is not pushed.
->= [label] [#] [*] Jump if the tile being pointed at's value is less than the given value. If [*] is placed, the execution stack is not pushed.
->. [label] [*] Jump if the comp flag is set.
<- Returns from a jump by popping the execution stack.
<-> Reversed the value in the pointed at tile. (12 -> 21)
<&> Flips the stack.
; [#] Halts the given number of milliseconds. If the number is a multiple of 2, the grid is shown.
~ Ends the program and displays the grid.
| Comment

Example Programs

Hello World

# 1 12
? ascii
&< 72
&< 101
&< 108
&< 108
&< 111
&< 32
&< 87
&< 111
&< 114
&< 108
&< 100
&< 33
<&> 

@ unload_loop
.!
<&
>
.&
->. unload_loop
~

Snail

# 10 10
? ascii

() 5 5
` 32

&< 65
&< 65
&< 65
&< 65
&< 65
&< 65
&< 65
&< 65
&< 65
&< 65

<&
^
<&
<
<&
<
<&
v
<&
v
<&
>
<&
>
<&
>
<&
~

Resources