← Programming The PowerPC 1994

Programming The PowerPC 1994

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

New Technology Building Blocks Programming The PowerPC Programming Native Applications for the New Power Macintosh DISK INCLUDED Learn how to exploit the new RISC processors Develop native applications for the new Power Macs Learn to port existing programs from 680x0 to native PowerPC Examples in MetroWerks CodeWarrior and Symantec C++ Series Editor: Tony Meadow Bear River Associates M&T BOOKS Dan Parks Sydow

A book cover with a dark blue and black layout, large white title text, a red-orange circuit-board image of an eye on the right, a floppy disk icon labeled DISK INCLUDED on the left, and a bear logo for Bear River Associates near the bottom.

Reading notes: The small text on the circuit-board image (such as 'R 139' and 'C64') is not transcribed as it is part of the artwork rather than advertising copy. The 'Series Editor' line and the 'Bear River Associates' logo text are small and were read with moderate confidence.

Printed product names
MetroWerks CodeWarrior · Symantec C++
Languages
English
PDF page 1

New Technology Building Blocks Programming The PowerPC Programming Native Applications for the New Power Macintosh DISK INCLUDED • Learn how to exploit the new RISC processors • Develop native applications for the new Power Macs • Learn to port existing programs from 680x0 to native PowerPC • Examples in MetroWerks CodeWarrior and Symantec C++ Series Editor: Tony Meadow Bear River Associates BEAR RIVER ASSOCIATES M&T BOOKS Dan Parks Sydow

A book cover with a black header band, a blue lower panel, a green-gray side strip, and a red-orange circuit-board image of an eye in the right-center area.

Reading notes: Small circuit-board labels within the eye image (such as R 138 and C64) are not transcribed as they are not part of the printed copy. The bear logo text 'BEAR RIVER ASSOCIATES' is small and was transcribed from the logo area.

Printed product names
Programming The PowerPC · MetroWerks CodeWarrior · Symantec C++
Languages
English
PDF page 2

PROGRAMMING THE POWERPC DAN PARKS SYDOW M&T BOOKS

A centered bold black title above an illustration of a PowerPC microchip with the label 'Power PC' on its top surface, with the author name and M&T Books logo below on a white background.

Reading notes: Faint background text fragments at the top and middle of the page are not legible and were omitted.

Languages
English
PDF page 3

Programming the Power PC

M&T Books A Division of MIS:Press, Inc. A Subsidiary of Henry Holt and Company, Inc. 115 West 18th Street New York, New York 10011 © 1994 by M&T Books Printed in the United States of America All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any infor- mation storage and retrieval system, without prior written permission from the Publisher. Contact the Publisher for information on foreign rights. Limits of Liability and Disclaimer of Warranty The Author and Publisher of this book have used their best efforts in preparing the book and the programs contained in it. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The Author and Publisher make no warranty of any kind, expressed or implied, with regard to these programs or the documentation contained in this book. The Author and Publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs. All products, names and services are trademarks or registered trademarks of their respective companies. Library of Congress Cataloging-in-Publication Data Sydow, Dan P. Programming the Power PC : programming native applications for the new power Macintosh I Dan Parks Sydow. p. cm. Johnson's name appears first on the earlier edition. Includes index. ISBN 1-55851-400-7 : $34.95 1. Macintosh (Computer) -Programming. ming. I. Title. 2. PowerPC microprocessors-Program- QA76.8.M3S965 1994 005.265-dc20 97 96 95 94 4 3 2 1 Development Editor: Michael Sprague Production Editor: Patricia Wallen burg Copy Editors: Greg Robertson Technical Editor: Peter Ferranti 94-37488 CIP

Reading notes: Primary heading reads 'Programming the Power PC' with subtitle 'programming native applications for the new power Macintosh'; exact heading boundary is uncertain. Cataloging text split across lines ('Program-ming') may affect subject heading reading.

Printed product names
Macintosh (Computer) · PowerPC microprocessors
Printed prices
$34.95
Printed dates
1994 · © 1994 · 97 96 95 94 4 3 2 1
Languages
English
PDF page 4

The image is a plain, blank white page with no visible artwork, layout, or printed content.

Reading notes: No visible text found; image appears entirely blank white.

PDF page 5

ACKNOWLEDGMENTS Anthony Meadow, Bear River Associates, for being the only person I know who can completely and accurately outline his thoughts for an entire book in one five minute conversation. Michael Sprague, Development Editor, M&T Books, for his patience, sense of humor, patience, input, patience, encouragement, and, least I forget, for his patience. Patty Wallenburg, Production Editor, M&T Books, for a page layout effort that resulted in such a polished looking book. Peter Ferrante, Apple Computer, for another suggestion-filled technical book and software review. Steve Devino, Teradyne, Inc., for additional software reviewing. Dave Hirsh, for granting permission to include his data fork erasing utility program, DFerase, with this package. Carol,e McClendon, Waterside Productions, for making this book happen. William Barnekow, Professor, Milwaukee School of Engineering, for sparking my interest in computers and computer architecture.

Reading notes: Source text has irregular spacing and a stray comma in 'Carol,e McClendon' that may be an extraction artifact

Languages
English
PDF page 6

TABLE OF CONTENTS

TABLE OF CONTENTS introduction xvii What's on the Disk XIX What You Need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . XIX Why This Book is for You xx CHAPTER 1 The PowerPC and the Power Macs 1 The Need for a New Chip . . . . . . . . . . . . . . . . . . . . . . . . . 2 CISC and RISC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 RISC Leads to More Than Just Speed . . . . . . . . . . . 4 The Power Macintosh Line . . . . . . . . . . . . . . . . . . . . . . . . 5 Features of the New Macs . . . . . . . . . . . . . . . . . . . . . 5 The Customer Base . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Is It Still a Mac? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 vii

Reading notes: Chapter heading spacing and page numbers are irregular in the extracted table of contents

Printed product names
PowerPC · Power Macintosh · Power Macs
Languages
English
PDF page 7

Programming the PowerPC The PowerPC System Software . . . . . . . . . . . . . . . . . 9 Software Compatibility . . . . . . . . . . . . . . . . . . . . . . . . I 0 Hardware Compatibility . . . . . . . . . . . . . . . . . . . . . . 10 Developer Support . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Chapter Summary 11 CHAPTER 2 CISC and RISC Technologies 13 CISC and the 680x0 Series . . . . . . . . . . . . . . . . . . . . . . . . . 14 Why CISC? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Instruction Execution on a 680x0 . . . . . . . . . . . . . . . 14 The Timing of Instructions on a 680x0 . . . . . . . . . . 17 CISC-Fast, But Not Fast Enough . . . . . . . . . . . . . . 20 RISC and the Power Mac Series . . . . . . . . . . . . . . . . . . . . 20 Why RISC? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Instruction Execution on a Power Mac . . . . . . . . . . 21 The Timing of Instructions on a Power Mac . . . . . . 25 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 CHAPTER 3 PowerPC Architecture 29 viii Branch Processing Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Instruction Fetching . . . . . . . . . . . . . . . . . . . . . . . . . 30 Instruction Fetching and the Branch Unit . . . . . . . . 32 Superscaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 The Superscalar Design Branch Processing Unit 37 38

Reading notes: Table of contents page numbers and some section titles have irregular spacing and possible OCR spacing artifacts

Printed product names
PowerPC · 680x0 · Power Mac
Languages
English
PDF page 8

Table of Contents

Table of Contents Integer Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Floating-Point Unit . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Data Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Instruction Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Chapter Summary 43 CHAPTER 4 PowerPC System Software: The Emulator and Mixed Mode 45 The PowerPC System Software . . . . . . . . . . . . . . . . . . . . . 46 Ported System Software Routines . . . . . . . . . . . . . . . 46 The New System Software . . . . . . . . . . . . . . . . . . . . . 49 PowerPC Execution of System Software Routines . . 50 The 68LC040 Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 The Mixed Mode Manager . . . . . . . . . . . . . . . . . . . . . . . . 57 Instruction Set Architecture . . . . . . . . . . . . . . . . . . . 58 Cross-Mode Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 680x0 to PowerPC Cross-Mode Calls . . . . . . . . . . . . 59 PowerPC to 680x0 Cross-Mode Calls . . . . . . . . . . . . 60 The Programmer's Role in Mode-Switching . . . . . . 61 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 CHAPTER 5 PowerPC System Software Code Fragments 65 The PowerPC Runtime Environment . . . . . . . . . . . . . . . . 66 What the Runtime Environment Is . . . . . . . . . . . . . . 66 ix

Languages
English
PDF page 9

Programming the PowerPC A New Runtime Environment- And Why It Was Needed . . . . . . . . . . . . . . . . . . . . 66 Import Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Linked Libraries and Import Libraries . . . . . . . . . . . 68 Advantages oflmport Libraries . . . . . . . . . . . . . . . . . 69 Code Fragments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 About Code Fragments . . . . . . . . . . . . . . . . . . . . . . . 73 The Code Fragment Manager . . . . . . . . . . . . . . . . . . 74 Transition Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 The Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . 79 Chapter Summary 84 CHAPTER 6 PowerPC Compilers 87 x The Metrowerks CodeWarrior Compilers 88 What Metrowerks Consists Of . . . . . . . . . . . . . . . . . . 88 Creating a CodeWarrior Project . . . . . . . . . . . . . . . . 90 Adding to the Project . . . . . . . . . . . . . . . . . . . . . . . . . 92 The Prefix File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Creating the Resource File . . . . . . . . . . . . . . . . . . . . 98 The MWdemoPPC Source Code . . . . . . . . . . . . . . . . 100 Creating the PowerPC Application . . . . . . . . . . . . . . 103 Symantec's Cross-Development Kit (CDK) . . . . . . . . . . . . 105 What the CDK Consists Of . . . . . . . . . . . . . . . . . . . . 105 Installing AppleScript . . . . . . . . . . . . . . . . . . . . . . . . 106 Using AppleScript to Update ANSI Libraries . . . . . 107 Creating a Folder to Hold Your Power Mac Project 109 Creating the Resource File . . . . . . . . . . . . . . . . . . . . 112

Reading notes: Table of contents page numbers and chapter layout are not verifiable from the supplied text alone.

Printed product names
Metrowerks CodeWarrior · Symantec's Cross-Development Kit (CDK) · AppleScript · MWdemoPPC · Power Mac
Languages
English
PDF page 10

Table of Contents Opening the CDK Project . . . . . . . . . . . . . . . . . . . . . 115 Required Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 119 The CDKdemoPPC Source Code . . . . . . . . . . . . . . . 121 Creating the PowerPC Application . . . . . . . . . . . . . . 126 Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 CHAPTER 7 Universal Procedure Pointers 133 Universal Procedure Pointer Theory 134 Procedure Pointers and the 680x0 Processor . . . . . 134 Universal Procedure Pointers and the PowerPC . . . 136 Using U niversalProcPtrs . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Using a UniversalProcPtr in a Call to ModalDialog() . . . . . . . . . . . . . . . . . . . . . . 140 How the Compiler Chooses Between ProcPtr and U niversalProcPtr . . . . . . . . . . . . . . . . 144 Using UniversalProcPtrs In Other Toolbox Calls . . 146 UniversalProcPtr Example Programs . . . . . . . . . . . . . . . . 152 ModalDialog() and UPPs . . . . . . . . . . . . . . . . . . . . . 152 Another Example of User Items and UPPs . . . . . . . 157 Chapter Summary 164 CHAPTER 8 Fat Binary Applications 167 Fat Application Theory 168 Applications and 680x0/PowerPC Compatibility . . 168 Structure of a 680x0 Application . . . . . . . . . . . . . . . 171 xi

Reading notes: Source text is a table of contents with dot leaders; no body copy, headline, products, prices or dates present.

Languages
English
PDF page 11

Programming the PowerPC Structure of a PowerPC Application ............ . Structure of a Fat Application ................. . Using CodeWarrior to Create Fat Apps ............. . Creating the PowerPC Version ................ . Creating the 680x0 Version ................... . Creating the Fat Binary ...................... . Using Symantec's CDK to Create FatApps ........... . Creating the PowerPC Version ................ . Creating the 680x0 Version ................... . Creating the Fat Binary ...................... . Gracefully Exiting a PowerPC-only App ............. . PowerPC-only Applications and User-Friendliness . The 680x0 Resource File The 680x0 Source Code Copying the Resources to the PowerPC-only App .. Stripping Fat Applications ........................ . Converting a Fat Binary to a PowerPC Application . Converting a Fat Binary to a 680x0 Application ... Chapter Summary 173 173 176 176 179 181 184 185 187 190 193 194 195 196 197 200 200 202 208 CHAPTER 9 The PowerPC Numerics Environment 209 xii Switching from SANE to PowerPC Numerics 210 PowerPC Numerics Data Formats . . . . . . . . . . . . . . . . . . . 211 The Single Format . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 The Double Format . . . . . . . . . . . . . . . . . . . . . . . . . . 212 The Double-Double Format . . . . . . . . . . . . . . . . . . . 212 Numeric Data Format Summary . . . . . . . . . . . . . . . . 212

Reading notes: Source appears to be a table of contents; page numbers are listed without clear reading-order context

Languages
English