Re: signum

2013-10-21 Thread Paul Gilmartin
On 2013-10-21 16:31, John Gilmore wrote: > PL/I was robbed of FIXEDOVERFLOW for binary fixed values. It is still > available for PL/I decimal fixed, i.e., packed decimal values. > > ... > > This a is a pity, a disagreeable consequence of the fact that much > PL/I implementation machinery is now s

Re: signum (was: Linear search vs binary)

2013-10-21 Thread John Gilmore
PL/I was robbed of FIXEDOVERFLOW for binary fixed values. It is still available for PL/I decimal fixed, i.e., packed decimal values. The LE does in fact make a facility available for executing what is in efffect an arbitrary SPM instruction; but it is documented so poorly---It has been all but h

signum (was: Linear search vs binary)

2013-10-21 Thread Paul Gilmartin
On 2013-10-21 11:06, John Gilmore wrote: > > [signum] is available as a BIF called sign in PL/I, where it is [almost > always] > implemented in line. An analogous function is available for strings > in C, where it is implemented as a library subroutine. It has always > been available in FORTRAN

Hardware or Compiler Design? (was: Linear search vs binary)

2013-10-21 Thread Paul Gilmartin
On 2013-10-21 14:35, Gainsford, Allen wrote: >> It is known, was indeed emphasized by Backus, is that he was much >> concerned not to deprive 704 assembly-language programmers of >> facilities they prized. His situation was very different from >> ours today. He wanted to open up programming to ot

Re: Linear search vs binary

2013-10-21 Thread Robert A. Rosenberg
At 06:27 -0700 on 10/21/2013, retired mainframer wrote about Re: Linear search vs binary: If your search target is uniformly distributed against the key, then on average a linear search will require 1750 iterations of your compare loop. A binary search will require a constant 12 iterations regar

Re: Linear search vs binary

2013-10-21 Thread Gainsford, Allen
> It is known, was indeed emphasized by Backus, is that he was much > concerned not to deprive 704 assembly-language programmers of > facilities they prized. His situation was very different from > ours today. He wanted to open up programming to others, but he > crucially needed to convince 704 a

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
John McCarthy, who for a time used CAS---as well as CAR and CADDR, which survived---in LISP, thought that the instruction came first, i.e., that the instruction was the model for the arithmetic-IF statement. It is my guess that he was right, but it may now be too late to resolve this particular ch

Re: Linear search vs binary

