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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c1b618c3b35129ab X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-13 10:34:29 PST Path: supernews.google.com!sn-xit-02!sn-xit-01!supernews.com!newshub2.rdc1.sfba.home.com!news.home.com!newsfeed.direct.ca!look.ca!nntp2.aus1.giganews.com!NetNews1!attws2!attor2!attor1!ip.att.net!news.hitter.net!news!news.crc.com!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: logical operations in Ada Date: Tue, 13 Feb 2001 11:44:11 -0600 Organization: CRC: A wholly owned subsidiary of Thermo Electron Message-ID: <96bro9$ivb$1@hobbes2.crc.com> References: <87pugp2x4p.fsf@deneb.enyo.de> <512i6.239390$JT5.8526649@news20.bellglobal.com> NNTP-Posting-Host: 198.175.145.56 X-Trace: hobbes2.crc.com 982086217 19435 198.175.145.56 (13 Feb 2001 17:43:37 GMT) X-Complaints-To: abuse@crc.com NNTP-Posting-Date: 13 Feb 2001 17:43:37 GMT X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: supernews.google.com comp.lang.ada:5230 Date: 2001-02-13T17:43:37+00:00 List-Id: Here's an example of bit-wise operations on modular types with conversions to and from characters to do what you said you wanted to do. -- begin source code -- with Ada.Text_IO; with Ada.Unchecked_Conversion; with Interfaces; procedure Bit_Ops is function To_Character is new Ada.Unchecked_Conversion (Source => Interfaces.Unsigned_8, Target => Character); function To_Unsigned_8 is new Ada.Unchecked_Conversion (Source => Character, Target => Interfaces.Unsigned_8); Mask : constant Interfaces.Unsigned_8 := 2#1101_1111#; use type Interfaces.Unsigned_8; begin for C in CHARACTER'('a') .. CHARACTER'('z') loop Ada.Text_IO.Put (To_Character (Mask and To_Unsigned_8 (C))); end loop; Ada.Text_IO.New_Line; end Bit_Ops; --end source code -- "Freelancer" wrote in message news:512i6.239390$JT5.8526649@news20.bellglobal.com... > I am well aware of ada.characters.handling. That isn't my objective. > As you said, I am trying to fiddle with bits. How to do this in Ada? > > A small example would be greatly appreciated. :) > Thank you for your references though. > > > "Florian Weimer" wrote in message > news:87pugp2x4p.fsf@deneb.enyo.de... > > "Freelancer" writes: > > > > > Could anyone tell me how to do basic operation on ASCii characters? > > > > Why do you think these are 'logical operations'? > > > > > More specifically, I would like to do a to_upper function for example : > > > > > > 'a' becomes 'A' ( a to_upper function) > > > > Do you need a function for case conversion, or do you want to do > > fiddle with bits? Have a look at the package Ada.Characters.Handling > > or modular types (for which logical operations are defined). > > > > > Is it possible to define a block of assembly language code in an ada > > > program as well? > > > > Yes, see your compiler documentation on 'Machine Code Insertions'. > >