Inline assembly - How to deal with arrays in AT&T style?
by vmelkon from LinuxQuestions.org on (#6KAVA)
Hello all,
I know that there are many choices in the world of programming ...
In my case, I have some code that I had written in Intel style for Microsoft VC++ 6. It uses 32 bit addresses. It uses some ordinary x86 instructions and also MMX at some places and SSE at some places.
On Linux, I use Qt Creator as my IDE. I think that underneath it, it uses the g++ compiler.
Step 1: I updated the code to use 64 bit addresses.
Step 2: There are more registers. So I did minor changes to use more registers.
Step 3: Compile the Intel code under Linux? Some people mention using a compiler flag for gcc. I did not do this.
Step 4: So, I learned AT&T style. I learned asm extended assembly for gcc and went ahead and converted from Intel Style to AT&T style. (Maybe Iim nuts?)
Step 5: That %0, %1, %2 stuff. Oh boy! Too late did I learn that it is possible to use labels.
MY MAIN QUESTION:
In my Intel style code, I have
Code:addps xmm0, xmmword ptr[Global_NfloatArray]where Global_NfloatArray is some float array.
In AT&T style
Code:addps %0, %%xmm0;where %0 represents Global_NfloatArray.
It compiles but doesnit work.
I think it is because it copies the address to xmm0 instead of referencing the RAM pointed to by pointer Global_NfloatArray
So, I guess I need to write
Code:addps (%0), %%xmm0;but that doesnit compile.
Another case:
In my Intel style code, I have
Code:fld dword ptr[t1]
fld dword ptr[t1+4]In AT&T style
Code:fld %1; ?????????
fld %1+4;where %1 is float t1[100]
I tried to learn by example but canit find what I am looking for.
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
I know that there are many choices in the world of programming ...
In my case, I have some code that I had written in Intel style for Microsoft VC++ 6. It uses 32 bit addresses. It uses some ordinary x86 instructions and also MMX at some places and SSE at some places.
On Linux, I use Qt Creator as my IDE. I think that underneath it, it uses the g++ compiler.
Step 1: I updated the code to use 64 bit addresses.
Step 2: There are more registers. So I did minor changes to use more registers.
Step 3: Compile the Intel code under Linux? Some people mention using a compiler flag for gcc. I did not do this.
Step 4: So, I learned AT&T style. I learned asm extended assembly for gcc and went ahead and converted from Intel Style to AT&T style. (Maybe Iim nuts?)
Step 5: That %0, %1, %2 stuff. Oh boy! Too late did I learn that it is possible to use labels.
MY MAIN QUESTION:
In my Intel style code, I have
Code:addps xmm0, xmmword ptr[Global_NfloatArray]where Global_NfloatArray is some float array.
In AT&T style
Code:addps %0, %%xmm0;where %0 represents Global_NfloatArray.
It compiles but doesnit work.
I think it is because it copies the address to xmm0 instead of referencing the RAM pointed to by pointer Global_NfloatArray
So, I guess I need to write
Code:addps (%0), %%xmm0;but that doesnit compile.
Another case:
In my Intel style code, I have
Code:fld dword ptr[t1]
fld dword ptr[t1+4]In AT&T style
Code:fld %1; ?????????
fld %1+4;where %1 is float t1[100]
I tried to learn by example but canit find what I am looking for.
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html