Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Assembler routine for COBOL "SEARCHALL" verb

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

New User


Joined: 13 May 2008
Posts: 16
Location: kolkata

PostPosted: Sat Jul 26, 2008 3:31 pm    Post subject: Assembler routine for COBOL "SEARCHALL" verb
Reply with quote

In some of COBOL codes,SEARCH verb was being used for all search purpose.But I have changed them to "SEARCH ALL" to process it faster wherever binary search was going on.
Now i am thinking of changing "SEARCH ALL" verb by an equivalent Assembler routine(for binary search).I think it will make that operation much more faster.I am a novice in Assembler coding.So can anyone of expert in Assembler help me out by provide an assembler routine for replacing those "SEARCH ALL" verbs?
Thanks in advance.
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: Sat Jul 26, 2008 4:11 pm    Post subject:
Reply with quote

Hello,

Do you understand the mechanics of a binary search? If not, learning how a binary search operates internally would be a good thing to do.

Keep in mind that when a binary search is specified, the actual search is done in assembler not cobol.

Also, keep in mind that the SEARCH statement supports condition-names and conditional expressoins that relate to components in the cobol code.

Once you are into the code and there are questons or problems, post what you have and your questions about it and someone here will be able to offer suggestions.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sun Jul 27, 2008 2:45 am    Post subject: Re: Assembler routine for COBOL "SEARCHALL" verb
Reply with quote

avik wrote:
I am a novice in Assembler coding.So can anyone of expert in Assembler help me out by provide an assembler routine for replacing those "SEARCH ALL" verbs?
Thanks in advance.


Considering all the options that are available in SEARCH ALL in COBOL I don't think this would be a good beginner's project. How will you handle different data formats (ie. comparing a PD field with a Binary, or a PIC x(5) with a PIC x(8) etc.)?
Back to top
View user's profile Send private message
avik

New User


Joined: 13 May 2008
Posts: 16
Location: kolkata

PostPosted: Sun Jul 27, 2008 2:15 pm    Post subject:
Reply with quote

Refer to Dick's suggestion,For "SEARCH ALL" option what is the underlying Assembler code? Can you provide me that showing a very small example assuming some dummy conditions? Or is there any website for getting such code help for getting underlying code of "SEARCH ALL".
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: Sun Jul 27, 2008 2:37 pm    Post subject:
Reply with quote

Hello,

If you want to see the assembler for a SEARCH ALL you could look at the assembler generated by the compile of the cobol program containing the SEARCH ALL.

If you want to practice assembler and would like to implement a basic binary search, you may find this helpful:
http://en.wikipedia.org/wiki/Binary_search_algorithm
This routine would do nothing but search an ordered list - it would not replace SEARCH ALL.

As Craig mentioned, trying to write code that would be usable in place of SEARCH ALL is not a beginner task.
Back to top
View user's profile Send private message
avik

New User


Joined: 13 May 2008
Posts: 16
Location: kolkata

PostPosted: Sun Jul 27, 2008 3:05 pm    Post subject:
Reply with quote

Thanks for your valuable suggestions.Actually I want to reduce the CPU execution time for binary search.So previously I have adopted COBOL best practice & converted "SEARCH" to "SEARCH ALL".As our cobol code consists a lots of use of binary search,So I thought of changing it to a Assembler code. icon_rolleyes.gif
But I didn't think it will be so tough.So is it not possible of providing any generic Assembler routine by which I can replace my binary search to reduce my CPU execution time? or is there any other suggestion for improving binary search execution time?
Anyway I will go through the link provided by you & will will try to implement them.
Thanks...
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7997
Location: Bellevue, IA

PostPosted: Sun Jul 27, 2008 7:24 pm    Post subject:
Reply with quote

Quote:
Actually I want to reduce the CPU execution time for binary search.
Have you studied complexity of computer algorithms? Do you know what O(log n) refers to? For example,
Quote:
Implementing Binary Search

Although the algorithm is simple to describe informally, it is tricky to produce a working binary search function. The first published binary search algorithm appeared in 1946, but the first correct published program appeared in 1962!

The difficulty is maintaining the following two invariants with each iteration:

* The key must always remain between the low and high indices.
* The low or high indice must advance each iteration.

The boundary cases are very tricky: zero elements left, one elements left, two elements left, and an even or odd number of elements!


Your best bet is to reduce the number of searches being done. If you can't do that, your next best bet is to live with the current time. Any Assembler routine you create is (a) not likely to be right, and (b) not likely to be any faster than the existing COBOL code.
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: Sun Jul 27, 2008 11:02 pm    Post subject:
Reply with quote

Hello,

Another thing to remember is that we had need of a binary search long before SEARCH and SEARCH ALL were included in the cobol language. When we needed one, we wrote it "long-hand". IIRC it took less than 50 procedure division statements to code a binary search that performed well and worked correctly every time. There were also a handful of working storage variables to "keep track of where you were" and the array itself.

These hand coded binary searches quite out-performed a sequential search. When the SEARCH and SEARCH ALL were made available, they outran any of the "same" hand-coded routines.

Another aid to improving performance of this process (and others) may be found in the following. . .

At several sites i've discovered one "situation" that repeats over and over. The coders had written exactly to the specifications (i.e. when you get to this pont in the process, retrieve some value or verify the existence some "key") and searched as directed. What was not in the specs was that if the current value is the same as the previous value that came thru the code, there is no need to search again.
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 SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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