LT4335 strings.
Version of 8 July 2011.
Home.

By a string is meant a sequence of bits, not the character string directly supported in many environments. Rather, on this machine the character string is a higher-order abstraction that the programmer might choose to implement; the same goes for the character itself. Consequently, the LT4335 does not have a native character set.

The string type is the best choice when the programmer wants to manipulate raw bits, because many instructions for the integer and float types perform formatting automatically.

The bits in a register are numbered 0…255; if only a portion of them are needed, the higher-numbered bits are omitted.

In the instruction descriptions:

Interpretation of b9
if…then… if…then…
b0b8 = 09 see details at instruction description b5b8 = 1000b0b4 is the 5-bit string to use
b0b8 = 108 the string to use will be of zero size b6b8 = 100b0b5 is the 6-bit string to use
b1b8 = 107 b0 is the 1-bit string to use b7b8 = 10b0b6 is the 7-bit string to use
b2b8 = 106 b0b1 is the 2-bit string to use b8 = 1 b0b7 is the 8-bit string to use
b3b8 = 105 b0b2 is the 3-bit string to use bnb8 = 108−n b0bn−1 is the n-bit string to use
b4b8 = 104 b0b3 is the 4-bit string to use  

Interpretation of b12
if…then… if…then…
b0b11 = 012 see details at instruction description b6b11 = 105 b0b5 is the 6-bit string to use
b0b11 = 1011 the string to use will be of zero size b7b11 = 104 b0b6 is the 7-bit string to use
b1b11 = 1010 b0 is the 1-bit string to use b8b11 = 1000 b0b7 is the 8-bit string to use
b2b11 = 109 b0b1 is the 2-bit string to use b9b11 = 100 b0b8 is the 9-bit string to use
b3b11 = 108 b0b2 is the 3-bit string to use b10b11 = 10 b0b9 is the 10-bit string to use
b4b11 = 107 b0b3 is the 4-bit string to use b11 = 1 b0b10 is the 11-bit string to use
b5b11 = 106 b0b4 is the 5-bit string to use bnb11 = 1011−n b0bn−1 is the n-bit string to use

Sometimes the size of a string is represented by a signed integer; an exception will be thrown in response to a requested string size greater than 255, less than 0, or null.

Many of the get, put, and get-and-put instructions involve an offset. This number, when added to the address of the next physical instruction (which equals the address of the current instruction plus 17), gives the address in genspace whence to read data, or whither to write it.


Get. (see also integer and float) The first instruction (SG_E) pushes an embedded string of as many as eleven bits; the others push strings found in genspace.

SG_Estring get, value embeddedb12_10_001  
Pulled: none

Pushed:
• #0 string: data retrieved

b12 is the string to be retrived. An exception is thrown if b12 = 012.

SG_AEstring get, absolute address, size embeddedu8_000_10_1101 SG_ARstring get, absolute address, all operands in registers08_000_10_1101
Pulled:
• #0 signed integer: the address to read in genspace

Pushed:
• #0 string: data retrieved

u8 is how many bits to read. If zero, SG_AR is performed instead.

Pulled:
• #0 signed integer: the address to read in genspace
• #1 signed integer in 0…255: how many bits to read

Pushed:
• #0 string: data retrieved

SG_AE_Ystring get, absolute address, size embedded, synchronizedu8_100_10_1101 SG_AR_Ystring get, absolute address, all operands in registers, synchronized08_100_10_1101
Same as SG_AE, plus synchronization. If u8 is zero, SG_AR_Y is performed instead. Same as SG_AR, plus synchronization.
SG_ROstring get, relative address, offset embeddeds9_01_10_1101  
Pulled:
• #0 signed integer in 0…255: how many bits to retrieve

Pushed:
• #0 string: data retrieved

s9 is the offset.

SG_RSstring get, relative address, size embeddedu8_010_10_1101 SG_RRstring get, relative address, all operands in registers08_010_10_1101
Pulled:
• #0 signed integer: offset

Pushed:
• #0 string: data retrieved

u8 is how many bits to retrieve. If zero, SG_RR is performed instead.

