Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1761 from guwirth/asm-label
improve inline assembler support for VC & GCC
- Loading branch information
Showing
6 changed files
with
151 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
cxx-squid/src/test/resources/parser/GCC/inline-assembler.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
void main() | ||
{ | ||
asm("movl %ecx %eax"); /* moves the contents of ecx to eax */ | ||
__asm__("movb %bh (%eax)"); /*moves the byte from bh to the memory pointed by eax */ | ||
|
||
__asm__ ("movl %eax, %ebx\n\t" | ||
"movl $56, %esi\n\t" | ||
"movl %ecx, $label(%edx,%ebx,$4)\n\t" | ||
"movb %ah, (%ebx)"); | ||
|
||
// Qualifiers | ||
asm volatile ( "movl %ecx %eax" ) | ||
asm __volatile__ ( "movl %ecx %eax" ) | ||
asm inline ( "movl %ecx %eax" ) | ||
__asm__ volatile ( "movl %ecx %eax" ) | ||
__asm__ __inline__ ( "movl %ecx %eax" ) | ||
__asm__ inline ( "movl %ecx %eax" ) | ||
|
||
// Extended Asm | ||
int a=10, b; | ||
asm ("movl %1, %%eax; | ||
movl %%eax, %0;" | ||
:"=r"(b) /* output */ | ||
:"r"(a) /* input */ | ||
:"%eax" /* clobbered register */ | ||
); | ||
} | ||
|
||
// Asm Labels: | ||
|
||
// Assembler names for data: | ||
int foo1 asm ("myfoo1") = 2; | ||
int foo2 __asm__ ("myfoo2") = 2; | ||
extern const char cert_start1[] asm("_binary_firmware_pho_by_crt_start1"); | ||
extern const char cert_start2[] __asm__("_binary_firmware_pho_by_crt_start2"); | ||
|
||
// Assembler names for functions: | ||
int func2 (int x, int y) asm ("MYFUNC1"); | ||
int func3 (int x, int y) __asm__ ("MYFUNC2"); | ||
|
||
// support workaround | ||
#define __asm__ asm | ||
void func() | ||
{ | ||
__asm__("movl %ecx %eax"); | ||
} |
28 changes: 28 additions & 0 deletions
28
cxx-squid/src/test/resources/parser/VC/inline-assembler.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// asm_overview.cpp | ||
// processor: x86 | ||
void main() | ||
{ | ||
// Naked functions must provide their own prolog... | ||
__asm { | ||
push ebp | ||
mov ebp, esp | ||
sub esp, __LOCAL_SIZE | ||
} | ||
|
||
// ... and epilog | ||
__asm { | ||
pop ebp | ||
ret | ||
} | ||
|
||
__asm push ebp; | ||
__asm mov ebp, esp; | ||
__asm sub esp, __LOCAL_SIZE; | ||
} | ||
|
||
// support workaround | ||
#define __asm asm | ||
void func() | ||
{ | ||
__asm push ebp; | ||
} |