When embedding assembler code in a C / C ++ program, you can avoid scrambling registers by saving them using the push command (or specifying a compiler compiler list).
If you turn on the inline assembly and want to avoid the overhead of pushing and popping scrambled registers, is there a way to let gcc select the registers for you (for example, those that it knows do not have any useful information in them).
. , ( ) , . . . , :
asm("your assembly instructions" : output1("=a"), // I want output1 in the eax register output2("=r"), // output2 can be in any general-purpose register output3("=q"), // output3 can be in eax, ebx, ecx, or edx output4("=A") // output4 can be in eax or edx : /* inputs */ : /* clobbered registers */ );
intrinsics - C/++. , , ( ). , .
, C , . ,
struct TwoVectors { __m128 a; __m128b; } // adds two vectors A += B using the native SSE opcode inline void SimdADD( TwoVectors *v ) { v->a = _mm_add_ps( v->a , v->b ); // compiles directly to ADDSS opcode }
, , , ( ):
asm ( "your assembly instructions" : "=a"(output1), "=r"(output2), "=q"(output3), "=A"(output4) : /* inputs */ : /* clobbered registers */ );
, , / (.. , ). clobber (, "% xmm1", "% rcx" ), , , . , .
Source: https://habr.com/ru/post/1709453/More articles:working with very large integers in C # - c #List.Sort IComparer performance - sortingHow can I get form1 to update when I close form2 - c #How to create custom statements in C # / VS? - c #Built-in data warehouse for commercial Windows applications? - databaseError "isEqualToString" Cocoa - objective-cWhy am I getting the isEqualToString error in this Cocoa code? - objective-c"звуковые", "Вы имели в виду функциональность THAT", используя полнотекстовый поиск в SQL Server 2005 - sql-serverTracking other peoples projects with git - gitC / C ++ USB Drive Event - c ++All Articles