← How To Write Macintosh Software 1992

How To Write Macintosh Software 1992

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

THIRD EDITION How to Write Macintosh Software The Debugging Reference for the Macintosh® Scott Knaster FOUNDER TALL GENT BUGS JOLT COLA

A cartoon book cover showing a cluttered office with people among computers, bugs, and debris, with a framed portrait labeled FOUNDER on the wall and a yellow background.

Reading notes: Small labels such as the bug-related text on the box and the pink sign and can text are partly stylized and may be imprecise Fine print on the cover is minimal and not fully legible

Printed product names
Macintosh · Jolt Cola
Languages
English
PDF page 1

How to Write Macintosh Software

THIRD EDITION How to Write Macintosh Software The Debugging Reference for the Macintosh® Scott Knaster FOUNDER TALL GENT JOLT COLA MAC BUG DOOM

Book cover with a cartoon of a cluttered office where people sort, carry and stack old computers and debris beneath pipes and a framed portrait labeled FOUNDER, with a bubble-gum-blowing child and a pink car in the foreground.

Reading notes: Small props such as the 'TALL GENT' sign, 'FOUNDER' plaque, 'MAC BUG' bottle and 'DOOM' box are only partly legible and read approximately. 'Jolt Cola' on the can is partly visible and may be stylized. 'Scott Knaster' appears in red script-like type; the author name is transcribed as printed.

Printed product names
Jolt Cola
Languages
English
PDF page 2

HOW TO WRITE MACINTOSH SOFTWARE

HOW TO WRITE MACINTOSH SOFTWARE

A title page with a thin horizontal rule across the upper-middle area and a three-line all-caps serif title in the left-middle of an otherwise blank white page.

Languages
English
PDF page 3

HOW TO WRITE MACINTOSH SOFTWARE

HOW TO WRITE MACINTOSH SOFTWARE The Debugging Reference for Macintosh® Third Edition Scott Knaster Addison-Wesley Publishing Company Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei

A title page with black serif headline text on white, a horizontal rule near the top, and the Addison-Wesley logo mark above the publisher name and city list at the bottom.

Reading notes: Title page of a book rather than an advertisement; no prices or dates are printed. The ® symbol after Macintosh is a registered trademark mark, transcribed as printed.

Printed product names
Macintosh
Languages
English
PDF page 4

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book and Addison-Wesley was aware of a trademark claim, the designations have been printed in initial capital letters. The authors and publisher have taken care in preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. ISBN 0-201-60805-7 Copyright © 1992 by Scott Knaster All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Published simultaneously in Canada. Sponsoring Editor: David Rogelberg Technical Reviewer: Jim Reekes Project Editor: Joanne Clapp Fullagar Cover Illustration: Angelo Torres Cover Design: Jean Seal Set in 10-point Palatino by Publication Services, Inc. 2 3 4 5 6-MW-96959493 Second printing, August 1993 Addison-Wesley books are available for bulk purchases by corporations, institutions, and other organizations. For more information please contact the Corporate, Government and Special Sales Department at (617) 944-3700 x 2915.

A plain text-only book copyright page with several blocks of black serif text on a white background and no artwork or images.

Reading notes: This is a book copyright page rather than an advertisement, poster, or page with advertised products, so productNames and prices are empty. The number '2 3 4 5 6-MW-96959493' is a printing number line and was transcribed as printed.

Printed dates
1992 · August 1993
Languages
English
PDF page 5

For Dad

A mostly blank off-white page with faint speckled scanner noise and a single line of small italic serif text reading "For Dad" centered near the middle.

Reading notes: The text "For Dad" is a dedication-style line rather than a headline, so headline is set to null. Speckled background noise across the page is not text and was not transcribed.

Languages
English
PDF page 6

Contents Acknowledgments xiii Introduction xv About This Book xix PART ONE How It All Works 1 Chapter 1 Getting Started 3 Different 3 The ROM 5 Everything you know is wrong 7 How to get there from here 9 Resources 10 Building our application 12 Other kinds of programs 16 Power tools 17 vii

A black-and-white book table of contents page with a large serif 'Contents' heading over a rule, followed by two columns listing front matter, Part One and chapter entries with right-aligned page numbers, and a small page number 'vii' at the bottom right.

Reading notes: Table of contents layout read in reading order; page numbers in right column are roman and arabic numerals as printed.

Languages
English
PDF page 7

viii Contents Chapter 2 Things in Memory 21 Fables 21 That amazing moving memory 22 Allocating memory 26 Heaps 27 Purging 34 How relocation works 35 Explicit dereferencing 39 Implicit dereferencing 45 Chapter 3 More About Heaps and Fragmentation 55 What does "Out of Memory" really mean? 55 Blocks in heaps 62 Heap zone header 62 Heap block header 64 Master pointers 67 Using the Memory Manager 69 Reducing fragmentation 71 Segmenting your application 74 Unloading your segments 76 PART TWO Debugging 79 Chapter 4 Debugging Macintosh Software 81 Bugs 81 Kinds of bugs 82 Why system errors don't tell you very much 83 The art of debugging 84 Debugging questions 85 Debugging tools 91 Hardware debuggers 94

