comp.lang.ada
 help / color / mirror / Atom feed
* Packing Record Structures in Ada
@ 1998-01-12  0:00 Randall_Rathbun
  1998-01-12  0:00 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Randall_Rathbun @ 1998-01-12  0:00 UTC (permalink / raw)



Has anyone struggled and fixed the following problem with ordering inside
the Ada83 record structure? We are working with two compilers, call them
A & B, and they pack the record structure inversely. A typical example:
type sample_message_type is
   record
      first_field  : unsigned_20_bits_type;
      second_field : unsigned_22_bits_type;
      third_field  : unsigned_22_bits_type;
   end record
sample_message : sample_message_type;

When compiler A sends a message out across a bus, it will send
  |1.........20|21......32|   1st quad-word
   first field   second
  |1...10|11............32|   2nd quad-word
    2nd      third field

However when the message is received, using compiler B it gets
  |1.....12|13..........32|   1st quad-word
    2nd        1st field
  |1...........22|23....32|   2nd quad-word
    3rd field      2nd
(this is due to the way data is sent across the bus, 32 bits at a
time)
When the 2nd compiler B tries to understand what compiler A sent,
it will force its interpretation, but since the relative order has
been horizontally flipped, garbage results. One compiler stacks 8 bit
bytes left-to-right inside the quadword, the other in the opposite
order.

If you've encountered this problem in Ada83, and developed work-arounds,
I'd like to hear from you Currently we're using a rotate function that
uses the "with System" module to remedy this ugly mess. Thanks!
please email: Randall_Rathbun@rc.trw.com

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1998-01-19  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-12  0:00 Packing Record Structures in Ada Randall_Rathbun
1998-01-12  0:00 ` Matthew Heaney
1998-01-13  0:00 ` Robert Dewar
1998-01-13  0:00   ` Corey Minyard
1998-01-13  0:00     ` Robert Dewar
1998-01-15  0:00     ` Michael F Brenner
1998-01-15  0:00       ` Robert Dewar
1998-01-19  0:00 ` Anonymous

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox