Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 23
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
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm
No new posts Need a help how to replace a string i... gurunath82 CLIST & REXX 12 Tue Jul 26, 2016 11:43 pm

Back to Top
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us