LT4335 integer instructions.
Version of 12 July 2011.
Home.

In the instruction descriptions:

Sometimes the size of a integer is itself represented by a signed integer; an exception will be thrown in response to a requested integer 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. A null offset throws an exception.


Get. (see also float and string) All the integer get instructions trim the result as it is placed into a register. If an untrimmed integer is preferred, the programmer should use a string get instruction.

The first instruction listed, IG_E, pushes a signed integer embedded within its opcode, while the others push a signed integer found in genspace.

IG_Einteger get, value embeddeds12_01_001  
Pulled: none

Pushed:
• #0 signed integer: data retrieved

s12 is the signed integer to be retrived.

IG_AEinteger get, absolute address, size embeddedu8_000_10_1011 IG_ARinteger get, absolute address, all operands in registers08_000_10_1011
Pulled:
• #0 signed integer: address to read in genspace

Pushed:
• #0 signed integer: data retrieved

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

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

Pushed:
• #0 signed integer: data retrieved

IG_AE_Yinteger get, absolute address, size embedded, synchronizedu8_100_10_1011 IG_AR_Yinteger get, absolute address, all operands in registers, synchronized08_100_10_1011
Same as IG_AE, plus synchronization. If u8 is zero, IG_AR_Y is performed instead. Same as IG_AR, plus synchronization.
IG_ROinteger get, relative address, offset embeddeds9_01_10_1011  
Pulled:
• #0 signed integer 0…255: how many bits to retrieve

Pushed:
• #0 signed integer: data retrieved

s9 is the offset.

IG_RSinteger get, relative address, size embeddedu8_010_10_1011 IG_RRinteger get, relative address, all operands in registers08_010_10_1011
Pulled:
• #0 signed integer: offset

Pushed:
• #0 signed integer: data retrieved

If u8 is zero, IG_RR is performed instead.

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

Pushed:
• #0 the signed integer: data retrieved

IG_RO_Yinteger get, relative address, offset embedded, synchronizeds9_11_10_1011  
Same as IG_RO, plus synchronization.
IG_RS_Yinteger get, relative address, size embedded, synchronizedu8_110_10_1011 IG_RR_Yinteger get, relative address, all operands in registers, synchronized08_110_10_1011
Same as IG_RS, plus synchronization. If u8 is zero, IG_RR_Y is performed instead. Same as IG_RR, plus synchronization.


Put. (see also float and string) These instructions pull an integer from the stack and write it into genspace. They attempt to convert the integer from the size it assumed in the register to the size requested for genspace, which is likely different from the trimmed size. If the integer will not fit into the requested size, a null is written instead.

IP_AEinteger put, absolute address, size embeddedu8_000_01_1011 IP_ARinteger put, absolute address, all operands in registers08_000_01_1011
Pulled:
• #0 signed integer, the address to write in genspace
• #1 signed integer, data to write

Pushed: none

u8 is how many bits to write. If zero, IP_AR is performed instead.

Pulled:
• #0 signed integer: address to write in genspace
• #1 signed integer in 0…255: how many bits to write
• #2 signed integer: data to write

Pushed: none

IP_AE_Yinteger put, absolute address, size embedded, synchronizedu8_100_01_1011 IP_AR_Yinteger put, absolute address, all operands in registers, synchronized08_100_01_1011
Same as IP_AE, plus synchronization. If u8 is zero, IP_AR_Y is performed instead. Same as IP_AR, plus synchronization.
IP_ROinteger put, relative address, offset embeddeds9_01_01_1011  
Pulled:
• #0 signed integer 0…255: how many bits to write
• #1 signed integer: data to write

Pushed: none

s9 is the offset.

IP_RSinteger put, relative address, size embeddedu8_010_01_1011 IP_RRinteger put, relative address, all operands in registers08_010_01_1011
Pulled:
• #0 signed integer: offset
• #1 signed integer: data to write

Pushed: none

u8 is how many bits to write. If zero, IP_RR is performed instead.

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

Pushed: none

IP_RO_Yinteger put, relative address, offset embedded, synchronizeds9_11_01_1011  
Same as IP_RO, plus synchronization. .
IP_RS_Yinteger put, relative address, size embedded, synchronizedu8_110_01_1011 IP_RR_Yinteger put, relative address, all operands in registers, synchronized08_110_01_1011
Same as IP_RE, plus synchronization. If u8 is zero, IP_RR_Y is performed instead. Same as IP_RR, plus synchronization.


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

To test as equal, it is not necessary that the two integers have been trimmed to the same number of bits. For instance, the 6-bit integer 100_110 equals the 9-bit integer 100_110_000. (If an exact match of bit patterns is desired, the string version of get-and-put should be used.) If the "new value" integer is of such large magnitude that it will not fit into the indicated region of genspace, a null will be written instead.

