# The Complete Book of Macintosh Assembly Language Programming, Volume II — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/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-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-022784e9c2d825378307f815ce9d7478488f23e9a5e60eef15db91ccba5ed144)

Transcribed text:

The Complete Book of Macintosh Assembly Language Programming Volume II

Dan Weston

"The Complete Book of Macintosh Assembly Language Programming, Volumes I and II, are a must for anyone serious about programming the Mac. They contain information not found anywhere else, and cover the real-life problems of a software developer."
David Smith, Publisher
MacTutor

Image description: A book cover with a bold yellow and gray diamond lattice background, large navy title text with a large stylized "M" in "Macintosh", the author name in navy below, and a white endorsement box with magenta and black text at the bottom.

Reading notes: Title is split across the large 'Macintosh' wordmark and smaller 'The Complete Book of' and 'Assembly Language Programming Volume II' lines; reading order follows the visual arrangement. Endorsement box text reads as a quotation with magenta highlighted title and italic 'must'; the hyphenated 'any-where' is a line break in the original.

Printed product names: The Complete Book of Macintosh Assembly Language Programming

Languages: English

[Original Image 1](https://www.vintageapple.net/files/2d1e5363a3bf72dce24b00185a6ef63ad5f3e3ddcd159c1cc48a406058c1822b/bcf398b3f32106f52f0a3347.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-d39c61b874ee7029e44271cb5692f3f295aa3a1914c8994d5fa57ae157e33b1e)

Transcribed text:

"The   Complete   Book   of Macintosh   Assembly   Language
Programming,   Volumes   I   and   II,   are a   must   for anyone serious
about programming the Mac. They contain_information not found   any-
where else, and cover the real-life problems   e>f   a software developer."
David   Smith,   Publisher
MacTutor

Reading notes: No headline is present in the supplied copy; the quotation is body text. 'e>f' in 'real-life problems e>f a software developer' is likely an OCR error for 'of' and needs checking against the page. 'contain_information' appears to be missing a space or contain an underscore artifact and needs checking. 'any-where' is a line-break hyphenation that should be read as 'anywhere'. Irregular spacing in the supplied copy may reflect layout, and the reading order of the attribution lines is uncertain. No prices, dates, or years appear in the supplied copy, and the transcript is empty per the instruction to use the separately preserved extracted text.

Printed product names: The Complete Book of Macintosh Assembly Language Programming

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-39b49eb4fddda12ceb17e1724ec7966b9e53ca7bdfaa180440f0e9da7f3b6d72)

Save yourself hours of typing

Transcribed text:

Save   yourself   hours of typing
A source code disk containing all the programs in this book is available from the author.   Use   the
card below or send $14.95 to:
Source Code Disk #3
Nerdworks
195 23rd NE
Salem,   OR   97301
------------------------------------------------
Order   Form -   please   print
Name _______________________
Address----------------------
City-------------- State_ Zip ___
Date--------------
Please enclose a check or money order for $14.95.
The price includes shipping and handling.
Send orders to:
Source Code Disk #3
Nerdworks
195 23rd NE
Salem,   OR   97301
./

Reading notes: Transcript intentionally left empty because exact extracted text is preserved separately; other fields are based only on the supplied copy. Headline spacing was normalized from the extracted text (original showed multiple spaces between words). The 'Date' label on the order form is a blank field label, not a printed date, so printedDates is empty. The trailing './' line and the dashed separator lines appear to be extraction artifacts or layout rules rather than advertised copy. Multiple-space gaps in the body text (for example 'Use   the' and 'Salem,   OR') are likely layout spacing from extraction and were not treated as meaningful.

Printed product names: Source Code Disk #3

Printed prices: $14.95

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-ea2274aa7dd399b99b8f3c9f6862fa473508d5a2c13abd1b364706b4958fb457)

Image description: The image is a entirely blank white page with no visible artwork, layout elements, or markings.

