This was my first try at #6, but I couldn't get it to work in z390. )-:  

I don't like the multiply, though.  I would have liked to just shift the bits 
one to the left to do the multiply by 2, but I didn't figure out how to do that 
yet.  

START    LH    R1,=X'004A'        R1 contains byte to convert
         LA    R2,7               R2 contains offset into BINNUM disp
         XR    R4,R4              R4 zero (MR overflow)
         LA    R5,1               R5 contains AND mask (counting)
NEXT1    LR    R3,R5              R3 temporary register
         NR    R3,R1              Test if bit is on
         BZ    ZERO                ..No, write "0"
         L     R3,=X'000000F1'    Move "1" to R3
         STC   R3,BINNUM(R2)      Move to BINNUM
         B     SKIP
ZERO     L     R3,=X'000000F0'    Move "0" to R3
         STC   R3,BINNUM(R2)      Move to BINNUM
SKIP     LA    R3,2               Set R3 to 2 for multiply
         MR    R4,R3              Double R4 to shift bit 1 to left
         LTR   R2,R2              Is it zero?
         BZ    PRINTIT            Yes, done, print results
         BCTR  R2,R0              Decrement R2
         B     NEXT1              Go get next one
*
PRINTIT  TPUT  BINNUM,L'BINNUM    TPUT Results
*
*
BINNUM   DC    CL8'$$$$$$$$'      Converted Number


-----Original Message-----
From: IBM Mainframe Discussion List on behalf of Binyamin Dissen
Sent: Wed 12/12/2007 8:52 PM
To: [email protected]
Subject: Re: Mainframe Assembler Coding Contest
 


Constraints are not well defined.

If one can use an 8*256 byte table .... 3 silicon instructions (4, if LB is in
silicon) - not tested

...entry logic
       LB    R1,BYTE
       SLL   R1,3
       LA    R2,TABLE+8*128(R1)
       MVC   RESULT,0(R2)
...exit logic

   TABLE   DC C'10000000'
           DC C'10000001'
         ...
           DC C'11111111'
           DC C'00000000'
           DC C'00000001'
         ...
           DC C'01111111'

--
Binyamin Dissen <[EMAIL PROTECTED]>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel


Should you use the mailblocks package and expect a response from me,
you should preauthorize the dissensoftware.com domain.

I very rarely bother responding to challenge/response systems,
especially those from irresponsible companies.

----------------------------------------------------------------------
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


----------------------------------------------------------------------
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