Being aware that we do not do the homework for pupils here, but since Dave is apparently not

and I found it an interesting problem, here is my solution:


*
*
****** R14 thru R1 are used
*
*
         LA    R14,WORK
         LHI   R1,10       length of number
         LA    R15,0(R14,R1)    load end of number
AFTER    EQU   8           number of digits after the point
         TM    WORK,X'F0'  does it start with a digit
         JO    NO_SIGN
         CLI   0(R14),C'+'
         JE    NOT_MINUS
         AHI   R1,256*1    now we have 01 ll in R1
NOT_MINUS      DS  0H
         AHI   R14,1       correct start
         BCTR  R1,0        adjust length
NO_SIGN        DS  0H
         LHI   R0,C'.'
         SRST  R15,R14
         LA    R0,AFTER   do not destroy CC here (!!)
         JP    NO_POINT   nothing found
         BCTR  R1,0       adjust length
         EXRL  R1,MVC     0(*-*,R15),1(R15) remove point
         SR    R15,R14    =number of digits ahead of the point
         SR    R15,R1     =number of digits after the point(+sign)
         LPR   R15,R15
         NILL  R15,X'00FF' remove sign-indicator
         SR    R0,R15    r0 is now number of digits to shift left
NO_POINT DS    0H
         BCTR  R1,0
         EXRL  R1,PKA
         SRL   R1,8
         EXRL  R1,OI     correct the sign
         LR    R15,R0    make r0 usable in SRP
         SRP   RESULT,0(R15),0   adjust decimals
*
*        this is it
*

*
MVC      MVC   0(*-*,R15),1(R15) remove point
PKA      PKA   RESULT,0(*-*,R14)
OI       OI    RESULT+L'RESULT-1,*-*
*
*
*
WORK     DS    CL40
RESULT   DS    CL16

*

Dave: if you want I send you the testpgm around the above that I used to develop this

Reply via email to