How is assembly language included in the program?

I read in many places that assembly language is usually not used to create complete programs, but is used by other programs to make some procedures more efficient, especially those that are called pairs of thousands of times per second. I am wondering how the small bits of the assembly code are included in larger programs.

  • I thought it was possible to make a small executable file and then run from another program, but that seems inefficient.

  • Then I thought about the built-in assembly for Visual Studio, but what is typical for Microsoft and it seems that there would be a better way.

So, how can you use the small bits of the assembly code in a larger program without creating separate programs or using the built-in Visual Studio assembly?

+3
source share
4 answers

Here's an example (GCC):

__asm__ ("movl %eax, %ebx\n\t"
"movl $56, %esi\n\t"
"movl %ecx, $label(%edx,%ebx,$4)\n\t"
"movb %ah, (%ebx)");

For Microsoft Inline Assembly, the __asm ​​keyword, assembly code is wrapped in curly braces, this is not a string, but the destination register is now on the left.

Microsoft example:

int foo(void) {
  __asm{
   mov eax,100 ; Moves 100 into eax!
   leave
   ret
  };
}

Links for more information

Instructions and links for embedded installation: http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

IBM x86-specific tutorial: http://www.ibm.com/developerworks/linux/library/l-ia.html

+1
source

Visual Studio - GCC . . - , - , Microsoft x64 .

, , , , ++. . , - .

+5

Visual Studio, , Microsoft, , .

, .

, , . .

+1

, , . Microsoft! (GCC , ).

(, ) ( , ), , .

, , , , ( ). , , ( ).

0

Source: https://habr.com/ru/post/1710880/


All Articles