Rick Fochtman wrote:
Tom Marchant wrote:

On Thu, 13 Dec 2007 17:13:09 -0800, Tom Simons wrote:

Here's 8 instructions to translate 8 bits to 8 chars of 1's or 0's:

       LA    R3,8
       IC    R5,INBYTE
       SLL   R5,24
LOOP     SLL   R4,3
       SLDL  R4,1
       BCT   R3,LOOP
       ST    R4,OUTCHAR
       UNPK  OUTCHAR(9),OUTCHAR(5)

OUTCHAR  DS    CL8
       DS    X
INBYTE   DC    B'10101011'

Cool.  Here's a minor improvement

        LA    R3,8
        ICM   R5,8,INBYTE
LOOP     SLL   R4,3
        SLDL  R4,1
        BCT   R3,LOOP
        ST    R4,OUTCHAR
        UNPK  OUTCHAR(9),OUTCHAR(5)

OUTCHAR  DS    CL8
        DS    X
INBYTE   DC    B'10101011'

Don't you want a STM R4,R5,OUTCHAR ??? Instead of a ST R4,OUTCHAR ???
Don't think so. At point of the ST the 8 values are stored in 4-bit nibbles and only occupy 32 bits.

Did the original problem statement require this be done with a loop? If not, why not use straight line code with only 4 executed instructions instead of the 28 or 29 with the loops as above? For Example:
         MVC  OUTCHAR(1),INBYTE
         MVC  OUTCHAR+1(7),OUTCHAR   8 COPIES OF ORIGINAL BYTE
         NC   OUTCHAR,=XL8'8040201008040201'
         TR   OUTCHAR,BIT2CHR
...
OUTCHAR  DS   CL8
INBYTE   DC   B'10101011'
*   THE ONLY USED BYTES BELOW ARE
*   AT BIT2CHR +0,+1,+2,+4,+8,+16,+32,+64, AND +128
BIT2CHR  DC   C'0',128C'1'

This requires more storage because of the table, but that would even out if multiple conversions were needed within the same program - or if you got sufficiently clever (and obscure) to use the 120 unused bytes in the 129 byte table for other purposes.




--
Joel C. Ewing, Fort Smith, AR        [EMAIL PROTECTED]

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to