Re: CW inline assembly and Rosetta



I was most concerned with the access of global variables. Is what is shown in any way CodeWarrior-specific (I hope not!)?

Anon wrote:

In article <dbm19q$5ra$1@xxxxxxxxxxxxxxxxxxx>,
 Michael McLaughlin <mpmcl@xxxxxxxxx> wrote:


Apologies if this is a bit off-topic.

The function below is the (PowerPC) core of a pseudo-random-number generator which is nearly four times faster than the best C equivalent I can write. [The basic operation, subtract-with-borrow (subfe), is a single instruction that must be simulated in C.]

Can anyone tell me whether Rosetta will handle a function like this, including fetching and storing the globals, or will I have to write an x86 assembly routine? [I do not have an x86 computer and have never written x86 assembly.]

Thanks in advance.

asm void URandomLib::Refill()
{
      lwz      r3,Ultra_brw      // fetch global addresses from TOC

. . .

      li       r5,148            // 4*37 bytes
      sth      r5,0(r7)          // reinitialize
      blr
}

--
Mike McLaughlin


The only reason Rosetta would not be able to handle it is if any of those instructions are not available on a G3. I don't believe that is the case so it should be fine. However, it will almost certainly be slower under emulation.

Chris.
.