# How To Write Macintosh Software 1992 — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-3a15b531dd4668a34c169b7ec1b1f36e73e56c62089091177c6ab032c0d0f05f)

Transcribed text:

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

Image description: 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

[Original Image 1](https://www.vintageapple.net/files/d195b836222e621e746a6efbc78ad33516b247759fe9fe4cd761b55b9e29f7f7/9337e6baa204ff1e7a74e56b.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-50cb0d023a35eed0fb284776cf753e0b22f17b036e497baa3018e70f54a7431f)

How to Write Macintosh Software

Transcribed text:

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

Image description: 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

[Original PDF page 1](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-b19c1ca20b2d5e2f09d64f8ca6761c703bf43855987da235586ebb048b58d049)

HOW TO WRITE MACINTOSH SOFTWARE

Transcribed text:

HOW TO WRITE
MACINTOSH
SOFTWARE

Image description: 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

[Original PDF page 2](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-92cc5b8c4d103d2978f6e9fda0f4609417635d60f6b44f746b9925ec2c88d5ba)

HOW TO WRITE MACINTOSH SOFTWARE

Transcribed text:

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

Image description: 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

[Original PDF page 3](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-0d76f7a5691c9ce8f3d2fc603edd473991a42c76b6b1c82691d4a048676fa8da)

Transcribed text:

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.

Image description: 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

[Original PDF page 4](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-250b3798c556c077f8fe987dfc34ff46685ffc9bbde77dbcad3ef374832a3231)

Transcribed text:

For Dad

Image description: 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

[Original PDF page 5](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-9b7e29ee8fbd93641203d40e284e1bb03e092f9d23bd60c8d155936af49d8bf6)

Transcribed text:

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

Image description: 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

[Original PDF page 6](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-5a6837db1dc25b4ee9eb21d161c68fa52365d4b5506d5eb7551c54d013b58f64)

Transcribed text:

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

Image description: 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

[Original PDF page 7](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-81eef70b0cdfc65bc1df01547c9c2b611ed60c15ae88e1542527a3afe8f15de0)

Transcribed text:

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

Image description: 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

[Original PDF page 8](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-45f80b062919eaf32645b9455356768164e6679ce8ce96aa97c1652b6765b8b9)

Transcribed text:

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

Image description: 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

[Original PDF page 9](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-6286bf20939c2b729bf667b8758644eba0263c3969d76f00707782ea96ba87de)

Transcribed text:

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

Image description: 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

[Original PDF page 10](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/1#scan-77d13d0c4d2430fc29bee649258af842dfaa0ffbaeee85e0453994aa8b1a5c42)

Transcribed text:

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

Image description: 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

[Original PDF page 11](https://www.vintageapple.net/files/886e630768fa79a6375be566a18d8fd60b83218e0fef4e9654d28c6121d5d88b/How_To_Write_Macintosh_Software_1992.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-how-to-write-macintosh-software-1992-1a67d9/2.md)
