The macro at the end of my reply will generate a reverse translate table. I tested it enough to see that it looked right but it has nothing to do with my original point. I've found this discussion interesting and it has given me reason to play with something other than the complex process I'm working on now. My original point, as was taken by Charles, was that I prefer automatic processes to generate anything but the simplest translate tables. I prefer to do it in a program and copy it from a dump into a program because the table is static. I don't need to generate it every time I assemble.
In regards to TROO, the original problem was stated as translating a 64 bit register. A STG, TR for 8 bytes, followed by a LRVG will more than suffice. Though, I find your argument about the use of a TRTRE to simulate a FROGR interesting. It brings the whole bit reversal into perspective. I'm not a big fan of translate instructions (I use them often enough), particularly those that require facilities and facility enhancements, unless you're translating "long" strings and are willing to test the facility bits. I'm sure that the translation and parsing facilities exist on most customer's boxes by now but I emphasize "most". When I awakened this morning, I wrote an algorithm to do a load reverse bytes and bits using FLOGR to drive the process. I'm going to give the idea of a FROGR simulation more thought and continue this exercise later. MACRO &LABEL REVTABLE , * Construct reverse bits translate table LCLA &I,&J,&K,&L,&M,&N,&O LCLC &X &LABEL DS 0D LIKE EM DOUBLE WORD ALIGNED &I SETA 0 STARTING VALUE .TABLOOP ANOP LOOP UNTIL TABLE IS DONE &K SETA 1 NEED SIXTEEN ENTRIES PER LINE &X SETC 'AL1(' AGO .X16LP .X16NXT ANOP &X SETC '&X'.'&J'.',' .X16LP ANOP 16 ENTRY LOOP &J SETA 0 STARTING RESULT &L SETA 1 STARTING ADDEND &M SETA 1 8 BITS PER BYTE &N SETA 128 STARTING COMPARAND X'80' &O SETA &I COPY CURRENT BYTE TO REVERSE .BYTELP ANOP AIF (&O LT &N).BYTEFT LESS THAN CURRENT - 0 &O SETA &O-&N &J SETA &J+&L .BYTEFT ANOP &L SETA &L*2 NEXT ADDEND &N SETA &N/2 NEXT COMPARAND &M SETA &M+1 NEED EIGHT BITS AIF (&M LE 8).BYTELP &I SETA &I+1 &K SETA &K+1 AIF (&K LE 16).X16NXT &X SETC '&X'.'&J'.')' DC &X AIF (&I LT 256).TABLOOP MEND -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of John Gilmore Sent: Wednesday, July 24, 2013 10:29 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: Is there a "reverse bits" hardware instruction? 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 ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN