ebook img

What's Where in the Apple. A Complete Guide to the Apple Computer PDF

275 Pages·1983·19.94 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview What's Where in the Apple. A Complete Guide to the Apple Computer

t>OC·JO""~BFr:'F ~OOOO"'SOOFF $0000""'$00 \ f" $0000"'$000' $0000""$0\' $0000 ((' $()001"'$ $0010"'$- 0$()1) 1 t ( 1 t11)012"~0C. $0~'\1 .{i!''$00 1 •ocg <2CH t n., '110016"4.\0017 $0016 t .12} [ ( rn~,..,_- What's Where in the APPLE A Complete Guide to the Apple Computer William F. Luebbert President, Computer Literacy Institute Adjunct Professor of Engineering Dartmouth College, Hanover, New Hampshire Apple I I e Appendix by Phil Daley MICRO INK P.O. Box 6502 Chelmsford, Massachusetts 01824 Notice Apple is a registered trademark of Apple Computer, Inc. MICRO is a trademark of MICRO INK. . Every effort has been made to supply complete and accurate information. However, MICRO INK assumes no responsibility for its use, nor for infringements of patents or other rights of third parties which would result. Copyright © by MICRO INK P.O. Box 6502 Chelmsford, Massachusetts 01824 All rights reserved. No part of this book may be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic or other record, without prior agreement and written permission of the publisher. What's Where in the Apple A Complete Guide to the Apple Computer ISBN: 0938222-09-0 Printed in the United States of America Printing 10 9 8 7 6 5 4 Contents Introduction 5 Chapter 1: There's More In Your Apple II System 7 Than You May Think Chapter II: The World of System-Specific Programming 9 Chapter Ill: PEEKing Can Be Informative 15 Chapter IV: POKEs Can Make Changes 21 Chapter V: CALLs Can Make Things Happen 26 Chapter VI: Apple Architecture I 41 Chapter VII: Apple Architecture II: 53 Addressing in the Apple II Microprocessor Chapter VIII: Machine-Language Programs Can Live Happily 63 In a BASIC Environment Chapter IX: Overview of Apple System 66 Memory Allocation Chapter X: The Apple System Quick-Access Area 71 Memory Page 0 ($0000-$00FF) Chapter XI: The Apple System Stack Page 72 Chapter XII: The Apple Keyboard Input Buffer 78 Memory Page 2 ($0200-$02FF) and the GETLN System of Input Associated With It ,,, Chapter XIII: The Monitor and DOS Vector Page 85 Chapter XIV: Text and Low-Resolution Graphics Display 87 Memory Pages 4-7 and 8-11 ($400-$7FF and $800-$1 BFF) Chapter XV: 'User Memory' for BASIC Programmers 93 Typically Pages 9-149 ($0800-$95FF) But Highly Variable Chapter XVI: High-Resolution Graphics Display 111 Memory Pages 32-63 and 64-95 ($2000-$3FFF and $4000-$5FFF) Chapter XVII: The Disk Operating System 125 = Default Location Memory Pages 150-191 ($9600-$BFFF) Chapter XVIII: The Specialized Input/Output Memory 134 (Some of It Behaves Very Strangely and Some Isn't There At All) Memory Pages 192-207 ($COOO-$CFFF) Chapter XIX: Applesoft BASIC Interpreter 145 Chapter XX: The System Monitor Location 150 Memory Pages 248-255 ($F800-$FFFF) Index 152 Use-Type Guide 156 Atlas 157 Gazetteer 217 Appendix A: The Apple //e --A New Edition 257 Memory Pages 192-207 and 248-255 ($COOO-$CFFF and $F800-$FFFF) Includes //e Atlas and Gazetter Author's Acknowledgements The information in this book has been accumulated over several years from a wide diversity of sources, including a variety of publications from Apple Computer, Inc., articles from many Apple user group publications and from many magazines, as well as from personal investigations triggered by one or more of these sources. Unfortunately no record was made in the computer database at the time of original entry of the original source of each datum. Nevertheless the following persons, either through their writings or through per sonal contact, come to mind as particularly significant sources of information to whom I wish to extend my special gratitude: Darrell Aldrich Andy Hertzfeld Lou Rivas Rick Auricchio Donald Hyde David Roe Bob Bishop Peter Lechner Mike Rowe C. Bongers Lee Meador Loy Spurlock John Crossley C.K. Mesztenyi Dick Suitor William Dougherty Mark Pump Don Worth Andrew Eliason Lee Reynolds Steve Wozniak Val Golding William Reynolds I know that the moment this book goes to the printer, the names of several others who have been inad vertently omitted but who fully deserve to be on this list of those deserving special acknowledgement, will rise up out of my memory to weigh upon my conscience. To such worthy but unrecognized toilers in the orchard I offer, in advance, my sincere apologies. William F. Luebbert Hanover, N.H. July 1981 Special thanks go to the Kiewit Computation Center, Dartmouth College, Hanover, New Hampshire, for assistance in producing the Atlas and Gazetteer output. Publisher's Acknowledgements A work of this complexity takes the dedicated labor of many individuals to bring it to completion. The following individuals each made significant contributions, above and beyond the call of duty. Chief Editor: Marjorie Morse provided overall management of the project through its may iterations, in addition to performing a superb job of editing and rewriting. Technical Editors: Ford Cavallari and Phil Daley gave guidance and worked diligently to produce technically accurate materials. Layout and Production: Paula Kramer was instrumental in creating an easy-to-read product. Typesetting: Emmalyn Bentley worked many hours on the detailed technical typesetting which resulted in the clean look of the book. Robert M. Tripp Chelmsford, MA INTRODUCTION You can get more out of your Apple - or any block of locations. Included are the major other computer with limited resources - by system-specific hardware locations in the familiarizing yourself with its overall hardware Apple as well as the major subroutines, and software environment. This book helps you parameters, buffers, and code-entry points get to know your Apple better. It provides you in the Apple system monitor, disk with information about hardware and software operating system, Applesoft and Integer resources that are imbedded within the Apple at BASIC interpreters. all times, but are usually hidden froiD. users other 3. Part III, the Programmers' Gazetteer, is a than exceptionally well-informed and experienced detailed breakdown of all named memory system-level programmers. locations in the Apple II system, arranged What's Where in the Apple also introduces, in alphabetical order by memory location explains, and demonstrates techniques for using name. Like the main Atlas, it contains hex this knowledge both in a BASIC language environ adecimal and decimal memory locations, ment and in an assembly-language environment. memory location name, and the nature and Even more importantly, it introduces the description of the use of the location(s) by concepts of programming in a Quasi-BASIC or the Apple II system. system-specific BASIC environment. (Quasi This information and these techniques should BASIC is BASIC augmented by non-BASIC Apple help you become a better-informed and more assembly-language firmware.) This environment creative programmer. requires little, if any, user-written machine code, but makes extensive use of machine code written It is amazing how much well-informed and and polished by the professional programmers creative programmers can get from a, micro who put the Apple II system together. computer when they use their knowledge of the inner workings and hidden mechanisms of the This work is organized in three parts: total system's hardware and software environ 1 . Part I, 'the Programmers' Guide, is a com ment. It is disheartening to see how much time prehensive guidebooki:o the hardware and many inadequately-informed programmers waste firmware organization and architecture of because they lack this knowledge. the Apple II system. It also discusses con The information and techniques presented cepts and programming techniques you here should be of special value when you graduate may find useful in exploiting the inner from simple programs to more ambitious pro workings and hidden mechanisms of the grams involving careful control of man-machine Apple II system. interaction, analog to digital or digital to analog 2. Part II, the Programmers' Atlas, is a de conversion, extensive use of computer graphics, tailed breakdown of the inner structure and the control of external devices, database manage organization of the Apple II system. Ar ment, sorting, or word-processing. When (and if) ranged in memory-address sequence, it you get into real-time programming, adding your contains specific information on each of own specialized interfaces, performing activities over 2000 memory locations and blocks of which require the absolute maximum speed or memory locations inside the Apple II absolute minimum memory utilization, the in system. This information includes hex formation here becomes critical if you don't want adecimal and decimal addresses, memory to waste time and effort wheel-spinning. location name (if any), and a description of function(sJ performed at each location or Some people may take a quick look at the Pro- 6 Introduction grammers' Atlas database listings in this book and disk operating system), can be accessed via decide that the Atlas and the system-specific pro CALLs to provide useful capabilities without gramming techniques are tools exclusively for writing any additional code. Some of the more systems programmers and machine-language (or powerful and deeply imbedded machine-language assembly-language) programmers. Because these routines will require the passing of parameters to techniques can be extremely useful to such pro and from them. This can usually be done by grammers, this belief has just enough superficial POKEs and PEEKs. truth in it to be a serious conceptual and practical Usually the code you find built into the Apple error. system has been carefully written in machine lan Though the Atlas does provide a great deal of guage, optimized by good programmers, and takes information useful in machine-language program less space or less computer time than the same ming, it still offers at least equal assistance to the function would require if programmed by the user. BASIC programmer. BASIC programmers who are Even in the most awkward cases, where deeply non-machine-language programmers may want to imbedded firmware requires the pre-setting of take full advantage of the capabilities of the com machine-level hardware registers, it is possible to puter by exercising direct control over the hard perform the set-ups without doing any assembly ware and the machine-language firmware which is or machine-language coding by use of the PEEKs, normally resident in the hardware. POKEs, and CALLs to the register SAVE and Often you can exercise this control by using RESTORE routines built into the system the information in higher-level language programs monitor. (There is another similar pair of and by changing control parameters in programs SAVE/RESTORE routines also built into the Disk that are executed by the system itself as part of its Operating System.) normal operations. Other times it may require the Some users may find it more esthetically use of machine-language subprograms which are pleasing to perform the linkage directly by using accessed by PEEKs, POKEs, and CALLs which are machine-language instructions such as LOA not themselves machine language but are written (LoaD Accumulator), LOX (LoaD X-register) or in a higher-level language, BASIC. Even then, the LOY (LoaD Y- register) to form a tiny machine only machine-language programs used may be language linkage program, load it into memory by those already available in firmware. means of POKEs or S.H. Lam's technique for PEEKs, POKEs, and CALLs all refer to memory dynamically entering and exiting the system locations which are identifiable by what they con monitor from a BASIC program. If this is your tain or what they do. PEEK examines the contents preference, you will find that it is neither of a specified memory location and allows you to necessary nor desirable to use an assembler for use that content in a program. POKE changes the this process. It is easier to hand-code from the in content of a designated memory location to some formation in the Apple Reference Manual, specified value. It can be used to change para perhaps using the disassembler in your Apple II or meters of the operating environment or to set up or Apple II+ (and/ or the mini-assembler in the change pieces of program or data. A CALL transfers Apple II) to check your work. program control to a particular memory location Incidentally, there could hardly be an easier back to the CALLing routine in the user's program. and less painful way to back gently into develop Subroutines and other pieces of code from the ing expertise for doing machine-language/ Apple's firmware (i.e., its MONITOR and BASIC assembly-language programming than by starting interpreter - Applesoft or Integer BASIC), and out with imbedding just a few machine-language from its quasi-firmware (i.e., the DOS 3.2 or 3.3 instructions into a predominately BASIC program. Chapter I functions alluded to earlier, the Apple IT system monitor (old version) contained routines that per There's More formed the following functions: moved blocks of In Your Apple ll System memory from place to place, verified that one Than You May Think block of memory contained the same contents as another, simulated the existence within the Apple of a 16-bit microprocessor (the 'Sweet-16'), 1.1 single-stepped a machine-language program, The Apple System Environment - assembled a machine-language program with mnemonic operations codes and any of several Hardware and Firmware kinds of machine addressing into binary code which will run as a program on the computer, dis~ The Apple IT system environment consists of assembled binary code back into mnemonic form, the system hardware, plus a great deal of software converted decimal inputs to hexadecimal display provided by the manufacturer, which extends the or binary internal formats or vice versa, etc. system's capabilities. The most important parts of this software are often called 'firmware.' (Note: Similarly, the Applesoft BASIC interpreter (or Firmware is software that is a permanent part of any other higher-level language interpreter) is the computer operating environment. It is always usually also a gold-mine of useful software. For available and may be considered an extension of example, it contains software packages for imple the system hardware, available regardless of what menting all the operations of floating-point kind of problem the computer is attacking and arithmetic. (Floating-point arithmetic is used for what language it is using. Software that is put into numbers which contain decimal points or scien a ROM (Read-Only Memory) and is available tific power-of-ten notation. J without any special setup procedures is a prime example of firmware. J 1.2 The 'firmest' of the firmware in the Apple IT is Making Hardware and Firmware the system monitor. Without the monitor you Resources Accessible · · could not load other programs into the system, nor make effective use of the keyboard for input, The Programmers' Guide provides a frame or the display screen for text or graphic output; work for understanding both the overall organiza the system would be functionally inoperable. tion and structure of the Apple system and those However, the monitor is not the only piece of programming techniques which exploit that firmware you'll normally find imbedded in the knowledge. The Atlas and Gazetteer provide Apple every time you try to run a program. To use supplementary detailed reference information the BASIC language you need a BASIC inter you need in actual programming. preter, either Integer BASIC Ol" Applesoft BASIC. This detailed information is presented in To use the disk sub-system you need disk 'Geographical' (Memory Map) order in the Pro operating system firmware, usually known as grammers' Atlas (Part IT) with an alphabetic-by DOS firmware. name Programmers' Gazetteer (Part ill) to pro These three major software/firmware vide an alternate means of retrieval. An optional packages each contain a gold-mine of carefully diskette version of the database together with a written routines which can make it possible to retrieval program provide machine-implemented write better, faster-running programs. However, selective retrieval as well (see page 4). most of these resources, and many of the The information in both the text and on the hardware-specific characteristics of the Apple diskette can stand alone as sources and tech system remain hidden away and are not readily niques for making more effective use of the Apple available to the typical Apple user. Oftentimes IT. You can learn a great deal about system even finding out about their existence and specific programming techniques for the Apple IT capabilities becomes a task worthy of the talents and about its hardware/software architecture of Sherlock Holmes. Sometimes only the manu from the text. You can find out how particular facturer's 'systems programmers' learn about sections of memory are used and about the char some of the features. acteristics of software in particular areas of Even within a single module of firmware there memory. You can use the Atlas database tables or can be a great diversity of routines useful to the printouts from the diskette to identify software average programmer. For example, in addition to by specific names. And you can search the disk the program-loading, input/o utput, and graphics ette database using the retrieval program on the 8 Chapter I diskette to find hardware locations, parameters, Parts II and III of this booklet. The answer is sim or software descriptions which use keywords ple; if you already know about where in the Apple you're interested in exploring. system a particular parameter, subroutine, or capability should be located, it is probably worth For example, if you're interested in all while to go to the appropriate area of memory in memory locations and software in the Apple that the tabular printout (Part III) and use the diskette relate to the 'slots' used for plug-in of auxilliary only if you can't find what you are looking for. cards, you could use the diskette to conduct a (After all, the information might be somewhere keyword search on the word 'slot'. To find out else in the Apple where you didn't expect it.) If about hi-res graphics you could search on the you already know the standard Apple name for a word 'HI-RES'. (In both cases you would be flooded parameter or subroutine, it is probably best to with more information than you are likely to look it up in the alphabetic-by-name tabular want or use, but it would all be information printout (Part III). If you don't find it, try the relative to your request. However, with a little diskette - it is often more difficult to determine practice you will learn to narrow your requests ~o standard Apple names for memory locations or exactly the information you want.) You could, m subroutines than to find out information about principle, achieve the same results more labor what they do. iously (and with a higher human-error rate) by scanning through the forty-odd pages of Apple In some cases the information on the database Atlas database printout in Part II of this book. diskette may be more brief than that in the tabular printouts. This was necessary to squeeze The Atlas will also help you find information the information into the available space on the you may already have available in sources such as diskette. A larger version of the Programmers' your language-oriented reference manual (e.g., Atlas database and retrieval program is available the Applesoft Programmers' Reference Manual) via timeshare from the Apple information library or a systems reference manual (e.g., the Apple (APPLELIB * * *) on the Dartmouth College time Reference Manual). share computing system. This system is acces You may want to know when you should use sible to any qualifed user from anywhere in the the diskette database and retrieval program and nation via the communications facilities of when you should use the tabular printouts in TELENET. Chapter ll dependent features (such as PEEKs, POKEs, and The World of CALLs) built into their versions of BASIC. Often they may see interesting, but difficult-to System-Specific Programming understand, published programs for the Apple which are made up almost exclusively of these commands. These programs are often written by 2.1 highly experienced assembly-language program BASIC Doesn't Have To Be mers who use techniques not commonly covered A Straightjacket; in academic textbooks or computer programming Neither Does Assembly Language courses. Many programmers get the false impres sion that they need esoteric knowledge if they do Often inadequately-informed programmers more than use an occasional PEEK, POKE or CALL. feel they are boxed-in by the characteristics and limitations of the BASIC language, not realizing 2.2 that the versions of BASIC available on the Apple System-Specific Programming: (and many other microcomputers) are not as limited as they think. These versions do allow A Programming Approach for BASIC you to access and exercise significant direct con and Assembly-Language Programmers trol over the hardware and firmware of your system. Programmers often mistakenly assume that to take effective advantage of the inner workings This work emphatically rejects the viewpoint and hidden mechanisms of system software and that when using BASIC you must give up control hardware capabilities they must abandon BASIC of what is happening in the software and hard and become assembly-language experts. Under ware of your computer. these circumstances it is not surprising that they This work also emphatically rejects the view don't feel strongly motivated to learn about point that BASIC and assembly-language pro machine-language code - information which is gramming are such totally separate worlds that in their computers and potentially available for the programmer must choose one or the other, their use every time they run a BASIC program. but never mix them in the same problem. It rejects Assembly-language programming is not every the viewpoint that you must become an expert one's cup of tea. Many excellent programmers assembly-language programmer before you can shy away from assembly and machine-language understand and make effective use of the inner programming because they do not want to get workings and hidden mechanisms of the software bogged down with its limitations. and hardware of your computer. Well-written assembly-language programs do Instead, this book adopts the viewpoint that often run faster and use less memory than BASIC with the Apple (and other microcomputers) you programs, but they usually take longer to write can readily shift back and forth along a con and longer to test and debug than BASIC pro tinuum of possibilities from (nearly) system grams. Human error rates in writing assembly independent BASIC, to system-specific BASIC, to language are often high. Assembly-language pro BASIC augmented by assembly or machine grams are harder to read and understand than language, to assembly language using BASIC BASIC programs. And, they are even harder to input-output and service routines, to full use of modify and update without extremely careful assembly language. documentation - and most assembly-language In fact, What's Where in the Apple suggests programs are difficult to document well. There is that the best results are obtained by taking a also a significant investment in time and effort careful look at the circumstances and at the involved in learning how to control the operation nature of the problems being attacked before of an assembler and how to use it effectively. deciding where to position yourself on this spec Often programmers associate these limita trum of alternatives. You'll discover new tions not just with full-scale assembly-language capabilities you can use in your own program or machine-language programming efforts, but ming which will challenge your creativity and in with all aspects of hardware-dependent and crease your willingness to undertake more dif system-specific programming. As a result many ficult and interesting programming tasks. avoid any programming effort that seems to have It is amazing how many capable and well any whiff of involvement with machine language informed microcomputer users fail to appreciate or the details of their computers' internal the full significance of system- and machine- architecture.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.