"Jason Dawes" <[EMAIL PROTECTED]> wrote in message
news:11873@palm-dev-forum...
>
> At 12:55 PM 5/17/00 -0400, you wrote:
> >
> > Extern MSLErr MSLOpen( UInt uRefNum ) SYS_TRAP ( sysLibTrapOpen );
> >
>
> I was going to say "find out what the SYS_TRAP macro is defined as - you
> might be able to build a dynamic version", but it uses an undocumented
> compiler define __attribute__.

If you decompose that function as the compiler sees it,
SYS_TRAP( sysLibTrapOpen )       ->
SYS_TRAP( 0xA801 )               ->
// SYS_TRAP decomposes into TWOWORD_INLINE at this point
TWOWORD_INLINE(m68kTrapInstr+sysDispatchTrapNum,0xA801)   ->
TWOWORD_INLINE( 0x4E40 + 15, 0xA801)     ->
TWOWORD_INLINE( 0x4E4F, 0xA801 )  ->
0x4E4F, 0xA801

The resulting assembly, once the compiler adds its move.w of uRefNum, is
this:
00000040: 3F2E FFFE          move.w    -2(a6),-(a7)
00000044: 4E4F               trap      #15
00000046: A801               _SndDisposeChannel

That is,
"move the refNum onto the stack,"
"Call the shared library trap dispatcher, which will pick up the refNum off
the stack,"
"Pass it A801 as the address of the function to run."

See http://oasis.palm.com/dev/kb/article.cfm?id=1670 for the whole story.
All this comes out of that article.

I was told by Palm that the two separate argument-passing mechanisms was for
efficiency.

-Jeff Ishaq



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to