PowerPC Developing
Volume Number: 10
Issue Number: 3
Column Tag: Powering up
Related Info: Memory Manager
Developing for PowerPC
Porting considerations
By Richard Clark and Jordan Mattson, Apple Computer, Inc.
Note: Source code files accompanying article are located on MacTech CD-ROM or
source code disks.
Last month, we promised to answer the questions “What’s it like to develop for
PowerPC?”, and “What are applications going to do with all that speed?” The simplest
answers - “it’s the same as any other Macintosh” and “anything they want” are
perhaps too simple. Developers have to change their code where PowerPC and 68K code
might interact, and not all applications will benefit equally from the PowerPC’s speed.
This month’s column uncovers the issues behind mixing 68K and PowerPC code,
describes some potential bugs you might encounter in ported code, and gives some tips
for maximizing application performance. These are changes that you can make without
having to have your own PowerPC processor-based Macintosh.
Developing for PowerPC
The PowerPC development tools have been described here - in Dennis Cohen’s
excellent review of Metrowerks’ Code Warrior last January, and in the synopses of
what happened at MacWorld. The tools are more evolutionary than revolutionary,
though native compilers can handle well over 100,000 lines per minute. The
programming model remains the same as before - a Macintosh with PowerPC runs the
same toolbox and operating system as a Macintosh with a 68000-series processor,
except that some parts (including native application code) run up to four times as fast
as a high-end 68040 Macintosh.
“Don’t call us, we’ll call you”
When recompiling for PowerPC, the only mandatory changes involve passing
“Universal Procedure Pointers” to the toolbox instead of “ordinary” pointers to
PowerPC code. Universal Procedure Pointers don’t point to code directly, but to an
intermediate data structure called a “Routine Descriptor.” Information in the routine
descriptor allows the Mixed Mode Manager to switch between running emulated 68K
code and “native” PowerPC code automatically.
Since you have to create a Universal Procedure Pointer anytime you pass a
PowerPC code pointer to the toolbox, the new “universal” interface files for PowerPC
and 68K development include macros to create these. (The macros create “regular”
procedure pointers on 68K systems and “Universal” procedure pointers on
PowerPC-based systems.) So, a call to TrackControl which used to read:
partCode = TrackControl(myControl, startPoint, myActionProc);