IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

String Instrucitons in HLASM


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ganasrinivasan

New User


Joined: 06 Nov 2006
Posts: 27
Location: Montreal

PostPosted: Fri Aug 10, 2007 6:46 am
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

Moderator Emeritus


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

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

Hello,

See if this is of any use. . . .

Quote:
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 R2,STRING1
LA R3,L'STRING1
LA R4,STRING2
LA R5,L'STRING2
LA R0,3
LA R1,C' '
LOOP CUSE R2,R4
BC 1,LOOP
. . .
. . .
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 R2,STRING
LA R3,L'STRING
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'*'
LOOP CUSE R2,R4
BC 1,LOOP
. . .
. . .
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Search string in job at regular Spool... CLIST & REXX 0
Search our Forums:

Back to Top