* How do I use ADA to calculate a checksum? @ 1997-09-23 0:00 Charles Phillips 1997-09-23 0:00 ` Tom Moran 1997-09-24 0:00 ` David C. Hoos, Sr. 0 siblings, 2 replies; 5+ messages in thread From: Charles Phillips @ 1997-09-23 0:00 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use ADA to calculate a checksum? 1997-09-23 0:00 How do I use ADA to calculate a checksum? Charles Phillips @ 1997-09-23 0:00 ` Tom Moran 1997-09-24 0:00 ` David C. Hoos, Sr. 1 sibling, 0 replies; 5+ messages in thread From: Tom Moran @ 1997-09-23 0:00 UTC (permalink / raw) I presume you want to calculate a byte or word-wise checksum on data which is a record (ie, not an array of bytes or words)? Yoy can delcare an array of bytes/words and use a representation clause to make it overlay, ie, start at the same address as, the record. Then just run through the array calculating the checksum, CRC, or whatever. If you are passed an Access type rather than an Address, use the appropriate function in System.Address_To_Access_Conversions to get an Address. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use ADA to calculate a checksum? 1997-09-23 0:00 How do I use ADA to calculate a checksum? Charles Phillips 1997-09-23 0:00 ` Tom Moran @ 1997-09-24 0:00 ` David C. Hoos, Sr. 1997-09-30 0:00 ` Charles Phillips 1997-09-30 0:00 ` Charles Phillips 1 sibling, 2 replies; 5+ messages in thread From: David C. Hoos, Sr. @ 1997-09-24 0:00 UTC (permalink / raw) 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 <implementation-defined>; -- 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 <charles@scarecrow.gcs.redstone.army.mil> 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 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use ADA to calculate a checksum? 1997-09-24 0:00 ` David C. Hoos, Sr. @ 1997-09-30 0:00 ` Charles Phillips 1997-09-30 0:00 ` Charles Phillips 1 sibling, 0 replies; 5+ messages in thread From: Charles Phillips @ 1997-09-30 0:00 UTC (permalink / raw) To: David C. Hoos, Sr. David C. Hoos, Sr. wrote: Sorry I didn't provide enough specifications. Thanks for the assistance in directing me to storage units. Seems I was making it more difficult(in other words, like C) than necessary. > 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. > Thanks for the recommendation. Charles ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I use ADA to calculate a checksum? 1997-09-24 0:00 ` David C. Hoos, Sr. 1997-09-30 0:00 ` Charles Phillips @ 1997-09-30 0:00 ` Charles Phillips 1 sibling, 0 replies; 5+ messages in thread From: Charles Phillips @ 1997-09-30 0:00 UTC (permalink / raw) To: David C. Hoos, Sr. David C. Hoos, Sr. wrote: Sorry I didn't provide enough specifications. Thanks for the assistance in directing me to storage units. Seems I was making it more difficult(in other words, like C) than necessary. > 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. > Thanks for the recommendation. Charles ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1997-09-30 0:00 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-09-23 0:00 How do I use ADA to calculate a checksum? Charles Phillips 1997-09-23 0:00 ` Tom Moran 1997-09-24 0:00 ` David C. Hoos, Sr. 1997-09-30 0:00 ` Charles Phillips 1997-09-30 0:00 ` Charles Phillips
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox