TroshLyash Encoding for Virtual Machine


The virtual machine uses variable-length-instruction-word (VLIW),  loosely inspired by head and tails instruction format(HTF).  HTF uses VLIW’s which are 128 or 256 bits long, however there can be multiple instructions per major instruction word.

VLIW’s Head Index

The head is really a parse index, to show the phrase boundaries. In TroshLyash each bit represents a word, each of which is 16bits, when a phrase boundary is met then the bits flip from 1 to 0 or vice-versa.  Let’s look at a simple hello example: “hnatkapyatno” meaning “print hello!”, breaks down into the words “hnat ka pyat no” and the phrases “hnatka pyatno”.
Thus since there are two words each, the index for it is 0011 or 1100 depending on place within the index.
The real index for a VLIW that only contains the above sentence would be 0110011111111111 since the index takes up the first 16bits of the VLIW.
This would lead to 256bit (32Byte) VLIW’s.

The real advantage of the indexing occurs when there either multiple sentences per VLIW, or when there are complex sentences in the VLIW’s.
Having the VLIW’s broken up into 32Byte chunks, makes it easier to address function entry points, which can be placed at the beginning of a VLIW.

Can fit 16 VLIWS in a POSIX page, 128 VLIW’s in a Linux page, so would only need 1 byte (8bits) for addressing functions that are within 1 page distance.

Word Compression

Now for the slightly more interesting issue of packing as many as 5 glyphs into a mere 16 bits. Why this is particularly interesting is that there is an alphabet of 32 glyphs, which would typically required 5 bits each, and thus 25bits in total. However the 16 bit compression is mostly possible due to the rather strict phonotactics of TroshLyash, as only certain classes of letters can occur in any exact place.

The encoding supports 4 kinds of words, 2 grammar word classes and 2 root word classes. Where C is a consonant, T is a tone and V is a vowel, they are CVT, CCVT, and CVTC, CCVTC respectively.


I’ll start with explaining the simplest case of the CCVTC word pattern.
To make it easier to understand the word classes can call is the CSVTF pattern, where S stands for Second consonant, and F stands for Final Consonant.

The first C represents 22 consonants, so there needs to be at least 5 bits to represent them.
Here are the various classes

“C”:[“p”,”t”,”k”,”f”, “s”,”c”,”x”, “b”,”d”,”g”,”v”, “z”,”j”, “n”,”m”,”q”,”r”, “l”,”y”,”w”],
“S”:[“f”,”s”,”c”,”y”, “r”,”w”,”l”,”x”, “z”,”j”,”v”],
“F”:[“p”,”t”,”k”,”f”, “s”,”c”,”n”,”m”],

(can check the phonology page for pronunciation)

C needs 5 bits,
S would need 4 bits, however the phonotactics means that if the initial C is voiced, then the S must be voiced, thus “c” would turn into “j”, “s” into “z” and “f” into “v”, also none of the ambigiously voiced phonemes (l, m, n, q, y, w, r) can come before a fricative because they have a higher sonority, thus must be closer to the vowel. So S only needs 3 bits.
V needs 3 bits
T needs 2 bits
and F needs 3 bits
which is a total of 16 bits.
5+3+3+2+3 = 16

However there are other kinds of words also. we’ll see how those work.


So here we have to realize that CVC or CVTC is actually HCVTF due to alignment.
So what we do is make a three bit trigger from the first word,
the trigger is 0, which can be three binary 0’s, 0b000
3+5+3+2+3 = 16

this does mean that now 0b1000, 0b10000 and 0b11000 is no longer useable consonant representation, however since there are only 22 consonants, and only 2 of those are purely for syntax so aren’t necessary, so that’s okay, simply can skip the assignment of 8, 16 and 24.


This is similar to the above, except we use 0b111 as the trigger,
meaning have to also skip assignment of 15, 23 and 31.
3+5+3+3+2 = 16


For this one can actually simply have a special number, such as 30,
which indicates that the word represents a 2 letter word.

what is P? P can be a parity-bit for the phrase, or simply unassigned.


Now with VM encodings, it is also necessary to make reference to binary numbers and things like that. The nice thing with this encoding is that we can represent several different things.
Currently with the above words, we have 1 number undefined in the initial 5 bits.

29 can be an initial dot or the final one, can call the the quote-flag (QF), depending on if parser works forwards or backwards. Though for consistency it is best that it is kept as a suffix (final one), as most other things are suffixes.
5+3+8 = 16
QF has a 3 bit argument of Length.
The Length is the number of 16bit fields which are quoted, if the length is 0, then the B is used as a raw byte of binary.
Otherwise the B represents the encoding of the quoted bytes, mostly so that it is easier to display when debugging.

The type information is external to the quotes themselves, being expressed via the available TroshLyash words. So in theory it would be possible to have a number that is encoded in UTF-8, or a string that is encoded as a floating-point-number. Though if the VM interpreter is smart then it will make sure the encoding is compatible with the type Lyash type, and throw an error otherwise.


This encoding already can represent over 17,000 words, which if they were all assigned would take 15bits, so it is a fairly efficient encoding. However the amount of words can be extended by increasing number of vowels, as well as tones. And it may even be possible to add an initial consonant if only one or two of the quote types is necessary.

However this extension isn’t likely to be necessary anytime in the near future, because adult vocabulary goes up to around 17,000 words, which includes a large number of synonyms. For instance the Lyash core words were generated by combining several different word-lists, which were all meant to be orthogonal, yet it turns out about half were internationally synonyms, so were cut down from around eight thousand to around four thousand words.

It will be possible to flesh out the vocabulary with compound words and more technical words later on. Also it might make sense to supplant or remove some words like proper-names of countries.

Table of Values

Can access it in the project repo here:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s