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: g2news2.google.com!news3.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!217.73.144.44.MISMATCH!ecngs!feeder.ecngs.de!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!gegeweb.org!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: Wed, 9 Feb 2011 21:29:51 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <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> <0c9a8fbb-465e-4a9b-a9e6-dba67b648283@t19g2000prd.googlegroups.com> <6cf0950a-d2a3-4df4-9f19-23474d568c28@q40g2000prh.googlegroups.com> <4d52b82f$0$19486$882e7ee2@usenet-news.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1297308596 28516 69.95.181.76 (10 Feb 2011 03:29:56 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 10 Feb 2011 03:29:56 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5931 Xref: g2news2.google.com comp.lang.ada:18177 Date: 2011-02-09T21:29:51-06:00 List-Id: "Hyman Rosen" wrote in message news:4d52b82f$0$19486$882e7ee2@usenet-news.net... > On 2/8/2011 9:33 PM, Adam Beneschan wrote: >> Dmitry asks, "How do you set the third >> bit?", and you say, "Well, if the third bit is a Ready bit in a >> hardware I/O register, I'd define a struct with bit components [yes, I >> think C has those] and just assign 1 to the component, which would be >> more readable than using a mask." > > This can be considerably more complicated depending on > the hardware and the compiler; you are trying to assign > to a single bit, but the compiler may do this by reading > an entire word, setting the bit in the result, and > assigning the entire word back. That could have dire > effects if writing adjacent bits does something. Quite true, there have been devices where you can't read the adjacent bits. Those are going to be problematical to deal with in any case (even in assembler). But of course the Ada solution handles that just fine (presuming you've appropriately used the Volatile and/or Atomic pragmas) -- you just have to assign an entire aggregate in that case. You still don't do any bit twiddling yourself. Randy.