Bltch1ang

From Esolang
Jump to navigation Jump to search
Note: the language's name is spelled with a lowercase L in "Bltch" and a number one in "1ang".

Bltch1ang (read as "BitchLang") is a language created by User:Dtp09. The purpose of it is to be annoying and unreadable, hence its name. The difficulty in programming with Bltch1ang is that the interpreter only accepts 5 characters that all look similar under the Courier New font.

Structure

Bltch1ang uses signed 16-bit integer storage. This means it can carry numbers from -32,768 to +32,767. It has a stack that can hold 2^16 values, and memory that can hold 2^16 values. It also has an internal stack for return addresses, holding a branch depth of 256 until the stack pointer will overflow and start overwriting at the front of the stack.

Syntax

The only acceptable characters are:

  • The number one
  • Lowercase L
  • Capital L
  • Lowercase i
  • Capital i

There are no comments. There are no spaces. Every character must be consecutive.

Opcodes

The interpreter reads every pair of 2 characters as an opcode. This is a chart that simply describes the combinations and what they do.

Simple Opcode Chart
First Char Second Character
One Lowercase L Capital L Lowercase i Capital i
One Push 8-bit Push 16-bit Pop Push from memory Set memory
Lowercase L Add Subtract Multiply Integer Divide Modulo
Capital L Branch Branch if equal Branch if unequal Branch if less Branch if greater
Lowercase i Input UTF-16 Input number Output number Output UTF-16 Update
Capital i Label indicator Return from branch Pop branch stack Push from memory by stack Set memory by stack

This is a descriptive chart that gives more information on opcodes.

Descriptive Opcode Chart
Opcode Description
Push 8-bit Uses 4 characters as an operand to push an 8-bit signed value to the stack.
Push 16-bit Uses 8 characters as an operand to push an 16-bit signed value to the stack.
Pop Pops the top value from the stack.
Push from memory Uses 8 characters as an operand to refer to a memory location. Push that memory location's value to the stack.
Set memory Uses 8 characters as an operand to refer to a memory location. Push the top stack value to that memory location.
Add Pop the top two stack values and push their sum.
Subtract Pop the top two stack values and push their difference (2nd top - top).
Multiply Pop the top two stack values and push their product.
Integer Divide Pop the top two stack values and push the floor of their quotient (2nd top / top).
Modulo Pop the top two stack values and push the modulo (2nd top % top).
Branch Accepts 4 characters as the label ID. Branch to label.
Branch if equal Accepts 4 characters as the label ID. Push PC to branch stack and branch to label if the top two stack value are equal.
Branch if unequal Accepts 4 characters as the label ID. Push PC to branch stack and branch to label if the top two stack values are unequal.
Branch if less Accepts 4 characters as the label ID. Push PC to branch stack and branch to label if the second top stack value is less than the top stack value.
Branch if greater Accepts 4 characters as the label ID. Push PC to branch stack and branch to label if the second top stack value is greater than the top stack value.
Input UTF-16 Accepts a UTF-16 character as input and pushes the code to the stack.
Input number Accepts a signed 16-bit integer as input and pushed it to the stack.
Output number Outputs the number at the top of the stack.
Output UTF-16 Outputs the top stack value as a UTF-16 character.
Update Force an update to occur. Useful for outputting in an infinitely looping program.
Label indicator Accepts 4 characters for the operand as a label ID. Unlike other opcodes, this isn't really an operation, it labels a position for a branch to go to.
Return from branch Set PC to the top value in the branch stack and pop it.
Pop branch stack Pop the top value in the branch stack without returning to it.
Push from memory by stack Push the memory address pointed by the top stack value.
Set memory by stack Set the memory address pointed by the top stack value to the value pointed by the 2nd top stack value.

Updates

An update is when everything sent to the output since the last update gets displayed to the user. Updates will not occur on program termination.

Operands

Numbers

Numbers are represented in base4 as follows:

Character Base4 Binary
Lowercase L 0 00
Capital L 1 01
Lowercase i 2 10
Capital i 3 11

For example, a signed 8-bit numeric opcode such as "LLLI" would encode to base4 "1113" which encodes to decimal 87.

Labels

Labels are 4 characters wide and can use any of the 5 available characters. This allows for 625 unique labels in a single program.

Examples

Hello, World!

11lilL11LiLl11LiIl11LIli11LiII11LLLI11lill11liIl11LiII11LiIl11LiIl11LiLL11Llil11llllI111111Lii1L11llllLL1111iI