On 4/29/2013 1:56 PM, Ed Jaffe wrote:
My ROT has always been to prefer linear search for single-digit
quantities and prefer binary or hash algorithms for ten or more.

A long time ago I implemented Knuth's balanced tree algorithm (AoP Vol. 3, sect 6.2) as a generalized subroutine, and routinely use it where appropriate. For small values (single digits), a TRT is faster (on all machines I tested on) than five CLI/BE levels.

All of which ignored the questionable design of the OP. The caller could pass a code for the operation (e.g., F1 for AND, F2 for OR, or similar, reducing the selection to a bounds check and index/offset calculation to point to the desired instruction); the bit mask could be constructed in a simple loop with SLDL/SLL or SRDL/SRL, followed by an execute; and the CC from the PSW via IPM/mask/shift. I would also use an otherwise invalid code for bad parameters.

Gerhard Postpischil
Bradford, Vermont

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to