Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #ifdef _MSC_VER //**************************************** For Microsoft Compiler **********************************
- #ifdef __GNUC__ //******************************************** For GCC Compiler ***********************************
- #ifdef _TINYC_ //******************************************** For TCC Compiler **********************************
- */
- #include <stdio.h>
- int add(int n1, int n2);
- ////////////////////////////////////////////////////////
- int main()
- {
- int n = add(2, 38);
- printf("n = %d\n", n);
- return 0;
- }
- #ifdef _MSC_VER
- ////////////////////////////////////////////////////
- int add(int n1, int n2)
- {
- __asm
- {
- mov eax, n1
- mov ebx, n2
- add eax, ebx
- }
- }
- #endif
- #ifdef __GNUC__
- ////////////////////////////////////////////////////
- int add(int n1, int n2)
- {
- __asm__
- (
- " mov eax, %0 ;"
- " mov ebx, %1 ;"
- " add eax, ebx ;"
- " mov %0, eax ;"
- ::
- "m"(n1),
- "m"(n2)
- :"%eax",
- "%ebx"
- );
- return n1;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement