H
hamze
hi,
I have some double precision numbers ( 64bit) which should be
transmitted and received via two FIFOs.
for example like below;
double d1, d2;
d1 = 3.2
send(d1);
d2 = receive(d2);
but my FIFOs are 32bit not 64bit so I must break double number before
send or concatenate them after reception. gcc compiler prohibit me to
break a 64 bit double to two 32 bit integesrs by below lines
first 32 bit : * ( (int *) ( &d_num) )
last 32 bit : * ( (int *) ( &d_num) +1 )
because it says that cast between double and int pointer is not
allowed. then I use void * :
first 32 bit : * ( (int *) (void *) ( & d_num ) )
last 32 bit : * ( (int *) (void *) ( & d_num ) +1 )
I used this way to break a double number for sending and also give
value to a double number which is received.
Now problem is :
when I turn compiler optimization ON there are some strange
problems!,
after debugging assembly code I understood that compiler can not
understand CHANGE or USAGE of a double variable by above lines, so
optimization mix up my code.
how can I solve this problem in an efficient way?
I have some double precision numbers ( 64bit) which should be
transmitted and received via two FIFOs.
for example like below;
double d1, d2;
d1 = 3.2
send(d1);
d2 = receive(d2);
but my FIFOs are 32bit not 64bit so I must break double number before
send or concatenate them after reception. gcc compiler prohibit me to
break a 64 bit double to two 32 bit integesrs by below lines
first 32 bit : * ( (int *) ( &d_num) )
last 32 bit : * ( (int *) ( &d_num) +1 )
because it says that cast between double and int pointer is not
allowed. then I use void * :
first 32 bit : * ( (int *) (void *) ( & d_num ) )
last 32 bit : * ( (int *) (void *) ( & d_num ) +1 )
I used this way to break a double number for sending and also give
value to a double number which is received.
Now problem is :
when I turn compiler optimization ON there are some strange
problems!,
after debugging assembly code I understood that compiler can not
understand CHANGE or USAGE of a double variable by above lines, so
optimization mix up my code.
how can I solve this problem in an efficient way?