Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1600
  • Last Modified:

PowerPC Assembler


I am trying to inline PPC assembler with Codewarrior 10 - but not the way it's normally done with CodeWarrior (without a function call if possible) and cannot figure out how to do it  Specifically, in the 68k world, I can use the following with no problems:

#pragma parameter SwitchStack(__A0)
extern void SwitchStack(SR *sr) =
{
    0x2178, 0x0BAE, 0x0010,
    .
    .
    .
    0x2E68, 0x0004
};

The call to SwitchStack is placed in my code and I switch stacks.  Later I restore my stack with another inline assembler routine.  I found the basis for this routine for the 68k on AppleLink years ago. The "classic" way to
inline code messes up the link register.  Is there an equivalent SwitchStack routine for the PowerPC that matches what the switch stack for the 68k does?

Thanks for your help,

Charles Copeland
Useful Software, Inc.

0
charles122996
Asked:
charles122996
1 Solution
 
gregjCommented:
CodeWarrior doesn't support what you are trying to do. The opcode inline style function is not supported by the PowerPC C or C++ compilers. And the PowerPC compilers don't allow you to specify which registers are used for parameters. See "Inside CodeWarrior 10," CL-38.

The PowerPC compilers do support inlined asm functions, but because they are real functions the compiler will determine register usage, and the link register is set before your code is entered. This is implied by the requirement documented on page CL-112 that every PowerPC assembly function must end in a "blr" instruction.

Even if all of these obstacles could be overcome somehow, the PowerPC optimizer would likely confound all of your efforts, and you'd have to make a lot of assumptions about what the compiler and optimizer will do.

Metrowerks has said publicly that they don't intend to support inlined blocks of assembly code in either the 68K or PowerPC compilers.

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now