comp.lang.ada
 help / color / mirror / Atom feed
From: Randall_Rathbun@rc.trw.com
Subject: Packing Record Structures in Ada
Date: 1998/01/12
Date: 1998-01-12T00:00:00+00:00	[thread overview]
Message-ID: <884639188.24707084@dejanews.com> (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




             reply	other threads:[~1998-01-12  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-12  0:00 Randall_Rathbun [this message]
1998-01-12  0:00 ` Packing Record Structures in Ada 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
replies disabled

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