← PowerPC Programmers Toolkit 1996

PowerPC Programmers Toolkit 1996

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

PowerPC™ Programmer's Toolkit The definitive resource on the latest PowerPC techniques CD-ROM includes a special version of Metrowerks CodeWarrior™ Lite Tom Thompson

A book cover with large yellow bold sans-serif title text on a dark maroon background, a small CD-ROM disc icon at the lower left, and a faint image in the upper center.

Reading notes: The small faint image at upper center contains no legible text. The CD-ROM label and the 'includes a special version of' line are small and were read from the image at low resolution; spacing is approximate.

Printed product names
PowerPC
Languages
English
PDF page 1

PowerPC™ Programmer's Toolkit The definitive resource on the latest PowerPC techniques CD-ROM includes a special version of Metrowerks CodeWarrior™ Lite Tom Thompson

A book cover with bold yellow sans-serif title text on a dark red textured background, a small faded image at top center, and a CD-ROM disc icon at the lower left beside the caption.

Reading notes: The small faded image at top center has no legible text. The trademark symbols after PowerPC and CodeWarrior are small and approximated as ™.

Printed product names
PowerPC
Languages
English
PDF page 2

PowerPC Programmer's Toolkit

A gray cover page with white and dark gray gear illustrations, and a central white rectangle with a black border containing the bold black title text.

Printed product names
PowerPC Programmer's Toolkit
Languages
English
PDF page 3

The image is a plain, entirely blank white page with no visible artwork, layout elements, or text.

Reading notes: No visible text appears anywhere on the page, so the transcript and printed fields are empty.

PDF page 4

PowerPC Programmer's Toolkit ©1996 Hayden Books, a division of Macmillan Computer Publishing All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system, without prior written permission of the pub- lisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Hayden Books, 201West103rd Street, Indianapolis, Indiana 46290. Library of Congress Catalog Number: 95-80297 ISBN: 1-56830-241-x This book is sold as is, without warranty of any kind, either express or im- plied. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information or instructions contained herein. It is further stated that the publisher and author are not responsible for any damage to or loss of your data or your equipment that results directly or indirectly from your use of this book. 98 97 96 4 3 2 1 Interpretation of the printing code: the rightmost double-digit number is the year of the book's printing; the rightmost single-digit number is the number of the book's printing. For example, a printing code of 96-1 shows that the first printing of the book occurred in 1996. Trademark Acknowledgments All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Hayden Books cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. PowerPC is a trademark oflnternational Business Machines Corporation, used under license therefrom. Apple, Macintosh, and the Apple logo are trademarks of Apple Corp., regis- tered in the U.S. and other countries.

Reading notes: OCR spacing and hyphenation irregularities in running text 'oflnternational' appears to be an OCR error for 'of International'

Printed product names
PowerPC · Macintosh · Apple
Printed dates
1996 · 95-80297 · 96-1
Languages
English
PDF page 5

The Hayden Books Team Publisher: Lyn Blake Publishing Manager: Laurie Petrycki Development Editor: Kezia Endsley Copy and Production Editors: Bront Davis, Lisa Wilson Technical Reviewers: Jim Trudeau, Metrowerks, Inc. Alan Llllich, Apple Computer, Inc. MarkAnderson, Metrowerks, Inc. Cover Designer: Karen Ruggles Interior Designer: Sandra Stevenson Production Analysts: Mary Beth Wakefield Production Team Supervisor: Laurie Casey Production Team: Heather Butler, Angela Calvert, Kim Cofer, Dan Caparo, David Garratt, Aleata Howard, Michelle Lee, Erika Millen, Beth Rago, Erich Richter, Karen Walsh Indexer: Brad Herriman ·/

Reading notes: Source lists a credits page with no advertised products, prices, or dates; headline is not explicitly printed

Languages
English
PDF page 6

Dedication To my wife, Brenda Jean, and my children, John and Evelyn. About the Author Tom Thompson has a BSEE degree and bought his first 128K Macintosh in early 1984. He is a Senior Tech Editor at Large for BYTE magazine and has been covering the Mac for over ten years. He is an Associate Apple Devel- oper, and has substantial programming experience, including authoring several shareware utilities. He has also researched and written numerous articles on programming and hardware technology.

Reading notes: Source text is a dedication and author biography with no explicit advertised products or prices; primary heading not present in supplied copy.

Printed product names
Macintosh
Printed dates
1984
Languages
English
PDF page 7

Acknowledgments A book is a lot like a programming project. It involves a lot of people working in concert to achieve the final outcome-all on budget and on schedule. While publishing doesn't normally involve writing code and using debuggers, in some ways it is more work because you have to explain things in a way that makes the most sense to the most people. People are pretty imprecise beings, unlike computers. Of course, this is a programming book where you do have to write code, use debuggers, as well as try to make things sensible. It can be done, but not without the capable assistance of many good people whom I'd like to thank. To Karen Whitehouse at Hayden Books for her support for the second edition of this book. Thanks to Llsa Wilson and Bront Davis for making my prose sensible. An award to my editor Kezia Endsley, for tirelessly shepherding this book into reality. To Greg Galanos, Jean Belanger, Dan Podwall, John McEnemey, Berardino Baratta, and the rest of the Metrowerks gang for providing timely support and updates to their excellent CodeWarrior software during the course of writing this book. To Jordan Mattson at Apple for his support and access to PowerPC material. To Eric Shapiro of Rock Ridge Enterprises for his valuable code contributions and suggestions. Eric taught me everything about 68K trap patching, and did it again for PowerPC trap patching. A lot of his code appears in the FlipDepth Extension shown in Chapter 6, and he made many recommendations that improved the SwitchBank application. Without his efforts and timely sup- port, Chapter 6 would not have been possible. Thanks to Roger Goode for the improved graphics. Thanks to my tech reviewer, Jim Trudeau, for his perceptive remarks. Special thanks to Richard Hooker and Marvin Denman for checking over the cache descriptions. Special thanks to Randy Thelen for his insights into the Power Mac run-time architecture, which helped shape Chapter 4. Thanks to Steve Jasik for providing a copy of The Debugger, software that will really make a difference in debugging PowerPC programs. Last but not least, I would like to thank my wife Brenda for her patience during the long nights I spent toiling away on this new edition. I

Reading notes: OCR-style spacing and character errors such as 'Llsa' and 'Bront' and 'McEnemey' may be misreadings of names. Reading order of the final line 'I' is uncertain.

Printed product names
CodeWarrior · The Debugger · Power Mac
Languages
English
PDF page 8

Overview Front Matter Introduction Chapter 1: The Power Macs and a Brief History Chapter 2: Beginning Programs Chapter 3: Using the Toolbox Chapter 4: The PowerPC Software Architecture Chapter 5: Putting ItAll Together Chapter 6: The Art of Debugging Chapter 7: Performance and Processors Appendix A: The PowerPC RISC Processor Family Appendix B: Porting to the PowerMac Appendix C: Program Llstings

Reading notes: "Llstings" in Appendix C may be an OCR error for "Listings" "ItAll" in Chapter 5 appears to be missing a space

Languages
English
PDF page 9

Contents Introduction 1 What You'll Need .................................................................................. 2 The Road Map ...................................................................................... 2 The Metrowerks CodeWarrior Lite on the CD ................................... 4 Additional Notes .................................................................................. 5 1 The Power Macs and a Brief History 7 History of the Power Macs ................................................................... 7 The Early Mac .............................................................................. 8 The First-Generation Power Macs ........................................... 10 Apple and IBM: Who Could Have Imagined It? ....................•.......... 13 Time for a Change (to Power Mac) ................................................... 25 2 Beginning Programs 27 Beginning Programs .......................................................................... 27 About the Toolbox .............................................................................. 28 Munge It .............................................................................................. 29 Getting Started ................................................................................... 30 The Code Tour .................................................................................... 32 Making Munger .................................................................................. 35 Running Munger ................................................................................ 40 Where's the Mac? ............................................................................... 42 Processes Revealed ............................................................................ 43 Gathering Processes ........................................................................... 45 A Word of Caution .............................................................................. 47 Just the Beginning............................................................................. 48 3 Using the Toolbox 49 Meet Some Managers ........................................................................ 51 Initializing Managers ......................................................................... 54 Run the Code ...................................................................................... 58 The Fork in the File ............................................................................ 59 Making Resources .............................................................................. 61 Making Menus .................................................................................... 63

