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-Thread: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.in2p3.fr!in2p3.fr!news.ecp.fr!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Tue, 8 Feb 2011 18:13:21 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <19fh1chm74f9.11cws0j5bckze.dlg@40tude.net> <4d4ff70e$0$6886$9b4e6d93@newsspool2.arcor-online.net> <737a6396-72bd-4a1e-8895-7d50f287960e@d28g2000yqc.googlegroups.com> <4d5008a5$0$6879$9b4e6d93@newsspool2.arcor-online.net> <4d5031fe$0$6765$9b4e6d93@newsspool3.arcor-online.net> <1f229967-d3cf-42b6-8087-c97ee08652f3@i40g2000yqh.googlegroups.com> <4d51169e$0$7657$9b4e6d93@newsspool1.arcor-online.net> <1bnp0pw1c8r5b$.guxc48qweiwe.dlg@40tude.net> <4d51a1c0$0$19486$882e7ee2@usenet-news.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1297210406 10903 69.95.181.76 (9 Feb 2011 00:13:26 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 9 Feb 2011 00:13:26 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5931 Xref: g2news1.google.com comp.lang.ada:17065 Date: 2011-02-08T18:13:21-06:00 List-Id: "Shark8" wrote in message news:ee766e88-e4c4-4278-8b05-fd0dc9aa3fdb@k17g2000pre.googlegroups.com... >> How do you test the third bit of a byte in Ada? > >One Way, assuming a 1..8 numbering for an 8-bit byte: Presuming I *wasn't* interviewing for a job, would be to point out that that is the wrong question. The question is typically something like testing the ready bit in a device. And the solution to that in Ada is to map the device to an appropriate record type, and then read that proper component. For instance: type Dev_Status is Read_Ready : Boolean; -- Bit 3. Write_Ready : Boolean; ... end record; for Dev_Status use record Read_Ready at 0 range 3 .. 3; -- Bit 3. Write_Ready at 0 range 4 .. 4; ... end record; My_Dev_Status : Dev_Status with Address => ; if My_Dev_Status.Read_Ready then -- Testing bit 3. QED. :-) Randy.