GORBITSA

From Esolang
Jump to navigation Jump to search
GORBITSA
Paradigm(s) imperative
Designed by David Barr
Appeared in 2020
Memory system Cell-based
Computational class Finite-state automaton
Reference implementation Implemented
File extension(s) .gbt, .bgbt

GORBITSA is a novelty esoteric programming language created by David Barr (aka javidx9) as a programming challenge for One Lone Coder community. It's jokingly named after one of community moderators Gorbit. It first appeared in OLC Discord server on 17th June 2020.

Complete description of the language as initially provided

Memory = 256 unsigned 8-bit cells
X = unsigned 8-bit register
Program counter starts at 0
256 program "instruction" slots
G = GRAB X, N            // Read X from mem[N]
O = OFFER X, N           // Write X to mem[N]
R = RECEIVE X            // Reads from input stream into X
B = BRANCH X == 0, N     // If X == 0, goto instruction N
I = INCREASE X, N        // Adds N to X register
T = TRANSMIT X           // Writes X to output stream
S = SET X <- N           // Set X explicitly to N
A = ADD X, N             // Adds mem[N] to X register
g = GRAB X, [N]          // Read X from mem[mem[N]]
o = OFFER X, [N]         // Write X to mem[mem[N]]
r = RECEIVE [N]          // Reads from input stream into mem[N]
b = BRANCH X == 0, [N]   // If X == 0, goto instruction mem[N]
i = INCREASE [N], X      // mem[N] = mem[N] + X
t = TRANSMIT [N]         // Writes to output stream mem[N]
s = SET X <- X XOR [N]   // Performs logic X XOR mem[N], stores in X
a = ADD X, [N]           // Adds mem[mem[N]] to X register
GORBIT-ROM - Program stream is in external memory
GORBIT-RAM - Program stream is in memory, each instruction is 2 bytes, therefore PC+=2 per op
Example syntax
R O201 R O202 S0 O203 G202 A202 O202 G201 I255 O201 B6 G202 T

Specification

Following section uses the words:

  • MUST - Means it is part of the standard and must be implemented by any given runtime/parser
  • UNDEFINED - Means that actual behavior is not defined in the language and support may vary.
  • MAY - Same as UNDEFINED but serves as a way that (may) helps implementors during implementation.
  • MUST NOT - Means the standard forbids it and it must be ensured that this may not happen.

to describe the Features.

ROM RAM Category Classification Description
Yes Yes Technical MUST 256 unsigned byte (8-bit) Cells, serving as Memory
Yes No Technical MUST 256 instruction slots. This means up to 256 instruction can be stored and addressed in a single ROM.
Yes Yes Technical MUST Single Register unsigned byte (8-bit) called X
Yes Yes Technical MUST unsigned byte (8-bit) MIN SIZE 0
Yes Yes Technical MUST unsigned byte (8-bit) MAX SIZE 255
Yes Yes Technical MUST unsigned byte (8-bit) roll over to MIN SIZE (0) if 255 + 1 is performed
Yes Yes Technical MUST unsigned byte (8-bit) roll over to MAX SIZE (255) if 0 - 1 is performed
No Yes Technical MUST Instruction size MUST be 2 bytes.
Yes Yes Technical MUST Initial values of Memory slots MUST be 0 initially.
Yes No Technical UNDEFINED Initial values of Instruction slots are UNDEFINED. Behavior when acessing them is up to implementor.
Yes No Technical MUST PC MUST increase by 1 after non-branching instructions executed.
No Yes Technical MUST PC MUST increase by 2 after non-branching instructions executed.
Yes Yes Technical MUST NOT Branching instructions MUST NOT modify the Program Counter (PC) after they executed.
Yes No Technical MUST Branching instructions MUST address absolute instruction slot (eg. B5 addresses instruction slot 5).
No Yes Technical MUST Branching instructions MUST address absolute Memory slot (eg. B5 addresses memory slot 5).
Yes Yes Format MUST A single instruction is made out of single-letter command code and up to 1 number parameter
Yes Yes Format MUST Instructions must be separated by spaces, an instruction consists of a valid letter and a number joined together: S97 T R T
Yes Yes Input UNDEFINED GORBITSA MAY use ascii characters as input or MAY use numbers as input.
Yes Yes Output UNDEFINED GORBITSA MAY use ascii characters as output or MAY use numbers as output. They MAY print a newline after output.
Yes Yes Technical UNDEFINED When PC points at invalid instruction, it is UNDEFINED wether execution stops or continues.
Yes Yes Technical MUST When PC points at (hypothetical) 256s instruction, execution halts.


Language overview

