Oppolzer - Informatik / Blog


Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie

ASSEMBLER-L - Binäre Suche mit ASSEMBLER (Codebeispiel)

Subject:

Re: Linear search vs binary

From:

Bernd Oppolzer <bernd.oppolzer@T-ONLINE.DE>

Reply-To:

IBM Mainframe Assembler List <ASSEMBLER-LIST@LISTSERV.UGA.EDU>

Date:

2013.10.26 17:31:53


BTW: the German mainframe Telefunken TR440 had a machine instruction which did a
binary search on a sorted table of (48 bit) machine words; the instruction was
called TLOG. Of course, there were other instructions for linear search, too.

See page 17 of the instruction set reference (only available in German, sorry):

http://bitsavers.informatik.uni-stuttgart.de/pdf/aeg-telefunken/tr440/RD441_InstructionSet_Oct70.pdf

There were other fancy machine instructions in the TR440 and in the predecessor
model TR4.

Kind regards

Bernd



Am 26.10.2013 17:11, schrieb Bernd Oppolzer:
> Some hours after I posted this, I got the impressions that it might be better to
> explain some of the hidden secrets that may be still in this code.
>
> First, the key field is in the records of the table at offset 3, that is the
> reason, why the compares with the search argument SUCHARG are done with 3(R7).
> The length of the compare is derived from the definition of SUCHARG, and the
> type of the compare is CLC or CP; the Structured Programming macro IF selects
> the machine instruction depending on the definition of SUCHARG.
>
> Then, as you can see, the IF has two conditions, separated by an asterisk; if
> the first condition is true, then control goes to the first THEN, if the second
> condition is true, then control goes to the second THEN, otherwise to the ELSE.
> This is in fact not a simple IF statement - looks more like SELECT ... WHEN ...
> OTHERWISE.
>
> The SP macros are home grown ... originally bought from another company in the
> early 70s, IIRC - long gone history. It's part of my job to keep them running;
> I'm working as a free lancer for this company since 1988.
>
> The rest should be self explaining ... I hope.
>
> To generalize this example (for example, to put it into a macro), it is only
> necessary to parameterize some pieces of the code, that is:
>
> - the number of the elements on entry
> - the size of one element which is multiplied to the index
> - the position of the key field
> - the length of the key field (which goes into the compare instruction)
> - and maybe the type of the compare instruction
>
> To further generalize it, the compare instruction should be a function call ...
>
> Kind regards
>
> Bernd
>

Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie