Anubha Agarwal wrote and asked for a video covering Search String (SRST). I don’t have a video quite yet, but here are my notes on this instruction. It’s an interesting one that can be used to search for the first occurrence of a single character in a given area of storage. It was probably added to the instruction set to help compiler writers who needed to search for C strings which are terminated with X’00’.
The interesting feature of the instruction is that it can be interrupted by the CPU for efficiency reasons when searching large areas of storage. The programmer can then decide whether to continue searching or not.
I stumbled over the examples given in the Principles of Operation, until I realized the code is flawed. A BC 1,LOOP instruction should be BC 3,LOOP, so pay close attention to those two examples.
Now that I’ve written down my thoughts, I’ll put together a video soon and provide some program examples you can experiment with. This instruction is definitely worth a look.
The comments on your second set of samples is incorrect, the first time you do search for xâFFâ, but the second time you are searching for xâ00â, while the comments still say xâFFâ, probably a cut/paste error.
SR R0,R0 SEARCH FOR Xâ00â
LA R5,SRCHAREA R5 POINTS AT THE SEARCH AREA
LOOP SRST R0,R5 SEARCH FOR Xâ00â,STOP AT BYTE 0
BO LOOP CONTINUE IF SEARCH INTERRUPTED
BH NOTFND CC = 2 â BYTE NOT FOUND
… XâFFâ WAS FOUND, R7 HAS THE ADDRESS
NOTFND EQU * XâFFâ WAS NOT FOUND
Brian
________________________________________________
Brian Westerman, PhD | Sr. Technical Specialist and Director of Research and Development | Syzygy Incorporated PO Box 119 | Pismo Beach, CA 93448 |â 800.767.2244 |ð 800.366.4082 |â Email Brian_Westerman@SyzygyInc.com
Thanks for taking the time to point that out. I have corrected the error.
I think BC 1, Loop is correct to check condition code 3.
Mohammad, Can you give me a little more information? Which code are you referring to?