From: Richard C. <rd_...@sb...> - 2003-11-24 07:50:13
|
I ran into 2 problems making the asset compiler on Mac OS X: using the makefile, ZByteSwap fails while compiling the release version (optimization flag -O2): {standard input}:1844:Parameter error: r0 not allowed for parameter 3 (code as 0 not r0) {standard input}:1869:Parameter error: r0 not allowed for parameter 3 (code as 0 not r0) Looking at the intermediate assembly file reveals the culprit: stw r2, 0(r0) The corresponding source looks like this: inline void ZByteSwap_32(register void* iValueAddress) { register int32 temp; asm ( "lwbrx %0, 0, %2\n" "stw %0, 0(%2)\n" : "=&r" (temp), "=m" (*(int32*)iValueAddress) : "r" (iValueAddress) : "cc" ); } But, if GCC optimizes iValueAddress into r0, the assembly will fail. (r0 gets special treatment in PPC assembly; it can't be used in the same way as the other GPRs.) We need to force gcc not to use that as a working register, and the easiest way is to force it is to make GCC use r0 for temp. The fix: change register int32 temp; to register int32 temp asm("r0"); in both inline void ZByteSwap_16(register void* iValueAddress) and inline void ZByteSwap_32(register void* iValueAddress) (It helps that I used to teach PowerPC assembly development for Apple ;)) ...Richard |