[futurebasic] Re: [FB] [FB^3] Converting 68k toolbox to ppc toolbox

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1999 : Group Archive : Group : All Groups

From: Derek Smith <dereksmi@...>
Date: Sun, 19 Sep 1999 13:02:57 -1000
On Sun, 19 Sep 1999, Dr. Steven J. Stratford wrote:

> Followup on my own message---
> <previous message>
> Here's the old assembly code which works perfectly:
> LOCAL FN YieldToAnyThread
>    '---------------------------------------
>    `     CLR.W     -(SP)
>    `     DC.W      $42A7,$303C,$0205,$ABF2
>    `     MOVE.W    (SP)+,D0
>    `     EXT.L     D0
> END FN = REGISTER(D0)                             'OSErr
> Here's the new TOOLBOX code I wrote:
> TOOLBOX FN YieldToAnyThread = WORD `0x42A7,0x303C,0x0205,0xABF2
> This works in cpu68k mode but crashes in cpuPPC compiler mode.
> </end previous message>
> <new info>
> The Apple Thread Manager docs state that "Threads must yield in the 
> CPU addressing mode (24 or 32 bit) in which the application was 
> launched." So I bet what's happening is that the TOOLBOX command 
> switches to emulation mode from PPC mode and that's what's causing 
> the crash.
> So--looks like I need BEGINASSEM to generate PPC code. Can someone 
> help convert my YieldToAnyThread function into PPC toolbox code?
> Also, how about PPC assembly code snippets to do the same thing with
> (1) toolbox fns that take 2- and 4-byte arguments
> (2) toolbox fns that have VAR arguments
> (3) toolbox fns that don't return a value

> (I'm hoping that there _IS_ a pattern in the assembly code we can 
> follow, just like with the 68k assembly code)
> </new info>

Aaaaaagh no!  The TOOLBOX statement does NOT do a mode switch!!  In PPC
mode it compiles into a ppc native toolbox call.  In 68k mode it compiles
into a 68k native toolbox call.

The reason this is crashing is because in PPC Mac OS the Thread Manager
lives inside a Shared Library.  What you must do here is tell FB what
library that is.

LIBRARY "ThreadManagerLib"  'or ThreadLib, I can't remember
TOOLBOX FN YieldToAnyThread = WORD `0x42A7,0x303C,0x0205,0xABF2

Your crash is because the powerpc functions are jumped to by their names
and no function with the name YieldToAnyThread exists in the default