2013-10-21 Thread Gerhard Postpischil
On 10/21/2013 1:06 PM, John Gilmore wrote: It has always been available in FORTRAN in the form of the much deprecated but in fact enormously useful arithmetic-IF statement Which brings up the question of whether the trinary compare results (e.g., CAS [C

Re: Linear search vs binary

2013-10-21 Thread Alan Atkinson
ISKEYLN4 is the length of an entire entry - 12 bytes in your case iirc. I did say I may not have edited it as well as I might have. -Original Message- From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@LISTSERV.UGA.EDU] On Behalf Of Dougie Lawson Sent: Monday, October 21, 2013 1:2

Re: Linear search vs binary

2013-10-21 Thread Dougie Lawson
On 21 October 2013 13:34, Alan Atkinson wrote: > > MHRF,ISKEYLN4 > Hi Alan, Thanks for the code sample. I wasn't sure what value that ISKEYLN4 half word should hold. I found a really neat macro as part of IMS (member IMSORT in IMS.SDFSMAC) which means I can easily build a static t

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
The arithmetic function that mathematicians call signum, viz., for an arithmetic expression x signum(x) = -1, a < 0, signum(x) = 0, a = 0, signum(x) = +1, a > 0 is available as a BIF called sign in PL/I, where it is [almost always] implemented in line. An analogous function is available for st

Re: Linear search vs binary

2013-10-21 Thread Paul Gilmartin
> - Original Message - > > From: "Dougie Lawson" > To: ASSEMBLER-LIST@LISTSERV.UGA.EDU > Sent: Monday, October 21, 2013 6:32:15 AM > Subject: Linear search vs binary > > If I have a table of 3,500 entries of twelve bytes (I'm doing a compare of > eight bytes to find the entry I'm looking f

Re: Linear search vs binary

2013-10-21 Thread DASDBILL2
It is not worth the pain of changing it if this code is only executed once a day.  It is absolutely essential to change it if this code is executed one thousand times per second, in disabled code, some other process is waiting for this code to finish, you hold a lock, etc., etc. etc. In other w

Re: missing functionality in TRTE

2013-10-21 Thread Ed Jaffe
On 10/21/2013 1:11 AM, Martin Trübner wrote: Be very very carefull. My POP say about MVST: The CPU-determined number is at least one. Good catch! Never ASS-U-ME anything! :-) -- Edward E Jaffe Phoenix Software International, Inc 831 Parkview Drive North El Segundo, CA 90245 http://www.phoenixs

Re: Linear search vs binary

2013-10-21 Thread Paul Gilmartin
On 2013-10-21, at 07:13, John Gilmore wrote: > Perhaps also worth noting explicitly is that the linear-search scheme > done well is not significantly less complex than the binary-search > one. > You've earlier advocated the value of comparison operands having a ternary result. Of course this is a

Re: Linear search vs binary

2013-10-21 Thread retired mainframer
Obviously your data must be sorted for the question to be relevant. Is it already sorted or is the cost of sorting it part of the difference? If your search target is uniformly distributed against the key, then on average a linear search will require 1750 iterations of your compare loop. A binary

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
Perhaps also worth noting explicitly is that the linear-search scheme done well is not significantly less complex than the binary-search one. John Gilmore, Ashland, MA 01721 - USA

Re: Linear search vs binary

2013-10-21 Thread John Gilmore
For match-seeking binary search Knuth's classical figure of merit for an ordered table of n elements is M(n) = 2[(n + 1)q + 2e] – n in which q = floor[log2(n + 1)] and e = n - (2**q - 1). Here q = 11, e = 3500 - 2047 = 1453, and thus M(3500) = 2[3501 x 11 + 2 x 1453] - 3500 = 78324 For linear

Re: Linear search vs binary

2013-10-21 Thread Alan Atkinson
Bad edit - sorry. SQSRCH L RF,=A(YOUR TABLE) L R1,=A(YOUR TABLE) AR1,=a(l'table) AHIR1,l'entry R1 = A(LAST ENTRY) Should be SQSRCH L RF,=A(YOUR TABLE) L R1,=A(YOUR TABLE) AR1,=a(l'table) AHIR1,-l'en

Re: Linear search vs binary

2013-10-21 Thread Paul Raulerson
Guys- doesn't that depend - a lot - on how often the code is actually executed? A couple billion times a day makes it a no-brainer to do a binary search, a couple thousand times per day, perhaps just the opposite. Paul Typos courtesy of my iPhone and my fat fingers! > On Oct 21, 2013, at 7:38

Re: Linear search vs binary

2013-10-21 Thread Alan Atkinson
Leaving aside hashing and suchlike, we've used this for a while in multiple places. It's a ripoff of the C binsrch algorithm in the Tenenbaum data structures book, so there's nothing ~that~ proprietary about it. I edited it to take out our specific stuff, so check carefully as I may have missed

Re: Linear search vs binary

2013-10-21 Thread Martin Truebner
As Rob has already said- YES it is worth it I say that too- worth it- here is my point. assumptions: 1.) every instr is one unit (yes I know this is pretty simple but ...) 2.) random access pattern so here we go a simple search is n instructions- a binary search is +x instructions for a

Re: Linear search vs binary

2013-10-21 Thread Bodoh John Robert [Contractor]
I would use a hash table. It's much faster. John -Original Message- From: IBM Mainframe Assembler List [mailto:ASSEMBLER-LIST@listserv.uga.edu] On Behalf Of Dougie Lawson Sent: Monday, October 21, 2013 7:32 AM To: ASSEMBLER-LIST@listserv.uga.edu Subject: Linear search vs binary If I hav

Re: Linear search vs binary

2013-10-21 Thread Rob van der Heij
If you want to make it 4096 entries, you could step through the table with binary search very cheap by shifting a mask on each pass. I would already think about it with 35 entries... ;-) On 21 October 2013 13:32, Dougie Lawson wrote: > If I have a table of 3,500 entries of twelve bytes (I'm doi

Linear search vs binary

2013-10-21 Thread Dougie Lawson
If I have a table of 3,500 entries of twelve bytes (I'm doing a compare of eight bytes to find the entry I'm looking for and a check on a half word marker for the end of the table to avoid running off the end) then is it worth the pain of re-writing it as a binary search. If it is worth the pain a

Re: missing functionality in TRTE

2013-10-21 Thread Martin Truebner
Bernd, >> I believe that the RC = 2 was found to be not necessary in the case of TRTE, because this case (nonzero function byte in the last byte of the string to be tested) Absolutly- If I reshuffle my code such that I maintain position within source (and target of course) I could easy forget abo

Re: missing functionality in TRTE

2013-10-21 Thread Steve Hobson
> I don't think I've ever truly leveraged RC=2 from TRT. I usually test > the length remaining at the top of the loop via DOEXIT. Never leverage a short word where a long one will do. Best regards, Steve Hobson CICS Strategy, HLASM Development, Master Inventor Hursley Laboratories, MP 189, Room A

Re: missing functionality in TRTE

2013-10-21 Thread Binyamin Dissen
On Mon, 21 Oct 2013 10:11:50 +0200 Martin Trübner wrote: :>>> Also, these instructions have the benefit of a guaranteed 256-byte minimum before :>>> they are interrupted, :>and :>>> if you know you are working with "short" data (<256 bytes) you :>>> don't need to check for RC=3 at all...

Re: missing functionality in TRTE

2013-10-21 Thread Martin Trübner
Ed, >> Also, these instructions have the benefit of a guaranteed 256-byte minimum >> before >> they are interrupted, and >> if you know you are working with "short" data (<256 bytes) you >> don't need to check for RC=3 at all... Be very very carefull. My POP say about MVST: The CPU-deter