IGP_AEinteger get-and-put, absolute address, size embeddedu8_000_11_1011 IGP_ARinteger get-and-put, absolute address, all operands in registers08_000_11_1011
Pulled:
• #0 signed integer: the address to examine in genspace
• #1 signed integer: the old value
• #2 signed integer: the new value

Pushed:
• #0 one-bit string: result

u8 is how many bits of genspace to examine. If zero, IGP_AR is performed instead.

Pulled:
• #0 signed integer: address to examine in genspace
• #1 signed integer in 0…255: how many bits of genspace to examine
• #2 signed integer: the old value
• #3 signed integer: the new value

Pushed:
• #0 one-bit string: result

IGP_AE_Yinteger get-and-put, absolute address, size embedded, synchronizedu8_100_11_1011 IGP_AR_Yinteger get-and-put, absolute address, all operands in registers, synchronized08_100_11_1011
Same as IGP_AE, plus synchronization. If u8 is zero, IGP_AR_Y is performed instead. Same as IGP_AR, plus synchronization.
IGP_ROinteger get-and-put, relative address, offset embeddeds9_01_11_1011  
Pulled:
• #0 signed integer 0…255: how many bits of genspace to examine
• #1 signed integer: the old value
• #2 signed integer: the new value

Pushed:
• #0 one-bit string: result

s9 is the offset.

IGP_RSinteger get-and-put, relative address, size embeddedu8_010_11_1011 IGP_RRinteger get-and-put, relative address, all operands in registers08_010_11_1011
Pulled:
• #0 signed integer: offset
• #1 signed integer: the old value
• #2 signed integer: the new value

Pushed:
• #0 one-bit string: result

u8 is how many bits of genspace to examine. If zero, IGP_RR is performed instead.

Pulled:
• #0 signed integer: offset
• #1 signed integer in 0…255: how many bits of genspace to examine
• #2 signed integer: the old value
• #3 signed integer: the new value

Pushed:
• #0 one-bit string: result

IGP_RO_Yinteger get-and-put, relative address, offset embedded, synchronizeds9_11_11_1011  
Same as IGP_RO, plus synchronization.
IGP_RS_Yinteger get-and-put, relative address, size embedded, synchronizedu8_110_11_1011 IGP_RR_Yinteger get-and-put, relative address, all operands in registers, synchronized08_110_11_1011
Same as IGP_RS, plus synchronization. If u8 is zero, IGP_RR_Y is performed instead. Same as IGP_RR, plus synchronization.


Versus. (see also float, string, and branch) Two integers may be compared with each other. The result is a string at #0, which contains 20 bits. Its contents are:

Address of bit within #0new With IV_R, bit equals 1 when … Comments
0#0old and #1old both have values, and #0old > #1old never both 1analogous to float and string
1#0old and #1old both have values, and #0old ≤ #1old
2#0old and #1old both have values, and #0old ≠ #1old never both 1
3#0old and #1old both have values, and #0old = #1old
4#0old and #1old both have values, and #0old < #1old never both 1
5#0old and #1old both have values, and #0old ≥ #1old
6#0old is null never the sameanalogous to float
7#0old has a value
8#1old is null never the same
9#1old has a value
10#0old and #1old are similar never the same
11#0old and #1old are dissimilar
12#0old has a value, and #1old is null never the same
13#0old is null, or #1old has a value
14#0old is null, and #1old has a value never the same
15#0old has a value, or #1old is null
16#0old has a value, and #1old has a value never the same
17#0old is null, or #1old is null
18#0old is null, and #1old is null never the same
19#0old has a value, or #1old has a value

The result of a one-register comparison (IV_E) is the same as that of the two-register version (IV_R), except that the signed integer embedded within the opcode is substituted for #1.

IV_Einteger versus, one comparand embeddeds9_1111_0011 IV_Rinteger versus, both comparands in registers081_1111_0011
Pulled:
• #0 signed integer, a comparand

Pushed:
• #0 20-bit string, the result

If s9 is null, IV_R is performed instead.

Pulled:
• #0 signed integer: comparand
• #1 signed integer: comparand

Pushed:
• #0 20-bit string: result

Note that integer comparison is not trichotomous, but is better described by a tetrachotomy. For any two integers m and n:

This fact greatly influences the writing of code. However, the existence of nulls encourages the programmer to consider error conditions that might otherwise be overlooked.

Arithmetic. (see also float) Addition, subtraction and multiplication are nonsurprising. A result is null if either input is null, or if there is positive or negative overflow. All results are trimmed.

IA_Einteger add, addend embeddeds9_0000_0011 IA_Rinteger add, addend in register081_0000_0011
Pulled:
• #0 signed integer: augend

Pushed:
• #0 signed integer: augend plus addend

If s9 is null, IA_R is performed instead.

Pulled:
• #0 signed integer: augend
• #1 signed integer: addend

Pushed:
• #0 signed integer: augend plus addend