Reading notes: No visible text found; the page appears blank white, so transcript and printed fields are empty.

[Original PDF page 3](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-cc4f5fd7a248ddef1243b71bf12b277b54e70d1de0a20966bf6cdbb47ab4affc)

Transcribed text:

The   Complete   Book of
acintosh
Assembly   Language
Programming
Volume   II
Dan Weston
Scott,   Foresman and Company
Glenview,   Illinois   London

Reading notes: The leading 'M' of 'Macintosh' appears damaged or missing in the source, reading as 'acintosh'. Headline reconstructed from fragmented lines; word spacing in the source is irregular.

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-e91ee7f3d61134074bd4f3b495e0d5625cbc52a56dbe7414ea087f423efa5e4f)

Transcribed text:

This book is for my children,
Sarah   and Asa.
ISBN 0-673-18583-4
Copyright   ©   1987 Scott, Foresman and Company.
All Rights Reserved.
Printed in the United States of America.
Library of Congress Cataloging-in-Publication Data
(Revised for vol. 2)
Weston, Dan
The complete book of Macintosh assembly language
programming.
Bibliography: v. 1, p.   ; v. 2, p.
Includes indexes.
1.   Macintosh (Computer)-Programming. 2. Assembler
language (Computer program language).   I.   Title.
QA76.8.M3W47   1986   5.265   86-3866
ISBN   0-673-18379-3 (v. 1)
ISBN   0-673-18583-4 (v. 2)
I 2 3 4 5 6-KPF-91   90   89 88 87 86
Apple, MacPaint, MacDraw, MacWrite, and   Finder   are trademarks of Apple Computer, Inc.   Macin-
tosh is a trademark licensed to Apple Computer Inc. Microsoft and   MS-DOS   are trademarks of
Microsoft Corporation. UNIX is a trademark of AT&T. GEM is a trademark of Digital Research,
Inc. PostScript is a trademark of Adobe Systems, Inc.
Notice of Liability
The information in this book is distributed on an   "As   Is"   basis, without warranty. Neither the author nor Scott,
Foresman and Company shall have any liability to customer or any other person or entity with respect to any
liability, loss, or damage caused or alleged to be caused directly or indirectly by the programs contained herein.
This includes, but is not limited to, interruption of service, loss of data, loss of business or anticipatory profits,
or consequential damages from the use of the programs.
Scott, Foresman Professional Publishing Group books are available for bulk sales at quantity discounts. For
information, please contact: Marketing Manager, Professional Books, Professional Publishing Group, Scott, Fores-
man and Company,   1900   East Lake Avenue, Glenview, IL   60025.

Reading notes: Printed page numbers in the bibliography line are blank ('p.   ; v. 2, p.') and the Library of Congress catalog code '5.265' is ambiguous in reading order

Printed product names: Apple · MacPaint · MacDraw · MacWrite · Finder · Macintosh · MS-DOS · UNIX · GEM · PostScript

Printed dates: 1987 · 1986 · 86-3866

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-ef60ba1ccbff14d4676286547ae356909f3610b217f3946e07069e3ecf2d0fdf)

Transcribed text:

D
Contents
CHAPTER 1   Memory Management and Debugging   1
The Application Heap   1
The   System   Heap   3
Low-Memory Globals   3
The Trap Dispatch Table   5
The   Screen   and   Sound   Buffers   6
The Application Globals   7
The Big Picture   10
Pointers   10
Handles   13
A Closer Look at the Heap   16
Getting Ready to Look at the Heap   16
Identifying Heap Objects   17
Using   the Find Command to Identify Heap Objects   19
Two More Unidentified Objects   21
Other   Identified Objects   22
Debugging   Strategy   23
Program Segmentation   24
Summary   26
CHAPTER 2   New   ROM-Old   ROM   27
The Toolbox and the Operating   System   27
The Trap Mechanism   28
Trap Dispatch Table   31
64K   ROM   31
128K   ROM   32