Reading notes: Table of contents formatting contains stray characters such as '•' and '.....' that may be OCR artifacts

Printed product names
Metrowerks CodeWarrior Lite · Power Mac
Languages
English
PDF page 10

0- ~!"!' ~'~'"'~":!.'C' !~~"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Making Dialog Boxes ......................................................................... 68 Editing Dialog Boxes ................................................................. 70 Adding Buttons .......................................................................... 72 Numbering Dialog Items .......................................................... 73 Status Display ..................................................................................... 74 Adding Alerts ...................................................................................... 76 Saving Resource Data as Text ............................................................ 82 Some Words on Events ...................................................................... 83 Code at Last ........................................................................................ 85 The First Function .............................................................................. 88 Munger Code, Revisited .................................................................... 89 Input and Output Filenames ............................................................. 92 Basic Application Functions ............................................................. 96 Main Event Loops ............................................................................ 100 The Initialization Function ............................................................. 106 Build Munger .................................................................................... 108 High-Level Events ............................................................................ 110 Make Munger Handle High-Level Events ...................................... 111 Modifying the Event Loop Code ..................................................... 112 Delivering High-Level Events .......................................................... 113 Writing the Handlers ........................................................................ 116 Making SonOMunger High-Level Event Savvy..................................................................................... 123 New Alerts ......................................................................................... 124 Bundle Resource .............................................................................. 125 Finishing Up .................................................................................... 130 The Fork in the Road ........................................................................ 131 4 The PowerPC Software Architecture 133 The 680x0 Application Run-Time Architecture ............................. 135 The PowerPC Application Run-Time Architecture ....................... 144 Segue: The Care and Feeding of Stack Frames .............................. 153 680x0 Function Calls ............................................................... 154 PowerPC Function Calls ........... ...................................... ........ 156 Mode Mixing..................................................................................... 162 A Tale of Two Processors ................................................................. 170

Reading notes: Table of contents format with page numbers; headline taken as first chapter entry Some characters are garbled (e.g. 'SonOMunger' in an entry), possibly OCR damage

Languages
English
PDF page 11

________________________________________________ <e.o~te~" -0 5 Putting It All Together 171 SwitchBank: Initial Investigation and Design................................ 173 Building Resources with Rez ..................... ........... .. ......................... 175 Using Rez with the ToolServer ............................................... 188 Using Rez from Inside CodeWarrior ...................................... 193 The SwitchBank Program ................................................................ 196 Making a Fat Binary ......................................................................... 222 Handling a Code Fragment ............................................................. 228 Interlude: The Anatomy of a Trap ................................................... 229 Writing a Fat Trap ............................................................................ 234 Building a Fat Trap ........................................................................... 265 Building a Fat Resource ................................................................... 276 Showlnitlcon Code .......................................................................... 278 Compiling the Fat Resource ............................................................ 287 Summary ........................................................................................... 295 6 The Art of Debugging 297 About Debuggers .............................................................................. 298 Using the CodeWarrior Debugger .................................................. 302 Low-Level Debuggers ...................................................................... 321 MacsBug .................................................................................. 321 The Debugger .......................................................................... 326 Debugging Techniques .................................................................... 332 A Bug Taxonomy ..................................................................... 334 Debugging Miscellany ............................................................ 340 Enough Debugging .......................................................................... 343 7 Performance and Processors 345 Planning and Profiling ..................................................................... 346 Profiling for a Purpose ............................................................ 346 Performance Issues ................................................................. 347 Code Tuning ..................................................................................... 348 A Word about Caches ....................................................................... 349 Cache Operation .................................................................... : 350 Cache Details ........................................................................... 351 General Caching Principles ............................................................. 353

Reading notes: Source appears to be a table of contents with OCR noise such as '<e.o~te~"' and '~' characters Primary heading not clearly identifiable from the supplied copy

Languages
English