Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22248

Understanding GCC inline assembly code that uses memory source operands and x87 fcomi / fcmov

$
0
0

I'm reading the research paper Privado: Practical and Secure DNN Inference to hide the input-dependent branch. I am trying to understand the following GCC assembly code in that paper:

float temp;asm volatile("fld %2 \n""fld %3 \n""fcomi \n""fcmovbe %%st(1), %%st \n""fstp %0 \n""fstp %1 \n"      :"=m"(maxval), "=m"(temp)      :"m"(val), "m"(maxval));

I am confused about what each line of the code means. What does %%st(1),%%st mean? Why are there %0,%1,%2,%3 when there are only three variables temp, maxval and val?

I know the function of this code is similar to:

if(val>maxval)   maxval=val;

But I don't know how the code operates internally. I want to change the code slightly into:

if(val>maxval)    val2=maxval;

where val2 is a new variable


Viewing all articles
Browse latest Browse all 22248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>