Pulled:
• #0 signed integer: offset
• #1 signed integer in 0…255: how many bits to retrieve

Pushed:
• #0 string: data retrieved

SG_RO_Ystring get, relative address, offset embedded, synchronizeds9_11_10_1101  
Same as SG_RO, plus synchronization.
SG_RS_Ystring get, relative address, size embedded, synchronizedu8_110_10_1101 SG_RR_Ystring get, relative address, all operands in registers, synchronized08_110_10_1101
Same as SG_RS, plus synchronization. If u8 is zero, SG_RR_Y is performed instead. Same as SG_RR, plus synchronization.


Put. (see also integer and float) These instructions pull a string from the stack and write it into genspace. The number of bits to write is equal to the size of the data, as indicated by a meta-register.

SP_Astring put, absolute address08_000_01_1101  
Pulled:
• #0 signed integer: the address to write in genspace
• #1 string: data to write

Pushed: none

##1old is how many bits to write.

SP_A_Ystring put, absolute address, synchronized08_100_01_1101  
Same as SP_A, plus synchronization.
SP_ROstring put, relative address, offset embeddeds9_01_01_1101 SP_RRstring put, relative address, all operands in registers08_010_01_1101
Pulled:
• #0 string, data to write

Pushed: none

##1old is how many bits to write.

s9 is the offset. If null, SP_RR is performed instead.

Pulled:
• #0 signed integer: offset
• #1 string, data to write

Pushed: none

##1old is how many bits to write.

SP_RO_Ystring put, relative address, offset embedded, synchronizeds9_11_01_1101 SP_RR_Ystring put, relative address, all operands in registers, synchronized08_110_01_1101
Same as SP_RO, plus synchronization. If s9 is null, SP_RR_Y is performed instead. Same as SP_RR, plus synchronization.


Get and conditional put. (see also integer and float) The machine compares the string in genspace to the "old value" string. Then:

If the "new value" and "old value" strings are not of the same size, an exception is thrown. Otherwise, their mutual size determines how many bits of genspace to read and possibly write.

SGP_Astring get-and-put, absolute address08_000_11_1101  
Pulled:
• #0 signed integer, the address to examine in genspace
• #1 string: the old value
• #2 string: the new value

Pushed:
• #0 one-bit string: result

SGP_A_Ystring get-and-put, absolute address, synchronized08_100_11_1101  
Same as SGP_A, plus synchronization.
SGP_ROstring get-and-put, relative address, offset embeddeds9_01_11_1101 SGP_RRstring get-and-put, relative address, all operands in registers 08_010_11_1101
Pulled:
• #0 string: the old value
• #1 string: the new value

Pushed:
• #0 one-bit string: result

s9 is the offset. If null, SG_PRR is performed instead.

Pulled:
• #0 signed integer: offset
• #1 string: the old value
• #2 string: the new value

Pushed:
• #0 one-bit string: result

SGP_RO_Ystring get-and-put, relative address, offset embedded, synchronizeds9_11_11_1101 SGP_RR_Ystring get-and-put, relative address, all operands in registers, synchronized08_110_11_1101
Same as SGP_RO, plus synchronization. If s9 is null, SGP_RR_Y is performed instead. Same as SGP_RR, plus synchronization.


Versus. (see also integer and float) Two strings may be compared with each other. Lexicographic order is used, meaning that the strings are searched, starting at address 0 and moving toward higher addresses, until a difference is found. A bit value of 1 is deemed greater than a bit value of zero. If one string ends before a difference is found, the longer string is deemed greater than the shorter. The result of comparison is a string at #0, which contains 6 bits. Its contents are:

Address of bit within #0new With SV_R, this bit equals 1 when … Comments
0#0old > #1oldnever the same analogous to integer and float
1#0old ≤ #1old
2#0old ≠ #1oldnever the same
3#0old = #1old
4#0old < #1oldnever the same
5#0old ≥ #1old

The result of a one-register comparison (SV_E) is the same as that of the two-register version (SV_R), except that the string embedded within the opcode is substituted for #1.

SV_Estring versus, one operand embeddedb9_1111_0101 SV_Rstring versus, both comparands in registers09_1111_0101
Pulled:
• #0 string: comparand

