The l33t Programming Language

Language Specification

l33t is an esoteric language based loosely on BrainF***, and influenced by Beatnik. The basic data unit is the unsigned byte (big-endian), which can represent ASCII values, numbers in the range 0-255, and, well, pretty much anything else you can put your sick little minds to.

Source is entered in l33t sP34k, and each word is evaluated as follows: Word are considered to be separated by spaces or carriage returns. The value of a word is obtained by adding the numerical digits within it together, e.g. l33t = 3 + 3 = 6.All other characters are valid but ignored. Words with no numeric characters (or in which the only numeric characters are “0”s) are evaluated to 0. It is possible to program in l33t just using numbers, i.e. not forming letters in l33t 5p34k. However, programmers who do this are “teh sUxX0r”, and the interpreter is well within its rights to format your hard drive for attempting this. Needless to say, l33t is case-insensitive, but extra kudos is awarded for random capitalisation ;o)

The language utilises a 64K block of memory, and 2 pointers - a memory pointer and an instruction pointer. The l33t interpreter tokenises all the words in the source to create a sequence of numerical opCodes (described below), and places them in order into the memory block, starting at byte 0. The instruction pointer starts at byte 0, and executes the command there to begin the program. Each opCode (except END) will move the instruction pointer, as described below. The memory pointer starts at the first byte after the instructions. Memory "wraps". Incrementing the memory pointer past 64K will cause it to run around to byte 0, and vice versa. The instruction pointer will behave in the same way.

It is legal to move the memory pointer into the area of memory occupied by the instructions, so code can be self modified at runtime. Similarly, the instruction pointer will keep incrementing or jumping until it encounters an END (see below), so code can be generated at runtime and subsequently executed. A program doesn't necessarily have to have an END command at the end of it. It can generate this at runtime, or run forever.

The Opcodes

The l33t language consists of 10 opCodes, all of them in the form of decimal numbers. They are as follows:

0 NOP No Operation, except to increment the instruction pointer.
1 WRT Writes the ASCII values of the byte under the memory pointer to the current connection (see CON). Increments the instruction pointer.
2 RD Reads a character from the current connection (see CON) and writes it to the byte currently under the memory pointer. Increments the instruction pointer.
3 IF Moves the instruction pointer forward to the command following the matching EIF, if the byte under the memory pointer is equal to zero. If the byte under the memory pointer does not equal zero, IF simply increments the instruction pointer.
4 EIF Moves the instruction pointer backwards to the command following the matching IF, if the byte under the memory pointer is not equal to zero. If the byte under the memory pointer does equal zero, EIF simply increments the instruction pointer.
5 FWD Move memory pointer forward by (next word+1) bytes. Adds 2 to the instruction pointer.
6 BAK Move memory pointer backward by (next word+1) bytes. Adds 2 to the instruction pointer.
7 INC Increment value of the byte under memory pointer by (next word+1). Adds 2 to the instruction pointer.
8 DEC Decrement value of the byte under memory pointer by (next word+1). Adds 2 to the instruction pointer.

Reads the 6 bytes starting with the memory pointer (the first 4 bytes specifying an IP in the format, and the last 2 bytes combining to make a 16-bit port number * ), and opens a connection if possible. If a connection can't be opened, l33t will return the error message:

 "h0s7 5uXz0r5! c4N'7 c0Nn3<7 l0l0l0l0l l4m3R !!!".

 and reset the current connection to the last successful one (stdin/stdout if there were no previous successful connections). If all 6 bytes read 0, l33t  reverts back to the local machine's stdin and stdout (this is the default setting upon starting a l33t program). Increments the instruction pointer. Regardless of whether the connection was successful or not, the memory pointer will be left in the same place as it was. Only FWD and BAK move the memory pointer.  

* The port number can be calculated by something along the lines of: portNumber = (byte5 << 8) + byte

10 END Closes all open connections and ends the program. The value 10 won't end the program if it is used as data for OpCodes FWD, BAK, INC or DEC.

Note that the words for the opCodes (NOP, WRT, etc) are just handy conventions for referring to the opCodes, and for explaining segments of l33t code as pseudo-code, nothing more. Writing INC in your source will do nothing (it will evaluate to 0, NOP); writing “pH34r” will do something (it will evaluate to 7, INC).

... And Now The Bad News...

A few points to be aware of:

©2005 Stephen McGreal