home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC / src / olecall.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  5.3 KB  |  168 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFX_OLE5_SEG
  14. #pragma code_seg(AFX_OLE5_SEG)
  15. #endif
  16.  
  17. // Note: because of the nature of these functions, it is not possible
  18. //  to create a 'C' or 'C++' version of them.  These functions are used
  19. //  for the lowest level of the OLE IDispatch implementation, and need
  20. //  to be ported to each supported platform.
  21.  
  22. extern "C" {
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // Intel 386 version
  26.  
  27. #ifdef _X86_
  28.  
  29. __declspec(naked) void AFXAPI
  30. _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  31. {
  32.     _asm
  33.     {
  34.         pop     edx         // edx = return address
  35.         pop     eax         // eax = pfn
  36.         pop     ecx         // ecx = pArgs
  37.         add     ecx,[esp]   // ecx += nSizeArgs (=scratch area)
  38.         mov     [ecx],edx   // scratch[0] = return address
  39.         sub     ecx,[esp]   // ecx = pArgs (again)
  40.         mov     esp,ecx     // esp = pArgs (usually already correct)
  41.         pop     ecx         // ecx = this pointer (the CCmdTarget*)
  42.         call    eax         // call member function
  43.         ret                 // esp[0] should = scratch[0] = return address
  44.     }
  45. }
  46. #endif // _X86_
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // MIPS R4000 version
  50.  
  51. #ifdef _MIPS_
  52.  
  53. extern "C" void _asm(char *, ...);
  54. void AFXAPI
  55. _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  56. {
  57.     _asm("addiu     %sp,%a1,0x0");      // sp = pArgs
  58.     _asm("addiu     %t6,%a0,0x0");      // t6 = pfn (save it)
  59.     _asm("lw        %a0,0x0(%sp)");     // a0 = param0
  60.     _asm("lw        %a1,0x4(%sp)");     // a1 = param1
  61.     _asm("lw        %a2,0x8(%sp)");     // a2 = param2
  62.     _asm("lw        %a3,0xc(%sp)");     // a3 = param3
  63.     _asm("j         %t6");              // ip = pfn (jump to target function)
  64. }
  65.  
  66. #endif // _MIPS_
  67.  
  68. /////////////////////////////////////////////////////////////////////////////
  69. // SH version
  70.  
  71. #if defined(_WIN32_WCE) 
  72.  
  73. #ifdef x86
  74.  
  75. __declspec(naked) void AFXAPI
  76. _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  77. {
  78.     _asm
  79.     {
  80.         pop     edx         // edx = return address
  81.         pop     eax         // eax = pfn
  82.         pop     ecx         // ecx = pArgs
  83.         add     ecx,[esp]   // ecx += nSizeArgs (=scratch area)
  84.         mov     [ecx],edx   // scratch[0] = return address
  85.         sub     ecx,[esp]   // ecx = pArgs (again)
  86.         mov     esp,ecx     // esp = pArgs (usually already correct)
  87.         pop     ecx         // ecx = this pointer (the CCmdTarget*)
  88.         call    eax         // call member function
  89.         ret                 // esp[0] should = scratch[0] = return address
  90.     }
  91. }
  92.  
  93. #endif // x86
  94.  
  95. #if defined(SHx)
  96.  
  97. void AFXAPI _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  98. {
  99.     __asm("mov   R5, sp");                // sp = pStack
  100.     __asm("mov   R4, R1");                // R1 = pfn (save it)
  101.     __asm("mov.l @sp, R4");               // R4 = arg1 ('this' pointer)
  102.     __asm("mov   #4, R0");                // R5 = arg2
  103.     __asm("mov.l @(R0,sp), R5");
  104.     __asm("mov   #8, R0");                // R6 = arg3
  105.     __asm("mov.l @(R0,sp), R6");
  106.     __asm("mov  #12, R0");                // R7 = arg4
  107.     // __asm("mov.l @(R0,sp), R7"); moved to delay slot
  108.     __asm("jmp  @R1\n"                    // jump to target function
  109.           "mov.l @(R0,sp), R7");
  110. }
  111.  
  112. #endif // SHx
  113.  
  114. #ifdef _ARM_
  115.  
  116. void AFXAPI _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  117. {
  118.     // Set up the stack pointer. Note that the first four dwords of arguments
  119.     // are saved on the callee's stack so 16 is added to the pointer to
  120.     // the arguments.
  121.     __emit(0xe281d010);     // add  sp, r1, #16
  122.  
  123.     // Save the function pointer in r12 (the only available scratch register)
  124.     __emit(0xe1a0c000);     // mov  r12, r0
  125.  
  126.     // Copy four words of arguments into r0-r3
  127.     __emit(0xe5910000);     // ldr  r0, [r1]
  128.     __emit(0xe5912008);     // ldr  r2, [r1, #8]
  129.     __emit(0xe591300c);     // ldr  r3, [r1, #12]
  130.     __emit(0xe5911004);     // ldr  r1, [r1, #4]
  131.  
  132.     // Jump to the function
  133.     __emit(0xe1a0f00c);     // mov  pc, r12
  134. }
  135.  
  136. #endif // _ARM_
  137.  
  138. #ifdef _PPC_
  139. void AFXAPI _AfxDispatchCall(AFX_PMSG /*pfn*/, void* /*pArgs*/, UINT /*nSizeArgs*/)
  140. {
  141.     __emit(0x7C812378); // mr          r1,r4
  142.     __emit(0x7C6903A6); // mtctr       r3
  143.     __emit(0x80610000); // lwz         r3,0(r1)
  144.     __emit(0x80810004); // lwz         r4,4(r1)
  145.     __emit(0x80A10008); // lwz         r5,8(r1)
  146.     __emit(0x80C1000C); // lwz         r6,0Ch(r1)
  147.     __emit(0x4E800420); // bctr
  148. }
  149. #endif // PPC
  150.  
  151. #endif // _WIN32_WCE
  152.  
  153. /////////////////////////////////////////////////////////////////////////////
  154. // DEC Alpha AXP version
  155.  
  156. #ifdef _ALPHA_
  157.  
  158. // Note: ALPHA version is in src\alpha\olecall_.s
  159.  
  160. // The ALPHA compiler does not support inline assembly, so it
  161. //  must be build separately with the ASAXP assembler.
  162.  
  163. #endif // _ALPHA_
  164.  
  165. } // end extern "C" block
  166.  
  167. /////////////////////////////////////////////////////////////////////////////
  168.