Base Instructions (GORBITSA)

Command code Parameter Description
G Yes: N X = Memory[N]
O Yes: N Memory[N] = X
R No Read input into X
B Yes: N if X == 0, IC = N
I Yes: N X += N
T No Write X into output
S Yes: N X = N
A Yes: N X += Memory[N]

Expanded Instructions (gorbitsa)

After limitations of base language were recognized, the instruction set was expanded to lower case letters.
New set allows direct I/O with memory, runtime computed goto destination and XOR.

Command code Parameter Description
g Yes: N X = Memory[Memory[N]]
o Yes: N Memory[Memory[N]] = X
r Yes: N Read input into Memory[N]
b Yes: N if X == 0, IC = Memory[N]
i Yes: N Memory[N] += X
t Yes: N Write Memory[N] into output
s Yes: N X = X xor Memory[N]
a Yes: N X += Memory[Memory[N]]

Computational class

Due to limited amount of cells and limited possible values in cells and register, it is a Finite-state automaton.

Basic Programs

Here are a few simple and/or "traditional" GORBITSA programs

Hello World

S72 T S101 T S108 T T S111 T S32 T S87 T S111 T S114 T S108 T S100 T

Cat program

R T

Cat program until EOF

Assumes 0-based command indexing.

R T B5 S0 B0 S0

Truth-machine

R O0 I255 O1 G0 T G1 B4
R B6 S1 T S0 B2 T
R T B255 S1 T S0 B3

Subtraction

R O0 R O1 G0 I255 O0 G1 I255 O1 B13 S0 B4 G0 T
S255 O255 r0 R s255 I1 A0 T

Multiplication

R O0 O1 R I255 O2 G0 A1 O0 G2 I255 O2 B15 S0 B6 G0 T
r201 R B17 I255 B16 O0 G201 O202 G202 i201 G0 I255 O0 B16 S0 B8 G201 T

Byte Swap

It swaps the values of Memory[0] and Memory[1]:

G0 s1 O0 G1 s0 O1 G0 s1 O0

For loop

The first parameter(In this program, 5) is the number of times the loop will be executed

S5 O0 S35 T G0 I255 O0 B10 S0 B2 S0 T

A 10x10 Box (By Megarev)

The first S10 and the third S10 define the size of the box

S10 O0 G0 I255 O0 B19 S10 T S10 O1 G1 I255 O1 S35 T G1 B2 S0 B10 S10 T

Simple Stairs (By Megarev)

The fifth S6 defines the size of stairs

S10 O10 S0 O1 S6 O0 G0 I255 O0 B24 t10 G1 I1 O1 O2 G2 I255 O2 S35 T G2 B6 S0 B15 t10

Number Comparison

Prints 'T' if A <= B else it prints 'F', runs in ROM and RAM mode, though it's one use only in the latter.

r0 r1 G0 B14 G1 B18 G0 I255 O0 G1 I255 O1 S0 B2 S84 T S0 B19 S70 T

Advanced Programs

What follows are some of the more advanced programs created in the GORBITSA esolang.

Modulus

Runs on GORBITSA-ROM with int output and int input

R O0 O1 R O2 O3 S255 O255 S0 B11 B19 
G3 s255 I1 A1 O1 O5 S0 B10 
G2 O10 G5 A10 B35 G5 B37 G10 B35 I255 O10 G5 I255 O5 S0 B21 S0 B8 G1 T

Guessing Game (by User:Geek Joystick)

Runs on GORBITSA-ROM with char output and int input (the python interpreter by User:Geek Joystick & TwistedLlama works for this program)

S0 S252 O0
S71 T S117 T S101 T S115 T T S32 T S40 T S48 T S45 T S57 T S41 T S63 T S32 T
R O1 I48 T S12 T
G0 A1 B50
S87 T S114 T S111 T S110 T S103 T S12 T S0 B0
S82 T S105 T S103 T S104 T S116 T S33 T

Self Interpreter (by User:ZippyMagician)

Runs on GORBITSA-ROM with any output (dependent on program being interpreted) and mixed input. Interpreted code is in GORBITSA-RAM, 123 commands maximum, instead of the 128 command limit on normal RAM programs. This is due to the requirement of indexes 248-255 needed for the program to store information. Each command and argument are inputted one after the other, with commands that take no arguments still requiring any number. Code will immediately be executed once the user enters "D" (due to this please refrain from using 68 as an argument). Full syntax supported.

