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.2 required=5.0 tests=BAYES_00,FROM_LOCAL_HEX, FROM_STARTS_WITH_NUMS autolearn=no 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!news1.google.com!news.glorb.com!news2.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Vinzent Hoefler" <0439279208b62c95f1880bf0f8776eeb@t-domaingrabbing.de> Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Tue, 08 Feb 2011 22:46:26 +0100 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> <4d51b568$0$19486$882e7ee2@usenet-news.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: individual.net ZPFVQJbcMdEOWbxiyVbFjgbqzpq6WPCN3KKlB4H5+NpYdSeQSp Cancel-Lock: sha1:ko1BfiqdqAOkQNhYG6A+9BoA3ro= User-Agent: Opera Mail/11.01 (Win32) Xref: g2news2.google.com comp.lang.ada:18020 Date: 2011-02-08T22:46:26+01:00 List-Id: Hyman Rosen wrote: > I think that's why I'll stick with (byte & (1 << (3 - 1))). > Or rather, I would most likely write a macro, > #define TEST_BIT(n, b) ((n) & (1 << ((b) - 1))) And it's still wrong. As we all know, C programmers start counting with zero (including bit numbers), so you're bit-addressing is off by one. Assembler can be so much more expressive: ; group A is port B and port C[7:4], definitions are MUTEX %ASSIGN MODE_A_0 (00b << 5) ; mode 0 for group A (bits [5:6]) %ASSIGN MODE_A_1 (01b << 5) ; mode 1 for group A %ASSIGN MODE_A_2 (10b << 5) ; mode 2 for group A ; group B is port A and port C[3:0], definitions are MUTEX %ASSIGN MODE_B_0 (0b << 2) ; mode 0 for group B (bit 2) %ASSIGN MODE_B_1 (1b << 2) ; mode 1 for group B At least it actually /has/ binary numbers. Vinzent. -- You know, we're sitting on four million pounds of fuel, one nuclear weapon, and a thing that has 270,000 moving parts built by the lowest bidder. Makes you feel good, doesn't it? -- Rockhound, "Armageddon"