Skip to content
Snippets Groups Projects
Commit b4250e4d authored by Erik von Reis's avatar Erik von Reis
Browse files

RCG DEMOD: Protect %rax from getting clobbered in sincos assembly

Some code in the demod rotation calcs was compiled with the assumption that %rax was preserved across a call to sincos.
This is not the case.  Now sincos saves %rax on the stack.
parent e975d158
No related branches found
No related tags found
2 merge requests!439RCG 5.0 release fro deb 10,!409RCG: avx demod parts added
......@@ -87,6 +87,7 @@ void avx_rotation_struct_set_frequency(avx_rotation_struct* self, double freq, u
if (idx >= MAX_STRIDE) return;
self->freqhist[idx] = freq;
sincos(freq * self->two_pi_over_rate, self->anglexy + 2 * idx + 1, self->anglexy + 2 * idx + 0);
RTSLOG_DEBUG("sin=%d cos=%d\n", (int)(1000000.0*self->anglexy[2*idx+1]), (int)(1000000.0*self->anglexy[2*idx]));
}
......
......@@ -39,7 +39,8 @@ sincos( double __x, double* __sinx, double* __cosx )
{
register long double __cosr;
register long double __sinr;
__asm __volatile__( "fsincos\n\t"
__asm __volatile__( "push %%rax\n\t"
"fsincos\n\t"
"fnstsw %%ax\n\t"
"testl $0x400, %%eax\n\t"
"jz 1f\n\t"
......@@ -52,7 +53,7 @@ sincos( double __x, double* __sinx, double* __cosx )
"jnz 2b\n\t"
"fstp %%st(1)\n\t"
"fsincos\n\t"
"1:"
"1: pop %%rax\n\t"
: "=t"( __cosr ), "=u"( __sinr )
: "0"( __x ) );
*__sinx = __sinr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment