Joel,

You must have missed my solution from a couple of days ago.  It uses six (6)
instructions with minimal table space.

Here it is again.

         MVC   OBUFF,IBYTE    Copy the byte to be converted    @xxnnnnn
         MVC   OBUFF+1(7),OBUFF                                @xxnnnnn
*                             Propagate the byte to all eight  @xxnnnnn
*                               (8) positions                  @xxnnnnn
         NC    OBUFF,=X'8040201008040201'                      @xxnnnnn
*                             Mask the appropriate bit in      @xxnnnnn
*                               each byte                      @xxnnnnn
         MVO   WORK5,OBUFF(4) Shift the high-order nibbles     @xxnnnnn
*                               associated with the high-order @xxnnnnn
*                               bits to the corresponding      @xxnnnnn
*                               low-order-nibbles in the work  @xxnnnnn
*                               buffer                         @xxnnnnn
         MVC   OBUFF(4),WORK5 Return the low-order nibbles to  @xxnnnnn
*                               the output buffer              @xxnnnnn
         TR    OBUFF,=C'011-1---1'                             @xxnnnnn
*                             Convert the bits masks contained @xxnnnnn
*                               in the output buffer to EBCDIC @xxnnnnn
*                               binary digits (0,1)            @xxnnnnn

IBYTE    DC    B'01110101'    Sample Input Value               @xxnnnnn

WORK5    DC    X'0000000000'  Work Area                        @xxnnnnn
OBUFF    DS    CL8            Output Value                     @xxnnnnn

         LTORG ,              Literal Pool                     @xxnnnnn

Summary of storage requirements:

  36 Bytes - Instructions
  17 Bytes - Literals
   1 Byte  - Input Buffer
   5 Bytes - Work Area
   8 Bytes - Output Area

  67 Bytes        - Total
   6 Instructions - Total

The use of the MVO/MVC sequence eliminates the need for a large translation
table.  Just 9 bytes are required.

John P Baker

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED] On Behalf
Of Joel C. Ewing
Sent: Friday, December 14, 2007 10:48 PM
To: [email protected]
Subject: Re: Mainframe Assembler Coding Contest

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