Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC Assembly "+t"

Tags:

c++

c

x86

gcc

assembly

I'm currently testing some inline assembly in C++ on an old compiler (GCC circa 2004) and I wanted to perform the square root function on a floating point number. After trying and searching for a successful method, I came across the following code

float r3(float n){
    __asm__("fsqrt" : "+t" (n));
    return n;
};

which worked. The issue is, even though I understand the assembly instructions used, I'm unable to find any particular documentation as to what the "+t" flag means on the n variable. I'm under the genuine idea that it seems to be a manner by which to treat the variable n as both the input and output variable but I was unable to find any information on it. So, what exactly is the "t" flag and how does it work here?

like image 330
Joe J. Avatar asked Apr 12 '17 00:04

Joe J.


1 Answers

+

Means that this operand is both read and written by the instruction. (From here)

t

Top of 80387 floating-point stack (%st(0)). (From here)

like image 77
Arash Avatar answered Sep 21 '22 10:09

Arash