This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: data alignment issues


Why not send structures if it works?  After all, if I've tested it and
there isn't any problems, then it's no problem right?  Is there any
better way sending data?  I suppose I could send the structure one field
at a time

I didn't mean I couldn't read a float in hex.  I mean I don't know how
it's stored in binary.  As in 00001000.10000000 would be 8.5, but I
don't know how this is stored in memory.  I know there aren't any two
byte floats, but that was just an example! :)

-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[mailto:ecos-discuss-owner@sources.redhat.com] On Behalf Of
rob.wj.jansen@philips.com
Sent: Thursday, August 09, 2001 1:55 AM
To: tadams@theone.dnsalias.com
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] data alignment issues




> Any comments on this alignment?  I thought the gcc compiler didn't do 
> any alignment?

The compiler has to perform alignment since the ARM processor used will
only read 32 bit words on a 4 bytes boundary. As already written in one
of the previous posts, a fetch of a 32 bit words from a non aligned
boundary will result in an exception. To prevent any alignment problems,
gcc will align all members on a word boundary (which is a 4 byte
boundary for the ARM core).

> Anyhow, I just ran a test.  I have the structure below.  All the char 
> fields are just dummy values to test data alignment issues when 
> sending the structure over the network to my PC.  Apparently, the PC 
> compiler

You should never send structures to another platform in the hope that
the alignment of structures (and data widths of the members) are the
same. If both targets use the same alignment style and endianes this
might work, you could check this by populating a structure on both
targets in the same way and comparing the actual memory content.

> I've forgotten how to read floats in hex! :)

That what computers are for:

     float f = 10.0;

     if(sizeof(f) == 4)
          printf("Your float reads %08X in hex.\n", *(int *) &f);

(you C ...)

Regards,

     Rob Jansen

Software Engineer
Competence Center Platforms
BU Mobile Communications
Meijhorst 60-10, 6537 KT Nijmegen, The Netherlands
Tel: +31-24-353-6329
Fax: +31-24-353-3613
mailto:Rob.WJ.Jansen@philips.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]