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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-7-bit Received: by 10.68.73.229 with SMTP id o5mr9152930pbv.7.1323696177005; Mon, 12 Dec 2011 05:22:57 -0800 (PST) Path: lh20ni14078pbb.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Does Ada support endiannes? Date: Mon, 12 Dec 2011 14:22:39 +0100 Organization: cbb software GmbH Message-ID: <53n2sd7edt5i.1boh4452h0aks.dlg@40tude.net> References: <23835087-313f-427c-b37e-4ff1bdef9d57@r6g2000yqr.googlegroups.com> <20e631fc-e7b4-41ca-be0f-aab8be3f9a25@f33g2000yqh.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-12-12T14:22:39+01:00 List-Id: On Mon, 12 Dec 2011 04:46:22 -0800 (PST), Gerd wrote: > On 12 Dez., 12:27, "Dmitry A. Kazakov" > wrote: > > Any suggestion on how to convert, others than using "/" and "mod"? Why not to use them? It would be a bad idea trying to avoid them. It won't give you much performance, because memory mapping would require unpacking, alignment, checksum evaluation, stuff which would turn into extra copying. So why not just: type Octet is new Unsigned_8; type Word is new Unsigned_16; type Octet_Array is array (Positive range <>) of Octet; procedure Get_Little_Endian (Data : Octet_Array; Index : in out Integer; Value : out Word) is -- No extra copying begin Value := Word (Data (Index)) + Word (Data (Index + 1)) * 256; Index := Index + 2; end Get_Little_Endian; Arithmetic is cheap. Memory access is expensive. Note also, that a real-life protocol could also have specially encoded values reserved for indication of status (overflow, underflow etc). So memory mapping would not work anyway. P.S. We are developing hard real-time communication applications handling various quite weird hardware protocols. Believe or not, we are using no representation clauses at all. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de