A printed table of contents page with a running header, bold chapter headings, and regular entries with right-aligned page numbers.

Reading notes: Page number 'viii' and 'Contents' header read clearly; no ad content present.

Languages
English
PDF page 8

Contents ix Common crashes 95 Some advice on debugging 100 Chapter 5 Examining Compiled Code 103 Compilers 103 Allocating space for data 106 Stack frames 110 Parameters 116 Statements and variables 122 Chapter 6 More about Compiled Code 141 Procedure and function calls 141 Conditional statements 162 Repetitive statements 168 With statements 172 Linked routines 173 Standard library routines 176 ROM interface routines 176 The jump table 180 Format of jump table entries 182 Miscellaneous things in your object code 186 Summary 187 Chapter 7 Real Live Debugging 189 What we'll do 189 Running the program 198 Watching more closely 206 Looking for the bus error 213 Finding the text bug 217 Finding the window-erase bug 219 Looking for more bugs 221

A book table of contents page with a running header 'Contents' and page number 'ix' above a horizontal rule, listing chapter titles in bold and section entries in regular type with right-aligned page numbers.

Reading notes: Page numbers in the right column are small and aligned; reading order is top to bottom, with chapter headings in bold.

Languages
English
PDF page 9

x Contents Optimizing with the debugger 231 Objects in the heap 244 Special free bonus 249 PART THREE Tips, Tricks, and Techniques 261 Chapter 8 General Techniques 263 Preflighting 263 How to get around Pascal's Type Checking 266 Which registers you can use 268 Chapter 9 Toolbox Techniques 271 Writing a definition function in a high-level language 271 Logical clipping 272 Using ResErrProc 273 Moving a resource from one file to another 275 The easy way to smooth animation 281 Automatic window updating 283 Textedit hooks 295 Resuming from system errors 297 Chapter 10 Operating System Techniques 301 How ROM calls work 301 Random access file I/O 302 When your application ends 309 Keeping things around between applications 310

A printed book table of contents page with a running header 'x Contents' and two-column layout listing section titles on the left with right-aligned page numbers, including bold part and chapter headings.

Reading notes: Page number 'x' and header are in the top margin; reading order follows the printed list top to bottom.

Languages
English
PDF page 10

Contents xi APPENDICES 313 Appendix A Assembly Language Overview 315 Appendix B Common Problems 345 Appendix C Ancient History 355 Appendix D Debugging Quick Reference Guide 377 Glossary 403 Index 413

A printed book contents page with a running header 'Contents' and page number 'xi' at top, a horizontal rule, and a list of appendices with bold labels, titles, and right-aligned page numbers on a plain white background.

Reading notes: Running header and page number at top are small but legible; reading order follows the table of contents layout top to bottom.

Languages
English
PDF page 11

Acknowledgments Without these people, this book would not exist, and you would now be staring at nothing and looking very silly. Jim Friedlander of Macintosh Technical Support provided massive help. He read the entire manuscript several times and kept me honest; he wrote most of the programs in Part Three; and he helped me keep up my energy level with his enthusiasm. Keith Rollin, coauthor of the second edition of Macintosh Programming Secrets and all-round Talented Gent, was invaluable in helping me figure out what had changed in the Macintosh world since the previous edition of this book appeared. Jean Seal of Addison-Wesley worked way beyond the call of duty with artist Angelo Torres to create the incredible cover that you see gracing this book. Carole McClendon and Steve Stansel helped fulfill this book's destiny of being published by Addison-Wesley, thus making it the only Macintosh book to be published in three editions under three different publishers (not my fault). Martha Steffen, Apple Publishing Evangelist, helped me figure out how to get started and what was happening to me along the way. Scot Kamins, Writéur, encouraged me, told me funny jokes, and gave me a great review. I also stole ideas from his books. Caroline Rose inspired me by being the best technical writer I've ever known, and by writing Inside Macintosh, without which no other Macintosh technical books would be possible. Cary Clark and Russ Daniels were very smart (and still are) and taught me a lot of the stuff that appears in this book. Bryan Stearns, Ginger Jernigan, Mark Baumwell, Louella Pizzuti, Bill Dawson, and Rick Blair of Apple Technical Support put up with me whenever I rambled on about this book. xiii

A printed book page with a large sans-serif-style heading 'Acknowledgments' over a horizontal rule, followed by justified body text in a serif typeface and a page number 'xiii' at the lower right.

Reading notes: Scot Kamins is printed with 'Writéur', which is reproduced as shown; the accent appears as printed. Italic titles 'Macintosh Programming Secrets' and 'Inside Macintosh' are rendered as plain text in the transcript.

Languages
English