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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,671b5d2d09a675ef X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: How do I use ADA to calculate a checksum? Date: 1997/09/24 Message-ID: <01bcc8cf$2e049910$0100007f@dhoossr>#1/1 X-Deja-AN: 275134310 Distribution: world References: <3427DF0F.4467@scarecrow.gcs.redstone.army.mil> X-Complaints-To: usenet@news.advicom.net X-Trace: polo.advicom.net 875094746 28847 (None) 165.113.131.104 Organization: ADViCOM -- Advanced Internet Communications Newsgroups: comp.lang.ada Date: 1997-09-24T00:00:00+00:00 List-Id: Hi Charles, For what it's worth, here's how I would go about it, given the limited "requirements specification.": -- First, define a type for the checksum. type Checksum_Type is ; -- Perhaps if you're looking for an n-bit checksum, the type would -- be mod 2 ** N. (See the LRM about modular types) -- Next, define the checksum function specification: function Checksum (Starting_Address : System.Address; Data_Length : Natural ) return Checksum_Type; -- Now, we can define the function body: function Checksum (Starting_Address : System.Address; Data_Length : Natural ) return Checksum_Type is -- Define a "storage unit" type type Storage_Unit_Type is mod 2 ** System.Storage_Unit; -- Define the type of an array of these "storage units" type Storage_Unit_Array_Type is array (1 .. Data_Length) of Storage_Unit_Type; -- Define the array of data to be checksummed Storage_Unit_Array : Storage_Unit_Array_Type; -- Now, locate the array where the data is for Storage_Unit_Array'Address use Starting_Address; -- Define the object to be returned, initialized to zero The_Checksum : Checksum_Type := 0; begin -- Now, the storage elements can be accessed individually -- e.g., -- Note that this loop will be executed Data_Length times, -- even if Dat_Length is 0 for i in Storage_Unit_Array'range loop --....:=... Storage_Unit_Array (i) ......... end loop; -- .......... return The_Checksum; end Checksum; There are many good books on Ada95, and I own well over a dozen. But.. if I had to limit myself to one it would be Norman Cohen's "Ada as a Second Language", Second Edition. You can get it at Madison Books and Computers. David C. Hoos, Sr., david.c.hoos.sr@ada95.com (205) 726-4965 Charles Phillips wrote in article <3427DF0F.4467@scarecrow.gcs.redstone.army.mil>... > Hello, > > I'm relatively new to ADA95, and would like to ask for assistance > from those of you who are more knowledgeable. > > I have an embedded application which requires me to perform several > checksum calculations. The question is, when passed a starting > address and a length, how do I "increment" the address and then > access the data at the location? > > Any help or recommendations with respect to reference books would > be greatly appreciated. > > Charles >