Search (SEA)/OP=39

Format

OP AF BF A Syllable B Syllable C Syllable

OP = 35

AF Number of units (digits or characters, depending on the A-address controller) to be compared between the two data fields. A value of 00 is equal to a length of 100 units. AF can be indirect or can indicate the A-syllable is a literal.
BF Number of units (digits or characters, depending on the B-address controller) that the B-address is incremented between comparisons. A value of 00 is equal to a length of 100 units. BF can be indirect.
A Address of the key field. Address can be indexed, indirect, or extended. The final address controller specifies the format for both the A- and B-fields and can be UN, SN or UA.
B Address of the first table entry. Address can be indexed, indirect, or extended. The data type is the same as that specified for the A-field. The final address controller bits determine the incrementation between comparisons. The base indicant of the table entry (B) and table limit (C) addresses must be the same. The processor does not check for improper memory assignments.

B Address Controller Increment in Digits
00 (UN) BF
01 (SN) BF+1
10 (UA) 2 x BF

C Address of table limit. Address can be indexed, indirect, or extended. The final address controller bits specify the type of search performed. The base indicant of the table entry (B) and table limit (C) addresses must be the same. The processor does not check for improper memory assignments.

C Address Controller Search Type
00 (UN) Search for equal
01 (SN) Search for low
10 (UA) Search for lowest

Function

SEA compares the key field (A) with the first table entry (B) in the manner prescribed by the C-address controller variants, then increments the table entry address by the amount specified by BF and the B-address controller. This new location is compared with the key field (A). This operation of compare and increment continues until the searched for condition is found or until the table entry is equal to or greater than the table limit (C), except in the case of search lowest.

Variants

C = 00 (Search For Equal)

The search is terminated when a table entry field equal to the key field is found or when the table limit (C) is reached or exceeded.

If a table entry field equal to the key field (A) is found, then the address of the table entry field is stored, relative to the same base as the B-operand in IX1 with the same base indicant as the resolved B-operand. Otherwise, IX1 remains unchanged (search for equal condition not met).

For SN data, a positive zero does not compare equal to a negative zero.

C = 01 (Search For Low)

The search is terminated when the first table entry field less than the key field (A) is found, or when the table limit is reached or exceeded.

If a table entry field equal to the key field (A) are found, then the address of the table entry field is stored, relative to the same base as the B-operand in IX1 with the same base indicant as the resolved B-operand. Otherwise, IX1 remains unchanged (search for low condition not met).

For SN data, a negative zero compares less than a positive zero.

C = 02 (Search for Lowest)

The search is terminated only when the table entry reaches or exceeds the table limit (C). If any table entry fields are found that are less than the key (A), then the address of the first table entry field, relative to the same base as the B-operand, which is less than or equal to all those less than the key, is stored in IX1 with the same base indicant as the resolved B-operand.

If no table entry fields are found that are less than the key (A), then the base relative address of the key (A) is stored in IX1 with the two most significant digits of IX1 set to C0 (search for lowest condition not met).

For SN data, a negative zero compares less than a positive zero.

Overlap

There are no overlap restrictions for this instruction.

Comparison Flags

When the searched for condition is met, the Comparison Flags are set to EQUAL; otherwise, the comparison flags are set to HIGH.

Overflow Flag

The Overflow Flag is reset by this instruction.

Notes

In each type of search, if the table entry field being compared to the key (A) overlaps with the table limit, incompatible results might be produced (see Compatibility Notes).

Examples

Example (1) Search Equal

OP AF BF A Syllable B Syllable C Syllable
39 01 02 A field UA 1000 UA 1020 UN
                    BEFORE                   AFTER
  A FIELD              C1                  unchanged
  B FIELD          C1F1C2F2C3F3C4F2C5F1    unchanged
  IX1              nnnnnnn                   +1000
  COMPARISON          nn                     EQUAL
  OVERFLOW            nn                      OFF

Example (2) Search Low, Condition not Found

OP AF BF A Syllable B Syllable C Syllable
39 01 01 A field UN 1000 UN 1010 SN
                    BEFORE                   AFTER
  A FIELD              2                   unchanged
  B FIELD          3459876345              unchanged
  IX1              nnnnnnn                 unchanged
  COMPARISON          nn                     HIGH
  OVERFLOW            nn                      OFF

Example (3) Search Lowest

OP AF BF A Syllable B Syllable C Syllable
39 01 01 A field UA 1000 UA 1020 UN
                    BEFORE                   AFTER
  A FIELD              C5                  unchanged
  B FIELD          C5C2C3C4C9C3C1E2C3C9    unchanged
  IX1              nnnnnnn                   +1012
  COMPARISON          nn                     EQUAL
  OVERFLOW            nn                      OFF
instructions/sea.txt · Last modified: 2011/07/20 12:42 by scott
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki