Rasen

From Esolang
Jump to navigation Jump to search

Rasen is a stack based, esoteric programming language created by User:Wolgr in early 2014 and inspired by both Assembly code and Brainfuck.

Current Version: v0.2

The Language

Syntax

  • Spaces, tabs, and newlines are all ways of starting a new line in code. Whitespace can only be used to indicate a new line.
  • [] brackets are used to enclose the data block, and the keyword is used to signify what it the data will be used for.
  • All data can be inputted as either hexadecimal or decimal.
  • The stack size is 0x0000 to 0xFFFF in hexadecimal, or 0 to 65535 in decimal.
  • One line comments are done with a hash (#)

Runtime

  • The only runtime input allowed in Rasen is decimal or a character. If you input a string it will only grab the first character.

Keywords

Rasen uses a system of 3 letter keywords followed by a data block for majority of code, although some keywords do not require a command block to run successfully.

General

Keyword Parameters Description
SET data_loc, num_data Sets the data at location 'data_loc' to 'num_data'.
MOV loc_1, loc_2 Replaces data at 'loc_2' with data from 'loc_1', sets data at 'loc_1' to 0.
DEL data_loc Resets the data at 'data_loc' to 0.
COP loc_1, loc_2 Copies data from 'loc_1' to 'loc_2'.
OUT data_loc, index Outputs data from 'data_loc', index specifies int (0) or char (1).
GET data_loc Get character input and store in 'data_loc'.
ADD loc_1,loc_2,loc_3 Adds the data at 'loc_1' and 'loc_2' and stores it in 'loc_3'.
SUB loc_1,loc_2,loc_3 Subtracts the data at 'loc_1' and 'loc_2' and stores it in 'loc_3'.
EXT N/A Exits the program.

Counter Based

Keyword Parameters Description
JMP data_loc Jump the counter to data location.
INC num_data Increment counter by 'num_data', no data block will increment by 1.
DEC num_data Decrement counter by 'num_data', no data block will decrement by 1.
ADC num_data Add 'num_data' to current counter location, no data block will add by 1.
SBC num_data Subtract 'num_data' from current counter location, no data block will subtract by 1.
OTC index Outputs data at current counter location, index specifies int (0) or char (1).
GTC N/A Gets input and stores it at current counter location.

Condition Statements

Keyword Parameters Description
IFF loc_1, loc_2, comp_index Compares loc_1 with loc_2, with the comp_index being == (0), < (1), or > (2).

Examples

Hello World! Program

Expanded form of the program.

SET[0x0,72]
SET[0x1,101]
SET[0x2,108]
SET[0x3,108]
SET[0x4,111]
SET[0x5,32]
SET[0x6,87]
SET[0x7,111]
SET[0x8,114]
SET[0x9,108]
SET[0xA,100]
SET[0xB,33]
OUT[0x0,1]
OUT[0x1,1]
OUT[0x2,1]
OUT[0x3,1]
OUT[0x4,1]
OUT[0x5,1]
OUT[0x6,1]
OUT[0x7,1]
OUT[0x8,1]
OUT[0x9,1]
OUT[0xA,1]
OUT[0xB,1]
EXT

A little bit nicer looking.

SET[0x0,72] SET[0x1,101] SET[0x2,108] SET[0x3,108] SET[0x4,111] SET[0x5,32]
SET[0x6,87] SET[0x7,111] SET[0x8,114] SET[0x9,108] SET[0xA,100] SET[0xB,33]
OUT[0x0,1] OUT[0x1,1] OUT[0x2,1] OUT[0x3,1] OUT[0x4,1] OUT[0x5,1]
OUT[0x6,1] OUT[0x7,1] OUT[0x8,1] OUT[0x9,1] OUT[0xA,1] OUT[0xB,1]
EXT

Cat Program

Grabs whatever character you enter and outputs it.

GET[0x0]
OUT[0x0,1]

Same can easily be done with number input.

GET[0x0]
OUT[0x0,0]

If Statement Program

The basic if statement, where if user input equal to 100, it is outputted.

GET[0x0]
SET[0xF,100]
IFF[0x0,0xF,1]
OUT[0x0,0]
EXT

Known Bugs

  • Issue with GET currently only accepting decimal input.

To Be Implemented

  • Program will loop until it comes across the EXT command.
  • Optimise reading of file.
  • Goto and Label commands.

Changelog

v0.2:

  • If statements added.
  • 1 line comments added.
  • Reorganization of source code.

v0.1:

  • Initial release.
  • All base functions.
  • Numerical and Character input.

External resources