Aug 96 Tips
Volume Number: | | 12
|
Issue Number: | | 8
|
Column Tag: | | Tips & Tidbits
|
Tips & Tidbits
By Steve Sisak
CodeWarrior Target Switch
Heres an easy way (in CodeWarrior) to build a project file for another target if you have been working on one target already (i.e., working on a 68K project, and now its time to make a PPC project).
Even though I create apps for both 68K and PPC, I always just work in a 68K project file, since I have a 68K Mac at home to work on.
When it comes time to make a PPC binary for testing, or just to see if the thing will compile with a PPC compiler, Ill go to the Finder and duplicate (Command-D) my 68K project file, and then rename the copy to something like MyProject (PPC).
Open the new project up, reset all the project prefs to a PPC target, set other prefs as needed, remove the 68K libraries, and add in the PPC libraries (and you might need to update the precompiled header files, unless you use something like a Prefix.h file that conditionally adds in the right precompiled header based upon the target).
Voilà! Its a pretty simple thing that saves you lots of time in recreating project files for multiple targets.
John Daub
The Origin of the GWorld
Sometimes, images drawn into offscreen GWorlds for a translucent drag dont draw properly if the GWorlds portRect starts at any location other than (0,0). This can result in items being clipped improperly, or not being drawn at all.
This problem only occurs when the user has multiple monitors hooked up.
Translucent drags will work fine if you create the GWorld for the drag image at location (0, 0).
Jeremy Vineyard
But How About Free Overnight Shipping?
If youd like to learn more tricks on optimizing PowerPC assembly language code, call IBM and order the 240-page PowerPC Compiler Writers Guide. Theyll charge you $1 (yes, one dollar) and you have to pay with a credit card (at this price you should order four or five for friends and family). The phone number is (800) 879-2755 (IBMs Manuals & Publications). The book is ISBN 0-9649654-0-2 and IBM part number MPRPPCOMP-01.
Heres an example from their Optimal Code Sequences chapter. The C code is calculating the absolute value of v0:
absoluteValue = (signed_word) v0 < 0 ? -v0 : v0;
The optimal instructions (which are nice to the pipeline, no branches) are:
srawi R4, R3, 31 // v0 is in R3 on entry
add R5, R4, R3
xor R6, R5, R4
There are about 40 other short sequences like this one given in the book, as well as discussions on instruction scheduling, alignment, etc. Well worth the price!
Mike Scanlin