Hey folks.  When I execute a function that is stored in a shared library
(MSLGetVersion), I get the following disassembly from Codewarrior:

MSLerr = MSLGetVersion( libRefNum1, &dwVer );
0000004A: 486E FFFA          pea       -6(a6)
0000004E: 3F2E FFFE          move.w    -2(a6),-(a7)
00000052: 4E4F               trap      #15
00000054: A805               _SndPlay
00000056: 1800               move.b    d0,d4

I understand what's going on here.  As a shared library function,
MSLGetVersion is defined to be this:

extern MSLErr MSLGetVersion (UInt uRefNum, DWordPtr dwVerP) SYS_TRAP(
MSLTrapGetVersion);

Note that MSLTrapGetVersion is == sysLibTrapCustom.

The body of the function, the SYS_TRAP call, expands into the 4E4F A805 that
you see in the disassembly.  Obviously, Codewarrior got confused and though
I was trying to call _SndPlay.  I'm not sure if 'trap #15' is reliable or
another product of Codewarrior confusion.

What happens here?  How does the OS get from this point to looking into
GSysLibTableP[myRefNum], and calling the fifth function in my lib's dispatch
table *dispatchTblP[5]?

Maybe the most elusive question of all is, how does it know which refNum's
SysLibTblEntry to use?  Surely I'm not the only shared library that could be
using sysLibTrapCustom one of its function's trap ID's.  Wouldn't that
generate the same code when run through SYS_TRAP?  I think so.

Hmm!
-jeff

Reply via email to