From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,43ad9ab56ebde91c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.189.194 with SMTP id gk2mr4744674pbc.3.1323949456368; Thu, 15 Dec 2011 03:44:16 -0800 (PST) Path: lh20ni25091pbb.0!nntp.google.com!news1.google.com!postnews.google.com!p16g2000yqd.googlegroups.com!not-for-mail From: Gerd Newsgroups: comp.lang.ada Subject: Re: Does Ada support endiannes? Date: Thu, 15 Dec 2011 03:27:48 -0800 (PST) Organization: http://groups.google.com Message-ID: <71bc4e7f-7c23-4180-9a8d-5c880a16d0c2@p16g2000yqd.googlegroups.com> References: <23835087-313f-427c-b37e-4ff1bdef9d57@r6g2000yqr.googlegroups.com> <108d5437-ae36-4e79-ad4e-aab3b903d0f4@gl2g2000vbb.googlegroups.com> <2f9744b6-4a45-4dd1-9621-c6f5d10166cb@r6g2000yqr.googlegroups.com> <0a7b55fd-1ecf-4a40-979c-12ce44071be9@p9g2000vbb.googlegroups.com> <6779f55b-e110-4673-b70b-cbd7c58f5d78@j10g2000vbe.googlegroups.com> NNTP-Posting-Host: 192.109.190.88 Mime-Version: 1.0 X-Trace: posting.google.com 1323949456 24704 127.0.0.1 (15 Dec 2011 11:44:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Dec 2011 11:44:16 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p16g2000yqd.googlegroups.com; posting-host=192.109.190.88; posting-account=XDglRgoAAAAB2wikSHYkYcjK-5hIYGIR User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLEUHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; InfoPath.2),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-12-15T03:27:48-08:00 List-Id: On 14 Dez., 21:16, Gautier write-only wrote: The problem space requires integers (signed), so using unsigned is not the right option. Could you please explain: What do you think how the data send from 68k to x86 will be converted from one data layout to the other? Will it happen "magically" on the wire? I think, conversion must be done explicit either on one side or on the other side, and this requires some code. Currently I use the htonl ntohl functions for it, which (as stated above) is not a good choice as it limits the allowed values to unsigned. > On 14 d=E9c, 17:16, Gerd wrote: > > > Are you sure the "/" and mod would work correct? > > > Assume, that the Value 16#000000FF# shall be converted to > > 16#FF000000#. > > > Native : Integer :=3D 16#000000FF#; > > > Remote : Integer; > > > Remote :=3D 16#01000000# * (Native mod 16#000000FF#); -- overflow! > > > PS: The task is to exchange Integer Values between an Motorola 68k and > > an Intel x86. > > Then you will use modular types, and with a definite size. > =A0 Native: Unsigned_32; > =A0 Remote: Unsigned_32; > They never overflow. > But typically (as you can see in Zip-Ada [1]) you won't presume > anything about the native endianness. > The "/" and "mod" (or faster: "Shift_Right" and "and") will do the job > automatically for you. > So your code will work on Intel, PowerPC, 68K - whatever - and > communicate with a remote hardware or media with a specific > endianness. > > [1]http://unzip-ada.sf.net/za_html/zip-headers__adb.htm#32_12 > _________________________ > Gautier's Ada programminghttp://gautiersblog.blogspot.com/search/label/Ad= a > NB: follow the above link for a valid e-mail address