← Macintosh Assembly Language

Macintosh Assembly Language

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

Mac M A C I N T O S H ASSEMBLY LANGUAGE AN INTRODUCTION JAN L. HARRINGTON

A yellow book cover with a red script 'Mac' logo above a teal horizontal band, and a central grid of tiles showing a pink flower with some tiles displaced or missing, with black type below.

Reading notes: The red script 'Mac' logo is stylized and read as 'Mac' with some uncertainty about exact letterforms. Spaced-letter rendering of MACINTOSH is transcribed as printed; no other uncertain spans.

Languages
English
PDF page 1

MACINTOSH ASSEMBLY LANGUAGE

Mac MACINTOSH ASSEMBLY LANGUAGE AN INTRODUCTION JAN L. HARRINGTON

A yellow book cover with a red script 'Mac' logo over a teal horizontal band, a grid of square photo tiles showing a pink flower with some tiles displaced to the lower right, and title text in black.

Reading notes: The red script 'Mac' logo is stylized and is transcribed as 'Mac'; its exact lettering may differ from a standard reading. Title and author text are clearly legible; no prices or dates are printed.

Printed product names
Macintosh
Languages
English
PDF page 2

The image is a blank white portrait-oriented page with no visible artwork, layout, or text.

Reading notes: No visible text was found in the image, so the transcript and printed fields are empty.

PDF page 3

AN INTRODUCTION

MAC I N+GSF1 AN INTRODUCTION Jan L. Harrington Bentley College Department of Computer Information Systems CBS COMPUTER BOOKS HOLT, RINEHART AND WINSTON New York Chicago San Francisco Philadelphia Montreal Toronto London Sydney Tokyo Mexico City Rio de Janeiro Madrid

Reading notes: Heading 'MAC IN+GSF1' appears garbled in the source text and may be an OCR artifact

Languages
English
PDF page 4

Production Manager: Paul Nardi Composition: The Publisher's Network, Morrisville, PA Copyright© 1986 by CBS College Publishing All rights reserved Address correspondence to: 383 Madison Avenue New York, NY 10017 Library of Congress Cataloging in Publication Data Harrington, Jan L. Macintosh assembly language. (CBS computer books). Includes index. · 1. Macintosh (Computer)-Programming. 2. Assembler language (Computer program language) I. Title. II. Series. QA76.8.M3H36 1986 005.265 85-30592 ISBN 0-03-000833-6 Printed in the United States of America Published simultaneously in Canada 678 039 987654321 CBS COLLEGE PUBLISHING Holt, Rinehart and Winston The Dryden Press Saunders College Publishing

Reading notes: Primary heading not clearly identifiable in the supplied copy; headline set to null

Printed product names
Macintosh
Printed dates
1986
Languages
English
PDF page 5

Table of Contents

Chapter 1 Chapter2 Chapter3 Chapter4 Chapters Table of Contents PREFACE INTRODUCTION Chapter Objectives 1 Assembly Language: Why Bother? 1 The Standard Macintosh User Interface 4 NUMBERING SYSTEMS: MACINTOSH'S MICROPROCESSOR AND MEMORY Chapter Objectives 15 Computer Numbering Systems and How Information is Represented in a Computer's Memory 15 Macintosh's Microprocessor 25 How Macintosh's RAM is Used 31 Addressing RAM 33 Questions and Problems 49 USING THE MACINTOSH 68000 DEVELOPMENT SYSTEM Chapter Objectives 51 Introduction 51 Using the Editor 55 The Assembler 58 The Linker 63 Running an Application 68 Run-Time System Errors 68 The Executive 72 Debugging 74 THE 68000 INSTRUCTION SET (PART 1) Chapter Objectives 80 Creating an 1/0 Shell 80 Assembler Directives 82 Data Manipulation Instructions 86 LOOPING 92 Making Comparisons 94 Testing the Condition Codes 95 Questions and Problems 99 THE 68000 INSTRUCTION SET (PART 2) Chapter Objectives 103 Integer Arithmetic 103 ix 1 15 51 80 103 v

