ts-7000
[Top] [All Lists]

[ts-7000] Re: transferring floating point data from PC to TS7300

To:
Subject: [ts-7000] Re: transferring floating point data from PC to TS7300
From: "Oguz Dilmac" <>
Date: Tue, 20 Feb 2007 06:54:39 -0000
My previous poject was running on TMS320C30. It has a native floating
point format which is different from IEEE format. That's why I
initially thought this was the problem :(

But thanks for struct alignment hints. 

Best regards,
Oguz.

--- In  "Don W. Carr" <> wrote:
>
> First, I do not know of ANY processor that has not adopted the
standard IEEE
> format for 4 byte and 8 byte floating point numbers. There should
never be
> ANY problem with the floating point numbers themselves. Integers, yes.
> 
> But, there is the problem of alignment, where, depending on the
> architecture, floating point numbers MUST be aligned on an even 2,
4, or 8
> byte boundary. So, compilers will even automatically byte pad
structures, to
> be sure that every structure in an array of structures, is aligned.
Thus, if
> you run the program below, depending on your architecture, the size
of the
> given structure could be either 9, 12, or 16, depending on BOTH
architecture
> and compiler. For instance, early Borland compilers were optimized
for space
> instead of time, and allocated only 9 bytes for the structure below, and
> then, at runtime, copied floating point numbers to an aligned memory
> location before accessing.
> 
> If you look at the assembly language output of your compiler, it can be
> quite interesting at times.
> 
> As a general rule, NEVER pass structures between computers, and
never read
> or write floating point numbers copied to buffers that are not known
to be
> aligned. You must first copy them to know aligned areas using memcpy().
> Hint: malloc() always returns memory, whose start is aligned for ALL
data
> types.
> 
> Don.
> 
> #include <stdio.h>
> 
> typedef struct mys_t
> {
>   double d;
>   char c;
> };
> 
> 
> int main(int argc, char *argv[])
> {
>   mys_t mys;
> 
>   printf("sizeof(mys) = %d\n", sizeof(mys));
> }
> 
> On 2/17/07, Oguz Dilmac <> wrote:
> >
> >   Hi all,
> >
> > I'm trying to pass some data from my pc to ts7300 via Ethernet.
> > It seems floating point formats of EP9302 and PC are different from
> > each other.
> >
> > In my program, I have a struct with both floating point and integer
> > variables. I simply send this data to ethernet from PC. On the arm
> > side, a user program gets the data from socket and put it to a FIFO to
> > pass to a kernel module. Then I print them with rt_printk.
> >
> > When I dmesg, Integer parts are OK. But float parts are garbage.
> >
> > I also tried to define three float variables in the module. Add them
> > to each other and print their values. They are OK too. No problem so
> > far with FPU or GCC or rt_printk.
> >
> > How can I convert from PC float format to ARM float format?
> > (A link which describes these formats also would be great :) )
> >
> > Or am I missing some obvious point?
> >
> > Best regards,
> > Oguz.
> >
> >  
> >
> 
> 
> 
> -- 
> Dr. Don W. Carr
> J. G. Montenegro 2258
> Guadalajara, Mexico
> +52-333-630-0704
> +52-333-836-4500 ext 2930
>




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU