As often happens, once you figure out how to do something for one application it suggests another application. Along the way there turned out to be a way to simplify the FINDASCB loop:
FINDASCB ICM 4,B'1111',0(2) LOAD POSSIBLE ASCB ADDRESS
BNP NEXTASCB BR IF NO ASCB ADDRESS
The ICM instruction sets the condition code. Most of the time we are just interested in zero or not zero, but it also notices the high order bit.
The original code was
FINDASCB TM 0(2),ASVTAVAL
BO NEXTASCB
L 4,0(,2)
N 4,=A(X'7FFFFFFF')
BZ NEXTASCB
ASVTAVAL is X'80'. so the TM instruction is testing if the high order bit is on. N 4,=A(X'7FFFFFFF') is testing if the remainder of the word is binary 0s.
The ICM instruction sets 3 possible condition codes.
- B'00' - All inserted bits are 0 (or the mask is B'0000', which is clearly not the case here)
- B'01' - The leftmost inserted bit is 1 (the remaining bits can be anything)
- B'10' - The left most inserted bit is 0, and at least one other inserted bit is 1
The condition mask in the BNP instruction is X'D', B'1101'
- B'1000' - Branch if the condition code is B'00'
- B'0100' - Branch if the condition code is B'01'
- B'0001' - Branch if the condition code is B'11'
By using the condition code from the ICM instruction intelligently we can collapse 5 instructions to 2, and avoid 2 storage references: the storage reference for the L instruction (the storage reference in the ICM instruction combined the storage references of the TM instrution and the L instruction) and the storage reference in the N instruction. ICM may be slower than the L instruction, though since we eliminated other instructions, that really doe not matter.
Though it really does not matter for our application, there are some applications where every instruction and (often more important) every storage reference matters.