Reading notes: Chapter numbering and page numbers in the table of contents are partly run together in the extracted copy.

Languages
English
PDF page 6

vi MACINTOSH ASSEMBLY LANGUAGE: AN INTRODUCTION Chapter6 Chapter7 Chapter a Chapter9 Logical Operations 11 O Subroutines 114 Putting the Instruction Set to Work - Sorting and Searching Arrays 116 Questions and Problems 130 THE PASCAL CONNECTION TO THE TOOLBOX AND OPERATING SYSTEM ROUTINES 133 Chapter Objectives 133 Pascal Elementary Data Types 134 User-Defined Data Types 137 Pascal Data Structures 138 Procedure and Function Calls 141 An Overview of the Toolbox and Operating System Routines 144 Calling Toolbox and Operating System Routines- The Trap Mechanism 149 Using Toolbox and Operating System Routines - Modifying the Sort and Search 150 Questions and Problems 156 SETTING UP THE DESKTOP: WINDOWS AND MENUS 159 Chapter Objectives 159 Creating Windows 159 Programming Technique- Making a Resource File Part of Program Code 175 Manipulating Windows 176 Creating Menus 183 Questions and Problems 191 CONTROLLING PROGRAM ACTIONS: MONITORING EVENTS 193 Chapter Objectives 193 The System Event Mechanism 193 Retrieving Events 198 Handling Mouse Down Events 202 Handling Key Down Events 220 Handling Update Events 221 A Word About Activate Events 223 Pulling Things Together Thus Far - WindowPlay 223 Questions and Problems 232 SCREEN AND KEYBOARD 1/0: USING TEXTEDIT, ALERT AND DIALOG BOXES Chapter Objectives 235 Entering, Displaying, and Editing Text 235 235

Reading notes: Table of contents fragment; no primary heading identified Some line-end hyphens and dashes may be OCR artifacts

Languages
English
PDF page 7

Chapter 10 Chapter 11 Chapter 12 TABLE OF CONTENTS vii Controlling Program Actions with Alert and Dialog Boxes 261 Questions and Problems 272 PRINTING 275 Chapter Objectives 275 Introduction 275 Accessing the Printing Manager 276 Data Structures for Printing 279 Programming Technique- Packing an Equates File 283 Establishing Print Records 284 The Sequence of Printing Manager Routines 285 Opening and Closing the Printing Manager 287 Collecting Information for the Print Record 287 Opening and Closing a Document 288 Printing a Single Page 289 Imaging and Printing Spool Files 300 Completing the Printing Task 301 Putting it All Together- BannerPrint 302 Questions and Problems 319 FILE 1/0 Chapter Objectives 322 Introduction 322 Data Structures for File Operations 323 Creating a Data File 330 Opening a File 332 Writing to Disk Files 333 Reading From Disk Files 336 Closing a File 339 Timing out for File 1/0 339 Managing Disk Changes and Choosing File Names - the Standard Package 340 Questions and Problems 344 322 ARITHMETIC 1/0: FLOATING POINT ARITHMETIC 347 Chapter Objectives 34 7 Introduction 347 The Binary-Decimal Conversion Package 348 Floating Point Decimal-to-Binary Conversions 350 Programming Technique - Using Separately Assembled Subroutines 355 Formats Available Through FP68K's Conversion Routines 357 Executing a Binary-to-Decimal Conversion 359 Programming Technique- Using Macros 360 An Overview of the FP68K and ELEM68K Routines 362

Reading notes: Source appears to be a table of contents; no advertised products, prices, or dates are printed.

Languages
English
PDF page 8

MACINTOSH ASSEMBLY LANGUAGE: AN INTRODUCTION

viii MACINTOSH ASSEMBLY LANGUAGE: AN INTRODUCTION Finishing the Task- Doing Binary to Decimal Conversions and Formatting Output 367 Questions and Problems 377 Appendix A THE VIDEO TAPE INDEX PROGRAM 380 Appendix B SUMMARY OF OPERATING SYSTEM AND TOOLBOX ROUTINES DISCUSSED IN THIS BOOK 448 1. INITIALIZING THE SYSTEM 448 2. USING A RESOURCE FILE 449 3. CREATING WINDOWS 449 4. MANIPULATING WINDOWS 449 5. CLOSlf'JG WINDOWS 450 6. CREATING MENUS 451 7. MANIPULATING MENUS 451 8. IDENTIFYING EVENTS 452 9. HANDLING EVENTS 453 10. HANDLING TEXT 454 11. DIALOG BOXES 456 12. ALERTS 456 13. PRINTING 456 14. MANAGIN~ COORDINATES 457 15. DRAWING· 457 16. MOVING TEXT 458 17. STRING COMPARISON 458 18. FONT CHARACTERISTICS 458 19. FILE PRpCE~SING 459 20. ARITHMETIC 459 Appendix C GLOSSARY 465 Appendix D MATERIAL~ FOR FURTHER REFERENCE 478 Index 479

Reading notes: Some OCR-like character errors in source (e.g., 'CLOSlf'JG', 'MANAGIN~', 'PRpCE~SING', 'MATERIAL~') Table of contents reading order may be uncertain in places

Languages
English
PDF page 9

PREFAeE It seems as though there is a flood of Macintosh software hitting the market these days, most of it written in Pascal on a Lisa (the Macintosh's now defunct big brother, most recently known as the Macintosh XL) or in assembly language on either a Lisa or a Macintosh. Some commercial software developers are also beginning to work in Forth and C. No language, however, gives a programmer more control over the Macintosh than assembly language. People who learn to program the Macintosh in assembly language gain in four ways: 1. They learn the basic principles of microcomputer architecture; 2. They learn how computers store and manipulate numbers; 3. They learn the basics of using an assembly language instruction set; 4. They learn to focus on creating applications with a standard, user-friendly interface. This book was written to teach the four areas listed above to both students in a classroom situation and an individual working alone. It is designed to take some- one who knows Pascal and get that person functioning in an assembly language environment. It assumes no background in computer architecture or assembly language. By the same token, it is not a definitive work. One of its primary goals is to give a programmer the tools needed to understand documentation so that he or she can independently go beyond what this book covers. Therefore, while it presents material common to assembly language programming on all computers, this is also a practical book, aimed at doing assembly language programming on the Macintosh. It was designed to teach assembly language programming specifi- cally on the Macintosh and is not intended to be a general 68000 assembly language text. Programming the Macintosh in assembly language isn't an easy task. In fact, it can be complex and tedious since access to the Macinotsh's internal ROM routines IX

Reading notes: OCR-style spelling 'Macinotsh' appears in the source text Page-running marker 'IX' appears at the end of the extracted copy

Printed product names
Macintosh · Lisa · Macintosh XL
Languages
English
PDF page 10

MACINTOSH ASSEMBLY LANGUAGE: AN INTRODUCTION

x MACINTOSH ASSEMBLY LANGUAGE: AN INTRODUCTION is really designed for Pascal, and assembly language programmers must simulate the Pascal syntax. Nonetheless, working in assembly language does give a programmer computing power that no other language can deliver. Learning to program in assembly language on the Macintosh presents two challenges: A person must not only master the microprocessor's instruction set, but also must be able to interact with the ToolBox and operating system routines that reside in Macintosh's ROM. All 1/0 is done through those routines. In tact, Macintosh assembly language programs are often little more than a series of calls to the ROM routines. The instruction set itself takes a back seat; it is used primarily to set up parameters before issuing a call. Because assembly language on the Macintosh is a rather complex task, this book is not intended to be an exhaustive treatment of the subject, but it will: 1. Provide the technical background needed to function in assembly language 2. Introduce the commonly used instructions in the Macintosh's instruction set 3. Demonstrate how to use the Tool Box and operating system routines neces- sary to create basic assembly language applications. This book does not deal specifically with producing Macintosh graphics. Creating spectacular graphics takes two kinds of knowledge: knowing how to use the ROM graphics routines and knowing how to sequence calls to those routines to draw the desired images. This book teaches the former, how to read the documen- tation that describes the graphics routines, and provides the skills needed to call the routines from assembly language. Sequencing calls to graphics routines to produce some particular picture, however, is beyond the scope of this book. The effective use of Macintosh graphics is an extensive subject that deserves a book all its own. Resources for Learning This book is based on Apple's Macintosh 68000 Development System (MOS), a package of software tools that supports the development of either stand-alone assembly language applications or assembly language routines that can be called by high-level language programs. While it is not the only such package available for the Macintosh, it is the most complete and the most convenient to use. If not available from your regular software supply house, it can be ordered directly from Apple: Macintosh Technical Support Apple Computer MS4-T 20525 Mariani Avenue Cupertino, CA 95014 To obtain an exact price and details on ordering, call the customer service line at 408-973-2222 between 9:30 A. M. and 1 :30 P. M. Pacific time.

Reading notes: Leading character before 'MACINTOSH' is garbled in the source copy '1/0' and 'tact' may be OCR misreadings of 'I/O' and 'In fact'

Printed product names
Macintosh 68000 Development System
Languages
English
PDF page 11

Complete documentation for all Macintosh ROM routines can be found in Inside Macintosh, now available at computer retailers and bookstores or through direct order from Apple. Though the book you are reading right now is indepen- dent of Inside Macintosh, programmers inevitably will wish to go beyond what this book presents and it may be difficult to teach a course in Macintosh assembly language without at least one copy of that manual available for reference. This book teaches people how to interpret what they find in Inside Macintosh, how to decipher the Pascal syntax for the Tool Box and operating system calls and turn it into assembly language. It also focuses on understanding the sequence in which they should use the ROM routines. There is one other reference that students should use in conjunction with this book and Inside Macintosh- The MC68000 Programmer's Reference Manual (hereafter referred to as the PRM). The PRM, which is included with the Macintosh 68000 Development System, is a reference work detailing the instruction set of the Macintosh's 68000 microprocessor. Developing assembly language programs is much easier with the aid of a number of utility programs that Apple has written. These include programs that dump the contents of a disk file in hexadecimal, print a spooled print file, and aid in creating screen formats and alert and dialog boxes. For a while Apple was distributing these utilities with the Software Supplement to Inside Macintosh. Now that Inside Macintosh is available in bookstores, however, the utilities can be downloaded from a number of dial-up information systems, such as CompuServe, and from public bulletin boards. They are also available from most Macintosh users groups. Reader Background This book assumes that the reader has knowledge equivalent to a one- semester course in Pascal, though not necessarily on the Macintosh. It also assumes that the reader has some experience working with the Macintosh itself. In particular, he or she should have used a Macintosh word processor such as MacWrite. Though Chapter 1 discusses in detail the characteristics of the Macin- tosh user interface, the book assumes that people are familiar with mouse-driven applications that use pull-down menus and overlapping windows. Overview of the Book The introduction found in Chapter 1 lays a foundation for the Macintosh assembly language environment. It discusses the differences between assembly language and high-level languages and explains what is to be gained by working in assembly language. The chapter also examines the characteristics of the standard Macintosh user interface, emphasizing that all successful Macintosh software adheres to that interface. PREFACE xi

Reading notes: Source header labelled PREFACE xi is not clearly a primary headline

Printed product names
Inside Macintosh · Macintosh ROM · MC68000 Programmer's Reference Manual · Macintosh 68000 Development System · MacWrite · CompuServe
Languages
English