>I am trying to modify an existing PEF-based threads library to work
>under Mach-O. One critical function must be written in assembly
[quoted text clipped - 22 lines]
>data references relative to that point? I have not found any special
>name or assembler directive that does the trick.
Hi,
Sorry for the delay in replying. I was hoping someone could help, but
when no one did I asked one of our PowerPC engineers... he said.
I generally look to the runtime libraries for examples, in this case
there is an assembler directive: picbase which associates a picbase
register with it's label:
runtime.c: __cvt_fp2unsigned()
asm unsigned long __cvt_fp2unsigned(register double d)
{
#if __MACH__
mflr r0
bcl 20,31,@1
@1 mflr r4
picbase r4,@1
addis r4,r4,ha16(__constants)
la r4,lo16(__constants)(r4)
// restore the link register (I moved down here as scheduling)
mtlr r0
#else
entry __uitrunc
lwz r4,__constants(RTOC)
#endif
It is important to use "bcl 30,31,@1" to avoid link register stack
delays which happen when using "bl" to compute the address of the next
instruction (code will run correctly but might be slower).
again my apology for the delay.
Ron

Signature
Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
-- http://www.metrowerks.com/community --
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com