THE MC6809 COOKBOOK by carl d. warren Red text is the original error correction in the book For corrections to the PDF or owners of copyright of the book want to remove it, please contact by [email protected]. This PDF is made only for the preservation of information of the color computer, not to affect the copyright, will always be preferable to the original purchase, the PDF also aids in searches in the book. Or if you can not easily acquire on the market, as in my case in Venezuela. Some pages were scan at 300 DPI (if font small) but most are 200 DPI, and ABBYY FineReader 8.0 Professional Edition Dedication For ACE No questions asked TAB BOOKS Inc. TAB BLUE RIDGE SUMMIT. PA. 17214 FIRST EDITION SECOND PRINTING Copyright © 1980 by TAB BOOKS Inc. Printed in the United States of America Reproduction or publication of the content in any manner, without express permission of the publisher, is prohibited. No liability is assumed with respect to the use of the information herein. Library of Congress Cataloging in Publication Data Warren, Carl D The MC6809 cookbook. Includes index. 1. Motorola 6809 (Computer) I.Title QA76.8.M67W37 001.64 80-23359 ISBN 0-8306-9683-0 ISBN 0-8306-1209-2 (pbk.) is a trademark of Motorola Inc. Contents Acknowledgments 6 Preface 7 1 General Descriptions 9 Introduction to the 6809—Basics of the 6809 µP—High Level Language Processor—Changed Configuration—The Right Nomenclature—Variety in Clocks—6809 MPU Signal Description—Pulling the Schmitt-Trigger—Tracing the Interrupt—Establishing a System 2 6809 µP Software Architecture 25 The Software Tale—Registers, Pointers and Things—Condition Codes Are Special—6800/6809 Software Incompatibilities- Equivalencies—Performance Summary 3 Addressing Modes 37 Basic Concepts—Inherent Addressing Mode—Immediate Addressing—Extended Addressing—Direct Addressing— Register Addressing—Indexed Addressing—Indexed Indirect- Relative Addressing—Summary 4 Into the Instruction Set 56 Push-Pull and Address It—Individual instructions 5 MEK6809EA Assembler 112 Basics of the Assembler—Typical Requirements— Expressions—Symbols—Assembler Listing 6 Implementation of VTL-09 118 Direct and Program Statements—Preliminary Concepts— Arithmetic Operations Appendix A Motorola 6809D4 134 Highlights—Model Types—Expansion—Software Features— Added D4B Software Features—MEK6809D4 Description— MEK68KPD Description—Sample Programs Appendix B Hexadecimal Values of Machine Codes 148 Appendix C Programmer's Card 153 Appendix D Instruction Index 169 Index 176 Acknowledgments When any work such as this is embarked upon, it requires a massive amount of support from a variety of sources. It was necessary to rely upon the suggestions and resources of a number of people and companies. Among these people are; Ron Denchfield of AMI who supplied, most of the figures and the programmer's card, Tim Ahrens, Bill Clendinning and Irwin Carroll of Motorola, who provided various tables and important suggestions, along with the 6809D4 evaluation unit. Since this book is about computer technology, it is only ap propriate that it was created with aid of a computer. The manu script was prepared on a Heath H-89 microcomputer, and printed on an Epson TX-80 dot matrix printer. The software that was used consisted of a variety of products. Among these were the editor and text formatter available from the Heath users' group (HUG), the PIE editor from the Software Toolworks, and a very special pro gram called COPY that permits interchanging software created under HDOS to CP/M compatible files. This unique piece of magic was created by Bob Mathias, a genius of our times. Other software was supplied courtesy of Tony Gold at Lifeboat Assoc. These consisted of Organic software's Textwriter III for text formatting and Digital Research's CP/M optimized for a 4200H base. Special thanks is reserved for the finest managing editor in the magazine industry today, Jordan Backler. It is because of his suggestions, coupled with those from fellow EDN editors Bob Peterson, and Ed Teja, that this work is as concise as it is. My wife Anne and daughter Tami played probably the most important part in the creation of this book—putting up with the writing process and making sure the coffee was always available. 6 Preface As a result of the profliferation of microprocessors (µP), since 1977 hardware and software designers have been able to extend their capabilities in terms of creating useful products for everyday life. Each day, new processor introductions are opening up even more exciting vistas. Unfortunately, there is a problem associated with the introduction of the newer devices: how to correctly use them for maximum benefit and efficiency. This book, like many of its type, attempts to give the engineer or technician an expert command of the fundamentals of the 6809 microprocessor (µP), and the basic skills for writing 6809 assem bly language level code. In systematic fashion, it proceeds from analysis of the microprocessors design to its important electrical characteristics. It continues with discussion on matters like inter nal logic, comparison to the 6800, interfacing to peripherals, software architecture, addressing techniques and the instruction set. It concludes with advice on how to build or make use of existing 6809 based systems. Further enhancing The MC6809 Cookbook's usefulness is the inclusion of a programmer's card, provided courtesy of American Microsystems Inc. (AMI). The MC6809 Cookbook may be studied as a course, proceed ing from the simple to the more complex. However, it should be more appropriate viewed as a reference source to be called upon as necessary. Therefore, I have kept the idea of a compact and concise reference work utmost in my mind while creating this book. As a 7 result of this goal, the diversified contents are readily identifiable to facilitate the finding of specific principles or functions associated with the 6809 µP. The MC6809 Cookbook aims to be comprehensive without being cumbersome. It seeks in all areas to be exact, clear and succinct. Throughout this book, µP, and µC are used to mean micro processor and microcomputer, respectively. These are stylistic nuances used at EDN magazine, and permit brevity without being imprecise. carl d. warren 8 General Descriptions The 6809 /xP, developed by Motorola and second sourced by American Microsystems Inc. (AMI), is a high performance mul- tifaceted device. It is considered by many industry observers and Motorola to be the interim processor between 8-bit and 16-bit devices. The general design philosophy of the device seems to support this conjecture in that it permits the handling of 16-bit registers with powerful instructions. INTRODUCTION TO THE 6809 The 6809 µP is unique because it represents an upward growth device from the ubiquitous 6800 (µP. This upward growth is in the form of software compatibility, at the source code level, and apparent similar operation of the two devices. As a result of these similarities, it is possible to design the 6809 µP into a variety of applications. Among these applications are process control, automobile system monitoring, television sets, intelligent terminals and other devices more far reaching than this book could even begin to mention. As an example of the use of the 6809 µP was recently incorporated into what will more than likely become the small computer system of the decade, the Radio Shack TRS-S0 Videotex (Fig. 1-1). This unit not only uses the 6809 /xP, but the entire spectrum of Motorola support and peripheral chips. The point is that it shows the flexibility of the 6809 µP. 9