Color Computer Assembly Language Programming

Color Computer Assembly Language Programming

Radio /hack Cat. No. 62-2077 TRS-80 ® Color Computer Assembly Language Programming By William Barden, Jr. ■ A comprehensive guide to 6809 instruction set and registers ■ Storing data to memory ■ Condition codes ■ Addressing and branching ■ Subroutines ■ Arithmetic operations ■ ROM subroutines ■ Graphics and sound COLOR COMPUTER ASSEMBLY LANGUAGE PROGRAMMING by William Barden, Jr. Copyright 1983 by Radio Shack, a division of Tandy Corporation, Fort Worth, Texas 76102 FIRST EDITION PRINTING 9 8 7 6 5 4 3 2 All rights reserved. Reproduction or use, without express permission, of editorial or pictorial content, in any manner, is prohibited. No patent liability is assumed with respect to the use of the information contained herein. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or ommissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. International Standard Book Number: Library of Congress Book Number: Printed in USA Preface The Color Computer is an exceptionally good machine on which to learn assembly language. For one thing, it uses a 6809 microprocessor. The 6809 microprocessor is a relatively new microprocessor with a powerful instruction set and addressing modes. The 6809 has many features that aren’t found in older microproces­ sors such as the Z-80, 6800, and 6502 — completely "position independent” code, which can be moved anywhere in memory without changing values, powerful "indexing” capability with "auto increment and decrement” to automatically adjust the index registers by one or two counts, a "user” stack pointer defining a user stack area, and a built-in Multiply instruction. Another feature that makes assembly-language programming attractive on the Color Computer is the availability of EDTASM+, the Radio Shack Hditor/Assembler/Debug package. This is a ROM-pack assembler that allows the three functions to be resident in memory at one time. This means that you can switch from Edit mode to Assembly mode in the wink of an eye, and then immediately switch to the Debug portion of EDTASM+ (ZBUG) for program checking. After debugging, you can get back to the Editor and Assembler just as easily. The interactiveness of EDTASM+ makes it very easy to learn assembly- language programming, as there are no long time delays loading three different programs to Edit, Assemble, and Debug. Finally there’s the Color Computer itself. I feel that it is highly underrated. Much more than a "game machinej’ it can do some powerful programming. And, of course, it has a built-in high-resolution color graphics capability, sound generation capability, and other input/output ports, all of which can be accessed with assembly language in addition to BASIC. In this book we’ve tried to make it easy for you to learn 6809/Color Computer Assembly Language. We’ll take you from the ground up (although some knowledge of BASIC is a definite help). There're plenty of interactive examples here, and we’ve made wide use of EDTASM+ capabilities. Color Computer Assembly Language Programming has 26 chapters. The first 18 chapters cover assembly-language basics, the instruction set of the 6809, the basic addressing modes of the 6809, and use of EDTASM+. The next 3 chapters describe how to interface assembly-language programs to BASIC — how to link the two types of code, how to pass "parameters,” and where in memory to put assembly-language code. Chapter 22 discusses BASIC ROM subroutines, segments of predefined code in the BASIC interpreter that can be used by the assembly-language pro­ grammer to do things such as displaying characters on the screen and reading keyboard data. in Chapter 23 describes the more advanced addressing modes of the 6809. While these modes do not have to be used in assembly-language programs, that do offer powerful "addressing” options that are not found in many microprocessors. The next two chapters, 24 and 25, are the "fun” chapters. These cover video and graphics work and sound generation. Included are a music synthesizer program with variable "envelope” and a "zoom” capability for graphics. The last chapter, 26, gives some guidelines on writing large assembly- language programs. It covers the procedures of design, flowcharting, coding, debugging, and documentation. Six appendices are also included in the book. Appendix I provides an alpha­ betized list of instructions with a capsulized description of each. Appendix II gives a "crib-sheet” type listing of 6809 instructions in more detail. Appendix III is a complete listing of EDTASM+ commands. Appendix IV is a conver­ sion chart of hexadecimal, binary, and decimal numbers from 0 through 255 decimal. Appendix V is a listing of "two’s complement” numbers from +127 through -128 decimal. Finally, Appendix VI is a list of ASCII codes for the Color Computer. Each chapter is preceded by a "Key Chart” which lists the material covered in the chapter, plus the material covered in preceding chapters. The Key Chart helps in finding a particular topic quickly. I’ve had a lot of fun writing this book and hope that you enjoy Color Computer Assembly-Language Programming as much I have. See you at $3 F00! William Barden, Jr. To Aunts Katherine Wilke and Jeanne Damp and Uncles Larry Wilke and Kelly Damp. (Letters follow if I have my relative addressing correct.) Table of Contents Chapter 1. 6809/Color Computer Assembly Language ..........................1 The 6809 Instruction Set — Instruction Mnemonics — Comment Lines — Labels —The Assembly-Language Process — Executing (Running) the Pro­ gram — EDTASM+ Edit Commands Chapter 2. 6809 Registers ..............................................................................13 What is a 6809 Register? — Register Functions — Binary and Hexadecimal — using the ZBUG Modify Register and Modify memory Commands Chapter 3. Transferring Data to Registers ............................................... 23 Loading Registers — Immediate Loads — Transferring Data Between CPU Registers — The EXG Instruction — A Special Clear Instruction — Inherent Addressing Chapter 4. Storing Data to M emory.......................................................... 35 Extended Addressing — Simple Indexed Addressing — Direct Page Addressing — When Should You Use Direct and When Extended Addressing? Chapter 5. Addition and Subtraction ........................................................45 Eight-Bit Adds — Sixteen-Bit Adds — Subtracts — Two’s Complement Numbers Chapter 6. Using the Condition C o d e s......................................................53 More on Adds and Subtracts - the Z Condition Code — The N(egative) Condition Code — The Compare — A Special CMP — The C(arry) Condition Code Chapter 7. Symbolic Addressing, Jumps, and Branches....................... 61 Symbolic Addressing — Unconditional Jumps — Conditional Jumps (Branches) — Conditions for Branches — A Comparison Test Using Modify Memory Chapter 8. Relative Branches, Conditional, and Unconditional ........69 Relative Addressing — Types of BRs — Limitations of BRs — The Long Branch is N ot a Fort Worth Ranch Chapter 9. Increments, Decrements, Complements, and Logical Operations ..................................................................79 Increments and Decrements — The LEA for 16-Bit Registers — The NEG and COM Instructions — Logical Operations — Using ORCC and ANDCC — A Special AND Chapter 10. Using the Carry for Gobs of Precision........................... 87 Multiple-Precision Numbers — Eight-Bit Add With Carry — Eight-Bit Subtracts With "Borrow” — Other Multiple-Precision Operations A List of Data — A Numeric Table Lookup — The FCB Pseudo-Op — Entries of More Than One Byte — The FDB Pseudo-Op — The FCC Pseudo-Op —Accessing Multiple-Byte Table Entries Chapter 12. Indexing Operations Using X and Y ................................ 109 Indexed Addressing — Variable Offsets From X or Y — Table Operations Using Indexing Chapter 13. Operations of a Different Sort and Unsigned Comparisons ........................................................................121 Types of Orders — Sorting — "Auto” Incrementing and Decrementing — Labeling a Variable Location — Using Expressions — Using LJnsigned Comparisons — A Bubble Sort of a Two-Byte Entry Table Chapter 14. Using Subroutines in Assembly L an gu age......................131 Subroutine Basics — The S Stack — Nested Stack Calls — A BSR for Every RTS — Other Branch to Subroutines Chapter 15. Using the Stack to Hold Temporary Results ................. 141 Stack Uses — PSHSes and PUI.Ses — Multiple Subroutines Chapter 16. Rotates, Shifts, and Multiplication..................................... 153 Rotates — Logical Shifts — Multiplying and Dividing by Shifting — Hard­ ware Multiplies — A 16 by 8 Multiply — Arithmetic Shifts Chapter 17. An Unsigned Divide and Signed Multiplies and D iv id e s..............................................................................................165 An Unsigned Divide — Dividing by Larger Numbers — Doing "Signed” Multiplies and Divides Chapter 18. Decimal Arithmetic and Miscellaneous Instructions .. .173 The Decimal Instruction — The RMB Pseudo Op — Using the U Stack — The NOP Instruction — How to Use 6809 Instructions Chapter 19. Program Origin and Interfacing Assembly Language to BA SIC ........................................................... 181 Memory Map — The ORG (Origin) Command and / AO — Repeatability — How to Make All Code Relocatable — Transferring Control to an Assembly- Language

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    304 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us