Asembler wbudowany (C)Inline Assembler (C)
Specyficzne dla firmy MicrosoftMicrosoft Specific
Wbudowany asembler umożliwia osadzenie instrukcji języka asemblera bezpośrednio w programach źródłowych C bez dodatkowych kroków zestawu i łącza.The inline assembler lets you embed assembly-language instructions directly in your C source programs without extra assembly and link steps. Wbudowany asembler jest wbudowany w kompilator — nie potrzebujesz oddzielnego asemblera, takiego jak asembler programu Microsoft Macro (MASM).The inline assembler is built into the compiler — you don't need a separate assembler such as the Microsoft Macro Assembler (MASM).
Ponieważ wbudowany asembler nie wymaga oddzielnego zestawu i kroków łączy, jest bardziej wygodne niż oddzielny asembler.Because the inline assembler doesn't require separate assembly and link steps, it is more convenient than a separate assembler. Wbudowany kod asemblera może używać dowolnej zmiennej języka C lub nazwy funkcji, która znajduje się w zakresie, dzięki czemu można łatwo zintegrować ją z kodem C programu.Inline assembly code can use any C variable or function name that is in scope, so it is easy to integrate it with your program's C code. I ponieważ kod zestawu może być mieszany z instrukcjami języka C, można wykonywać zadania, które są nieskomplikowane lub niemożliwe w języku C.And because the assembly code can be mixed with C statements, it can do tasks that are cumbersome or impossible in C alone.
__asm
Słowo kluczowe wywołuje asembler wbudowany i może występować wszędzie tam, gdzie instrukcja C jest prawna.The __asm
keyword invokes the inline assembler and can appear wherever a C statement is legal. Nie może być wyświetlana sama przez siebie.It cannot appear by itself. Po nim musi następować instrukcja zestawu, Grupa instrukcji ujętych w nawiasy klamrowe lub, co najmniej, pustą parę nawiasów klamrowych.It must be followed by an assembly instruction, a group of instructions enclosed in braces, or, at the very least, an empty pair of braces. Termin " __asm
blok" odnosi się do dowolnej instrukcji lub grupy instrukcji, niezależnie od tego, czy znajdują się w nawiasach klamrowych.The term "__asm
block" here refers to any instruction or group of instructions, whether or not in braces.
Poniższy kod to prosty __asm
blok ujęty w nawiasy klamrowe.The code below is a simple __asm
block enclosed in braces. (Kod jest sekwencją funkcji niestandardowej.)(The code is a custom function prolog sequence.)
__asm
{
push ebp
mov ebp, esp
sub esp, __LOCAL_SIZE
}
Alternatywnie możesz umieścić __asm
przed każdą instrukcją zestawu:Alternatively, you can put __asm
in front of each assembly instruction:
__asm push ebp
__asm mov ebp, esp
__asm sub esp, __LOCAL_SIZE
Ponieważ __asm
słowo kluczowe jest separatorem instrukcji, można również umieścić instrukcje zestawu w tym samym wierszu:Since the __asm
keyword is a statement separator, you can also put assembly instructions on the same line:
__asm push ebp __asm mov ebp, esp __asm sub esp, __LOCAL_SIZE
ZAKOŃCZENIE określonych przez firmę MicrosoftEND Microsoft Specific