On 5 January 2018 at 16:11, Grinsell, Don <[email protected]> wrote:
> Has anybody played with the SRST instruction?

Yes - I use it all the time.

> I am confused by the examples in the PoP.  Why do they branch back to the 
> SRST instruction when the string is found, e.g. BC 1,LOOP1?  Shouldn't the
> branch be to the FOUND label, e.g. BC 1,FOUND?
>
>       L 5,STRAADR
>       L 4,STRALEN
>       AR 4,5
>       LA 0,X'C1'
> LOOP1 SRST 4,5
>       BC 1,LOOP1
>       BC 2,NOTFND
> FOUND [Any instruction]
> ...
> NOTFND [Any instruction]
>
> --

Keep in mind that the number on the BC is not the expected value of
the condition code. BC 1 means branch if the CC is 3. SRST sets CC 3
if the CPU decides to stop the instruction before it's completed the
search. BC 2 *does* mean branch if CC=2, but that's just the way the
mask maps to the CC values. If you want to branch on character found
(CC=1), you'd use BC 4. In this code that's the fall-through.

Tony H.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to