Solved

PowerPC Assembler

Posted on 1997-01-05
1
1,508 Views
Last Modified: 2013-12-26

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
Comment
Question by:charles122996
1 Comment
 

Accepted Solution

by:
gregj earned 200 total points
ID: 1291400
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now