The construction of arbitrary translation tables can be error-prone,
and when it is it is better done procedurally.  I use the HLASM macro
language, which is entirely adequate to such tasks; mais à chacun son
goût.

Here, however, we have for a TROO only the 256 permutations taken two
at a time of the sixteen hexadecimal digits, viz.,

0==>0, 1==>8, 2==>4, 3==>c,
4==>2, 5==>a, 6==>6, 7==>e,
8==>1, 9==>9, a==>5, b==>d,
c==>3, d==>b, e==>7, f==>f

and they can be enumerated readily, by program or manually (and
certainly without resort to cut-and-paste from a dump).

Symmetries can also be exploited, and the whole thing can be
arithmetized, but to do either would put mathematics dropouts at a
disadvantage.

The problem CAN be addressed with left circular shifts/left rotations,
but they must be nested (and iterated for long bit strings).  The TROO
turns out to be faster, particularly for those long bit strings.

The problem of bit-string reversal has its own interest, but if its
purpose is in effect to simulate a FROGR using a FLOGR, then other
approaches are possible.

Specifically, a TRTRE, Translate and Test Reverse Extended, can be
used.  It proceeds from right to left, high to low storage address, in
a byte string only until it finds a non-zero value in its table that
corresponds to the current byte's rank.

Permutations taken two at a time of the hexadecimal digit-codes

0000==>0000, 0
0001==>0001, 1
0010==>0010, 2
0011==>0001, 1
0100==>0011, 3
0101==>0001, 1
0110==>0010, 2
0111==>0001, 1
1000==>0100, 4
1001==>0001, 1
1010==>0010, 2
1011==>0001, 1
1100==>0011, 3
1101==>0001, 1
1110==>0010, 2
1111==>0001, 1

in which zero indicates the absence of a one bit and a non-zero value
indicates both the presence of a one bit and its one-origin offset
from the rightmost bit position.  The permutations/code points

x'N0',  N = 1, 2, . . . , f

need 'special' treatment, 8 must be added to the values shown above for them.

Unsurprisingly, this turns out to be faster than reversal followed by FLOG.

John Gilmore, Ashland, MA 01721 - USA

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to