S255 O253 R I188 B12 I68 o252 S1 O250 i252 S0 B2 S71 O255 S18 O254 S0 B134 B143 S79 O255 S25 O254 S0 B134 B149 S82 O255 S32 O254 S0 B134 B155 S66 O255 S39 O254 S0 B134 B158 S73 O255 S46 O254 S0 B134 B168 S84 O255 S53 O254 S0 B134 B172 S83 O255 S60 O254 S0 B134 B175 S65 O255 S67 O254 S0 B134 B179 S103 O255 S74 O254 S0 B134 B185 S111 O255 S81 O254 S0 B134 B193 S114 O255 S88 O254 S0 B134 B201 S98 O255 S95 O254 S0 B134 B207 S105 O255 S102 O254 S0 B134 B219 S116 O255 S109 O254 S0 B134 B224 S115 O255 S116 O254 S0 B134 B230 S97 O255 S123 O254 S0 B134 B239 G251 s253 I1 A252 B255 S2 i251 i250 S0 B12 g251 s253 I1 A255 b254 S1 i254 S0 b254 g250 O248 g248 O249 S0 B124 g250 O248 G249 o248 S0 B124 r249 S0 B124 G249 B162 S0 B124 g250 O251 I1 O250 S0 B12 g250 i249 S0 B124 t249 S0 B124 g250 O249 S0 B124 g250 O248 g248 i249 S0 B124 g250 O248 g248 O248 g248 O249 S0 B124 g250 O248 g248 O248 G249 o248 S0 B124 g250 O248 R o248 S0 B124 G249 B211 S0 B124 g250 O248 g248 O251 I1 O250 S0 B12 g250 A249 o250 S0 B124 g250 O248 g248 T S0 B124 g250 O248 g248 O248 G249 s248 O249 S0 B124 g250 O248 g248 O248 G249 a248 O249 S0 B124

Pseudo Random Number Generator (by dandistine)

Runs on GORBITSA-ROM with int or ascii input and int output. Takes three seeds as input, outputs a PRNG sequence until terminated

S255 O0 S0 o0 S255 i0 G0 B10 S0 B3 r10 r11 r12 S1 O13 S1 i13 G13 A12 s10 O10 A11 O11 I1 s11 I255 B33 G11 I255 O20 O21 S0 B36 G11 O20 O21 G21 I255 O21 A21 s20 B44 S0 B36 G21 O11 s10 A12 O12 T S0 B15

Tic-tac-toe (by Horsey)

Runs on GORBITSA-ROM with ascii input and ascii output.

S255 O95 S2 O240 O241 O242 O243 O244 O245 O246 O247 O248 S9 O57 S88 O50 S240 O99 S10 T S3 O4 S124 T S3 O3 g99 B38 I255 B34 S32 O2 S0 B41 S88 O2 S0 B41 S79 O2 S0 G2 T S124 T G99 I1 O99 G3 I255 O3 B54 S0 B26 S10 T G4 I255 O4 B62 S0 B22 S240 O99 G57 B254 G50 T S58 T S32 T R I192 O7 G50 I168 O32 g7 I254 O56 B84 S0 B218 G32 B88 S0 B89 S1 o7 S3 O8 g99 I254 B121 g99 O255 G99 I1 O99 g99 O254 G255 s95 I1 A254 B109 S0 B121 g99 O255 G99 I1 O99 g99 O254 G255 s95 I1 A254 B236 G8 I255 O8 G8 A8 A8 O255 S249 O254 G255 s95 I1 A254 O99 G8 B139 S0 B92 S240 O99 S3 O9 g99 I254 B172 g99 O255 G99 I3 O99 g99 O254 G255 s95 I1 A254 B160 S0 B172 g99 O255 G99 I3 O99 g99 O254 G255 s95 I1 A254 B236 G9 I255 O9 I239 O99 G9 B181 S0 B143 G244 I254 B218 G244 O255 G240 O254 G255 s95 I1 A254 B195 S0 B202 G248 O254 G255 s95 I1 A254 B236 G246 O254 G255 s95 I1 A254 B211 S0 B218 G242 O254 G255 s95 I1 A254 B236 G32 B224 S88 O50 S0 B226 S79 O50 G56 B230 S0 B236 G57 I255 O57 B249 S0 B16 G50 T S32 T S119 T S111 T S110 T S0 O57 B16 S61 T S0 O57 B16

Saurons eye (By TrolledWoods)

Prints saurons eye if ascii output. Takes no inputs

S206 O132 S10 T S156 O97 S1 i97 S0 O7 G97 I237 O131 G97 i7 S1 i131 G131 B42 S0 B26 S0 O105 G132 I45 O131 G132 i105 S1 i131 G131 B68 S0 B52 G105 i7 S200 O105 G7 B94 G105 B102 S255 i7 i105 S0 B76 S46 T S0 B110 S35 T S0 B110 G97 B118 S0 B12 S1 i132 G132 B255 S0 B4

