![]() |
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_E | integer get, value embedded | s12_01_001 | |||
---|---|---|---|---|---|
Pulled: none
Pushed:
s12 is the signed integer to be retrived. | |||||
IG_AE | integer get, absolute address, size embedded | u8_000_10_1011 | IG_AR | integer get, absolute address, all operands in registers | 08_000_10_1011 |
Pulled:
• #0 signed integer: address to read in genspace Pushed:
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:
| ||||
IG_AE_Y | integer get, absolute address, size embedded, synchronized | u8_100_10_1011 | IG_AR_Y | integer get, absolute address, all operands in registers, synchronized | 08_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_RO | integer get, relative address, offset embedded | s9_01_10_1011 | |||
Pulled:
• #0 signed integer 0…255: how many bits to retrieve Pushed:
s9 is the offset. | |||||
IG_RS | integer get, relative address, size embedded | u8_010_10_1011 | IG_RR | integer get, relative address, all operands in registers | 08_010_10_1011 |
Pulled:
• #0 signed integer: offset Pushed:
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:
| ||||
IG_RO_Y | integer get, relative address, offset embedded, synchronized | s9_11_10_1011 | |||
Same as IG_RO, plus synchronization. | |||||
IG_RS_Y | integer get, relative address, size embedded, synchronized | u8_110_10_1011 | IG_RR_Y | integer get, relative address, all operands in registers, synchronized | 08_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_AE | integer put, absolute address, size embedded | u8_000_01_1011 | IP_AR | integer put, absolute address, all operands in registers | 08_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_Y | integer put, absolute address, size embedded, synchronized | u8_100_01_1011 | IP_AR_Y | integer put, absolute address, all operands in registers, synchronized | 08_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_RO | integer put, relative address, offset embedded | s9_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_RS | integer put, relative address, size embedded | u8_010_01_1011 | IP_RR | integer put, relative address, all operands in registers | 08_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_Y | integer put, relative address, offset embedded, synchronized | s9_11_01_1011 | |||
Same as IP_RO, plus synchronization. . | |||||
IP_RS_Y | integer put, relative address, size embedded, synchronized | u8_110_01_1011 | IP_RR_Y | integer put, relative address, all operands in registers, synchronized | 08_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_AE | integer get-and-put, absolute address, size embedded | u8_000_11_1011 | IGP_AR | integer get-and-put, absolute address, all operands in registers | 08_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:
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:
| ||||
IGP_AE_Y | integer get-and-put, absolute address, size embedded, synchronized | u8_100_11_1011 | IGP_AR_Y | integer get-and-put, absolute address, all operands in registers, synchronized | 08_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_RO | integer get-and-put, relative address, offset embedded | s9_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:
s9 is the offset. | |||||
IGP_RS | integer get-and-put, relative address, size embedded | u8_010_11_1011 | IGP_RR | integer get-and-put, relative address, all operands in registers | 08_010_11_1011 |
Pulled:
• #0 signed integer: offset • #1 signed integer: the old value • #2 signed integer: the new value Pushed:
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:
| ||||
IGP_RO_Y | integer get-and-put, relative address, offset embedded, synchronized | s9_11_11_1011 | |||
Same as IGP_RO, plus synchronization. | |||||
IGP_RS_Y | integer get-and-put, relative address, size embedded, synchronized | u8_110_11_1011 | IGP_RR_Y | integer get-and-put, relative address, all operands in registers, synchronized | 08_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 1 | analogous 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 same | analogous 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_E | integer versus, one comparand embedded | s9_1111_0011 | IV_R | integer versus, both comparands in registers | 081_1111_0011 |
---|---|---|---|---|---|
Pulled:
• #0 signed integer, a comparand Pushed:
If s9 is null, IV_R is performed instead. | Pulled:
• #0 signed integer: comparand • #1 signed integer: comparand Pushed:
|
Note that integer comparison is not trichotomous, but is better described by a tetrachotomy. For any two integers m and n:
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_E | integer add, addend embedded | s9_0000_0011 | IA_R | integer add, addend in register | 081_0000_0011 |
---|---|---|---|---|---|
Pulled:
• #0 signed integer: augend Pushed:
If s9 is null, IA_R is performed instead. | Pulled:
• #0 signed integer: augend • #1 signed integer: addend Pushed:
| ||||
IM_E | integer multiply, multiplier embedded | s9_1000_0011 | IM_R | integer multiply, multiplier in register | 081_1000_0011 |
Pulled:
• #0 signed integer: multiplicand Pushed:
If s9 is null, IM_R is performed instead. | Pulled:
• #0 signed integer: multiplicand • #1 signed integer: multiplier Pushed:
| ||||
IS_S | integer subtract, subtrahend embedded | s9_0100_0011 | IS_R | integer subtract, both operands in register | 081_0100_0011 |
Pulled:
• #0 signed integer: minuend Pushed:
If s9 is null, IS_R is performed instead. | Pulled:
• #0 signed integer: minuend • #1 signed integer: subtrahend Pushed:
| ||||
IS_M | integer subtract, minuend embedded | s9_1100_0011 | |||
Pulled:
• #0 signed integer: subtrahend Pushed:
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_D | integer quotient, denominator embedded | s9_0010_0011 | IQ_R | integer quotient, both operands in registers | 081_0010_0011 |
---|---|---|---|---|---|
Pulled:
• #0 signed integer: numerator Pushed:
If s9 is null, IQ_R is performed instead. | Pulled:
• #0 signed integer: numerator • #1 signed integer: denominator Pushed:
| ||||
IQ_N | integer quotient, numerator embedded | s9_1010_0011 | |||
Pulled:
• #0 signed integer: denominator Pushed:
If s9 is null, IQ_R is performed instead. | |||||
IR_D | integer remainder, denominator embedded | s9_0110_0011 | IR_R | integer remainder, both operands in registers | 081_0110_0011 |
Pulled:
• #0 signed integer: numerator Pushed:
If s9 is null, IR_R is performed instead. | Pulled:
• #0 signed integer: numerator • #1 signed integer: denominator Pushed:
| ||||
IR_N | integer remainder, numerator embedded | s9_1110_0011 | |||
Pulled:
• #0 signed integer: denominator Pushed:
If s9 is null, IR_R is performed instead. | |||||
IQR_D | integer quotient and remainder, denominator embedded | s9_0001_0011 | IQR_R | integer quotient and remainder, both operands in registers | 081_0001_0011 |
Pulled:
• #0 signed integer: numerator Pushed:
If s9 is null, IQR_R is performed instead. | Pulled:
• #0 signed integer: numerator • #1 signed integer: denominator Pushed:
| ||||
IQR_N | integer quotient and remainder, numerator embedded | s9_1001_0011 | |||
Pulled:
• #0 signed integer: denominator Pushed:
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_TE | integer format trim, size embedded | u8_0101_0011 | IF_TR | integer format trim, size in register | 08_0101_0011 |
---|---|---|---|---|---|
Pulled:
• #0 signed integer: to be resized Pushed:
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:
| ||||
IF_TQ | integer format trim, query | ?_0_1101_0011 | IF_TM | integer format trim, minimum | ?_1_1101_0011 |
Pulled:
• #0 signed integer: that would be resized Pushed:
#0new contains the size that #0old would become if it were supplied to IF_TM. | Pulled:
• #0 signed integer: to be resized Pushed:
|