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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4e9860765413318c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-22 18:26:32 PST Path: archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.sttln1.wa.home.com.POSTED!not-for-mail From: "DuckE" Newsgroups: comp.lang.ada References: <9m0gn6$b6j$1@zeus.orl.lmco.com> Subject: Re: Hi byte and Lo Byte Question X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Message-ID: Date: Thu, 23 Aug 2001 01:26:31 GMT NNTP-Posting-Host: 24.248.45.203 X-Complaints-To: abuse@home.net X-Trace: news1.sttln1.wa.home.com 998529991 24.248.45.203 (Wed, 22 Aug 2001 18:26:31 PDT) NNTP-Posting-Date: Wed, 22 Aug 2001 18:26:31 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:12301 Date: 2001-08-23T01:26:31+00:00 List-Id: You don't really say anything about the data types you're working with, so I'll just assume you're using Interfaces.Unsigned_16. This sample Ada program fairly closely matches the C example you gave, although you didn't give any examples of types. with Interfaces; use Interfaces; with Ada.Text_Io; procedure testbytes is package Unsigned_16_Io is new Ada.Text_Io.Modular_Io( Unsigned_16 ); function LOBYTE( value : Unsigned_16 ) return Unsigned_16 is pragma Inline( LOBYTE ); begin return value and 16#FF#; end LOBYTE; function HIBYTE( value : Unsigned_16 ) return Unsigned_16 is pragma Inline(HIBYTE); begin return Shift_Right( value, 8 ); end HIBYTE; begin declare a : Unsigned_16; begin a := 16#0102#; Ada.Text_Io.Put( "Value: " ); Unsigned_16_Io.Put( a, 8, 16 ); Ada.Text_Io.New_Line; Ada.Text_Io.Put( "LOBYTE: " ); Unsigned_16_Io.Put( LOBYTE( a ), 8, 16 ); Ada.Text_Io.New_Line; Ada.Text_Io.Put( "HIBYTE: " ); Unsigned_16_Io.Put( HIBYTE( a ), 8, 16 ); Ada.Text_Io.New_Line; end; end testbytes; BTW: In Ada things are usually described in a more abstract manner, except sometimes when dealing with interfaces. SteveD "mop" wrote in message news:9m0gn6$b6j$1@zeus.orl.lmco.com... > > I need to parse data into hi byte and lo byte. Does Ada have some built in > macros or .... I could use? From the looks of it no. > > here's the C version .... Need the Ada version as am new to Ada. > > lo = LOBYTE(Value); -- need Ada version for this LOBYTE macro > hi = HIBYTE(Value); -- need Ada version for this HIBYTE macro > WORD.Data.Word5_Data_Value_In_HB_LB_Order[0] = hi; > WORD.Data.Word5_Data_Value_In_HB_LB_Order[1] = lo; > > >