Scan (SCAN)


Op Code (Hex) Extender Operand 1 Operand 2 Operand 3 Operand [4-5]
SCAN 10D3
Receiver Base Compare operand


SCANB 1CD3 Branch options Receiver Base Compare operand Branch targets


SCANI 18D3 Indicator options Receiver Base Compare operand Indicator targets
Operand 1: Binary variable scalar or binary array.

Operand 2: Character variable scalar.

Operand 3: Character scalar.

Operand 4-5:

Description  The character string value of the base operand is scanned for occurrences of the character string value of the compare operand.

The base and compare operands must both be character strings. The length of the compare operand must not be greater than that of the base string.

The operation begins at the left end of the base string and continues character by character, from left to right, comparing the characters of the base string with those of the compare operand. The length of the comparisons are equal to the length of the compare operand value and function as if they were being compared in the Compare Bytes Left-Adjusted (CMPBLA) instruction.

If a set of bytes that match the compare operand is found, the binary value for the ordinal position of its leftmost base string character is placed in the receiver operand.

If the receiver operand is a scalar, only the first occurrence of the compare operand is noted. If it is an array, as many occurrences as there are elements in the array are noted.

The operation continues until no more occurrences of the compare operand can be noted in the receiver operand or until the number of characters (bytes) remaining to be scanned in the base string is less than the length of the compare operand.

When the second condition occurs, the receiver value is set to 0. If the receiver operand is an array, all its remaining elements are also set to 0.

The base operand and the compare operand can be variable length substring compound operands.

Substring operand references that allow for a null substring reference (a length value of zero) may be specified for operands 2 and 3. The effect of specifying a null substring reference for the compare operand or both operands is that the receiver is set to zero (no match found) and the instruction's resultant condition is null compare operand. Specifying a null substring reference for just the base operand is not allowed due to the requirement that the length of the compare operand must not be greater than that of the base string.

Resultant Conditions 

Authorization Required

Lock Enforcement

Exceptions

06 Addressing

08 Argument/Parameter

0C Computation

10 Damage Encountered

1C Machine-Dependent

20 Machine Support

22 Object Access

24 Pointer Specification

2C Program Execution

2E Resource Control Limit

36 Space Management

44 Protection Violation