Pushed:
• #0 6-bit string: the result

If b9 = 09, SV_R is performed instead.

Pulled:
• #0 string: comparand
• #1 string: comparand

Pushed:
• #0 6-bit string: the result


Manufacture. These instructions push a string created from scratch.

SM_E0string manufacture, size embedded, fill with zeroesu8_00000_0101 SM_R0string manufacture, all operands in registers, fill with zeroes08_00000_0101
Pulled: none

Pushed:
• #0 string: full of zeroes

u8 is the size of #0new. If zero, SM_R0 is performed instead.

Pulled:
• #0 signed integer in 0…255: size of #0new

Pushed:
• #0 string: full of zeroes

SM_E1string manufacture, size embedded, fill with onesu8_10000_0101 SM_R1string manufacture, all operands in registers, fill with ones08_10000_0101
Pulled: none

Pushed:
• #0 string: full of ones

u8 is the size of #0new. If zero, SM_R1 is performed instead.

Pulled:
• #0 signed integer in 0…255: size of #0new

Pushed:
• #0 string: full of ones

SM_Zstring manufacture, size zero0111_01_001  
Pulled: none

Pushed:
• #0 string: size zero

This is a renaming of the integer instruction IG_E with a null value embedded, which will trim to zero bits.


Resize. The following operations resize a string. If the string is made larger, zeroes or ones are added on the right. If the string is made smaller, bits toward the right are truncated. Either way, bits with lower addresses are unchanged. If a string is being made smaller, SR_E0 and SR_E1 have the same effect, as do SR_R0 and SR_R1.

SR_E0string resize, new size embedded, fill with zeroesu8_01000_0101 SR_R0string resize, all operands in registers, fill with zeroes08_01000_0101
Pulled:
• #0 string: in the old size

Pushed:
• #0 string: in the new size

u8 is the size of #0new. If zero, SR_R0 is performed instead.

Pulled:
• #0 string: in the old size
• #1 signed integer in 0…255: size of #0new

Pushed:
• #0 string: in the new size

SR_E1string resize, new size embedded, fill with ones u8_11000_0101 SR_R1string resize, all operands in registers, fill with ones 08_11000_0101
Pulled:
• #0 string: in the old size

Pushed:
• #0 string: in the new size

u8 is the size of #0new. If zero, SR_R1 is performed instead.

Pulled:
• #0 string: in the old size
• #1 signed integer in 0…255: size of #0new

Pushed:
• #0 string: in the new size

To resize a string to zero, delete the top item of the stack, and then perform SM_Z.


Circulate. Strings may be shifted within a register. If D the distance of shift, and A the old address of a bit, then the value of A is moved to address A + D if this sum would be both less than the size of the string, and greater than −1. Otherwise the bit is discarded. Bits that do not otherwise receive a value are set to 0 or 1 according to the instruction. Any nontrivial shift loses information, and if the magnitude of D exceeds the size of the string, all information is lost.

