#Pascal->asm->C
A friend is having a problem that I am unable to help with, so I promised to
ask the combined genius here on CI$ and see if someone else knows. Since I do
not know assembly (or at least haven't looked at it since 1980), I'm not really
in a position to give them an answer.
They have a MPW Pascal program that was converted to Think C. It now works,
but there is one function that is much slower than it was before. They believe
that this is likely the result of the way one function was converted. Since it
was inline assembly code, I can't really help.
The original code was:
FUNCTION CallTLPM(tlCode: INTEGER; pmParams: PMParamPtr;theProc: ProcPtr):
OSErr;
INLINE $205f,$4e90;
{——————————————————————-}
{ This procedure is a glue routine for jumping into an executable }
{ block of memory pointed to by the handle "tlProtocol" – a handle }
{ detached from a protocol handler resource. The routine passes }
{ to the protocol handler a "tlCode" (ie: open, close, write, read) }
{ and a parameter block "pmParams". The protocol handler will }
{ return its result as the function result of this glue routine. }
{ }
{ The INLINE code translates into: }
{ MOVEA.L (SP)+,A0 ; $205f }
{ JSR (A0) ; $4e90 }
{——————————————————————-}
This was converted to the following:
//===================================================================
pascal OSErr CallTLPM
(
short tlCode,
PMParamPtr pmParams,
ProcPtr theProc
)
{
OSErr err;
// we put our assembly code here to call the TLPM code resource proc
// since had problems reading the function arguments, we pass the
// arguments on stack again. Inefficient but works !
asm{
move.l tlProc, a0
clr.w -(sp) // make space for result
move.w tlCode, -(SP)
move.l pmParams, -(sp)
jsr (a0) // call code resource
// we should pop off 6 bytes off stack here but
// it appears that the TLPM code does it for us, so not necessary
move.w (sp)+, err // pop up result
}
return( err );
}
As I said, the code _does_ work, but appears to be a bottleneck somehow. Any
suggestions are greatly appreciated!
– Burt