Snake (By Horsey)

Uses ascii output and ascii input (using the keys hjkl) on GORBITSA-ROM. Requires a terminal with support for ANSI escape codes to clear the screen and show colors. Can be run on an interpreter which does not block on R if no input is available, instead setting X to its previous value or another character such as NULL, EOT, ETX or -1 (255). However, such behavior, while not incompatible with the specification, is non standard.

S255 O95 S27 O1 S28 O2 S29 O3 S255 O165 S3 O33 S20 O34 S27 T S91 T S50 T S74 T S10 T S34 O151 S95 T G151 I255 O151 B34 S0 B26 S10 T S16 O152 S255 O156 O157 S124 T S16 O153 G33 O158 g158 O255 B73 S16 O159 S0 O160 G160 A152 O160 G159 I255 O159 B63 S0 B54 G160 I240 A153 O160 O254 G255 s95 I1 A254 B108 G158 I255 O158 B79 S0 B47 G160 O255 G34 O254 G255 s95 I1 A254 B90 S0 B104 S27 T S91 T S57 T S49 T S109 T S219 T S0 B120 S32 T S0 B120 S27 T S91 T S57 T S50 T S109 T S219 T G157 s156 O157 i153 G153 B128 S0 B45 S27 T S91 T S48 T S109 T S124 T S10 T G152 I255 O152 B146 S0 B41 S34 O154 S196 T G154 I255 O154 B156 S0 B148 G33 O161 G1 O163 g33 O170 G161 I255 O162 g162 o161 G162 O161 B172 S0 B162 R I152 B183 I254 B191 I255 B187 I255 B195 S0 B197 S1 O165 S0 B197 S16 O165 S0 B197 S240 O165 S0 B197 S255 O165 G163 A165 O1 G34 O255 G1 O254 G255 s95 I1 A254 B211 S0 B217 S1 i33 G170 o33 s254 O34 G33 O166 G33 O167 G167 O255 G166 O254 G255 s95 I1 A254 B239 g167 O255 g166 O254 G255 s95 I1 A254 B255 G167 I255 O167 B245 S0 B221 G166 I255 O166 B251 S0 B219 S0 B14 S0

Implementations

(Please note that while included, PC, PM, PNN, INN, OM, and ONN are non-standard according to this esolang's creator)

Name Meaning
PC Parse Input Supports Characters (eg. Sa gets read as S97; S1 gets read as S49)
PM Parse Input Supports Mixed (eg. Sa gets read as S97; (char)1 gets read as S1)
PN Parse Input Supports Numbers (eg. Sa gets rejected; S1 gets read as S1)
PNN Parse Input Supports Negative Numbers (eg. Sa gets rejected; S-1 gets read as S255)
IC Input Supports Characters (eg. (char)a gets read as (uint8)97; (char)1 gets read as (uint8)49)
IM Input Supports Mixed (eg. (char)a gets read as (uint8)97; (char)1 gets read as (uint8)1)
IN Input Supports Numbers (eg. (char)a gets rejected; (char)1 gets read as (uint8)1)
INN Input Supports Negative Numbers (eg. (char)a gets rejected; (char)-1 gets read as (uint8)255)
OC Output Supports Characters (eg. (uint8)97 gets outputted as (char)a; (uint8)49 gets outputted as (char)1)
OM Output Supports Mixed (eg. (uint8)97 gets outputted as (char)a; (uint8)49 gets outputted as (char)1; (uint8)1 gets outputted as (char)1)
ON Output Supports Numbers (eg. (uint8)97 gets outputted as (string)97)
ONN Output Supports Negative Numbers (eg. (uint8)255 gets outputted as (string)-1)
Language Base (ROM/RAM/BOTH) PC PM PN PNN IC IM IN INN OC OM ON ONN Author(s) Link
Python3 ROM N N Y Y Y N Y Y Y N Y N codeskulptor
Node.JS BOTH N N Y N Y Y Y N Y N Y N repl_it
JavaScript BOTH N N Y N N N Y N Y N Y N
  • Sir Felix Delazar
Site
C BOTH Y Y Y Y Y Y Y Y Y N Y N repl_it
Brainfuck ROM Y N N N Y N N N Y N N N
  • Gorbit99
/bf-interpreter
Python3 ROM N N Y N Y N Y N Y N Y N GORBITSA to C Compiler
Node.js BOTH Y Y Y Y Y Y Y Y Y Y Y Y Interpreter