Strings may also be rotated. Let S be the size of the string (in other words ##0old), D the distance of rotation, and A the old address of a bit. Then that bit's new address is (A + D) mod S. The effect is that, if one rotation is performed with distance D, and then another rotation with distance −D, the original string is produced; a rotation never loses information. If S = 0, an exception is thrown.

The final instruction simply reverses the sequence of bits.

SC_SE0string circulate shift, distance embedded, fill with zeroess9_1011_0101 SC_SR0string circulate shift, distance in register, fill with zeroes081_1011_0101
Pulled:
• #0 string: before shift

Pushed:
• #0 string: after shift

The first 9 bits of the opcode are the distance of shift, a signed integer. If s9 is null, SC_SR0 is performed instead.

Pulled:
• #0 string: before shift
• #1 signed integer: distance to shift (need not be in −255…+255, but a null throws an exception)

Pushed:
• #0 string: after shift

SC_SE1string circulate shift, distance embedded, fill with ones s9_0011_0101 SC_SR1string circulate shift, distance in register, fill with ones081_0011_0101
Pulled:
• #0 string: before shift

Pushed:
• #0 string: after shift

The first 9 bits of the opcode are the distance of shift, a signed integer. If s9 is null, SC_SR1 is performed instead..

Pulled:
• #0 string: before shift
• #1 signed integer: distance to shift (need not be in −255…+255, but a null throws an exception)

Pushed:
• #0 string: after shift

SC_REstring circulate rotate, distance embeddeds9_0111_0101 SC_RRstring circulate rotate, distance in register081_0111_0101
Pulled:
• #0 string: before rotation

Pushed:
• #0 string: after rotation

The first 9 bits of the opcode are the distance of rotation, a signed integer. If s9 is null, SC_RR is performed instead.

Pulled:
• #0 string: before rotation
• #1 signed integer: distance to rotate (need not be in −255…+255, but a null throws an exception)

Pushed:
• #0 string: after rotation

SC_Bstring circulate backwards?_11_000_10_0101  
Pulled:
• #0 string: operand

Pushed:
• #0 string: result

No instruction of the circulate family changes the size of a string.


Overwrite. These instructions replace a contiguous segment of the superstring with some substring. A part of the old value of the superstring is lost. An exception is thrown if the substring will not fit into the superstring at the location requested.

SO_Lstring overwrite, location embeddedu8_100_10_0101  
Pulled:
• #0 string: superstring
• #1 string: substring

Pushed:
• #0 result string

u8 is the address within the superstring to start writing the zeroes.

SO_Sstring overwrite, substring embeddedb9_1001_0101 SO_Rstring overwrite, all operands in registers09_1001_0101
Pulled:
• #0 string: superstring
• #1 signed integer in −255…+255: n (throws exception if out of range)

Pushed:
• #0 result string

b9 is string to be retrived, as in the table for SG_E. If b9 = 09, SO_R is performed instead.

Pulled:
• #0 string: superstring
• #1 string: substring
• #2 signed integer in −255…+255: n (throws exception if out of range)

Pushed:
• #0 result string

#2 is the location at which the substring begins to be written.

SO_0Lstring overwrite with zeroes, location embeddedu8_001_10_0101  
Pulled:
• #0 string: superstring
• #1 signed integer in 0…255: how many zeroes to write

Pushed:
• #0 result string

u8 is the address within the superstring to start writing the zeroes.

SO_0Qstring overwrite with zeroes, quantity to write embeddedu8_101_10_0101 SO_0Rstring overwrite with zeroes, all operands in registers08_101_10_0101
Pulled:
• #0 string: superstring
• #1 signed integer in 0…255: starting location

Pushed:
• #0 result string

u8 is how many zeroes to write. If zero, SO_0R is performed instead.

Pulled:
• #0 string: superstring
• #1 signed integer in 0…255: starting location
• #2 signed integer in 0…255: how many zeroes to write

Pushed:
• #0 result string

SO_1Lstring overwrite with ones, location embeddedu8_011_10_0101  
Pulled:
• #0 string: superstring
• #1 signed integer in 0…255: how many ones to write

Pushed:
• #0 result string

u8 is the address within the superstring to start writing the ones.

SO_1Qstring overwrite with ones, quantity to write embeddedu8_111_10_0101 SO_1Rstring overwrite with ones, all operands in registers08_111_10_0101
Pulled:
• #0 string: superstring
• #1 signed integer in 0…255: starting location

Pushed:
• #0 result string

u8 is how many ones to write. If zero, SO_1R is performed instead.

Pulled:
• #0 string: superstring
• #1 signed integer in 0…255: starting location
• #2 signed integer in 0…255: how many ones to write

Pushed:
• #0 result string


Extract. A substring may be extracted from a superstring. An exception is thrown if any bit requested has an address less than zero, or not less than the size of the superstring.

SE_Astring extract, starting address embeddedu8_010_10_0101  
Pulled:
• #0 string: superstring
• #1 signed integer: how many bits to extract

Pushed:
• #0 string: substring

u8 is the starting address.

SE_Sstring extract, size embeddedu8_110_10_0101 SE_Rstring extract, all operands in registers08_110_10_0101
Pulled:
• #0 string: superstring
• #1 signed integer: starting address

Pushed:
• #0 string: substring

u8 is how many bits to extract. If zero, SE_R is performed instead,

Pulled:
• #0 string: superstring
• #1 signed integer: starting address
• #2 signed integer: how many bits to extract

Pushed:
• #0 string: substring

An exception is thrown if any bit of the extract would be before the first bit of #1old, or after the first bit of #1old.


Find. The first eight instructions search a superstring to find an instance of a substring. If the substring is longer than the superstring, it cannot be found, but that is no cause to throw an exception. The final two instructions tell how many times the substring appears, but not where it is.

string find, location of ith instance of substring, starting at bit b
SF_IR… and proceeding to the right, i embeddedu8_11100_0101 SF_BR… and proceeding to the right, b embeddedu8_01100_0101
Pulled:
• #0 string: superstring
• #1 string: substring
• #2 signed integer: b

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

Pulled:
• #0 string: superstring
• #1 string: substring
• #2 signed integer: i

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

SF_BR… and proceeding to the right, substring embeddedb9_1101_0101 SF_RR… and proceeding to the right, all operands in registers09_1101_0101
Pulled:
• #0 string: superstring
• #1 signed integer: i
• #2 signed integer: b

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

If b9 = 09, SF_RR is performed instead.

Pulled:
• #0 string: superstring
• #1 string: substring
• #2 signed integer: i
• #3 signed integer: b

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

SF_IL… and proceeding to the left, i embeddedu8_10100_0101 SF_BL… and proceeding to the left, b embeddedu8_00100_0101
Pulled:
• #0 string: superstring
• #1 string: substring
• #2 signed integer: b

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

Pulled:
• #0 string: superstring
• #1 string: substring
• #2 signed integer: i

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

SF_BL… and proceeding to the left, substring embeddedb9_0101_0101 SF_RL… and proceeding to the left, all operands in registers09_0101_0101
Pulled:
• #0 string: superstring
• #1 signed integer: i
• #2 signed integer: b

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

If b9 = 09, SF_RL is performed instead.

Pulled:
• #0 string: superstring
• #1 string: substring
• #2 signed integer: i
• #3 signed integer: b

Pushed:
• #0 signed integer: address of instance of #1old, or null if not found

SF_QEstring find, quantity of instances of substring, substring embeddedb9_0001_0101 SF_QRstring find, quantity of instances of substring, substring in register09_0001_0101
Pulled:
• #0 string: superstring

Pushed:
• #0 signed integer: how many times b9 appears within #0old.

b9 is the substring to seek, unless b9 = 09, in which case SF_QR is performed instead. If b9 = 108, then #0new = 1 + ##0old.

Pulled:
• #0 string: superstring
• #1 string: substring

Pushed:
• #0 signed integer: how many times #1old appears within #0old.

If ##1old = 0, then #0new = 1 + ##0old.


Join. Catenation is simple:

SJstring join?_01_000_10_0101
Pulled:
• #0 string: going to lower-order bits
• #1 string: going to higher-order bits

Pushed:
• #0 combined string


Boolean. The first instruction changes every bit of the string:

SB_Nstring boolean not?_10_000_10_0101
Pulled:
• #0 string: the operand

Pushed:
• #0 string: the result

The next instruction preforms the usual boolean operations bit-by-bit on two strings, if they are the same size. If not the same, an exception is thrown.

SB_Ostring boolean, operation embeddedb4_?_00_000_10_0101
Pulled:
• #0 string: an operand
• #1 string: an operand

Pushed:
• #0 string: the result

The four operation bits within the opcode are interpreted thus:

Bit patternValue is 1 when …   Bit patternValue is 1 when …
0000never 1111always
0001#0 = 1 and #1 = 11110#0 = 0 or #1 = 0
0010#0 = 1 and #1 = 01101#0 = 0 or #1 = 1
0011#0 = 1 1100#0 = 0
0100#0 = 0 and #1 = 11011#0 = 1 or #1 = 0
0101#1 = 1 1010#1 = 0
0110#0 ≠ #1 1001#0 = #1
0111#0 = 1 or #1 = 11000#0 = 0 and #1 = 0