Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
String Instrucitons in HLASM

Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message

New User

Joined: 06 Nov 2006
Posts: 25
Location: Montreal

PostPosted: Fri Aug 10, 2007 6:46 am    Post subject: String Instrucitons in HLASM
Reply with quote

Can any one post a sample program using CUSE instruction. (Compare Until Substring Equal).
Back to top
View user's profile Send private message

dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Aug 10, 2007 7:49 am    Post subject:
Reply with quote


See if this is of any use. . . .

The CUSE (COMPARE UNTIL SUBSTRING EQUAL) instruction is given both the address and the length of the two storage locations to be compared. It is also given a pad byte that is logically appended to the shorter of the two storage locations. Finally it is also provided the length of the substring. It will search for equal substrings of specified length at same offsets in both storage locations.

LA R0,3
LA R1,C' '
. . .
. . .
STRING1 DC C'Now is the time for all good men to come to the aid'
STRING2 DC C'Suffragettes protested for women and their right to vote'

The above will find the three letter sequence 'men' in both strings at same offset. R2 will point to 'men' in STRING1 and R4 will point to 'men' in STRING2. Somehow this does not seem like a very common programming need, does it?

There are some IBM APARs that specify code fixes concerning CUSE. These were in compression and database modules so apparently there's an esoteric use for CUSE in those areas. Maybe it's in data dictionaries?

I could see code using CLCL to compare two storage areas. Should the CLCL end on an unequal condition, with register addresses updated to point to differing bytes in each storage area, the code could then pick up from there with a CUSE instruction to find the next matching sequence or substring. This might be an efficient, or at least simple, means to isolate changes in a buffer when compared to previous content. Of course, the specification of substring size would require care.

Let's get a little tricky. What if length of one storage area is given as zero, substring size as 3 and pad byte as asterisk ("*")? This could be a very neat (and quick?) way to pick out '***' strings.

LA R4,?????? does this address even have to be valid since length = 0?
XR R5,R5 length of zero
LA R0,3
LA R1,C'*'
. . .
. . .
STRING DC C'Now is the time ! *** F L A S H *** ! for all good men'

You could quite readily skip through the buffer from one '***' to the next '***' and so on until end of buffer. Maybe you wish to flutter from ellipse ("...") to ellipse? Easy enough.

Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1


Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm
No new posts line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts How to change a string containing the... chong.zhou TSO/ISPF 6 Tue Aug 29, 2017 4:54 pm

Back to Top
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us