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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1048aea26a740e29 X-Google-Attributes: gid103376,public From: G Subject: Re: Bit operators & asm in Ada (novice question) Date: 2000/02/13 Message-ID: <38A624B3.5709A464@interact.net.au>#1/1 X-Deja-AN: 585196750 Content-Transfer-Encoding: 7bit References: <884o85$jjv$1@news.fsu.edu> <48np4.505$e6.7474@newsread1.prod.itd.earthlink.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@interact.net.au X-Trace: news.interact.net.au 950412521 203.33.177.111 (Sun, 13 Feb 2000 14:28:41 EST) Organization: BDF MIME-Version: 1.0 NNTP-Posting-Date: Sun, 13 Feb 2000 14:28:41 EST Newsgroups: comp.lang.ada Date: 2000-02-13T00:00:00+00:00 List-Id: > > > base 10 > > 1 = 1 & 3 > > 3 = 3 & 3 > > 2 = 6 & 3 > > 3 = 7 & 3 > > declare > I : Interfaces.Unsigned_32; > begin > I := 1 and 3; > I := 3 and 3; > etc > end; > > > base 2 (same as above) > > 001 = 001 & 011 > > 011 = 011 & 011 > > 010 = 110 & 011 > > 011 = 111 & 011 > > declare > I : Interfaces.Unsigned_32; > begin > I := 2#110# and 2#011#; > I := 2#111# and 2#011#; > etc > end; > > > > Ada is a systems programming language, just like C/C++. Anything you > can do in C, you can do in Ada. > I have been reading the Art of Assembly. I was wondering how to do exactly these sorts of operations in Ada. If my terminology is correct, and from what is above, I am thinking that I can apply bit masks to bytes by using modular integers (OR by declaring a variable as Interface.Unsigned_32,( for 32bit ops only, I assume - and that modular integers would allow for contraction to 16 or 8 and rotation or shift operations ???)). So - in Borland C++ I may actually write asm directly into code (not that I can yet), but - is this possible in Ada ? I have read many times and in many places that actual running programs spend on average 90% of their time in 10% of the code. And that assembly is often employed to rewrite that 10%. I guess what I am wondering is, how does an assembly programmer do this if a program has been written for Ada ? Does the Ada programmer have to construct their programs with a preconceived notion that it will have to be rewritten in parts in Assembly ? Or is it that at the machine level these sorts of questions are totally irrelevant. I wonder because it is not at all transparent. -- -- GM Wallace. BDF -- caveat: I can not afford a computer science education, please do not flame me. (I received some nasty, almost threatening, messages a while back from someone (anonymous) here so I feel I have to qualify my ignorance very cautiously).