Reading notes: Source is a table of contents rather than advertising copy; no products, prices or dates are advertised.

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-a40c6d38ce006c1356f743128c2d64a03370c45f7532d74d3426538102d722a7)

Transcribed text:

Patching   ROM   32
Trap Words and Trap Numbers   33
Two Strategies for Patching   ROM   33
System-Based   ROM   Patch   34
Application-Based   ROM   Patch   39
New Routines in 128K   ROM   44
Determining Which   ROM   Is Installed   46
Summary   47
CHAPTER   3   The   Clipboard   and   Switcher:   Sharing   Data Between Programs   48
What Kinds of Data Go on the Clipboard?   49
The Desk   Scrap   and the Private   Scrap   50
Is the Private   Scrap   Really Necessary?   53
Desk   Scrap   in Memory and on Disk   53
Putting Information on the Clipboard   54
Getting Information off the Clipboard   56
When to Convert the Clipboard   58
Program   Startup   and Termination   58
Activate/Deactivate Events and Clipboard Conversion   59
An Alternate Method for Controlling Clip Conversion   59
How Does Switcher Convert the Clipboard?   66
The Desk Accessory Ruse   67
The Switcher Event   70
Summary   73
CHAPTER   4   Using   the Print Manager   75
Available Printers   75
QuickDraw, GrafPorts, and Printers   77
Using the Print Manager   78
The Glue Routines   79
Opening the Printer Resource File   79
Setting   Up   a Print Record   80
The Print Manager Dialogs   81
Opening the Print Document/grafPort   84
The Printing Loop   85
Spool   Printing the Document   86
Closing the Print Manager   87
Example Program Module   88
The Documentation Header   88

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-bb9a766686fbeae13f100adc6c5d838ec47677af743a7b55d99422874880a2ff)

Transcribed text:

Setting   Up   the   Stack   Frame   89
Opening the Print Manager   90
Filling in the Print Record   90
Using   the Print Manager Dialogs   91
Opening the Printing Port   91
Calculating the Page   Size   92
Determining the Number of Copies   93
Imaging Each Page   94
Spool   Printing   98
Cleaning   Up   99
Optimizing for the LaserWriter   100
Installing Print Idle Procedures   102
Tweeking the Print Record   106
Summary   110
CHAPTER   5   HFS,   MFS,   and the   Standard   File   Package   112
HFS-MFS   Compatibility   113
Using   the Standard File Package   115
Parameters for   SFGetFile   116
The File Filter Procedure   117
The Dialog Hook Procedure   119
Parameters for   SFPutFile   122
Using   the File Manager with SFReply Records   122
Determining   If   HFS   or   MFS   Is Active   125
Searching for Files Directly on   MFS   Volumes   126
Searching for Files Directly on   HFS   Volumes   132
Recursion and   HFS   132
HFS-Specific   Routines   135
HFSFileSearch Code   136
Summary   145
CHAPTER   6   Making   Your   Macintosh   Talk   147
Overview of MacinTalk   147
The MacinTalk Driver   148
CheapTalkII: A   Simple   Speech   Application Example   149
The Documentation Header   150
Making the Connection to SpeechASM.Rel   151
Setting   Up   Equates   151

Reading notes: Source is a table of contents listing chapters and page numbers rather than advertising copy, so no advertised products, prices, or dates are present.

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-21eb28b4cd7b8181a5ce27d58b8e183f8e231a5e292634f80b60d33e7e66cb20)

Transcribed text:

