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

Assembler routine for COBOL "SEARCHALL" verb


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sat Jul 26, 2008 4:11 pm
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
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
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

Moderator Emeritus


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

PostPosted: Sun Jul 27, 2008 2:37 pm
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:
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
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sun Jul 27, 2008 7:24 pm
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

Moderator Emeritus


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

PostPosted: Sun Jul 27, 2008 11:02 pm
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 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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top