Atari-ST-Internals.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
INTERNALS The authoritative insider's guide By K. Gerits, L. Englisch, R. Bruckmann A Data Becker Book Published by Abacus Software Third Printing, July 1986 Printed in U.S.A. Copyright © 1985 Data Becker GmbH Merowingerstr.30 4000 Dusseldorf, West Germany Copyright © 1985 Abacus Software, Inc. P.O. Box 7219 Grand Rapids, MI 49510 This book is copyrighted. No part of this book 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 Abacus Software or Data Becker, GmbH. Every effort has been made to insure complete and accurate information concerning the material presented in this book. However Abacus Software can neither guarantee nor be held legally responsible for any mistakes in printing or faulty instructions contained in this book. The authors will always appreciate receiving notice of subsequent mistakes. ATARI, 520ST, ST, TOS, ST BASIC and ST LOGO are trademarks or registered trademarks of Atari Corp. GEM, GEM Draw and GEM Write are trademarks or registered trademarks of Digital Research Inc. IBM is a registered trademark of International Business Machines. ISBN 0-916439-46-1 Table of Contents 1 The Integerated Circuits 1 1.1 The 68000 Processor 3 1.1.1 The 68000 Registers 4 1.1.2 Exceptions on the 68000 7 1.1.3 The 68000 Connections 7 1.2 The Custom Chips 13 1.3 The WD 1772 Floppy Disk Controller 20 1.3.1 1772 Pins 20 1.3.2 1772 Registers 24 1.3.3 Programming the FDC 25 1.4 The MFP 68901 28 1.4.1 68901 Connections 28 1.4.2 The MFP Registers 32 1.5 The 6850 ACIAs 41 1.5.1 The Pins of the 6850 41 1.5.2 The Registers of the 6850 44 1.6 The YM-2149 Sound Generator 48 1.6.1 Sound Chip Pins 50 1.6.2 The 2149 Registers and their Functions 52 1.7 I/O Register Layout of the ST 55 2 The Interfaces 65 2.1 The Keyboard . 67 2.1.1 The mouse 71 2.1.2 Keyboard commands 74 2.2 The Video Connection 85 2.3 The Centronics Interface 88 2.4 The RS-232 Interface 90 2.5 The MIDI Connections 93 2.6 The Cartridge Slot 96 2.7 The Floppy Disk Interface 97 2.8 The DMA Interface 99 3 The ST Operating System 101 3.1 The GEMDOS 104 3.1.1 GEMDOS error codes and their meaning 139 3.2 The BIOS Functions of the Atari ST 140 3.3 The XBIOS 155 3.4 The Graphics 206 3.4.1 An overview of the "line-A" variables 226 3.4.2 Examples for using line-A opcodes 229 3.5 The Exception Vectors 234 3.5.1 The interrupt structure of theST 236 3.6 The STVT52 Emulator 242 3.7 The ST System Variables 247 3.8 The 68000 Instruction Set 255 3.8.1 Addressing modes 256 3.8.2 The instructions 260 3.9 The BIOS listing 268 4 Appendix - The System Fonts 443 4.1 The System Fonts 445 4.2 Alpahbetical listing of GEMDOS functions 447 11 List of Figures 1.1-1 68000 Registers 5 1.2-1 GLUE 14 1.2-2 MMU 16 1.2-3 SHIFTER 17 1.2-4 DMA 19 1.3-1 FDC1772 21 1.4-1 MFP 68901 29 1.5-1 ACIA6850 42 1.6-1 Sound Chip YM-2149 49 1.6-2 Envelopes of the PSG 53 2.1-1 6850 Interface to 68000 68 2.1 -2 Block Diagram of Keyboard Circuit 70 2.1.1-1 The Mouse 72 2.1.1-2 Mouse control port 74 2.1.2-1 Atari ST Key Assignments 84 2.2-1 Diagram of Video Interface 86 2.2-2 Monitor Connector 87 2.3-1 Printer Port Pins 88 2.3-2 Centronics Connection 89 2.4-1 RS-232 Connection 92 2.5-1 MIDI System Connection 95 2.6-1 The Cartridge Slot 96 2.7-1 Disk Connection 98 2.8-1 DMA Port 100 2.8-2 DMA Connections 100 3.4-1 Lo-Res-Mode 208 3.4-2 Medium-Res-Mode 210 3.4-3 Hi-Res-Mode 212 111 Chapter One The Integrated Circuits 1.1 The 68000 Processor 1.1.1 The 68000 Registers 1.1.2 Exceptions on the 68000 1.1.3 The 68000 Connections 1.2 The Custom Chips 1.3 The WD 1772 Floppy Disk Controller 1.3.1 1772 Pins 1.3.2 1772 Registers 1.3.3 Programming the FDC 1.4 The MFP 68901 1.4.1 68901 Connections 1.4.2 The MFP Registers 1.5 The 6850 ACIAs 1.5.1 The Pins of the 6850 1.5.2 The Registers of the 6850 1.6 The YM-2149 Sound Generator 1.6.1 Sound Chip Pins 1.6.2 The 2149 Registers and their Functions 1.7 I/O Register Layout of the ST Abacus Software Atari ST Internals The Integrated Circuits 1.1 The 68000 Processor The 68000 microprocessor is the heart of the entire Atari ST system. This 16-bit chip is in a class by itself; programmers and hardware designers alike find the chip very easy to handle. From its initial development by Motorola in 1977 to its appearance on the market in 1979, the chip was to be a competitor to the INTEL 8086/8088 (the processor used in the IBM-PC and its many clones). Before the Atari ST's arrival on the marketplace, there were no affordable 68000 machines available to the home user. Now, though, with 16-bit computers becoming more affordable to the common man, the 8-bit machines won't be around much longer. What does the 68000 have that's so special? Here's a very incomplete list of features: 16 data bits 24 address bits (16-megabyte address range!!) all signals directly accessible without multiplexer hassle-free operation of "old" 8-bit peripherals powerful machine language commands easy-to-learn assembler syntax 14 different types of addressing 17 registers each having 32-bit widths These specifications (and many yet to be mentioned here) make the 68000 an incredibly good microprocessor for home and personal computers. In fact, as the price of memory drops, you'll soon be seeing 68000-based 64K machines for the same price as present-day 8-bit computers with the same amount of memory. Abacus Software Atari ST Internals 1.1.1 The 68000 Registers Let's take a look at 68000 design. Figure 1.1-1 shows the 17 onboard 32-bit registers, the program counter and the status register. The eight data registers can store and perform calculations, as well as the normal addressing tasks. Eight-bit systems use the accumulators for this, which limits the programmer to a total of 8 accumulators. Our 68000 data registers are quite flexible; data can be handled in 1-, 8-, 16- and 32- bit sizes. Even four-bit operations are possible (within the limits of Binary Coded Decimal counting). When working with 32-bit data, all 32 bits can be handled with a single operation. With 8- and 16-bit data, only the 8th or 16th bit of the data register can be accessed. The address registers aren't as flexible for data access as are the data registers. These registers are for addressing, not calculation. Processing data is possible only with word (16-bit) and longword (32-bit) operations. The address registers must be looked at as two distinct groups, the most versatile being the registers AO-A6. Registers A7 and A7' fulfill a special need. These registers are used as the stack pointer by the processor. Two stack pointers are needed to allow the 68000 to run in USER MODE and SUPERVISOR MODE. Register A7 declares whether the system is in USER or SUPERVISOR mode. Note that the two registers work "under" A7, but the register contents are only available to the respective operating mode. We'll discuss these operating modes later. The program counter is also considered a 32-bit register. It is theoretically possible to handle an address range of over 4 gigabytes. But the address bits A24-A31 aren't used, which "limits" us to 16 megabytes. The 68000 status register comprises 16 bits, of which only 10 bits are used. This status register is divided into two halves: The lower eight bite (bits 0 to 4 proper) is the "user byte". These bits, which act as flags most of the time, show the results of arithmetical and comparative operations, and can be used for program branches hinging on those results. We'll look at the user byte in more detail later; for now, here is a brief list: BIT 0 = Carry flag BIT 1 = Overflow flag BIT 2 = Zero flag BIT 3 = Negative flag BIT 4 - extend flag Abacus Software Atari ST Internals Figure 1.1-1 68000 Registers 31 16 15 8 7 D 0 j D 1 D 2 DATA D 3 REGISTERS D 4 D 5 D 6 . D7 1 31 A 1 A 2 ADDRESS REGISTERS A 3 A 4 A 5 A6- 31 System Stack Pointer SSP A7 STACK POINTER User Stack Pointer OSP 31 24 23 PC PROGRAM I L COUNTER 15 8 7 I Sys Byte I User Byte I gj> STATUS REGISTER Abacus Software Atari ST Internals Bits 8-10, 13 and 15 make up the status register's system byte.