Yes, you can always do multiple precision that way, but there is a performance 
hit, especially from those conditional branches. Maybe we need skip 
instructions such as the 7090 had.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3


________________________________________
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on behalf of 
Thomas David Rivers <riv...@dignus.com>
Sent: Wednesday, September 9, 2020 8:35 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Support for 128-bit arithmetic - was: Re: PL/I support of vector 
instructions?

Seymour J Metz wrote:

>I was asking whether it supported vector instructions for FIXED, not for 
>FLOAT.; in particular, whether it supported FIXED BIN(127,0).
>
>
>--
>Shmuel (Seymour J.) Metz
>http://mason.gmu.edu/~smetz3
>
>
>
You would not need vector instructions to support FIXED BIN(127,s)
(quad-word scaled
or unscaled integers if s is 0.)

In fact, you could do it with 370 code (our C compiler happens to do
that for __int128
and __uint128.)

The problems come when consider conversions to-from other items... the
definitions
of those conversions are pretty straight-forward.  The issue is
examining all the conversion
permutations for PL/I to make sure it's implemented...   then there are
the library I/O
characteristics to consider (which are mostly handled by the conversion
answers.)
Will you need a PIC that handles this, is the maximum PIC length
sufficent (_lots_
of base-10 digits in those things.)   Do you need to read the values
from a FILE,
then you'll need CHAR -> FIXED BIN(127,s) conversion support... etc...

Our C compiler, as well as GCC, gets around this by saying you can
declare 128-bit
integers, and do basic arithmetic with them - but the runtime library
doesn't support them
(so formating for printing, for example, is up-to-you.)   That seems to
handle the current
uses for 128-bit integral arithmetic.  Of course, C doesn't have scaled
integers, making
the problem even easier there.

And - to drive the point home - let's consider this small snippet:

__int128
foo(__int128 a, __int128 b)
{
   return a + b;
}

which just adds 2 128-bit signed integers.   This is the 370 code that
is generated
from our C compiler:

* ******* End of Prologue
* *
         L     15,0(0,1)
* ***      return a + b;
         LM    2,5,4(1)
         AL    5,32(0,1)
         BC  12,@@gen_label0
         AL    4,@lit_147_0
         BC  12,@@gen_label0
         AL    3,@lit_147_0
         BC  12,@@gen_label0
         AL    2,@lit_147_0
@@gen_label0 DS 0H
         AL    4,28(0,1)
         BC  12,@@gen_label1
         AL    3,@lit_147_0
         BC  12,@@gen_label1
         AL    2,@lit_147_0
@@gen_label1 DS 0H
         AL    3,24(0,1)
         BC  12,@@gen_label2
         AL    2,@lit_147_0
@@gen_label2 DS 0H
         AL    2,20(0,1)
         STM   2,5,95(13)
         MVC   0(16,15),95(13)
* ***   }
* * **** Start of Epilogue

which is quite a lot!

But - if you tell the compiler it can take advantage of more recent
architectures (with
the -march=z13 option) - that same snippet generates this (in 31-bit mode):

* ******* End of Prologue
* *
         L     15,0(0,1)
* ***      return a + b;
         LMG   2,3,4(1)
         ALG   3,28(0,1)
         ALCG  2,20(0,1)
         STMG  2,3,95(13)
         MVC   0(16,15),95(13)
* ***   }
* * **** Start of Epilogue

which is a better demonstration of how to do 128-bit arithmetic without
vector
instructions.

      - Dave R. -

p.s. the return value is address via the first incoming parameter
(0(0,1)) if that helps
       make sense of what's going on here.

p.p.s.  This facility would be available in LE mode too, so you _could_
compile
            C code with our compiler and link it with the IBM PL/I
compiler to do your
            128-bit arithmetic; with careful definitions of the C
functions an PL/I EXTRNs.
            But, it might just be easier to write the PL/I PROCs to do
the various arithmetic
            functions on 128-bit values held in structures - or maybe
get really fancy
            and use the PL/I preprocessor to generate the code for the
basic operations.



--
riv...@dignus.com                        Work: (919) 676-0847
Get your mainframe programming tools at 
http://secure-web.cisco.com/1s90SO-UjL1WSVjVvb4AkJv2WPMJEueXQpFNLATgdwd3EHMXFE1iUBqoDQZLLvjq44lHvKMhIH0JF3bAw22v3WNj-8yUJAZe7Mgiw3mCCqbA5v1O3gHj_CucREhI5F4KIDLLqDUr33WO53oJQUzaLVnobKrb_3RgZorQHbo8AoYwavGFUJTobBrLageGchvdhaZUDBXFhLq5Yo9OmJSxZEUdiHJlqxHBfnJYnbhAANAAARmUTA9ujSfQOxhWM6jGJZAzQxVgEVjcGOr_sDboqRdSP-go0uNWVfVYGNqXARC_jfL0DQAAemO7MuXOB8PmLjHHe1AdIKVh48ZnxxTqJsDP8H0MiBZZCmOsOQ8zBM-eQWXzD7b8W0cJFYBTn8uSVGX5uQUhW1HZltx4z4_NhreVNI0zIiGvR490g_NhkVUZklaCY9WfOvYn3Irz-ADe3/http%3A%2F%2Fwww.dignus.com

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

Reply via email to