home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef USE_ASSEMBLY
- #define USE_ASSEMBLY 1 // set this to zero to never use inline assembly.
- #endif
-
- #ifndef USE_GENERIC_C
- #define USE_GENERIC_C 1 // set this to zero for separate asm files (no generic C)
- #endif
-
- ///--------------------------------------------------------------------------------------
-
- #if USE_ASSEMBLY && (TARGET_CPU_68K || GENERATING68K)
-
- #define USE_68K_ASSEMBLY 1
- #define USE_PPC_ASSEMBLY 0
- #define USE_X86_ASSEMBLY 0
-
- #elif USE_ASSEMBLY && (TARGET_CPU_PPC || GENERATINGPOWERPC)
-
- #define USE_68K_ASSEMBLY 0
- #define USE_PPC_ASSEMBLY 1
- #define USE_X86_ASSEMBLY 0
-
- #elif USE_ASSEMBLY && (TARGET_CPU_X86 || defined(_X86_) )
-
- #define USE_68K_ASSEMBLY 0
- #define USE_PPC_ASSEMBLY 0
- #define USE_X86_ASSEMBLY 1
-
- #else
-
- #define USE_68K_ASSEMBLY 0
- #define USE_PPC_ASSEMBLY 0
- #define USE_X86_ASSEMBLY 0
-
- #endif
-
- ///--------------------------------------------------------------------------------------
-
- #if USE_ASSEMBLY
-
- // INLINE ASSEMBLY declarations and explanations
-
- #if USE_68K_ASSEMBLY // Motorola 68020+ asm
-
- // note: all parameters on stack (A7) , fralloc gives us stack frame (A6) for args and locals
- // compiler generates global refs automatically, using either A4 or A5 (resource vs. app)
- // return value normally in D0/A0 (int vs. ptr)
-
- // note: registers D0-D2, A0-A1 are volatile
-
- #if __MWERKS__ // Metrowerks CodeWarrior
-
- #define ASM_FUNC asm
- #define ASM_BEGIN machine 68020; fralloc +
- #define ASM_END frfree; RTS
- #define ASM_NUM(x) %(x)
-
- #pragma code68020 on
-
- // determine size of an int (is it .L, or .W ?)
- #define LONGINTS __option(fourbyteints)
-
- #elif THINK_C // THINK C
-
- #define ASM_FUNC
- #define ASM_BEGIN asm 68020 {
- #define ASM_END }
- #define ASM_NUM(x) #(x)
-
- #pragma mc68020
-
- // determine size of an int (is it .L, or .W ?)
- #if __option(int_4)
- #define LONGINTS 1
- #else
- #define LONGINTS 0
- #endif
-
- #else
-
- #error Compiler unsupported for inline 68k assembly! (set USE_ASSEMBLY = 0)
-
- #endif
-
- #elif USE_PPC_ASSEMBLY // PowerPC asm
-
- // note: parameters implicitly in registers (r3-r10), no stack frame needed for args
- // global refs normally through RTOC (don't forget to deref to get the actual value)
- // return value normally in r3
-
- // note: registers r0, r3-r12, fp0-fp12, cr0-cr1, cr5-7 are volatile
-
- #if __MWERKS__ // Metrowerks CodeWarrior
-
- // note: to avoid CW wasting cycles by storing parameters automatically;
- // declare all parameters as 'register' locally, and never use a stack frame.
-
- #pragma warn_unusedarg off // avoids a warning, using param registers directly
-
- #define IF_NOT 0x04 // constant for BO field
-
- #define CR_NO 4 // multiplier for BI field no
- #define CR_LT 0 // constant for BI field
- #define CR_GT 1 // constant for BI field
- #define CR_EQ 2 // constant for BI field
- #define CR_SO 3 // constant for BI field
-
- #if __MWERKS__ > 0x2300 // <-- just guessing the version here, playing it safe
- #define ASM_NOFRALLOC nofralloc
- #else
- #define ASM_NOFRALLOC // (nofralloc = old default behaviour)
- #endif
-
- #define ASM_FUNC asm
- #define ASM_BEGIN ASM_NOFRALLOC
- #define ASM_END blr
- #define ASM_NUM(x) #(x)
-
- #else
-
- #error Compiler unsupported for inline PPC assembly! (set USE_ASSEMBLY = 0)
-
- #endif
-
- #elif USE_X86_ASSEMBLY // Intel x86 asm
-
- // note: all parameters on stack
-
- #if __MWERKS__ // Metrowerks CodeWarrior
-
- #define ASM_FUNC
- #define ASM_BEGIN asm {
- #define ASM_END }
- #define ASM_NUM(x) #(x)
-
- #else
-
- #error Compiler unsupported for inline X86 assembly! (set USE_ASSEMBLY = 0)
-
- #endif
-
- #else
-
- #error Platform unsupported for inline assembly! (set USE_ASSEMBLY = 0)
-
- #endif /* USE_***_ASSEMBLY */
-
- // These asm instructions written by Anders F Björklund in 1995-1999.
-
- #endif
-