IM_Einteger multiply, multiplier embeddeds9_1000_0011 IM_Rinteger multiply, multiplier in register081_1000_0011
Pulled:
• #0 signed integer: multiplicand

Pushed:
• #0 signed integer: multiplicand times multiplier

If s9 is null, IM_R is performed instead.

Pulled:
• #0 signed integer: multiplicand
• #1 signed integer: multiplier

Pushed:
• #0 signed integer: multiplicand times multiplier

IS_Sinteger subtract, subtrahend embeddeds9_0100_0011 IS_Rinteger subtract, both operands in register081_0100_0011
Pulled:
• #0 signed integer: minuend

Pushed:
• #0 signed integer: minuend minus subtrahend

If s9 is null, IS_R is performed instead.

Pulled:
• #0 signed integer: minuend
• #1 signed integer: subtrahend

Pushed:
• #0 signed integer: minuend minus subtrahend

IS_Minteger subtract, minuend embeddeds9_1100_0011  
Pulled:
• #0 signed integer: subtrahend

Pushed:
• #0 signed integer: minuend minus subtrahend

To negate the integer in #0, use a minuend of zero.

If s9 is null, IS_R is performed instead.

Integer division requires further comment. It involves two inputs (numerator N and denominator D) and two outputs (quotient Q and remainder R). Elsewhere in mathematics, the numerator is termed the dividend, and the denominator is called the divisor, but here those words are avoided because both begin with the letter d.

Here are the specifications:

Examples (in decimal):

Whatever the signs of N and D, Q is rounded toward negative infinity; no attempt is made to round Q to the nearest integer. Other rounding policies could reasonably have been chosen, as there is no consensus in computer science or mathematics on this matter. In any case, −∞ is simple to remember.

A result is null if either of the inputs is null, or if there is division by zero; in particular, null divided by zero is null. All results are trimmed.

IQ_Dinteger quotient, denominator embeddeds9_0010_0011 IQ_Rinteger quotient, both operands in registers081_0010_0011
Pulled:
• #0 signed integer: numerator

Pushed:
• #0 signed integer: quotient

If s9 is null, IQ_R is performed instead.

Pulled:
• #0 signed integer: numerator
• #1 signed integer: denominator

Pushed:
• #0 signed integer: quotient

IQ_Ninteger quotient, numerator embeddeds9_1010_0011  
Pulled:
• #0 signed integer: denominator

Pushed:
• #0 signed integer: quotient

If s9 is null, IQ_R is performed instead.

IR_Dinteger remainder, denominator embeddeds9_0110_0011 IR_Rinteger remainder, both operands in registers081_0110_0011
Pulled:
• #0 signed integer: numerator

Pushed:
• #0 signed integer: remainder

If s9 is null, IR_R is performed instead.

Pulled:
• #0 signed integer: numerator
• #1 signed integer: denominator

Pushed:
• #0 signed integer: remainder

IR_Ninteger remainder, numerator embeddeds9_1110_0011  
Pulled:
• #0 signed integer: denominator

Pushed:
• #0 signed integer: remainder

If s9 is null, IR_R is performed instead.

IQR_Dinteger quotient and remainder, denominator embeddeds9_0001_0011 IQR_Rinteger quotient and remainder, both operands in registers081_0001_0011
Pulled:
• #0 signed integer: numerator

Pushed:
• #0 signed integer: quotient
• #1 signed integer: remainder

If s9 is null, IQR_R is performed instead.

Pulled:
• #0 signed integer: numerator
• #1 signed integer: denominator

Pushed:
• #0 signed integer: quotient
• #1 signed integer: remainder

IQR_Ninteger quotient and remainder, numerator embeddeds9_1001_0011  
Pulled:
• #0 signed integer: denominator

Pushed:
• #0 signed integer: quotient
• #1 signed integer: remainder

If s9 is null, IQR_R is performed instead.


Format. (see also float) When an integer is stored into a register, it is by default trimmed so as to use the fewest bits. However, the programmer can change it to something different. Requesting a size smaller than the minimum will result in a null, still with the requested number of bits.

IF_TEinteger format trim, size embeddedu8_0101_0011 IF_TRinteger format trim, size in register08_0101_0011
Pulled:
• #0 signed integer: to be resized

Pushed:
• #0 signed integer: in its new size

If u8 is zero, IF_TR is performed instead.

Pulled:
• #0 signed integer: to be resized
• #1 signed integer in 0…255: new size

Pushed:
• #0 signed integer: in its new size

IF_TQinteger format trim, query?_0_1101_0011 IF_TMinteger format trim, minimum?_1_1101_0011
Pulled:
• #0 signed integer: that would be resized

Pushed:
• #0 signed integer: minimum size of #0old

#0new contains the size that #0old would become if it were supplied to IF_TM.

Pulled:
• #0 signed integer: to be resized

Pushed:
• #0 signed integer: in the smallest legal size