Defining Macros   152
Setting Up Global Variables for Speech   153
Initialization   154
Opening   the Driver   154
Opening   the Dialog   155
Speaking Pretranslated Speech   157
The Dialog Loop   158
The   Dialog   Filter Procedure   159
Translating English to Phonetics and Then Speaking   165
Checking the Rate and   Pitch   167
Setting the Speech Mode   171
Ending the   Program   173
Memory Considerations   174
Putting It All Together   175
Summary   178
CHAPTER   7   Dialog   User   Items   179
Defining   User Items in the Resource File   180
The Documentation Header   183
Iriitialization   184
Installing User Items   186
ModalDialog Loop   188
Filter   Procedure   189
Line Drawing User Item
Big Button User Item
Quitting the   Program
TrackRect Utility Routine
The   Lllik   File   205
194
196
199
200
User Items and Segmentation:   Possible   Problems   205
Summary   207
CHAPTER   8   RAM Disk+   208
RAM Disk Installer   209
Memory Layout   210
The Documentation Header   212
The Equates   213
Global Variables   214

Reading notes: Source appears to be a table of contents with chapter and page numbers rather than advertising copy. Some OCR spacing irregularities (e.g., 'Iriitialization', 'Lllik') may be damaged characters.

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-d0e62b3190e94fbe397fc7cf93c4a90ea9973b7cf5a5c9c4e5c7e04b4d0c5047)

Transcribed text:

Initialization and Entry   214
The First Pass   217
The Second Pass   226
Pevice   Drivers: Overview   237
Structure of Device Drivers   237
The Driver Header   238
Entry and Exit Conventions   239
RAM Disk Driver   241
The   Open   Routine   242
The Prime Routine   244
The Control Routine   247
The Status Routine   250
The Close Routine   251
The Link Files   251
The Resource Compiler File: Putting It All Together   252
Summary   256
CHAPTER   9   The List Manager   257
Using   PACKO   to Access the List Manager   258
Creating a New List   259
Filling in the List Cells   264
Disposing of a List   265
Mouse Clicks in a Cell   266
Finding the Selected Cells   267
Changing the Size of a List Window   269
Updating a List Window   272
Activating a List Window   274
Customizing the List Manager   275
The Init Routine   278
The Draw Routine   278
The Highlight Routine   281
Creating an LDEF Resource   282
Icon Lister Program   283
Building a List of Icons   284
Setting the Selection Parameters   287
Summary   288

Reading notes: Source appears to be a table of contents with page numbers rather than advertising copy; no headline, products, prices, or dates identified. Some chapter titles contain irregular spacing, e.g. 'Pevice Drivers: Overview' likely corresponds to 'Device Drivers: Overview'.

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/1#scan-dac5d928cea0dad54ed0795f2ce9c3cb7ee92f50f56836af4d3de66934205890)

APPENDIX A Source Code Listing

Transcribed text:

APPENDIX   A   Source   Code   Listing
initPatch.ASM   289
initPatch. LINK   291
initPatch.R   292
AppPatch.ASM   293
PrintModule.ASM   295
MFSFileSearch.ASM   303
HFSFileSearch.ASM   306
CheapTalkll.ASM   310
CheapTalklI.pNK   322
CheapTalkll.R   323
UITest.ASM   325
UITest.LINK   333
UITest.R   334
TrackRect.ASM   335
RD+ Install.ASM   338
RD+ Install.LINK   351
RD+ Install.R   352
RAMDisk + .ASM   355
RAMDisk +.LINK   360
ListMacros   361
Lister.ASM   364
Lister.LINK   347
Lister.R   380
LDEF2.ASM   382
LDEF2.LINK   386
lconList.ASM   387
lconList. LINK   398
lconList.R   399
APPENDIX   B Other   Sources   of Macintosh   Information   401
APPENDIX   C   Trap Words and Heap   Compaction   Information   403

Reading notes: Source listing contains irregular spacing between words, possibly from OCR or layout extraction Some filenames show inconsistent spacing such as 'initPatch. LINK' and 'Lister.LINK'

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/ef35798515d5b48c016a3bfc0f539667b42890b38cea16c8119e0a93c443fe87/The_Complete_Book_of_Macintosh_Assembly_Language_Programming_Volume_ll_1987.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-the-complete-book-of-macintosh-assembly-language-programming-volume-ll-1987-ac7ff7/2.md)
