Family Systems Design and Data Book 1st Edition Basic Decisions in System Design 1<11111 Product Selection Guide A First Encounter: Getting Your Hands on a 9900 Hardware Design: Architecture and Interfacing Techniques Software Design: Programming Methods and Techniques Instruction Set 6...._ Program Development: Software Commands- Descriptions and Formats Product Data Book Applications Glossary, Appendix 9900 Family Products PRODUCT AND AVAILABILITY INFORMATION: • Contact a TI Sales Office or authorized Distributor. Additional copies of the 9900 Family System Design Book LCC4400: • Contact an authorized distributor, or send purchase order to: Texas Instruments Incorporated P.O. Box 225012 M/S 54 Dallas, Texas 75265 Complete worldwide listing of TI Sales Offices and Distributors in the appendix on pages A-15 and A-16. 11 9900 Family Systems Design and Data Book .\f . • '" • . . •- - - . FIRST EDITION By: William D. Simpson, MSEE, Staff Consultant Gerald Luecke, MSEE, Manager of Technical Product Development Don L. Cannon, PhD., Staff Consultant David H. Clemens, Staff Consultant Texas Instruments Learning Center and The Engineering Staff of Texas Instruments Incorporated TEXAS INSTRUMENTS INCORPORATED P.O. Box 1443 M/S 6404 Houston, Texas 77001 LCC4400 97049-118-NI Printed in U.S.A. iii Acknowledgement: Many members of the engineering and marketing staff of Texas Instruments Incorporated have contributed previously authored materials for the content of this book. The contributions, which are significant but are too numerous to identify individually, have been edited and combined with original authored material into the present book written by the Texas Instruments Learning Center and its staff consultants. A final review and edit was done by the 9900 Family marketing and engineering staffs. Design and artwork by: Schenck, Plunk & Deason ISBN 0-89512-026-7 Library of Congress Catalog Number: 78-058005 IMPORTANT Texas Instruments makes no warranty, either express or implied, including but not limited to any implied warranties of merchantability and fitness for a particular purpose, regarding these materials and makes such materials available solely on an "as-is" basis. In no event shall Texas Instruments be liable to anyone for special, collateral, incidental, or consequential damages in connection with or arising out of the purchase or use of these materials and the sole and exclusive liability to Texas Instruments, regardless of the form of action, shall not exceed the purchase price of this book. Copyright CJ 1978 Te?'as Instruments Incorporated. All rights reserved. Unless otherwise noted, this publication, or parts thereof, may not be reproduced in any form by photographic, electrostatic, mechanical, or any other method, for any use, including information storage and retrieval. For condition of use and permission to use materials contained herein for publication in other than the English language, apply to Texas Instruments Incorporated. For permissions and other rights under this copyright, please write Texas Instruments Learning Center, P.O. Box 225012 MS-54, Dallas, Texas 75265. iv 9900 FAMILY SYSTEMS DESIGN TABLE OF CONTENTS Chapter 1. Basic Decisions in System Design .. . . . . 1-1 Introduction . . . . . . . . . . . . . . . . . . . . . .1-2 The Impact of Semiconductors . . . . . . . . . . .1-3 Applications of Programmable Semiconductors. .1-11 Single-Chip Microcomputer Applications . . .. 1-12 Multi-Chip Microcomputer Applications . . . 1-13 Building a Microprocessor Based System . 1-15 Basic Hardware Components . . . . . . . . 1-15 Programming for Microcomputers . . . . . . 1-17 Which Microprocessor or Microcomputer to Use .. . 1-20 Evolution of Memory-to-Memory Architecture . . . 1-22 Getting up to Speed on Microprocessors . 1-30 Bibliography . . . . 1-31 Books . . . . . . . . . . . . . . . . . . . 1-31 Articles . . . . . . . . . . . . . . . . . . 1-32 List of Periodicals to be Monitored. . 1-32 Chapter 2. Product Selection Guide . . . 2-1 The 9900 Family - What Is It? . . . . . . . . . . 2-2 Family Overview . . . . . . . . . . . . . . . . . . . . . . . 2-2 The Hardware Family . . . . . . . . . . . . . . . . . 2-2 The Software and Development Systems Support . 2-2 Typical Applications . . . . . . . . . . . . . . . . . . 2-8 Hardware Selection . . . . . . . . . . . 2-9 The Component Route: CPU . . . 2-10 CPU Selection. . . . . . . . 2-12 Flexible 1/0 . . . . . . . . . 2-14 Family Members Fitted to the Application . 2-15 Interrupt Flexibility . . . . . . . 2-15 Advantages of 9900 Family CPUs . . 2-15 True Compatibility . . 2-15 Lower Costs . . . . . . . . . . . . 2-15 Instruction Set . . . . . . . . . . . 2-16 Memory-to-Memory Architecture . . 2-16 The Component Route: Peripherals . . . . 2-17 Interface Techniques . . . . . . . . . . ... 2-18 Serial 1/0 for Data Communications . 2-18 ParalleU/O . . . . . . . . . . . . 2-18 Clock and Support Logic . . . . . . . . 2-21 Cost Effectiveness of NMOS LSI . 2-22 CRU Interface . . . . . . . . . . . . . 2-23 The Component Route: Memory ... . . 2-23 The Component Route: Miscellaneous Components. . 2-28 The Modular Route: Microcomputer Modules . . 2-29 The Minicomputer Route . . . . . . . . . . . . . ... . 2-34 9900 FAMILY SYSTEMS DESIGN T-1 TABLE OF CONTENTS 9900 Family Software and Development Systems . 2-36 Importance of Software . . . . . . 2-36 Software Development Systems. . 2-37 Support Software and Firmware . 2-46 Chapter 3. A First Encounter: Getting Your Hands on a 9900 ................................ 3-1 Purpose ... . . 3-2 Where to Begin . . . . . . . . . . 3-2 What You Have . . . . . . . . . . . 3-3 Getting It Together. . . . . . . . 3-5 Unpacking and Checking the Microcomputer (TM 990/lOOM-1) . . 3-13 Connecting the Microterminal TM 990/301 . . 3-15 Operating the Microcomputer . . . . . . . 3-15 Telling the Microcomputer What to Do .. . 3-18 How Was It Done? .. . 3-24 Back to Basics . . . . . 3-25 Registers . . . . . . . . . 3-26 Workspace . . . . . . . . 3-28 SBZ and SBO Instructions. . 3-30 1/0 Selection . . 3-32 TB Instruction. . . . . 3-34 Idea to Flowchart . . . 3-35 Flow Charts . . . . . . 3-36 WAIT Subroutine .. . 3-38 Subroutine Jump . . . . . 3-39 A Loop Within the WAIT Subroutine . 3-41 Loading a Register for the Time Delay . 3-42 Where Does the Program Start? . 3-43 Writing the Program . . . . . . . . 3-45 WAIT Subroutine Call. . . . .. . 3-46 Return from WAIT Subroutine. . 3-47 Writing the Machine Code . . .. 3-52 Immediate Instructions. . 3-52 Instructions SBO, SBZ . . .. 3-54 Instruction BL. . . . . . . .. 3-55 Miscellaneous Instructions. . 3-55 Jump Instructions . . . . . . . 3-56 Summary . . . . . . . . . . . . . . . 3-59 Assembly Language Program: Table 3-2 . . . 3-60 Chapter 4. Hardware Design: Architecture and Interfacing Techniques . 4-1 Introduction . . . . . . . . . . . . .4-2 Architecture . . . . . . . . . . . . .4-5 Basic Microprocessor Chip ... .4-5 Microprocessor Registers . . . . .4-5 Memory-to-Memory Architecture . .4-9 Context Switching . . . . . . . . . . . .4-11 T-2 9900 FAMILY SYSTEMS DESIGN TABLE OF CONTENTS Memory . . . . . . . . . . . . . . 4-12 Memory Organization .. . 4-13 Memory Control Signals . . 4-15 Static Memory. . . . 4-23 Dynamic Memory. .4-25 Buffered Memory . . 4-28 Memory Parity . .4-28 Memory Layout. .4-30 Instruction Execution . 4-32 Timing .. .4-32 Cyclic Operation .4-35 Input/Output . . . . . . . . . .4-42 Direct Memory Access. . 4-42 Memory Mapped II 0 . . .4-43 Communications Register Unit (CRU) .. .4-45 CRU Interface . . . . . .4-46 CRU Interface Logic. .4-46 Expanding CRU 1/0. .4-47 CRU Machine Cycles .4-47 CRU Data Transfer. . . 4-51 CRU Paper Tape Reader Interface . . . . . . . . .... 4-54 Burroughs SELF-SCAN Display Interface .. .4-57 Interrupts . . 4-59 Reset . . . . . . . . . . .4-60 Load . . . . . . . . . . .4-61 Basic Machine Cycle . .4-63 Maskable Interrupts . .4-64 Interrupt Service .. . .. 4-64 Interrupt Signals .. .4-66 Interrupt Masking . .4-67 Interrupt Processing Example .. . 4-70 Electrical Requirements . . . . . . . . . . . . 4-71 Understanding the Electrical Specifications ... . .4-71 Detailed Electrical Interface Specifications (TMS 9900) . . 4-75 TMS 9900 Clock Generation . .4-75 TMS 9900 Signal Interfacing . . . . . 4-78 TMS 9940 Microcomputer . . . . . . . . . . . . .. 4-82 Pin Assignments and Functional Control . 4-83 Interrupts . . . . . . . . . . . . . . . . . .. 4-83 Decrementer. . . . . . . . . . . . . . . . . . . . . . . . .. 4-86 CRU Implementation. . . . . . . . . . . . . . . . . . . .. 4-86 Multiprocessor System Interface (MPS!) . 4-87 Summary . . . . . . . . . . . . . . . . . . . . .. 4-88 9900 FAMILY SYSTEMS DESIGN T-3 TABLE OF CONTENTS Complete Listing of Machine Cycles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-89 Machine Cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-89 9900 Machine Cycle Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-90 Terms and Definitions . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-90 Data Derivation Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-91 Workspace Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-91 Workspace Register Indirect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-91 Workspace Register Indirect Auto-Increment (Byte Operand) . . . . . . . . . . . . . . . . . . . . 4-91 Workspace Register Indirect Auto-Increment (Word Operand) . . . . . . . . . . . . . . . . . . . . 4-91 Symbolic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-92 Indexed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-92 Instruction Execution Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ... 4-92 A, AB, C, CB, S, SB, SOC, SOCB, SZC, SZCB, MOV, MOVB, COC, CZC, XOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-92 MPY (multiply) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-93 DIV (divide) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-94 XOP . . . . . . . . . . . . . . . . . . . . . . . . . . : . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-94 CLR, SETO, INV, NEG, INC, INCT, DEC, DECT, SWPB . . . . . . . . . . . . . . . . . . . . . 4-95 ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-95 x ........................................................ 4-96 B. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-96 BL .. .' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-96 BLWP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-97 LDCR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-97 STCR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-98 SBZ, SBO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-99 TB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-99 JEQ, JGT, JH, JHE, JL, JLE, JLT, JMP, JNC, JNE, JNO,JOC,JOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-99 SRA, SLA, SRL, SRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-100 AI, ANDI, ORI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-100 CI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-101 LI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-101 LWPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-101 LIMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-101 STWP, STST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-102 CKON, CKOF, LREX, RSET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-102 IDLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-102 RTWP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-103 Machine-Cycle Sequences in Response to External Stimuli . . . . . . . . . . . . . . . . . . . . . . . . . . 4-103 RESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-103 LOAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-104 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-105 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-105 T-4 9900 FAMILY SYSTEMS DESIGN TABLE OF CONTENTS Chapter 5. Software Design: Programming Methods and Techniques . . . . . . 5-1 9900 Architecture . . . . . . . . . . . .5-2 Instruction Register and Cycle . 5-4 Program Counter (PC) .. . .5-6 Status Register (ST) . . . . . . . . 5-7 Workspace Pointer (WP) ... . . 5-8 Program Environment or Context . . 5-9 Memory Organization . . . . . . . .5-10 ROM/RAM Partitioning . .5-11 Reserved Memory . . . . . . 5-11 Workspace Utilization . . . . . . . . 5-12 The Workspace Concept and Uses. . . ..... . . .. 5-12 Dedicated Areas of Workspaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-15 Workspace Location . . . . . . . . . 5-17 Subroutine Techniques . . . . 5-19 Types of Subroutines . . . . . 5-19 Parameter Passing . . . . . .5-25 Multiple Level Shared Workspace Subroutines. . 5-28 Shared Workspace Mapping. . 5-28 Re-entrant Programming .5-30 Programming Tasks . . . . . . . .5-33 Initialization . . . . . . . . . .. 5-33 Masking and Testing . . .5-35 Arithmetic Operations .. ... 5-38 Input/Output . . . . . . . . . . . .5-43 Memory Mapped Input/Output .5-43 CRU Input/Output . . . . . .5-44 Input/Output Methods .. . .5-45 Chapter 6. Instruction Set . . 6-1 Software Features of the 9900 ... . 6-2 Processor Registers and System Memory . . 6-2 Program Counter . . 6-3 Workspace ... . 6-3 Status Register . . . 6-4 Addressing Modes . . . . .6-6 Workspace Register Addressing .. . . . . . 6-6 Workspace Register Indirect Addressing . . .... 6-6 Workspace Register Indirect Addressing with Autoincrement .. . . . . . 6-6 Symbolic or Direct Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7 Indexed Addressing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8 Special Addressing Modes . . . . . . . .6-8 Assembly Language Programming Information . . . .6-10 Assembly Language Formats . . . . . . . . . 6-10 Terms and Symbols . . . . . . . . . . . .. 6-11 Survey of the 9900 Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 9900 FAMILY SYSTEMS DESIGN T-5 TABLE OF CONTENTS Instruction Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16 Data Transfer Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . ... 6-18 LI Load Immediate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18 LIMI Load Interrupt Mask Immediate . . . . . . . . ... 6-18 LWPI Load Workspace Pointer Immediate . . .. . . . . . . . . . . . . . . . . . . . . . 6-19 MOV Move Word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 MOVB Move Byte . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . . . 6-20 SWPB Swap Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-21 STST Store Status . . . . . . . . . . . . . . . . . 6-21 STWP Store Workspace Pointer . . . . . . . . . 6-22 Arithmetic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23 A Add Words. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23 AB Add Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-24 AI Add Immediate . . . . . . . . . . . . . . . . . . . . . . . . . 6-25 S Subtract Words . . . . . . . . . . . . . . . . . . . . . . 6-25 SB Subtract Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-26 INC Increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-27 INCT Increment by Two . . . . . . . . . . . . . . . . 6-27 DEC Decrement . . . . . . . . . . . . . . . . . . . . .... 6-28 DECT Decrement by Two . . . . . . . . . . . . . . . .. 6-28 NEG ·Negate . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 ABS Absolute Value . . . . . . . . . . . . . . . . . . . . . . . . . . 6-29 MPY Multiply .. . . . . . 6-30 DIV Divide . . . . . . . . . . . . . . . . . . . 6~31 Comparison Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32 C Compare Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-32 CB Compare Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . 6-33 CI Compare Immediate . . . . . . . . . . . . . . . . . . . . . . ... 6-34 COC Compare Ones Corresponding . . . . . . . . . . . . 6-34 CZC Compare Zeroes Corresponding . . . . . . . . ... 6-35 Logic Instructions . . . . . . . . . . .... 6-36 ANDI AND Immediate . . . . . . . . . . . . . . . 6-36 ORI OR Immediate . . . . . . . . . .6-37 XOR Exclusive OR . . . . . . . . .. 6-38 INV Invert . . . . . . . . . . . . . . . . .. 6-38 CLR Clear . . . . . . . . . . . . . .. 6-39 SETO Set to One . . . . . . . . . . . . . . . . . 6-39 SOC Set Ones Corresponding . . . . . . . . . . . . 6-40 SOCB Set Ones Corresponding, Byte . . . . . . . . . . . . . . . . . . . ... . . . . . . . . . . . 6-40 SZC Set to Zeroes Corresponding . . . . . . . . . . . . . .6-41 SZCB Set to Zeroes Corresponding, Bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-42 Shift Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-43 SRA Shift Right Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-43 SLA Shift Left Arithmetic . . . . . . . . . . .6-44 SRL Shift Right Logical . . . . . . . . . . . . . . . . . . . . . . . . . . ... 6-45 SRC Shift Right Circular. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-45 T-6 9900 FAMILY SYSTEMS DESIGN TABLE OF CONTENTS Unconditional Branch Instructions . . . . . . . . . . . . . . . . . . .. 6-46 B Branch . . . . . . . . . . . . . . . . . . . . . . 6-46 BL Branch and Link. . . . . . . . . . . . . . . . . . . . .. 6-47 BLWP Branch and Load Workspace Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 6-48 XOP Extended Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-49 RTWP Return with Workspace Pointer . . . . . . . . . . . . . . . . . .. . . 6-50 JMP Unconditional Jump. . 6-50 X Execute. . . . . . . . . . . .. . . . . . . . . . . . . . .. 6-51 Conditional Jump Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-52 JH, JL, JHE, JLE, JCT, JLT, JEQ, JNE, JOC, JNC, JNO, JOP . . . . . . . . . . . . . . . . . . . . . . 6-52 CRU Instructions . . . . . . . . . . . . . 6-53 SBO Set Bit to Logic One ... 6-53 SBZ Set Bit to Logic Zero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 6-54 TB Test Bit. . . . . . . . . ...... . . .. 6-54 LDCR Load CRU .. . 6-55 STCR Store CRU . . . . . . . . . . . . 6-57 Control Instructions . . . . . . . . . . . . . . . 6-58 LREX, CKOF, CKON, RSET, IDLE, . 6-58 Special Features of the 9940 . . . . . . . . . . . . . . 6-59 LIIM Load Immediate Interrupt Mask . .6-59 XOP Extended Operation . . . . . . . . . . 6-60 DCA Decimal Correct Addition . . . . . . . . . . . . . . 6-61 DCS Decimal Correct Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-62 Chapter 7. Program Development: Software Commands - Descriptions and Formats ........... . . 7-1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2 Assembly Language Programming: Formats and Directives . . . 7-3 Assembly Language Application . . . . . ..... . . . 7-4 Assembly Language Formats . . . ....... . . . 7-4 Terms and Symbols . . . . . . . . . . . . . . . . . . . . . . .. 7-6 Assembler Directives. . . . .. . . 7-8 Program Linkable Directives . . .. 7-15 Assembler Output . . . . . . . . . ..... . . 7-15 9900 Reference Data . . . . . . . . . . . . . . ... . . . . . . 7-17 TM990/ 402 Line-by-Line Assembler User's Guide ....... . . 7-25 General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-26 Operation . . . . . . . . . ... 7-27 Setup . . . . . . . . . . . . . . . . . . . . . . . 7-27 Inputs to Assembler . . . . . 7-27 Exiting to the. Monitor .. . 7-32 Pseudo-Instructions. . . . . 7-32 TIBUG Monitor . . . . . . . . . . 7-33 TM990/302 Software Development Board . . . . . . . . . . . . . 7-37 TXDS Commands for FS990 Software Development System . . . 7-43 AMPL Reference Data . . . . . . . . . 7-50 POWER BASIC MP 307. . 7-66 Cross Support . . . . . . . . . . . . . . . 7-76 9900 FAMILY SYSTEMS DESIGN T-7 TABLE OF CONTENTS Chapter 8. Product Data Book .................................... ,. ... 8-1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2 Family Description . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8-2 Common Key Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3 Key Features of Specific Devices . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 Organization of CPU Data Manuals and Instruction Set . . . . . . . . . . . . . 8-5 TMS 9900 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7 TMS 9900 Electrical Specifications . . . . . . . . . . . . . . . . . . . . 8-24 TMS 9900-40 Electrical Specifications . . .. 8-28 SBP 9900A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8-30 Architecture . . . . . . . . . . . . . . . . . . . . . . .. 8-31 Interfacing . . . . . . . . . . . . . . . . . . . . . . . . 8-47 Power Source . . . . . . . . . . . . . . . 8-50 Electrical Specifications · · · · · · · · · · · · · · · . . . . . . . 8-52 TMS 9980A/TMS 9981 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-56 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-58 Electrical Specifications . . . . . . . . . . . . . . . . . . . . . . . . 8-82 TMS 9940 . . . . . . . ... 8-85 Architecture . . . . . . . . . . . . . . . . . . . . .. 8-87 Instruction Set. . . . . . . . .. 8-103 EPROM Programming . . . . . . . . . . . . . .. 8-106 Test Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-109 Electrical Specifications . . . . . . . . . . . . . . . . . . . . .. 8-109 Design Support . . . . . . . . . . . . . . . . . . . . . 8-111 TMS 9985 - A Summary . . . . . . . . . .. 8-113 9900 Instruction Set . . . . . . . . . . . . . . . . . . . . 8-125 Peripheral and Interface Circuits . . . . . . . . . . . . . . . . . . . . . 8-137 TMS 9901 Programmable Systems Interface . . . . . . . . . . . 8-138 TMS 9902 Asynchronous Communications Controller . . . . . 8-160 TMS 9903 Synchronous Communications Controller . . .. 8-194 TIM 9904 Four-Phase Clock Generator Driver . . . . . . . . . . 8-249 TIM 9905 Data Selectors/Multiplexers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-263 TIM 9906 8-Bit Addressable Latches . . . . . . . . . . . . . 8-266 TIM 9907 8-Line-to-3-Line Priority Encoder . . .. 8-269 TIM 9908 8-Line-to-3-Line Priority Encoder . . .. 8-274 TMS 9909 Floppy Disk Controller . . . . . . . . . . 8-277 TMS 9911 Direct Memory Access Controller . . . . . . . . . . . . . ... 8-282 TMS 9914 General Purpose Interface Bus Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . 8-288 TMS 9915 Memory Timing (and Refresh) Controller Chip Set . . . . . . . . . . . . . . . . . . . 8-296 TMS 9927 Video Timer/Controller. . . . . . . . . . . . . . ....... . . . . . . 8-297 TMS 9932 Combination ROM/RAM Memory . . . . . . . . . . . . . . . . . 8-302 TMS 3064 65,536-Bit CCD Memory . . . . . . . . . . . . . . . . .. 8-307 TMS 6011 Asynchronous Data Interface (UART) . . . . . . . . . . . . . . . . . . . 8-307 T-8 9900 FAMILY SYSTEMS DESIGN TABLE OF CONTENTS SBP 9960 1/0 Expander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-308 SBP 9961 Interrupt Controller/Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-316 SBP 9964 Timing Controller for the SBP 9900A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-329 SBP 9965 Peripheral Interface Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-330 TM 990 Series Microcomputer Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-331 TM 990/lOOM Microcomputer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8-338 TM 990/101 Microcomputer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8-342 TM 990/180 Microcomputer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8-346 TM990/201 Memory Expansion Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-351 TM 990/206 Expansion Memory Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-356 TM 990/310 1/0 Expansion Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-360 TM990/301 Microterminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-364 TM990/401 TIBUG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-368 TM 990/ 402 Line-by-Line Assembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-369 TM 990/ 500 Accessories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-370 TM 990/189 University Microcomputer Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-373 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3 75 Dynamic Random-Access Memory (RAM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-376 Static Random-Access Memory (RAM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-380 Read-Only Memory (ROM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-384 Programmable ROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-387 Eraseable Programmable ROM . . . . . . . . " . . . . . . . . . . . . . . . . . . . . . . . . . . . . : .... 8-389 Mechanical Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-391 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-397 TMSWlOlMT Transportable Cross-Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-398 TM 990/302 Software Development Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-400 TM 990/ 40DS Design Aid for TMS 9940 Microcomputer . . . . . . . . . . . . . . . . . . . . . . . . . 8-406 TM 990/450, 451, 452, TMSW201F POWER BASIC Family . . . . . . . . . . . . . . . . . . . . . . 8-409 Chapter 9. Applications ............................................. 9-1 A Simulated Industrial Control Application (With TM990/100M Microcomputer and 5MT 1/0 Modules) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 A Low Cost Data Terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-75 TMS 9900 Floppy Disk Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .... 9-89 Glossary ......................................................... G-1 Appendix ........................................................ A-1 9900 FAMILY SYSTEMS DESIGN T-9 CHAPTER 1 Basic Decisions In System Design 1~ INTRODUCTION Basic Decisions In System Design INTRODUCTION Texas Instruments has developed and is manufacturing a family of microprocessor ~1 products and systems based on the architecture of its 990 minicomputer. The purpose of this book is to present enough factual information about the 9900 and the family of devices and systems surrounding it to serve not only as a guide for deciding to use the 9900 in an application, but also as the primary reference for design and programming activities. The book is much more than a data book or a collection of application notes. It contains basic concepts, presents methods and techniques, and most important of all, shows how the architecture of the 9900, substantially superior to other microprocessor architectures, can be translated into cost effective applications. The time investment you make in learning how to use the 9900 will inevitably produce substantial benefits because your designs will be advanced well beyond other microprocessor systems; they will be expandable, flexible, easily upgraded and will not be obsolescent. The capital investment in programming systems will bring powerful computing equipment and software. tools to your design team that will have them out- distancing the competition in a very short time. In reading this book, you _will see the 9900 product as more than a single microprocessor. You will find a family of processors, peripherals, boards, minicomputers and systems all based on a single architectural concept called memory-to-memory architecture. It is this basic principle which, when fully understood at the fundamental level, will help you understand why and how the 9900 can be used to implement outstanding products. In addition, you will see why Texas Instruments has made the commitment to the continued support of the 9900 family in both hardware and software. New microprocessors and peripheral devices will retain and complement the basic architectural features-the 16-bit word length, the instruction set, the I/ 0 techniques. etc. Texas Instruments software support goes beyond the standard assembler, editor, linker and PROM programmer software. New design tools such as POWER BASIC and PASCAL are now available. These powerful software products bring structured programming disciplines into focus and help you to attain an advanced programming capability. All in all, the book is a collection of useful factual material which should be of substantial benefit to anyone considering designing with microprocessors. For those who have very limited exposure to designing with semiconductor products, the next few sections will be helpful because the theme of "more functions at lower cost" is demonstrated. These ideas lead to the basic philosophy that designing with standard hardware - semiconductor LSI products which are programmable - is the most economical procedure, and should be carefully considered for every new electronic product. 1-2 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design THE IMPACT OF SEMICONDUCTORS THE IMPACT OF SEMICONDUCTORS In the short thirty years since the invention of the transistor (the first semiconductor device to exhibit amplification), there have been more inventions and more scientific and 1 <111111111 engineering accomplishments than in all time previous. The field of digital electronics (especially computers) has been the greatest contributor of new products for these accomplishments and, therefore, has become one of the most rapidly growing industries. Manufacturers of semiconductor components (transistors, integrated circuits, microprocessors and memories) have been providing the building blocks, and the equipment manufacturers have been taking advantage of the opportunity by developing the most sophisticated systems that are economically feasible. In his keynote address to the 1977 National Computer Conference, Mark Shepherd, Chairman of the Board of Texas Instruments, made the following points: "Until 1971, the semiconductor industry was in the circuits business. Semiconductor circuits, complex though they were, constituted only a fraction of an entire system. The one-chip calculator developed in 1971 was the first significant complete system. Since then many calculators and watches have been developed where the entire system function is accomplished by one or a few semiconductor chips. These were custom chips because the technology did now allow any reserve computing power for other applications. "The semiconductor industry has now entered an era where the entire system function of an end product can be accomplished by a few semiconductor chips, or a single chip, with enough versatility to permit adaptation to many different applications through programming. "This change carries enormous implications for the system designer. 1) The lead time for system implementation is shortened because no special chip development is required. 2) The development cost will be low because it will be limited to software (which may be executed in hardware). 3) The required degree of electronic sophistication on the part of the user is much less. To achieve these advantages the system designer must be prepared to use standard products produced in large volume rather than custom devices. "The functional equivalent of a medium-scale computer (Figure 1-1) cost $30,000 in the early 1960s. Its cost equivalent has now dropped to $4,000 and is projected to be at less than $100 by 1985, penetrating the personal cost threshold. As this is accomplished, greater challenges will be encountered in the cost of sales, service, and maintenance, requiring that we learn to incorporate self-diagnostic and self- repair functions into our systems." 9900 FAMILY SYSTEMS DESIGN 1-3 THE IMPACT OF SEMICONDUCTORS Basic Decisions In System Design ~1 100,000 1-----+-----+-----+-----+------+------1 Cf) a: ~ 10,000 l-----+--~...!::----+----1----+----l ~-' -------I '' 1960 1965 1970 1975 1980 1985 Figure 1-1. Cost of Medium Scale Computer (M. Shepherd, 1977 NCC) The cost of the hardware components for a typical digital system has been decreasing with time because new and more powerful semiconductor devices have been developed. Equally important is the fact that the development cost for the typical digital system hardware has also been decreasing. Figure 1-2 illustrates how impressive this cost reduction has been. Contrast the figures of 7-8 million dollars in the early fifties with 8-9 thousand dollars in the late seventies; digital system development cost has been reduced by a factor of one thousand in a period of 25 years! An extension of this trend indicates that typical system hardware development cost will be approximately $1,000 by 1985. $10 MEG 1- (j) 0 o $1 MEG 1----4-----...,,.,._-+------+-------11----1 MICROPROCESSOR' '' $1K.___ _.__ _ _ _ ~ _ _ _ _..___ _ _ __J.___~ ' 1950 1960 1970 1980 Figure 1-2. Typical Digital System Hardware Development Cost at OEM Manufacturer 1-4 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design THE IMPACT OF SEMICONDUCTORS How has this been accomplished? Figure 1-3 shows what has been happening. As the number of components per chip of silicon increases, the development cost for each chip also increases. For a semiconductor manufacturer, volume production is required to 1 <1111111 offset the development cost. Semiconductor devices are therefore being batchedfabricated - a few hundred, a few thousand per chip - and this means lower cost per active element group or AEG. (An AEG is defined as a logic gate, flip-flop, or a memory cell.) 1-- 100,000 100 (f) Cl. 0 0 J: 1-- 0 z I- 10,000 w 0: 5 2 (l.. wO 0 Cl. 0: en O 1,000 10 _J w (.'.) 0 > w WW <( f-: 0 <( 100 w 0: > ~ (9 w I- _J ~ 10 w a: 1960 1970 1980 Figure 1-3. Evolution of Semiconductor Technology Figure 1-4 shows the chronology of semiconductor device development. An AEG in the early 1950's consisted of one or two transistors, several resistors, a capacitor or two, and some area of a printed circuit board to hold the parts together as an assembly. Early integrated circuits contained about 10 AEG's. Then medium scale integration achieved up to 100 AEG's per chip and large scale integration reached 1,000 AEG's per chip. At this point (the late 1960's), the semiconductor technologists had apparently reached an impasse. If they continued to increase the number of AEG's per chip the high degree of specialization would preclude volume production, and the benefits of LSI would be lost. In fact, the only area in which LSI appeared to be feasible was in memories - primarily read/write memories now called RAM's. Read only memories (ROM's) and programmable read only memories (PROM's) were not required until later (as you will see). But the semiconductor technologists continued their thrust toward greater numbers of AEG's per chip, focusing primarily on memory products. There was one other product which appeared to be feasible (in 1970) - a single-chip calculator. Here was an opportunity to stretch the imagination to greater degrees of achievement. At the producibility level of about 1,000 AEG's per chip, all of the functions of a microcomputer could be built on one chip - and the application certainly had the required volume potential. So custom LSI found a niche in the form of the hand- held calculator. 9900 FAl\IILY SYSTEMS DESIGN 1-5 THE IMPACT OF SEMICONDUCTORS Basic Decisions In System Design "DISCRETE" EARLY 19SO'S DEVICES (Transistor::;) ~1 "SMALL-SCALE EARLY 1960'S INTEGRATION" (Up to about 12 gates) ''MEDIUM-SCALE INTEGRATION" MIDDLE 1960'S (Up to about 100 gates: Building-blocks such as counters, adders, etc.) LATE 1960'S EARLY 1970'$: D "VERY LARGE- SCALE INTEGRATION'' (More than about 1000 gates: Complete system or SPECIAL ICs MADE JUST several subsystems) ICs THAT CAN BE PROGRAMMED FOR ONE SYSTEM DESIGN TO SUIT MANY DIFFERENT SYSTEMS: ''MICROPROCESSORS'' Figure 1-4. Stages in Evolution of Digital Semiconductor Circuitry. (G. McWhorter, Understanding Digital Electronics, Texas Instruments Inc., Dallas, Texas, 1978) From the very beginning the designers of the single chip microcomputer envisioned new and varied applications of this device, so it was made with a ROM for instructions and RAM for data. It wasprograf!lmable, at least it was "mask programmable." And as we witness the growth of this segment of the semiconductor market, we see a host of dedicated applications for single chip microcomputers such as controllers for microwave ovens, sewing machines, and other appliances. By designing a "standard" chip that could be programmed to do a variety of jobs, semiconductor technologists repeated the step taken by the inventors of the first programmable machine - the first computer...:.. in the late 1940's. The first digital computer was a stored program digital calculating machine. Programming provided versatility and variety of applications. Similarly, programmable single chip, LSI semiconductor devices - microcomputers - gave LSI variety of applicability. The next logical step in the evolution of LSI was the design of the general purpose microprocessor, a computer CPU on a chip. By interfacing the microprocessor to a memory - a set of chips arranged to provide as much storage as needed - one can build larger, more powerful microcomputers which can replace special purpose hardwired logic. In fact, general purpose hardware that is programmable provides multichip applicability of LSI technology. 1-6 9900 FAMILY SYSTEMS DESIGN Basic Decisions THE IMPACT OF SEMICONDUCTORS In System Design With this breakthrough in the concept of LSI application, the semiconductor technologists have been motivated to continue to increase the number of AEG's per device. Figure 1-5 projects the growth of AEG's per chip to over 106 by 1985 - a level 1 <111111 sufficient for a single chip 32-bit microcomputer. The 16-bit microprocessor and 4K RAM require about 50,000 AEG's. RAM's of 16K and 64K bits requiring up to 100,000 AEG's are not unrealistic extensions of the trends; they are real products rapidly moving into the marketplace. New advances are being made in semiconductor process technology to achieve the packing densities needed for the future. As Figure 1-5 indicates, optical techniques for defining regions and interconnections reach a resolution limit at about 10 5 AEG's. E-beam and X-ray technology will be required to further increase component density. 1011 Cl.. I RESOLUTION LIMITS 0 er: w Cl.. CJ) Cl.. 109 ______________________..,.... ::::> E-BEAM _.,,.. 0 107 ----------------;;--.,,,...- er: 64K RAM _,,- (.') 16K RAM i~t 32-BIT OPTICAL-- -----~-'i"// 1- zw 10s MICROCOMPUTER, 2 -- - - - - - - - - -=""/ e 1OOOK-BIT MEMORY w _J w w > 103 1-CHIP CALCULATOR 4K RAM e lt 16-BIT MICROCOMPUTER, 32K-BIT MEMORY ~ 16-BIT 0 MICROPROCESSOR <( 10 1960 1970 1980 1990 Figure 1-5. Semiconductor Chip Complexity (M Shepherd, 1977 NCC) The impact of programmable semiconductor devices is shown in Figure 1-6. Prior to 1972, semiconductor devices were designed as circuits. Now they are being designed as systems or at least subsystems. As the number of AEG's/ chip continues its rise, driving down the cost of CPU and memory devices, unlimited opportunity is being created for an unbelievable variety of new products. Figure 1-7 shows that a dramatic change is anticipated in the rate of AEG cost reduction with time due to the impact of microprocessors. Functions (AEG's) costing $1.00 in 1966 were obtained for around 5 cents in 197 6. In fact, the cost per AEG is projected to be less than a tenth of a cent by 1985. 9900 FAMILY SYSTEMS DESIGN 1-7 THE IMPACT OF SEMICONDUCTORS Basic Decisions In System Design 1 Ob 10 5 ~1 TIL ICs 10 5 1K RAM 104 0 104 0 4K RAM (f) --i Cl.. +O $:"Tl I: 103 103 mm 0 $:0 a: o~ w 0... :IJ~ 10 2 - w 50% HARDWARE 0 .....J HARDWARE ;:; 0 I- 25% HARDWARE HARDWARE 1950's 1960's 1970's 1980's Figure 1-9. Increasing% of Software Development Cost Development costs are changing - becoming more software oriented - and this has a strong impact on overall product cost. In any product design, the development cost is amortized over some production quantity, and this affects the price of the product. But developing software to achieve any design goal is less expensive than developing hardware to do the same thing. Therefore, the total development cost for "equivalent systems" is decreasing (perhaps by as much as 15-20% per year). The development ofprograf!lmable semiconductors has been a major accomplishment equivalent in importance to the inventions of the transistor, the integrated circuit, and the stored program computer. The trends appear to be well established. The number of AEG's per chip will be increasing by at least 75% per year for at least another two decades. As a result, AEG cost will decline by about 50% per year and RAM cost per bit will decline by about 20% per year. The computing power of LSI devices will increase while the price will continue to decrease. The impact will be felt in all walks of life. APPLICATIONS OF PROGRAMMABLE SEMICONDUCTORS The application of programmable semiconductors can be considered as an extension of the application of computers. All applications of LSI semiconductor devices are as computers because microprocessors, microcomputers and programmable LSI peripheral chips are programmed to perform the special functions required for each application. All the elements of a computer - ALU, control, memory and 1/0 - are present. As the price of computing power decreases, the number of applications increases. The number of computers of any given type being applied is inversely proportional to the cost (Figure 1-10). As of 1976 there were relatively few systems in the $100-$10000 range. But microcomputers are changing this. Applications are being found in new designs of digital electronic systems, in products previously using electro-mechanical devices, and in new products which previously were not economically feasible. 9900 FAMILY SYSTEMS DESIGN 1-11 APPLICATIONS OF Basic Decisions In System Design PROGRAMMABLE SEMICONDUCTORS UNITS ~1 100M 10M 1M SMALL BUSINESS COMPUTERS ---.----- NUMBER OF PROGRAMMERS 100K MAINFRAME COMPUTERS - "'... •\ \ PROGRAMMABLE CALCULATORS INTELLIGENT "-.... \ TERMINALS 10K MINICOMPUTERS 1K 10M 1M 100K 10K 1K 100 10 AVG. SYSTEM PRICE (DOLLARS) Figure 1-10. U.S. Installed Computer Base-1976 (M. Shepherd, 1977 NCC) While some people may feel that the number of computers cannot exceed the number of "programmers" (approximately one million according to Figure 1-10), it is evident that all designers of products which use microcomputers will acquire the necessary programming skills to achieve the desired end product results. SINGLE CHIP MICROCOMPUTER APPLICATIONS Single chip microcomputers are being used in the small, dedicated, high volume applications such as calculators, microwave ovens, and general appliance controllers. As the computing power of single chip devices increases, the range of applications will obviously expand. Early devices contained about lK bytes of memory. New devices with 2K bytes of ROM for instructions and small amounts (256 bytes) of RAM for data have been built and designed into more complex applications. One example is a terminal controller using the TMS 9940 microcomputer with one support chip; this is described in Chapter 9. 1-12 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design APPLICATIONS OF PROGRAMMABLE SEMICONDUCTORS MULTI-CHIP MICROCOMPUTER APPLICATIONS The application areas which involve the greatest number of designers and programmers by far are those using a multi-chip approach - a microprocessor, memory sized to the I ....ii application, and peripheral interface devices. Limitations are much less in multi-chip systems than for single chip microcomputers. Designs can be accomplished using the general purpose microcomputer boards which have been designed to be applied to a variety of end products. Or the designer can start with individual LSI devices and build a special microcomputer for each application. The list of applications for microprocessors is long and continues to grow. But a few of the representative areas are these: Instrumentation Test Equipment Industrial Process Control Point-of-sale Terminals Cash Registers Typewriter/Word Processing Equipment CRT Terminals Vending Machines TV Games Automobile Engine Ignition Controllers General Automotive Products CB Equipment Communications Controllers Educational Toys Personal Computers Special Dedicated EDP Functions In each application standard programmable semiconductor LSI devices are used to sense input information, process the information according to special procedures (algorithms), and send information to external devices for display, printing, physical control devices, etc. Obviously the need for interface circuits is great. They cover specific functions such as AID converters, DI A converters, transducers, and special display drivers, etc., as well as standard digital circuits for buffering, multiplexing, latching, etc. Figure 1-11 shows conceptually how the elements of the microcomputer are arranged for any application. 9900 FAMILY SYSTEMS DESIGN 1-13 APPLICATIONS OF Basic Decisions In System Design PROGRAMMABLE SEMICONDUCTORS ~1 >- a: 0 :::?: w :::?: ffi~ :<::o.. O:::i 0..(f) , ·I <( (/) a: 0(/) (/) _J 0 a: ~ I in 0 z t- z a: w w (/) 0 t- 0 :::J ()_ :::?: 0 0 0 (/) t- (/) a: :::J t- 0 (') ()_ (/) :::J ()_ ~ Ox t- t- _J :::J :::J :::J t- 0 :::J ~:::?: ()_ (') ~ 0 <( _J 0 _J _J <( ~ ~ z<( (5 (5 0 0 L_ _J Figure 1-11. Microprocessor Applications in Process Control Systems 1-14 9900 FAMILY SYSTEMS DESIGN Basic Decisions BUILDING A In System Design MICROPROCESSOR BASED SYSTEM BUILDING A MICROPROCESSOR BASED SYSTEM Given an application idea, how does one proceed toward designing a product in which a microprocessor is the central control device? The design steps may be diagrammed in 1..- great detail, but the most important steps are these. 1. System Specifications - The system requirements include electrical specifications for each input and output, timing details, and overall performance logic. 2. Division into small subsystems - By defining small, easily managed tasks, the hardware and software requirements can be measured, and design can be scheduled. 3. Decisions for hardware and software - This is the appropriate design point at which the tradeoff between hardware and software solutions for each task is evaluated. For economy, the best solution may appear to be software, but there may be a penalty in performance. 4. Hardware and software design - Here the two design activities may be carried out in parallel. The microcomputer parts are assembled on one or more breadboards and tested for signal flow. Software is developed using a software development system (a computer with appropriate peripherals and programs). Software testing may be done to provide algorithm functionality. 5. System integration - Ultimately, the hardware must be tested under program control. At this point the programs must be loaded into the system memory (usually PROM or EPROM) for testing. Often special logic analyzers and other computer based diagnostic tools are needed to debug the complete system (see the description of the AMPL system in Chapters 2 and 7). It is clear from the foregoing list of steps that a thorough understanding of the hardware components and a knowledge of programming is required to design with microprocessors and microcomputers. But this is not difficult to acquire. By learning the names of standard building blocks and software packages, you will have taken a major step toward understanding what you read about them. BASIC HARDWARE COMPONENTS Since the hardware for digital systems is being standardized, the basic elements and their functions can easily be studied. Comparisons of similar devices from various manufacturers must be made and design tradeoffs evaluated. Here are the basic building blocks, what they do, and how they are used. 9900 FAMILY SYSTEMS DESIGN 1-15 BUILDING A Basic Decisions In System Design MICROPROCESSOR BASED SYSTEM Microprocessor or CPU This fundamental chip contains the Arithmetic and Logic Unit (ALU) which basically ~1 performs addition and comparisons between two numbers. Temporary storage registers are available to hold numbers (called operands) and addresses (memory location numbers) which identify or point to instructions and data. Sometimes the ALU is used to calculate addresses by arithmetic operations on certain register contents. The microprocessor must also contain timing and control circuitry to direct all activities in an orderly step-by-step procedure. The actual control functions are determined by decoding and executing instructions. Instruction execution is a special type of operation on information which comes from memory. The memory stores numerical values which may be interpreted by the processor in one of two ways. Either the number is an instruction, which will direct the sequence of operations over the next few clock cycles, or it is data to be operated upon either arithmetically or logically. Memory The main memory of a microcomputer holds the program and data for the system. Because semiconductor RAM devices are volatile (that is, all data is lost when power is removed), it is desirable to use ROM devices (Real Only Memory or non-volatile memory) for the program and RAM for data. ROM devices are programmed (information stored in the cells) by means of a metalization pattern or mask at the time of chip fabrication. Programmable read only memories (PROM's) may be programmed by the manufacturer or the user because information is stored by burning small metalic fuse links via the application of electric current. Programming is performed on the device after it has been packaged. EPROM's are non-volatile read-only memories which may be erased, usually via the application of ultraviolet light. These devices are especially useful in prototyping and system development during which program changes are frequent. Memory devices are designed for cascading so that any size memory may be obtained by adding more devices. Capacities of 4K bits per chip are common; devices with 64K bits per chip are not far away. Input/Output For the input and output function - interfacing the microprocessor-memory combination to the "outside world" - usually consists of a variety of devices including programmable LSI devices. Examples of interface requirements are as follows: 1. For communication of digital information over a pair of wires, conversion from 8-bit bytes (parallel) to single bits sent in sequence (serial) is required. The I/O device must receive a number of bits, hold them in a register and then shift them serially to a transmission line. The reverse procedure, serial to parallel conversion, must be performed for receiving information from the transmission line. Since the clock rates, 1-16 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design BUILDING A MICROPROCESSOR BASED SYSTEM start and stop characters, and "handshaking" requirements can be complex in communications networks, the protocol is designed into the TMS 9902 and TMS 9903 programmable communications controllers (see Chapter 8 for details). 1..il 2. Man-machine interfacing may consist of arrays of switches and indicators or may be performed via a terminal such as a teletype (TTY) or a video display terminal (VDT). Arrays of switches are connected to microcomputers via multiplexers. The address bus may be used to select one of the switches for sampling at any given moment. Addressable latches are useful in supplying on-off data to arrays of indicators. The address bus is again used to select one specific display device (a single lamp) to be turned on (or oft) in a given computer cycle. Terminal interfacing can be accomplished via a serial data interface such as the TMS 9902 (see Chapter 9 - example using the TM 990/lOOM board). 3. The broad category of analog (continuously variable) inputs and outputs requires converters (A/D and D/ A) to obtain digital information on the computer side of the interface. Input signals from transducers or output signals to actuators (positioners) require this type of conversion. Connecting the I/ 0 devices to the CPU and addressing them may present problems in some microcomputer systems. The 9900 solves the problem by providing two types of general purpose I/ 0. Memory mapped I/ 0 allows a set of memory addresses to identify the I/O devices (as though they were words of memory), while the communications register unit (CRU) provides a separate I/O port specially designed to interface single bit devices, communications devices, standard computer peripherals, etc. Unique to the 9900 architecture, the CRU interface is a powerful and versatile I/O technique; it is easily utilized via the special LSI peripheral supports circuits (such as the TMS 9901, 2, and 3, and the TIM 9905 and 6). The rules for interconnecting the various elements of the microcomputer include loading specifications and signal level limitations. In observing these rules the designer will occasionally use a few standard devices to reduce loading or perform level shifting. Generally, the addition of such devices is an insignificant part of the overall design. (Details for hardware interfacing are given in Chapter 4.) PROGRAMMING FOR MICROCOMPUTERS The writing of programs - often called software development - is the companion activity to hardware breadboarding and testing in computer systems. But software is substantially more flexible than hardware because it consists primarily of ideas, documented in strings of characters on a page, or in l's and O's in a memory. In fact, until a program is actually loaded into a memory, it is truly a set of ideas on paper, hence the contrasting name, software. 9900 FAMILY SYSTEMS DESIGN 1-17 BUILDING A Basic Decisions In System Design MICROPROCESSOR BASED SYSTEM In developing the individual hardware components of a microcomputer, designers usually subdivide the activities into small, easily managed tasks. These tasks are ~1 performed sequentially by one designer or simultaneously by several members of a design team. The same is true of software design. Small, easily defined and understood sub-programs are given as individual assignments to the programmers on the design team. The disciplines for programming are set up so that each sub-program stands alone, yet couples to the other sub-programs in a harmonious manner. But the overall plan begins at the top (a program to handle all sub-programs) and expands to several lower levels (a "Christmas tree" of programs). This is known as "top-down programming", and it is a form of structured programming. The term structured programming means that discipline in programming in which each program module implements an algorithm with a single entry point, a single exit point and a definitive result for each possible input. Each module must contain its own buffer area so that it cannot alter procedures or data of other modules. (In some cases common buffers are allowed, but complex rules for their use are needed.) How is programming done? What equipment is needed? And what support can you get from a microcomputer manufacturer? First, there is a preparation phase in which the designer and/ or programmer must become familiar with the instruction set and the architectural elements of the microcomputer selected for the design. The second phase involves writing selected short program segments to gain insight into the memory requirements and the execution speed of various sub-programs. Then the main body of the program may be developed. Writing programs means writing code; writing program steps which must be executed in sequence. Usually these steps are written in a mnemonic language which uses one to four letters as operation codes, and strings of other characters to designate the operand (the number to be operated upon). These program steps must be translated and "assembled" into a set of 1'sand O's - the machine language executable by the microcomputer - by a special program development computer. The programmer writes the program on paper. Then he enters the program steps via a keyboard into the program development system (PDS), and directs the PDS to "assemble" the instruction into machine code. The output from the PDS is a set of numbers which represent the program steps, and a listing of the input and output codes. Obviously the PDS uses some special programs (software) for performing the tasks outlined. The programmer writes source code statements, submits them to the PDS via a program called the editor, then uses the assembler program to produce object code - the machine code used by the microcomputer. Errors in the program statements are printed along with the object code listing. Errors are corrected by editing the source code (via the editor) and resubmitting it to the assembler. 1-18 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design BUILDING A MICROPROCESSOR BASED SYSTEM After a number of program modules are complete, a set of two or more may be "linked" together as a single program. This is done by submitting object code programs to the linker. The output from the linker is a single program which may be loaded into the 1 <111111111 microcomputer. The list of support software is just beginning. The following outline of software products describes the program development cycle further. Program development software Editor - for entering and changing source code Assembler - for conversion from symbols and mnemonics into machine code Linker - for connecting several programs into one PROM programmer - for loading numbers (programs) into PROMs Program testing software Debug routines - for testing programs AMPL system software - for testing programs and the interaction with the hardware Software available for use with user programs Monitor - for checking status of all program modules Executive - for overall control Operating system - for operating peripheral devices Library (utility) programs - for performing special mathematical conversions and calculations High level language software for program development PASCAL - for structured programming POWER-BASIC - for ease of programming in BASIC language FORTRAN - for general computer problem solvi?g This partial list of software is intended as a categorical outline which should indicate the level of support one finds in the areas of software development. To comprehend the value of any or all of these software products, you must work with them and develop a few programs for microcomputers. The obvious difficulty with software evaluation is that few designers can afford the capital investment for a large PDS to properly evaluate each of the alternative paths for software development. But Texas Instruments has developed a variety of program development systems. Some of these are very economical and readily available. They were designed specifically for product and programming evaluation and for initial design. You will find descriptions and approximate prices for each PDS in Chapter 2. 9900 FAMILY SYSTEMS DESIGN 1-19 BUILDING A Basic Decisions In System Design MICROPROCESSOR BASED SYSTEM WmcH MICROPROCESSOR OR MICROCOMPUTER TO UsE You may be convinced that designing with programmable semiconductors is the best ~1 design philosophy, and you may be attempting to evaluate the various products on the market. But a significant decision point has been reached: "which microprocessor or microcomputer is best for my application?" The selection of the proper device is based on many factors, some of which are not related to architecture or instruction execution speed. Selection of a microcomputer or microprocessor usually means selection of one primary vendor (and sometimes one or more second sources) who manufactures the product and the compatible peripheral devices. It also means the purchase of a program development system designed especially for the specific microprocessor. Selection of one device means a commitment to using that device for future designs. Changing to another microprocessor is costly both in hardware and in the development of programming skills. Selection criteria for a microprocessor may be summarized as follows: 1. The microprocessor must be versatile so that it can be used in many applications. 2. The vendor must provide a comprehensive set of support and peripheral circuits. 3. One PDS should serve the programming activity for a significant period of time. 4. The cost of the devices and the PDS must be economically attractive. 5. The performance of the microprocessor must be sufficient to meet the design goals. 1-20 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design BUILDING A MICROPROCESSOR BASED SYSTEM Texas Instruments 9900 family of components and software systems clearly meets these selection criteria. Careful evaluation of the price/performance tradeoffs between the various microprocessor products on the market will reveal superior adaptability of the 1.... 9900 family to any product design. The selection criteria applied to the 9900 family may be summarized thus. 1. Versatility has been achieved by providing a family of processors using one basic 16-bit architecture. Both 16- and 8-bit versions are available as well as a single chip microcomputer. Instead of trying to apply a single microcomputer to a broad scope of applications, the designer may select from the 9900 family the most appropriate microprocessor for each application. Programming and software support is the same for all. 2. Numerous support devices are available from Texas Instruments, and new products are introduced regularly. Chapter 8 contains detailed data sheets for many of them. 3. A single PDS from Texas Instruments can provide programming support for all of the processors in the 9900 family. The powerful support software streamlines program development. And programs written for one microcomputer may be used on another. Software compatibility of the processor family is one of the primary benefits of designing with the 9900. 4. Product pricing of the microprocessors, peripheral devices and PDS's is economically attractive. Designing multiple applications from the same components and using the same development tools means even greater economic benefit. 5. The 16-bit architecture - especially the bus width and the register size - enables the 9900 family of processors to achieve outstanding performance. Performance is measured by throughput and computing power, not by clock speed alone. A complete evaluation of the 9900 in each of the above categories is not possible in so few words. But one specific feature of the product family should be included as a part of the evaluation. Memory-to-memory architecture, a unique computer concept developed by Texas Instruments for the 9900 minicomputer, is an outstanding feature because it enables the 9900 to achieve the most cost effective product development. The story of the evolution of this architecture will help you understand its importance. 9900 FAMILY SYSTEMS DESIGN 1-21 EVOLUTION OF Basic Decisions In System Design MEMORY-TO-MEMORY ARCHITECTURE EVOLUTION OF MEMORY-TO-MEMORY ARCHITECTURE All things change with time, and computers are no exception. An evolutionary process ~1 has been at work in computer design since the beginning. Early machines were designed around a single accumulator which served as the focal point of most of the instructions. Steps such as load the accumulator (LDA), add to the accumulator (ADD), and store the accumulator (STA) were common in programs written for such machines. (The instruction mnemonics used here are simply illustrative and are not intended to be identified with any specific computer or microprocessor.) But there was a fundamental limitation-the bottleneck effect of forcing all transactions to be performed via a single accumulator (Figure 1-12). PROCESSOR Figure 1-12. Single Accumulator Architecture 1-22 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design EVOLUTION OF MEMORY-TO-MEMORY ARCHITECTURE As circuit elements became less expensive, especially through the introduction of integrated circuits, multiple accumulator architectures emerged (Figure 1-13). A and B accumulators were the focal points of expanded instruction sets which allowed loading 1~ either accumulator (LDA, LDB), adding to either accumulator (ADA, ADB), and storing either accumulator (STA, STB). With this design came the increased use of an accumulator for holding the address of an operand, adding flexibility and power to the instruction set and to the architecture. It should be clear at this point that the instructions, the dictionary of words used by a computer to implement the ideas of the programmer, are as much a part of the architectural fabric as the registers, the control unit or the bus structure. In fact, by implementing instructions as strings of microinstructions stored in an on-chip control ROM, microprocessor designers have created the opportunity for increasing. instruction set power through microprogramming. PROCESSOR MEMORY Figure 1-13. Multiple Accumulator Architecture The next major step in the architectural evolution was the design of machines based on a set of general registers which could be used as accumulators for numerical operations or for storage of operand addresses (Figure 1-14). The expanded capabilities allowed increased flexibility not only in arithmetic functions but also, and more importantly, in the generation of operand addresses via indirect addressing, and indexed addressing. 9900 FAMILY SYSTEMS DESIGN 1-23 EVOLUTION OF Basic Decisions In System Design MEMORY-TO-MEMORY ARCHITECTURE .... 1 A x B c D E F y G H Figure 1-14. General Register Architecture Perhaps it is well to digress for a moment and explain these terms. Indirect addressing allows' a register to serve as a pointer to identify specific elements in a table or an array of data (Figure 1-15). Instructions for an arithmetic operation may be used over and over, with the pointer (or pointers) being adjusted to access different values for each pass. In indexed addressing, the instruction contains a base value while an index register holds the displacement value (Figure 1-16). The base value locates the table, and the index register contains the number of the element in the table (one, two, three, etc.). The base value must be added to the contents of the index register to obtain the actual memory address. ------------------ PROCESSOR MEMORY A B c D X1 E Y1 F YO G f--------------~ Y1 H r----------------1 Y2 1----------------~ Registers D and E contain the addresses of operands X1 and Y1. D and E may be incremented to address sequential elements in tables. Figure 1-15. Indirect Addressing 1-24 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design EVOLUTION OF MEMORY-TO-MEMORY ARCHITECTURE 1~ XO INDEX REGISTER XO is the address of the first element in the table. X1 is obtained by adding XO to the 1 in the index register. The index register may be incremented to address sequential entries in the table. Figure 1-16. Indexed Addressing The general register architectures were made economically feasible by the expanded capabilities of integrated circuits through the technological advancements of Medium scale integration (MSI) and large scale integration (LSI) (Figure 1-17). As more and more circuits were implemented on a chip, it became feasible to expand from two accumulators, to a general register file, to the general register file on a single LSI microprocessor chip. In discussing LSI, one must not fail to recognize that the single most important impact of LSI is in the development of memories. More bits per unit area of silicon means higher capacity and lower cost, generally without sacrificing speed. The advent of microprocessors was the natural evolutionary step in the utilization of memory for a greater variety of logic and control applications. REGISTER FILE Figure 1-17. LSI Microprocessor 9900 FAMILY SYSTEMS DESIGN 1-25 EVOLUTION OF Basic Decisions In System Design MEMORY-TO-MEMORY ARCHITECTURE In looking toward the future of memories and microprocessors, the technologists see the implementation of an ever increasing number of memory cells and microprocessor _....1 calculation and control functions on an ever-shrinking area of silicon (Figure 1-18). Registers and memory cells are virtually identical in their implementation at this point, so the words register and memory no longer connote high speed and low speed storage. In fact, memory speed is rapidly approaching register speed (Figure 1-19). 100K CL 10K I 0 a: w CL Cf) w 1K ~ (.!) :ft= 100 10 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 YEAR Figure 1-18. Trend in Gates per Chip In view of this convergence of memory speed and register speed, the architects of the 990 minicomputer (from which the 9900 is derived) envisioned an architecture in which the instructions are written with respect to memory words rather than registers. The architectural concept, called memory-to-memory architecture, was the basis for a new computer design in which all memory reference instructions operate on one or two words of memory and store the result before going on to the next instruction. There were actually two major reasons for developing such an architecture. First, since all instructions would reference words of memory and complete their cycles by placing results in memory, there would be no requirement for register-save operations in a multitask or interrupt processing environment. Second, while this approach might at first be slightly slower in some cases, the architects envisioned that the technological evolution would continue to narrow the gap between register speed and memory speed, and in the long run this minor disadvantage would vanish. 1-26 9900 FAMILY SYSTEMS DESIGN Basic Decisions In System Design EVOLUTION OF MEMORY-TO-MEMORY ARCHITECTURE 9 8 1...- 7 6 RATIO OF MEMORY SPEED 5 TO REGISTER SPEED 4 3 2 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 YEAR Figure 1-19. Ratio of Memory Speed to Register Speed Another important advantage of this new architecture, often overlooked, appears to be an even stronger and more important justification for the development of this radical departure from conventional computer architectures. When one instruction can identify two memory words or operands, perform an operation, and store the result in memory, it will replace common sequences such as LDA, ADA, STA found in the instruction sequences of all accumulator-based machines. Furthermore, a single instruction can access additional memory words for use in addressing operands and can even increment pointers and employ index registers all as a part of its execution sequence. If a single instruction can do all this, then the writing of instruction sequences, programming, must be substantially easier. Fewer lines of code are required. (In data manipulation and address computation sequences, the reduction is typically 3: 1.) Support software, such as monitors, executives, and operating systems can be smaller, easier to use and understand, and will consume less memory. For these reasons, benchmarks written to compare the 9900 architecture with conventional register file based microprocessors show the advantage of the 9900's memory-to-memory architecture in three important categories: the number of bytes of memory required, execution speed, and the number of instructions written to accomplish a given task (Figure 1-20). The 9900 comes out ahead in all three categories. 9900 FAMILY SYSTEMS DESIGN 1-27 EVOLUTION OF Basic Decisions In System Design MEMORY-TO-MEMORY ARCHITECTUR~ Program memory Assembler Execution time ~1 requirements (bytes) statements (microseconds) 9900 A B c 9900 A B c 9900 A B c Input/output handler 24 38 28 17 9 14 17 7 71 154 79 49 Character search 22 24 20 18 8 10 9 8 661 1636 760 808 Computer go to 12 12 17 14 5 5 11 8 98 362 145 145 Vector addition: AN--BN = CN(1 6) 20 30 29 46 5 14 20 22 537 2098 1098 1866 Vector addition: Aw-BN = CN (8) 20 32 23 40 5 15 14 22 537 2108 738 936 Shift right 5 bits 10 6 19 20 3 3 12 9 22 56 137 81 Move block 14 18 16 34 4 9 9 16 537 1750 1262 2246 Totals 122 160 152 189 39 70 92 92 2464 8154 4219 6131 Figure 1-20. Benchmark Comparison of 9900 vs. Other Microprocessors One final note about architecture. Memory-to-memory architecture and instructions in the 9900 do not sacrifice the concept of "registers" as they are conceived in the architectures with general register organizations. The general "register file" is conceptually retained as a block of sixteen words of memory (Figure 1-21). Over two thirds of the instructions in the 9900 refer in one way or another to this "register file" in much the same way as prior architectures referenced the general register file in the CPU. Thus, base addresses, subroutine linkage and interrupt save operations can all be accomplished via the "register-file-in-memory" concept. By using memory for the register file, the advanced memory-to-memory architecture allows new programming flexibility. There is a way to identify multiple register files in 9900 based systems (Figure 1-22). Each basic process can have its own set of "registers." There is no limit (except memory size) to the number of "registers" available for use in programming the functions _of a particular application. The memory-to-memory architecture of the 990 and 9900 products is clearly revolutionary and innovative. Programming effort for the 9900 is typically less than half that for any other microprocessor currently available because the instructions operate on words of memory and store results automatically. This means not only that programs consume less memory, but execution speed (for the 16-bit processors) is faster than that of other processors. 1-28 9900 FAMILY SYSTEMS DESIGN Basic Decisions ,In System Design EVOLUTION OF MEMORY-TO-MEMORY ARCHITECTURE 1~ PROGRAM MEMORY 9900 MICRO- PROCESSOR REGISTER FILE DATA MEMORY Figure 1-21. Register File in Memory PROGRAM .- - - - - - -. I MEMORY REGISTER FILE 1 9900 REGISTER MICRO- FILE PROCESSOR \ 2 REGISTER FILE 3 .___________. DATA MEMORY Figure 1-22. Multiple Register Files in Memory 9900 FAMILY SYSTEMS DESIGN 1-29 GETTING UP TO SPEED Basic Decisions In System Design ON MICROPROCESSORS GETTING UP TO SPEED ON MICROPROCESSORS By now you may be convinced that this book contains a great amount of information ~1 about microprocessors and microcomputers, but you may feel that you are not as well prepared to understand it as you would like to be. This section has the answer. Here are the steps you should take to learn about microprocessors and microcomputers. The knowledge gained will help you in all new designs and will be especially helpful in designing with the 9900 family of processors and peripherals. Few people have had the opportunity to learn about microcomputers in college. In fact, schools and colleges exist primarily to teach you how to learn, and not to teach you everything you need to know to do a particular job. Your effectiveness in;performing any job is directly related to your willingness to acquire new specialized knowledge in your particular field. This book will serve as one source of specialized knowledge in the field of microcomputers, but it is focused on the 9900 family. And you may require additional education in this field before achieving a full understanding of the material presented. It may be that knowledge of MOS and I2L technologies is needed for a clearer understanding of interfacing techniques. Basic computer fundamentals, such as storage of data and programs and the sequential operations may be an area you would like to study. It could be that you feel a need to improve your understanding of programming and the concepts of building programs via the modular approach. The list of specialized areas within the field of microcomputer technology can be quite long. Technology advances so rapidly today that it seems virtually impossible to keep up, much less catch up. But you can do both, and without spending an inordinate amount of time. To acquire specialized knowledge in any field, you should devote 30 minutes a day to reading books or periodicals which contain the information you need. Advising you on the implementation of such a program is not the intent of this section. You know where you are and where you are going. What you need is a clear path or plan of action to achieve the goal: the acquisition of specialized knowledge about microprocessors and microcomputers. The first step is to find authoritative texts on the various subjects in the field. This chapter contains a bibliography of texts and periodicals from which to begin your search for new information. Get your hands on these books and articles. Review them for general content and readability, then decide which ones are best suited to your needs. Set up a plan to read one or more of these books in a definite period of time, devoting a scheduled, uninterrupted period of 30 minutes a day to this program. Take notes while you are reading and (if the book belongs to you) underline the information which is especially important to you. 1-30 9900 FAMILY SYSTEMS DESIGN Basic Decisions BIBLIOGRAPHY In System Design As you are getting up to speed, you will become aware of certain periodicals that contain articles most directly suited to your background and experience. Subscribe to one or more of these or be sure to obtain each issue as it is published so that you are not only 1~ reading about fundamentals, but current topics, the latest improvements in devices and systems. Set up the goal, the plan of action; and then, above all, form the habit of reading for 30 minutes a day. Few people can set up such a plan, and fewer still can continue to execute it for long periods of time. But if you persist, you can learn, not just one, but al! facets of design with microprocessors and microcomputers, and in time you will achieve the success you desire. BIBLIOGRAPHY Boo Ks Altman, L., Microprocessors, Electronics Book Series, McGraw-Hill, 1975 Bartree, T. C., I. L. Lebow, and I. S. Reed, Theory and Design of Digital Machines, McGraw-Hill, 1969 Bibbero, R., Microprocessors in Instruments and Control, John Wiley, 1977 Blakeslee, Thomas R., Digital Design with Standard MS! and LSI, John Wiley, 1973 Gear, C. William, Computer Organization and Programming, McGraw-Hill, 1969 Greenfield, Joseph D., Practical Digital Design Using !C's, John Wiley, 1977 Hansen, P.B., The Architecture of Concurrent Programs, Prentice-Hall, Inc., 1977 Hansen, P.B., Operating System Principles, Prentice-Hall, Inc., 1973 Knuth, D. E. The Art of Computer Programming, VOL I, Fundamental Algorithms, 2nd Edition, Addison-Wesley, 1973. Knuth, D.E. The Art of Computer Programming, VOL II, Semi-Numerical Algorithms, Addison-Wesley, 1969 Knuth, D.E. The Art of Computer Programming, VOL III, Sorting and Searching, Addison-Wesley, 1973. Luecke, G., J. Mize, W. Carr, Semiconductor Memory Design and Application, McGraw- Hill, 1973 Malrino, A., Digital Computer Electronics, McGraw-Hill, 1977 McWhorter, G;, Understanding Digital Electronics, Texas Instruments Learning Center, 1976 Morris, R. L., J. D. Miller, Designing with TTL Intergrated Circuits, McGraw-Hill, 1971 9900 FAMILY SYSTEMS DESIGN 1-31 BIB LI OG RAPHY Basic Decisions In System Design Norris, B., Power Transmission and TTL Integrated-Circuit Applications, McGraw-Hill, 1977 ~1 Silver, G., Computer Algorithms and Flowcharting, McGraw-Hill, 1975 Sloan, M.E., Computer Hardware and Organization, Science Research Associates, Inc., 1976 Solomon, L., Getting Involved with Your Own Computer; A Guide for Beginners, Ridley Enslow Publishing, 1977 Soucek, B., Microprocessors and Microcomputers, John Wiley, 1976 Torrero, E., Microprocessors, New Directions for Designers, Electronic Design, Hayden, 1975 Wester, John G. and William D. Simpson, Software Design for Microprocessors, Texas Instruments Learning Center, 1976 Williams, Gerald E., Digital Technology, Science Research Associates, Inc., 1977 Zaks, R., Microprocessors: From Chips to Systems, Sybex, 1977 Staff of the Texas Instruments Learning Center, Understanding Solid-State Electronics, 3rd Edition, Texas Instruments Learning Center, 1978 ARTICLES Barna, Arpad, and Dan I. Porat, "Integrated Circuits in Digital Electronics': John Wiley, 1973 Reid-Green, K.S., ''A Short History of Computing", Byte, Vol. 3, No. 7,July 1978 Special Issue on Microelectronics, "Scientific American': Vol. 23 7, No. 3, September 1977 Electronic Business, ''New Rules in an Old Game': Vol. 18, No. 6, June 1978 LIST OF PERIODICALS TO BE MONITORED ACM Computing Surveys, The Survey and Tutorial Journal of the Association for Computing Machinery, ACM, Inc., Mt. Royal and Guilford Avenues, Baltimore, MD 21202 EDN, Cahners Publishing Co., 270 St. Paul St., Denver, Colorado 80206 Electronics, McGraw-Hill Inc., 1221 Avenue of the Americas, New York, N.Y. 10020 Electronics Design, Hayden Publishing Co., 50 Essex St., Rochelle Park, N.J. 07662 IEEE Spectrum, The Institute of Electrical and Electronics Engineers, Inc., 345 East 4 7 Street, New York, N.Y. 10017 Interface Age, McPheters, Wolfe & Jones, 16704 Marquardt Avenue, Cerritos, CA 90701 1-32 9900 FAMILY SYSTEMS DESIGN CHAPTER2 Product Selection Guide Product THE 9900 FAMILY- Selection Guide WHAT IS IT? THE 9900 FAMILY - WHAT IS IT? The 9900 Family is a compatible set of microprocessors, microcomputers, microcomputer modules, and minicomputers. It is supported with peripheral devices, development systems, and software. It provides a designer with a system solution having built-in protection against technological obsolescence. The family features true software compatibility, 1/0 bus compatibility and price/performance ratios which encompass a wide range of applications. The family is designed with a unique flexible architecture to allow technological changes to be easily incorporated while minimizing the impact these changes have on an overall system design. FAMILY OVERVIEW THE HARDWARE FAMILY Figure 2-1 is a diagram of the 9900 Family members. The spectrum of microprocessors and microcomputer products available in a variety of formats is shown in Figures 2-2 and 2-3. In the first part of Figure 2-1, the microprocessors or microcomputers are combined with microcomputer support components (Figure 2-3) to form systems. These systems also include 1/0 interface, read-only and random access memory, and additional support components such as timing circuits and expanded memory decode . The family also includes microcomputer board modules containing the 9900 microprocessors and peripheral components (Figure 2-4). As shown in the second part of Figure 2-1, these modules can be used for product evaluation, combined for system development or applied directly as end equipment components. When applications require minicomputers, completely assembled units can be purchased and installed. The software will be fully compatible with any associated microprocessor and microcomputer system. Figure 2-5 gives a brief overview of the minicomputers. These three levels of compatible hardware - the TMS9900 family parts, the TM990 microcomputer modules, and the 990 minicomputers - provide the flexibility to obtain an optimum match with the user's system application. THE SoFTW ARE AND DEVELOPMENT SYSTEMS SuPPORT New products cannot be made without design, development, test and debug. Development support for all of the levels is shown in Figure 2-1, including: A. Product documentation B. Software (or firmware) C. Software development systems D~ Prototyping systems. Software and development and prototyping systems are outlined in Figure 2-6. 2-2 9900 FAMILY SYSTEMS DESIGN Product Selection Guide FAMILY OVERVIEW MINICOMPUTERS 2~ Figure 2-1. The 9900 Family MULTIPLE-CHIP SYSTEMS 16-BIT DATA BUS 1 - 16-BIT 1/0 BUS 8-BIT DATA BUS 64 PINS 1 - 16-BIT 1/0 BUS SINGLE-CHIP SYSTEM 8-BIT DATA BUS 40 PINS 1 - 16-BIT 1/0 BUS 40 PINS 1 - 16-BIT 1/0 BUS 40 PINS 16-BIT SINGLE-CHIP MICROCOMPUTER TMS9940E/M (EPROM/ MASKED ROM) Figure 2-2. 9900 Family CPUs 9900 FAMILY SYSTEMS DESIGN 2-3 FAMILY OVERVIEW Product Selection Guide CPU's TMS9900 NMOS 16-Bit Microprocessor, 64 Pins TMS9900-40 Higher Frequency Version 9900 SBP9900A 12L Extended Temperature Range 9900 TMS9980A/ 40-Pin, NMOS 16-Bit Microprocessor with 8-Bit Data Bus. 9981 has 9981 XTAL Oscillator TMS9985 40-Pin, NMOS 16-Bit Microprocessor with Single 5V Supply and 256-Bits of RAM TMS9940E 40-Pin, NMOS Single Chip Microcomputer, EPROM Version TMS9940M 40-Pin, NMOS Single Chip Microcomputer, Mask Version PERIPHERAL DEVICES TMS9901 Programmable Systems Interface TMS9914 GPIB Adapter TMS9901-40 Higher Frequency Version of 9901 TMS9915 Dynamic RAM Controller Chip Set TMS9902 Asynchronous Communications Controller TMS9916 92K Magnetic Bubble Memory Controller TMS9902-40 Higher Frequency Version of 9902 TMS9922 250K Magnetic Bubble Controller TMS9903 Synchronous Communications Controller TMS9923 250K Magnetic Bubble Controller TMS9904 4-Phase Clock Driver TMS9927 Video Timer I Controller TMS9905 8 to 1 Multiplexer TMS9932 Combination ROM/RAM Memory TMS9906 8-Bit Latch SBP9960 1/0 Expander TMS9907 8 to 3 Priority Encoder SBP9961 Interrupt-Controller /Timer TMS9908 8 to 3 Priority Encoder w /Tri-State Outputs SBP9964 SBP9900A Timing Generator TMS9909 Floppy Disk Controller SBP9965 Peripheral Interface Adapter TMS9911 Direct Memory Access Controller ADD-ON MEMORY ROMS EPROMS DYNAMIC RAMS TMS4 700-1 024 X 8 TMS2508 -1024 x 8 TMS4027 -4096 X 1 ':'TMS4710-1024 X 8 TMS2708 -1024 x 8 TMS4050-4096 X 1 TMS4 732-4096 X 8 TMS27L08 x -1024 8 TMS4051-4096 X 1 SBP8316-2048 X 8 TMS2516 -2048 x 8 TMS4060-4096 X 1 SBP9818-2048 X 8 TMS2716 -2048 x 8 TMS4116-16,384 X 1 TMS2532 x -4096 8 TMS4164- 65,536 X 1 ':'Character Generator-ASCII ·:·':'PROMS STATIC RAMS SN74S287- 256 X 4 TMS4008 -1024 x8 TMS4043-2 - 256 x4 SN74S471- 256 X 8 TMS4016 -2048 x8 TMS4044 -4096 x1 SN74S472- 512 X 8 TMS4033 -1024 x1 TMS40L44 -4096 x1 SN74S474- 512 X 8 TMS4034 -1024 x1 TMS4045 -1024 x4 SN74S476-1024 X 4 TMS4035 -1024 x1 TMS40L45 -1024 x4 SN74S478-1024 X 9.6. TMS4036-2 - 64 x8 TMS4046 -4096 x1 TMS4039-2 - 256 x4 . TMS40L46 -4096 x1 .6.Equivalent to TMS4042-2 - 256 x4 TMS4047 -1024 x4 SN74S2708 TMS40L47 -1024 x4 ·:·•:•Also available in 54 series Figure 2-3. Microcomputer Support Components 2-4 9900 FAMILY SYSTEMS DESIGN Product Selection Guide FAMILY OVERVIEW MICROCOMPUTER MODULES TM990/100M Microcomputer, 1-4K EPROM TM990/101M Microcomputer, 1-4K ROM, 1K-2K RAM TM990/101 M-10 Microcomputer, 1-4K ROM, 1K-2K RAM, Evaluation POWER BASIC@ TM990/180 Microcomputer, (8-Bit Data Bus), 1-2K ROM, 256-1 KRAM TM990/189 Microcomputer, University Microcomputer Module TM990/201 Memory Expansion Module, 4K-16K ROM, 2K-8K RAM TM990/206 Memory Expansion Module, 4K-8K RAM TM990/301 Microterminal TM990/302 Software Development Module TM990/310 1/0 Expansion Module TM990/401 '~ TIBUG@ Monitor in EPROM TM990/ 402':' Line-by-Line Assembler in EPROM TM990/ 450':' Evaluation POWER BASIC@ -8K Bytes in EPROM TM990/451 ':' Development POWER BASIC-12K Bytes in EPROM TM990/452':' Development POWER BASIC Software Enhancement-4K Bytes in EPROM TM990/501-521 Chassis, Cable and Power Supply Accessories ~'FIRMWARE Figure 2-4. TM990 Board Modules and Software Support Software is provided in EPROM (firmware) to oper.ate with the assembled microcomputer modules. It is provided on either "floppy" diskette or on disk pack for use with the minicomputers, and is distributed on magnetic tape for use on in-house computing equipment. In addition to the development systems available directly from Texas Instruments, a Fortran-IV cross-support package with assembler and simulator is provided by TI for those desiring to use in-house computing equipment. GE, National-CSS and Tymeshare provide similar capabilities on a timeshared basis. POWER BASIC and PASCAL software systems have just been introduced and will continue to be expanded in the future. Hardware and software for development and production use is available in appropriate system sizes to support individual designers as well as large design teams. 9900 FAMILY SYSTEMS DESIGN 2-5 FAMILY OVERVIEW Product Selection Guide CS990/4 • A 990/4 Minicomputer with 4K words of RAM • Expanded memory controller with 4K words of RAM • 733 ASR ROM Loader • 733 ASR Data Terminal • Necessary chassis, power supply, and packaging FS990/ 4 • Model 990/ 4 Minicomputer with 48K bytes of parity memory in a 13-slot chassis with programmer panel and floppy disk loader /self-test ROM • Model 911 Video Display Terminal (1920 character) with dual port controller • Dual FD800 floppy disk drives • Attractive, office-style single-bay desk enclosure • Licensed TX990/TXDS Terminal Executive Development System Software with one-year software subscription service FS990/ 10 • Model 990/1 O Minicomputer with 64K bytes of error-correcting memory and mapping in a 13-slot chassis with programmer panel and floppy disk loader I self-test ROM • Model 911 Video Display Terminal (1920 character) with dual port controller • Dual FD800 floppy disk drives • Attractive, office-style single-bay desk enclosure • Licensed TX990/TXDS Terminal Executive Development System Software with one-year software subscription service DS990/ 1O • Model 990/1 O Minicomputer with mapping, 128K bytes of error-correcting memory in a 13-slot chassis with programmer panel and disk loader ROM • Model 911 Video Display Terminal (1920 character) with dual-port controller • Licensed copy of DX10 Operating System on compatible disk media, with one-year software subscription service • DS10 disk drive featuring 9.4M bytes of formatted mass storage, partitioned into one 4.7M-byte fixed disc and a 5440-type removable 4.7M-byte top-loading disk cartridge Options: One additional DS1 O disk drive with 9.4M bytes of formatted mass storage, in deskmount, rackmount, or quietized pedestal version Figure 2-5. 990 Minicomputers 2-6 9900 FAMILY SYSTEMS DESIGN Product FAMILY OVERVIEW Selection Guide PRODUCT DOCUMENTATION 9900 Family Systems Design and Data Book 9900 Software Design Handbook TM990 System Design Handbook 990 Computer Family Systems Handbook Product Data Manuals Product User's Guides Product Brochures Application Notes Application Sheets SOFTWARE AND FIRMWARE TM990/401 TIBUG Monitor in EPROM TM990/402 Line-by-Line Assembler in EPROM TMSW101MT ANSI-Fortran Cross-Support Assembler, Simulator and ROM Utility TM990/450 Evaluation POWER BASIC -SK Bytes in EPROM TM990/451 Development POWER BASIC - 12K Bytes in EPROM TM990/452 Development POWER BASIC Software Enhancement Package - 4K Bytes in EPROM TMSW201F/D Configurable POWER BASIC in FS990 Diskette TMSW301 F/D TIPMX - Tl PASCAL Executive Components Library SOFTWARE DEVELOPMENT SUPPORT SOFTWARE TM990/302 Software Development Module Edit, Assembler, Load, Debug, PROM Programming TM990/40DS Software Development system for Assembler, Debug Monitor, Trial-in-System Emulator, PROM TMS9940 Microcomputer Programmer CS990/4 Single User Software Development Text Editor, Assembler, Linking Loader, Debug Monitor, System (Cassette Based), uses PROM Programmer PX990 software. FS990/4 Software Development system Source Editor, Assembler, Link Editor, PROM Programmer (Floppy Disk) FS990/10 Software Development System Same as 990/4, e'xpandable to OS System (Floppy Disk) DS990/10 Disk Based 990/1 O with Macro Source Editor, Link Editor, Debug, Librarian, and High-Level Assembler Language such as FORTRAN, BASIC, PASCAL, and COBOL MICROPROCESSOR PROTOTYPING LAB FOR DESIGN AND DEVELOPMENT AMPL FS990 with video display and dual floppy diskettes includes TX990/TXDS system software - Text Editor, Assembler, and Link Utility - and has an in-circuit Emulator Module and a Logic-State Trace Module for proposed system emulation and analysis. TIMESHARE SYSTEMS GE, NCSS, Assembler, Simulator, ROM Utilities Tymeshare Figure 2-6. The 9900 Family Software and Development Systems 9900 FAMILY SYSTEMS DESIGN 2-7 FAMILY OVERVIEW Product Selection Gulde TYPICAL APPLICATIONS The range of applications for microprocessors and microcomputers expands each day; Figure 2-7 provides a broad scope of the applications extending from those that can be satisfied with single-chip microcomputers to those requiring high performance multichip systems. The market tends to be characterized by lower performance, high volume single-chip systems, and higher performance, low volume multichip systems. ~2 As shown in Figure 2-7, the spectrum of applications is satisfied throughout by 9900 Family members. The single-chip 16-bit microcomputer, the TMS 9940, is used where there is large volume, because it has the lowest cost, yet achieves outstanding performance. At the other end are the system with the 16-bit TMS 9900 and SBP 9900A CPUs, the specially designed family peripherals, and add-on memory. For maximum system performance, the bit slice SN74S481 units are available. For in-between performance limits there are the 16-bit CPUs using 8-bit data buses. The TMS 9980A/81 has lower cost, and the TMS 9985 will accommodate larger memory for extended applications. Both proc~ssors use the more economical 40-pin package. Applications in the low and medium performance range include simple instruments, computer peripherals, cash registers and controls for manufacturing. At the higher performance end, a myriad of products that are emulating many computer-like functions - data terminals, point-of-sale terminals, data acquisition systems, process control systems, military systems - are all gaining performance at lower cost by using microprocessor multichip systems. SN74S481 COMPUTERS (Bit Slice) INTELLIGENT GRAPHICS TMS9900-40 GRAPHIC SYSTEMS TMS9900 WORD PROCESSING DATA TERMINALS SBP9900A MILITARY SYSTEMS MEDICAL DIAGNOSTICS MICROCOMPUTERS TMS9985 POS DATA COLLECTION PROCESS CONTROL PATIENT MONITORS TMS9981 NUMERICAL CONTROL TMS9980A METERING CONTROLS SECURITY SYSTEMS PROTOTYPING w MANUFACTURING CONTROLS 0 z <( TMS9940E MEDICAL INSTRUMENTATION GAMES ~ AUTOMOTIVE a: 0 COMPUTER TERMINALS LL a: INSTRUMENTS w a.. TMS9940M CASH REGISTERS CALCULATORS VOLUME --------1~ Figure 2-7. Application Spectrum 2-8 9900 FAMILY SYSTEMS DESIGN Product Selection Guide HARDWARE SELECTION Figure 2-8 details further the applications for single-chip and multiple-chip systems. SINGLE-CHIP MICROCOMPUTER MULTIPLE-CHIP SYSTEMS Gas Pump Control Video Controllers CPU's-Microcomputer Alarm Systems Telephone Switching Computer Peripherals Paging Systems Word Processing Equipment Intelligent Terminals 2....- Sorters Manufactbring Material Handlers Tape Drive Controls Vending Machines Electronic Musical Instruments Graphic Terminals Microwave Ovens Small Business/Financial Systems Communications Network Appliance Control Factory Automation Communications Processing Power Tools Instrumentation Data Concentration Utility Meter Monitoring Data Acquisition Input Terminals Environmental Controls Machine Controls General Purpose Terminals Automotive Medical Equipment Games Security Systems Cryptography Machine Tool Controls Process Controls Navigation Equipment Metering Controls Figure 2-8. Applications HARDWARE SELECTION To reduce the range of detail which must be considered in a given system design, it is often possible to make a definite choice between the three hardware design levels; designing with individual components, designing with prefabricated modules, and designing with minicomputer subsystems. The criteria upon which this choice is based include the number of units to be manufactured per design, complexity of design, performance requirements, special feature requirements, microprocessor system design expertise available, and the importance placed on product introduction - the time to the market place. General tendencies of these decisions are known although the particular choice may be skewed by other considerations. Here are a number of examples. In terms of production volume, users tend to incorporate minicomputers in their designs up to a volume of 50 to 100 identical systems per year. They tend to use prefabricated modules if the volume is below 500 to 2000 systems per year, and for higher volume, they tend to develop from the component level right from the start. Simple systems may not be able to stand the cost of a minicomputer at any volume, while even at prnch higher volumes, performance requirements may force the utilization of a disk-based minicomputer. When system specifications require special features, this often forces the use of modules even at low volumes. However, the need for maintenance capability may force the use of minicomputers or prefabricated modules for system construction at extremely large volumes. A firm with expert microprocessor design teams would tend to maximize its value-added by designing from the component level, while a firm without hardware designers would look for completely prefabricated systems. 9900 FAMILY SYSTEMS DESIGN 2-9 HARDWARE SELECTION Product Selection Guide Finally, product introduction priorities often call for a compromise approach because of an urgent need to get a product to market ahead of competition. It is often ideal to enter the market with prefabricated systems an1-cj>4 TMS9901 (OR 9901-40) INT l/F 1-----~---'I INTERRUPTS { PSI 1/0 PROGRAMMABLE 9900 SYSTEMS FAMILY INTERFACE 2<11111 CPU ADDRESS ->---+---< CRUOUT ~-~ CRUCLK SERIAL 1/0 CRUIN TMS9902 ACC ASYNCHRONOUS { ASYNCHRONOUS SERIAL DATA ,--~ COMMUNICATIONS CONTROLLER (INCLUDES TIMER) TMS9903 SYNCHRONOUS { sec SYNCHRONOUS SERIAL DATA /----. COMMUNICATIONS ---~ CONTROLLER (INCLUDES TIMER) Figure 2-15. Microcomputer Component Peripherals for I I 0 Interface A significant advantage of the 9900/9901parallel1/0 interface through the CRU is the ability to transfer fields of from 1 to 16 bits of data as inputs or outputs under the command of one instruction and to modify this structure from instruction to instruction. Additionally, use of the CRU allows implementation of multiple functions in the TMS9901. MEMORY-MAPPED Since the CRU is essentially a time-division multiplexed serial port, speed critical applications may require a faster parallel technique. Memory-mapping, the treatment of a parallel 1/0 port as if it were a memory location, provides this technique. With the memory-to-memory architecture of the 9900 Family; direct manipulation of such an 1/0 port is practical. The dual-TTL drive of the 9900 Family allows economical construction of memory-mapped I/O ports using standard TTL or LS (Low-Power Schottky) components. 9900 FAMILY SYSTEMS DESIGN 2-19 HARDWARE SELECTION Product Selection Guide GPIB-GENERAL PURPOSE INTERFACE BUS In 197 5 the IEEE defined a very precise electrical and mechanical protocol designated the IEEE 488 Interface Bus, or commonly known as a General Purpose Interface Bus (GPIB). This protocol allows direct connection of instruments and processors supplied by various manufacturers. The TMS9914 General Purpose Interface Bus Adapter either directly, or under software control, adapts all the capabilities of the GPIB to a microprocessor bus including talker, listener, controller and control passer. This is a general purpose component and will work quite well with any microprocessor, although it is complemented by the speed and power of the 9900 Family. DMA-DIRECT MEMORY ACCESS Many 1/0 devices can be made more effective if transfer rates can be increased beyond the 8 microseconds required for a typical memory-mapped transfer. The GPIB mentioned above, for instance, allows data transfers at rates up to a million bytes per second. The TMS9911 Direct Memory Access Controller allows low cost implementation of two such super high speed ports. The TMS9911 itself is controlled by the CPU via the CRU bus, until one of the DMA channels takes control long enough to process a DMA transfer (either single or block) between 1/0 port and memory. FLOPPY DISK For those applications requiring more storage space than is convenient or economical in a microcomputer, a mass storage device is needed. Floppy disk units provide the benefits of fast access, reliable mass storage using a portable, easily stored media. Interfacing these units to microprocessors is greatly simplified by the TMS9909 Floppy Disk Controller. This device will control up to four floppy disk units using standard or minifloppies, single, double, or triple density, hard or soft sectors. It is also capable offull IBM compatibility (including double-sided, double density at the same time). This is a general purpose component and will work quite well with any microprocessor. It is a memory-mapped device and will also interface easily to a DMA controller such as the TMS991 l. The TMS9909 can be programmed for: 1. Data encoding formats 2. Number and type of diskette drives 3. Stepper motor control rates 4. Number of sectors and tracks It can perform the following functions: 1. Step to any track on the diskette 2. Format tracks (set initial conditions on diskette) 3. Read and write diskette data 4. Send status to the host system 2-20 9900 FAMILY SYSTEMS DESIGN Product Selection Guide HARDWARE SELECTION CRT CONTROL The TMS992 7 video timer I controller is a memory-mapped device which contains all of the logic necessary to generate all the timing signals for display of video data on CRT monitors, standard or not, and interlaced or not. This video timer I controller has nine 8-bit registers used for programming; seven for horizontal and vertical formatting and two for the cursor character and address. All the functions for generating the timing signals for video data display are programmable: 1. Characters per row 2. Data rows per frame 3. Raster scans per data row 4. Raster scans per frame All timing functions are implemented on the chip except the dot generation and dot counting which operate at video frequency. A character generator and shift register are used to shift out video data. The control registers can be loaded by the microprocessor or from PROM. This is a general purpose part for use with any microprocessor. MEMORY Contained in the microcomputer component peripherals is a unit for memory expansion, the TMS9932, a combination ROM/RAM memory unit with 1920 bytes of ROM and 128 bytes of RAM. It contains the same key features that characterize the 9900 Family support memory. MEMORY CONTROL The TIM9915 chip set consists of 3 packages, a 16-pin Refresh Timing Controller (TIM9915A), a 16-pin Memory Timing Control (TIM9915B), and a 28-pin Multiplexer/ Latch with tri-state outputs (TIM9915C). This chip set becomes the complete.packaged set for 4K to 64K of dynamic RAM memory, and provides all the timing and control signals necessary to interface dynamic RAM memory and make it appear as static RAM Clock and Support Logic Four-Phase Clock Generator I Driver Microprocessor and microcomputer systems require clock generators and drivers for the timing control of the system. The TMS9904 is such a unit. An oscillator which can be crystal or inductance controlled provides the basic timing source. Four high-level clock phases provide the 9900 microprocessor timing. Four additional TTL-level clocks can be used to time memory or other control functions in a 9900 system. 9900 FAMILY SYSTEMS DESIGN 2-21 HARDWARE SELECTION Product Selection Gulde Support Logic Common TTL MSI peripherals included in the 9900 Family of microcomputer components are: TIM9905 8 to 1 Multiplexer TIM9906 8-Bit Latch TIM9907 8 to 3 Priority Encoder TIM9908 8 to 3 Priority Encoder w /Tri-State Outputs The reason, of course, is that they are standard units for accomplishing the following tasks: 1. Parallel-to-Serial Conversion 2. Multiplexing from N-lines to one line 3. Providing multiple data selectors 4. Providing bus interface from multiple sources 5. Encoding 10 line decimal to 4 line BCD 6. Encoding 8 lines to 3 lines All units are fabricated using standard low-power Schottky TTL technology in 16-pin packages. They have tri-state output drivers to interface directly with a system bus and are fully compatible with all TTL interfaces. Cost Effectiveness of NMOS LSI Peripherals Figure 2-16 clearly demonstrates the cost effectiveness of the specially designed CRU microcomputer component peripherals. The replacement of large numbers of less complex packages provides a significant reduction in cost due to simplified design, layout, assembly and testing, besides the reduced material costs. In addition, there are major contributions to improving the reliability of the system just by reducing the number of packages and the associated solder connections and assembly connections external to the IC. SSI AND MSI FUNCTION UNIT USED PACKAGES REPLACED INTERRUPTS TMS9901 23 AND 1/0 ASYNCHRONOUS TMS9902 45 SERIAL COMMUNICATIONS SYNCHRONOUS TMS9903 100 SERIAL COMMUNICATIONS Figure 2-16. System Package Reduction Using Microcomputer Component Peripherals 2-22 9900 FAMILY SYSTEMS DESIGN Product Selection Gulde HARDWARE SELECTION CR U Interface In the features for the 9900 Family, the Communications Register Unit interface provides: 1. The most cost effective 1/0 for low and medium speed peripherals via the instruction driven serial data link. 2. Completely separate address space. 3. A choice of transferring fields of 1 to 16 bits per instruction. I 2~ The CRU serial data link is an effective mechanism for operation-per-instruction 110. The CRU interface is simpler and therefore less expensive than memory-mapped 1/0. In applications where there are many 1/0 transfers of one or two bits, the CRU serial data link provides execution times that are better than for memory-mapped 1/0, which always transfers 8 or 16 bits at a time. One way of demonstrating the cost effectiveness of the CRU is shown in Figure 2-17. Package pins per function are less using the CRU interface and the 9900 Family units. Thus, costs are saved over memory-mapping in implementing the example 1/0 functions shown. CRU MEMORY MAPPED FUNCTION PINS PINS 8-Bit Output 16 (TIM9906) 24 UART 18 (TMS9902) 24-40 USRT 20 (TMS9903) 24-40 Ft'gure 2-17. CRU vs Memory Mapped 110 - Package Pins Required Per Function THE COMPONENT RouTE: MEMORY Semiconductor memory is the most natural storage media to add to a 9900 system. It has fast access times, an interface that is completely compatible with the microprocessor or microcomputer, and high-density storage per package. Texas Instruments offers a broad spectrum of storage media products in support of the 9900 Family as shown in Figure 2-1~ 2-19 and 2-20. These products encompass dynamic and static random access memory, mask programmable read-only memory, fused-link programmable read-only memory, and eraseable programmable read-only memory. 9900 FAMILY SYSTEMS DESIGN 2-23 Product HARDWARE SELECTION Selection Guide WORDS BITS PER WORD 2 4 8 RAMs SN54174S189 16 SN5417 4S289 ROM 'QA. SN5417488A PROMS ~2 32 SN54174188A SN54/74S188 ~N54174S28B RAMs RAM SN10140 TMS 4036 64 SN10142 ,. PROM SN10148 SN54174186 ?-c_;,'O 128 RAMs ,,. ,. . s\~ RAMs TMS 4039, TMS 4042, TMS .4043 ROMs PROMS SN10144 SN7 4S207 SN7 4S208 SN54/74S271 SN5417 4S4 70 256 SN5417 4S20'f '" RO Ms PRO Ms SN54174S371 SN54174S471 SN54J74S301 SN54174187 SN54174S2B7 SN54174S387 /···,,. . \O'ZJ .. ROMs PROMs SN5417 4S270 SN54174S472 512 SN54/.~4S370 SN5417 4S4 73 SN54 /7 4S4 74 • SN5417 4S4 75 RAM RO Ms RAMs RAMs PROMs. • TMS 4008 TMS 4700 TMS 1103 TMS 4033·· TMS 4045 SN74S476 TMS 4710 EPROMs 1024 TMS 4034 TMS 4035 TMS 40L45. ,. . SN74S477 PRO Ms TMS 4062TMS 4063 · .. TMS 2508 · TMS 4047 TMS 2708 SN74S478 SN14S209 SN74S309 , TMS 40L47 ·TMS27L08 SN74S2708 RAM ROMs TMS 4016 )MS4800 SBP 8316 2048 EPROMs SBP 9818 TMS 2516 PROM ,.TMS 2716 SN74S452 ROM TMS 4732 4096 8192 16384 32768 65536 Figure 2-18. Matrix of Memory Products 2-24 9900 FAMILY SYSTEMS DESIGN Product Selection Guide HARDWARE SELECTION DYNAMIC RAMS ':'PKG. TYPE ORGAN. TECH PINS ACCESS TIME-ns Po-mW POWER TEMP 2~ TMS4027 4096 x 1 NMOS 16 150-200 460 +5V, -5V, +12V 0°C-70°C TMS4050 4096 x 1 NMOS 18 200-300 420 +5V, -5V, +12V 0°C-70°C TMS4051 4096 x 1 NMOS 18 250-300 460 +5V, -5V, +12V 0°C-70°C TMS4060 4096 x 1 NMOS 22 150-300 400 +5V, -5V, +12V 0°C-70°C TMS4116 16,384x1 NMOS 16 100-200 462 +5V, -5V, +12V 0°C-70°C TMS4164 65,536 x 1 NMOS 16 100-150 200 +5V 0°C-70°C '~MAXIMUM STATIC RAMS ACCESS ':'PKG. TYPE ORGAN. TECH. PINS TIME-ns Po-mW POWER TEMP. TMS4008 1024 x 8 NMOS 24 150-450 450 +5V 0°C-70°C TMS4016 2048 x 8 NMOS 24 150-450 495 +5V 0°C-70°C TMS4033 1024 x 1 NMOS 16 450 368 +5v 0°C-70°C TMS4034, 35 1024 x 1 NMOS 16 650-1000 368 +5V 0°C-70°C TMS4036-2 64 x 8 NMOS 20 450-1000 450 +5V 0°C-70°C TMS4039-2 256 X4 NMOS 22 450-1000 368 +5V 0°C-70°C TMS4042-2 256 X4 NMOS 18 450-1000 368 +5V 0°C-70°C TMS4043-2 256 X4 NMOS 16 450-1000 368 +5V 0°C-70°C TMS4044 4096 x 1 NMOS 18 150-450 440 +5v 0°C-70°C TMS40L44 4096 x 1 NMOS 18 200-450 275 +5V 0°C-70°C TMS4045 1024 x 4 NMOS 18 200-450 495 +5V 0°C-70°C TMS40L45 1024 x 4 NMOS 18 200-450 300 +5V 0°C-70°C TMS4046 4096 x 1 NMOS 20 150-450 440 +5V 0°C-70°C TMS40L46 4096 x 1 NMOS 20 200-450 275 +5V 0°C-70°C TMS4047 1024 X4 NMOS 20 150-450 495 +5V 0°C-70°C TMS40L47 1024 X4 NMOS 20 200-450 300 +5V 0°C-70°C *MAXIMUM Figure 2-19. Dynamic and Static RAM in Support of 9900 Family 9900 FAMILY SYSTEMS DESIGN 2-25 HARDWARE SELECTION Product Selection Gulde READ ONLY MEMORIES ROM PKG. TYPE ORGAN. TECH. PINS ACCESS TIME-ns Po-mW POWER TEMP. ... 2 TMS4700 1024 x 8 NMOS 24 450 *580 +5V, -5V, + 12V 0°C-70°C .6. TMS4710 1024 x 8 NMOS 24 450 *580 +5V, -5V, + 12v 0°C-70°C TMS4732 4096 x 8 NMOS 24 450 *788 +5V 0°C-70°C 0°C-70°C SBP8316 2048 X8 12L 24 650 500 +5v -55°C to +125°C (1.5V-30V) 0°C-70°C SBP9818 2048 X8 12L 24 200 500 500 MA -55°C to +125°C .6.Character Generator *MAXIMUM PROMS PKG. TYPE ORGAN. TECH. PINS ACCESS TIME-ns Po-mW POWER TEMP. SN54/74S287 256X4 TIL(s) 16 42 *708 0 +5v SN54: 0°C-70°C SN54/74S471 256 X8 TIL(s) 20 50 *814 +5v SN74: -55°C to +125°C SN54/74S472 512 x 8 TIL(s) 20 55 *814 +5v SN54/74S474 512 x 8 TIL(s) 24 55 *814 +5V SN54/74S476 1024 X4 TIL(s) 18 35 *735 +5v SN54/74S478 1024 x 8 TIL(s) 24 45 600 +5V SN54/74S2708 1024 x 8 TIL(s) 24 45 600 +5V *MAXIMUM EPROMS *PKG. TYPE ORGAN. TECH. PIN ACCESS TIME-ns Po-mW POWER TEMP. TMS2508 1024 x 8 NMOS 24 350 500 +5V 0°C-70°C TMS2708 1024 x 8 NMOS 24 350-450 800 +5V, -5V, + 12V 0°C-70°C TMS27L08 1024 x 8 NMOS 24 450 475 +5V, -5V, +12V 0°C-70°C TMS2516 2048 x 8 NMOS 24 450 525 +5v 0°C-70°C TMS2716 2048 x 8 NMOS 24 450 595 +5V, -5V, +12V 0°C-70°C TMS2532 4096 x 8 NMOS 24 450 840 +5V 0°C-70°C *MAXIMUM Figure 2-20. Read Only Memory in Support of 9900 Family 2-26 9900 FAMILY SYSTEMS DESIGN Product Selection Guide HARDWARE SELECTION Standard Memory and Compatibility A very important characteristic of the 9900 Family is that it uses standard semiconductor memory not memory that depends on a custom multiplexed or latched bus. The full range of MOS, TTL, FL and ECL memories are shown in Figure 2-18. Many of these units that support the 9900 Family are pin-compatible for ease in conversion from development systems to production systems. 2~ As an example, during development, package flexibility is provided. SRAM Initially, a static RAM is used; then EPROM's can be substituted as the + EPROM system design stabilizes, and when the system is proven and in volume + ROM production, mask ROM can be substituted. Here is an example of the socket compatibility: MEMORY SIZE SRAM EPROM PROM ROM lK X 8 4008 2508 SN74S2708/478 lK X 8 2708 SN74S2708/ 4 78 4700 2K x 8 4016 2516 SBP8316, SBP9818 4K X 8 2532 4732 (All of these devices can fit a single socket.) Even if the memory units are not completely compatible, due to power supplies or control pins, simple jumpers can be used to maintain socket compatibility. Read-Only Memory: Costs and Flexibility Figure 2-21 shows the characteristics of read-only memories and their cost per bit vs. design flexibility. Mask programmable read-only memory is lowest cost per bit but also has no flexibility. It is used for high volume production after a design is proved to be correct and no changes are expected. PROMs have excellent performance and have more flexibility because programming is done after they are manufactured. However, once programmed they cannot be changed. PROMs cost somewhat more than ROMs because they use more real estate. EPROM has much more flexibility because design changes are done quickly and because it is reuseable, but EPROM costs more to manufacture than ROM or PROM because it is eraseable. EAROM is also indicated in Figure 2-21. This is really "read mostly" memory, because it can be erased in a relatively short period of time (microseconds), but once programmed again, it acts like fixed storage. EAROMs as a practical product are still a bit in the future. The flexibility of EPROMs is well worth the added cost. This is especially true when used as a prototyping tool. 9900 FAMILY SYSTEMS DESIGN 2-27 HARDWARE SELECTION Product Selection Guide A. READ-ONLY MEMORY CHARACTERISTICS ROM PROM EPROM EAR OM COST (RANK) 1 2 3 4 PROGRAM TIME WEEKS MINUTES MINUTES MICROSECONDS SETUP CHARGE YES NO NO NO REUSABILITY NO NO YES YES SPEED FAST VERY FAST MEDIUM SLOW B. READ-ONLY MEMORY COST /BIT VS FLEXIBILITY • EAROM RELATIVE e EPROM COST/BIT e PROM •ROM RELATIVE FLEXIBILITY - - - - - - - ' - Figure 2-21. Read-Only Memory Overview THE COMPONENT ROUTE: MISCELLANEOUS COMPONENTS Included in the full support of the 9900 Family is the large array of SSI, MSI and linear integrated circuits. Information on all components manufactured by Texas Instruments may be found in the following data books: Power Data Book LCC4041 TTL Data Book (Second Edition) LCC4112 TTL Data Book (2nd Edition Supplement) LCC4162 Transistor and Diode Data Book LCC4131 Semiconductor Memories Data Book LCC4200 Optoelectronics Data Book (Fourth Edition) LCC4230 Optoelectronics Data Book (Fifth Edition) LCC4410 Linear Control Circuits Data Book LCC4241 Bipolar Microcomputer Components Data Book LCC4270 Interface Circuits Data Book LCC4330 Electro Optical Components LCC4340 Voltage Regulator Handbook LCC4350 MOS Memory - 1978 LCC4380 9900 Family Systems Design Book LCC4400 2-28 9900 FAMILY SYSTEMS DESIGN Product Selection Guide HARDWARE SELECTION Correspondence and inquiries about these books should be directed to: Texas Instruments Incorporated P.O. Box 225012, M/S 54 Dallas, Texas 75265 (214) 238-3894 Most of the above are concerned with SSI and MSI integrated circuits. The following is a 2 <111111 list of additional guides to discrete components. Optoelectronics Master Selection Guide CL-346 1978 Discrete Semiconductor Master Selection Guide CL-347 1978 Correspondence and inquiries about these units should be directed to: Texas Instruments Incorporated P.O. Box 225012, M/S 308 Dallas, Texas 75265 (214) 238-2011 THE MoDULAR RouTE: M1cROCOMPUTER MODULES TM990 microcomputer modules are preassembled, pre-tested, ready-to-use combinations of 9900 Family components which are available to meet the needs of the microprocessor and microcomputer systems designers. An overview of the TM990 microcomputer module product line, divided into the product series, is shown in Figure 2-22. A summary of key parameters are given in Tables 2-1, 2-2 and 2-3. The series ranges from microcomputers to expansion boards for memory and I/O, to software support in read-only memory (EPROM), to the accessories required to interconnect the modules. An IiO microterminal, TM990/301, is a low-cost terminal for system development included in the 300 series. A module ofl/O and memory for software development, the TM990/302, is included in the 300 series and will be discussed further in the software support section. The additional software products, TIBUG Monitor (TM990/401), Line-by-Line Assembler (TM990/402), and the POWER BASIC units (TM990/450, 451, and 452) will also be discussed in the software support section. 9900 FAMILY SYSTEMS DESIGN 2-29 HARDWARE SELECTION Product Selection Guide r-------------------1 ~~~!ES !I I I I I I I I i ~;~~~ioN MEMORY MEMORY MEMORY MEMORY L_ - - - - - - - - - - --------J r----------------, ~~~!ES : G I MEMORY I G : MICROCOMPUTERS ~2 L ___ - - - - - - - - - - - - - -1 r------------------1 300 SERIES G it--------------------1!110 OR lI MEMORY I G G G l ~~~~~~g~v L---------- ------- -- __ ..J 400 SERIES r-------------1 1 I ROM BASED FIRMWARE I I L._ _ _ _ - --- ------ _J ~~~IES r---------1I : ACCESSORIES . L----------...1 Figure 2-22. TM990 Microcomputer Module Series The Application Microcomputer modules are for the system designer who wants to: 1. Apply and evaluate a 9900 Family microcomputer without taking the time for all the engineering, planning, assembly and testing needed to design and assemble the equivalent microcomputer system. 2. Free himself from design details to concentrate on speeding an end product to market. 3. Expand memory of an existing 9900 Family system. 4. Assemble a low-cost software development system to edit, assemble, load and debug programs for PROMs. · 5. Expand a university course with low-cost hands-on hardware. 6. Evaluate POWER BASIC programs and apply them to microcomputer systems. A Special Product A special product in the microcomputer module series is the TM990/189 University Board. It is designed primarily as a learning tool for the engineer, student or hobbyist. It aids in the instruction of microcomputer fundamentals, machine and assembly language programming and microcomputer interfacing. A tutorial text and a list of assembly procedures are included. More information is found in Chapter 8. 2-30 9900 FAMILY SYSTEMS DESIGN Product HARDWARE SELECTION Selection Guide TM990/100 SERIES-MICROCOMPUTER MODULES Prioritized Serial Parallel vectored Product CPU EPROM (Bytes) RAM (Bytes) 1/0 ports 1/0 Lines interrupts Timers TM990/100M-1 TMS9900 2K (270B) 512 1 RS232C 16 16 2 (Contains TIBUG Monitor) Expandable to 1K 1 TTY Expandable to BK (2716) 2- Cl. I- 0: _J CD 0 Cl'l ~ Cl'l UJ CJ) CJ) CJ) ~ <( I- Figure 3-1. TM 990 I 1 OOM-1 Microcomputer 3-4 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 GETTING IT TOGETHER ;~·Tu-'s INSTl(UMtf.n ' ' ' Figure J-2. TM 9901301 Microterminal Just think, a complete microcomputer with: 1) 256 16-bit words of random access memory to hold program steps and program data, expandable to 512 words; 2) 1024 16- bit words of read only memory which contains pre-programmed routines (TIBUG Monitor) that provides the steps necessary for the TM990/100M-1 microcomputer to accept input instructions and data and to provide output data. This ROM capability can be expanded to 4096 words to provide program flexibility; 3) input/output interface that can handle 16 parallel lines expandable to 4096 and an interface for serial characters of 5-8 bits at a programmable data rate; 4) an input terminal to input the sequence of steps to solve a problem - the program. GETTING IT TOGETHER Of course, in order to operate the microprocessor system, it must be put together. It must be interconnected. What function will it perform? The first encounter application is shown in Figure 3-6. The microcomputer will be used to provide basic logic level outputs to turn on and off, in sequence, light emitting diode segments of a 7 segment numeric display element, the TIL303. This will demonstrate the "software" ~echniques used to provide de logic levels at the I/O interface which through proper drivers can later be used to control solenoids, motors, relays, lights, etc. In the first encounter application, the microterminal shown in Figure 3-2 will be used to input the instructions and data required to perform the function. 9900 FAMILY SYSTEMS DESIGN 3-5 GETTING IT TOGETHER A First Encounter: Getting Your Hands on a 9900 Recall that a light emitting diode (LED) is made of semiconductor material and emits light when a current is passed through it in the correct direction. Each segment of the 7-segment display is a separate LED. Four segments of the display will turn on in the sequence f, b, e, c at a slow or a fast rate depending on the position of a switch, as shown in Figure 3-6. Each segment will first be turned on, then a short delay, then off, then a short delay. The sequence is continued with the next segment; proceeding around through 4 segments and then starting over again. The rate is varied by changing the delay in the sequence. The switch position controls the delay. A 7-segment display is used because of its ready availability and its dual-in-line package. Only 4 of the segments will be programmed into the sequence although driver capability will be provided for 6 segments. This allows flexibility for the person doing the first encounter to experiment on their own to include the remaining 2 segments. A next step would be to provide an additional driver. In this way all 7 segments of the display can be included. Here's what's required to provide the segment display. Figure 3-7 shows the integrated circuit driver package for the LED segments, the SN74H05N. The physical package and a schematic are shown. It contains 6 open collector inverters, each capable of "sinking" 20 ma. A 14- or 16-pin dual-in-line socket is required. A wire-wrap one is shown. However, it could be a solder terminal unit just as well. Figure 3-8 shows the 7-segment display physical package and schematic and a 14- or 16-pin DIP socket for interconnection. 100 ohm resistors for limiting current through the LEDs are also required. CPU ALU ARITHMETIC AND LOGIC UNIT CONTROL AND OUTPUT INPUT CENTRAL TIMING MEMORY Figure 3-3. Generalized Computer 3-6 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 GETTING IT TOGETHER CPU ALU CONTROL AND CENTRAL TIMING 9900 MICROPROCESSOR PARALLEL INPUT/OUTPUT SERIAL INPUT /OUTPUT INTERFACE AND BUFFERING CENTRAL TIMING INTERFACE AND BUFFERING 9904 CLOCK ROM RAM (EPROM) 256 x 16 1K X 16 Figure 3-4. Miniature Computer System on TM 9901 lOOM-1 Module TIM 9904 CLOCK D 48MHz TMS 9901 TMS 9902 PSI ACC 1/0 CONNECTOR P3 & P4 P1 P2 Figure 3-5. TM 990 I 1 OOM-1 Block Diagram 9900 FAMILY SYSTEMS DESIGN 3-7 GETTING IT TOGETHER A First Encounter: Getting Your Hands on a 9900 POWER SUPPLY +5V + 12V -12V GND LOGIC LEVEL INPUT PERIODICALLY TESTED BY THE MICROCOMPUTER "ELEMENTS TM 990/100M +5V AS SHOWN MICROCOMPUTER ~3 r-- --- 1 II TMS 9901 PROGRAMMABLE TM 9901301 MICROTERMINAL I I~;~~~~;E l-'-----i------1 I I SEVEN I SEGMENT DISPLAY LOGIC LEVEL INVERTERS OUTPUTS UNDER USED AS LED SEGMENT CONTROL OF MICROCOMPUTER DRIVERS Figure 3-6. The First Encounter Task All of the components of Figure 3-7 and 3-8 are wired together on a separate printed circuit board as shown in Figure 3-9. The Radio Shack # 276-152 board provides individual plated surfaces around holes to make it easy to anchor components and to interconnect all components with wire-wrap. J4, the 40 pin wire-wrap PCB edge connector accepts the edge connections of P4 on the TM990/ lOOM-1 board shown in Figure 3-1. After wiring this connector, put a piece of tape across the top of this connector so that it is correctly oriented before the board is plugged in; or the same can be done here as for P 1 discussed a little later. Note also on Figure 3-1 that there is an area on the 990/lOOM-1 board for prototyping. The components of Figure 3-9 may be wired in this area rather than using a separate printed circuit board. Using a separate board allows this area to be used for more permanent components for a specific dedicated application of the 990/lOOM module. 3-8 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 GETTING IT TOGETHER A. SN74H05N SIX INVERTER IN 1 14 VCC ( + 5V) DRIVERS 14 PIN PLASTIC PKG. OUT 1 13 IN 6 IN 2 12 OUT6 OUT 2 4 11 IN 5 IN 3 5 10 OUT 5 3.. OUT 3 6 IN 4 GND 8 OUT4 C. SCHEMATIC OF SN74H05N (TOP VIEW) COMPONENT PARTS 1 - SN 74H05N HEX DRIVER (EACH DRIVER CAPABLE OF SINKING 20 MA.) B. 14-16 PIN DIP SOCKET (WIRE-WRAP OR SOLDER TERMINALS) 1 - 14 OR 16 PIN DIP SOCKET (RADIO SHACK # 276-1993, 94) (Tl # 811604 M&C - 16 PIN WIRE-WRAP) Figure 3-7. LED Driver Parts TOP VIEW A. TIL303 7 SEGMENT NUMERICAL DISPLAY a1 14 b Vee2 13Vee I3 12 g4 11 !1000!1000!1000!1oon!1000!1000 10 D.P. D. 100 OHM RESISTORS 1 /4 W e6 9c Vee? 8d C. SCHEMATIC OF TIL303 COMPONENT PARTS 1 - 7 SEGMENT DISPLAY TIL303 1 -14 OR 16 PIN DIP PACKAGE (C-811604 M&C - 16 PIN WIRE WRAP) B. 14 OR 16 PIN DIP SOCKET (RADIO SHACK- 276 -1993, 94) (WIRE-WRAP OR SOLDER TERMINALS) 6 -100 OHM RESISTORS, 1 /4 W Figure 3-8. Segment Display Parts 9900 FAMILY SYSTEMS DESIGN 3-9 GETTING IT TOGETHER A First Encounter: Getting Your Hands on a 9900 +5V S1 13 +5V --..., C5b I GND I I 7 SEGMENT " I DISPLAY J4 " I TIL303 "...... __, 9 100 Q 14 4 1/0 r- - - -6- - - - 8 , BIT 1 I 1 I I SN74H05N TIL 303 0 I I SN74H05N 31 I PRINTED CIRCUIT BOARD I I RADIO SHACK # 276-152 sl I I 3 I A. LAYOUT 91 I I I L - - - - - · - - - - - 7 __, +5V 1 S FAST SLOW 20 22 18 14 16 40-PIN WIRE WRAP J4 PCB EDGE CONNECTOR B. SCHEMATIC Figure 3-9. The Output Board Following is a complete list of the parts, tools and supplies required. This is the list that was referred to earlier. Check carefully that all necessary parts are purchased. PARTS LIST A. Microcomputer 1- TM990/100M-1 TMS9900 Microcomputer module with TIBUG monitor in two TMS 2708 EPROM's and EIA or TTY serial 1/0 jumper option. B. Terminal 1 - TM990/301 Micro terminal 3-10 9900 FAMILY SYSTEMS DESIGN A First Encounter: GETTING IT TOGETHER Getting Your Hands on a 9900 C. Output 1 - Hex LED Driver SN74H05N 1 - 7 Segment Display TIL303 2 - 14 or 16 Pin Dip Sockets TI wire-wrap; 16 Pin - C-811604 M&C; Radio Shack wire-wrap; 14 Pin 276-1993; 16 Pin 276-1994 6 - 100 ohm Resistors, Y-i W 1 - Switch, Toggle or Slide, SPSTorDPST 1 - J4, 40 pin, 0.1" c-c, TIH421121-20 wire-wrap 3... PCB Edge Connector Viking 3VH20/ 1JND5 (or equiv. solder terminal unit) 1 - Printed Circuit Board Radio Shack #276-152 D. Bus Connector (Use for Power in First Encounter) 1- Jl, 100-pin,0.125"c-c, TIH431121-50 wire-wrap PCB Edge Connector AMPHENOL 225-804-50 (or equiv. solder Viking 3VH50/9N05 terminal unit) Elco 00-6064-100-061-001 E. Power Supplies - Regulated Voltage Regulation Current +5V +3% 1.3A +12V +3% 0.2A -12V +3% O.lA F. Tools Wire-wrap connector tool Soldering Iron Wire-wrap disconnecting tool Wire stripper (30 G) Long-nose pliers Diagonal cutter VOM, DVM, DMM G. General Supplies Wire (30 G Kynar) Solder Plugs and jacks for power supply connections Note the power supplies required, the voltages, currents, and regulation. Assure that there is a common ground between all units. 9900 FAMILY SYSTEMS DESIGN 3-11 GETTING IT TOGETHER A First Encounter: Getting Your Hands on a 9900 (Electronic shops or laboratories might have available individual LEDs, therefore, Figure 3-10 is provided in case this alternate method of display is chosen. The necessary drivers and resistors are identified. The necessary substitutions can be made on Figure 3-9.) After wiring the output board, what remains is to supply power to the board. This is accomplished through Pl on the 990/lOOM-l board. Figure 3-11 shows how the edge connector is wired to supply power. Be careful to use the correct pins as numbered on Pl on the board; these pin numbers may not correspond to the number on the particular edge connector used. Label the top side of the edge connector "TOP" and the bottom "TURN OVER." This will prevent incorrect connection of power to board. Wire the connector pins so that the top and bottom connections on the board are used to supply llJiii.3 power, e.g., 1 & 2 for ground; 3 & 4 for +5V; 73 & 74 for -12V; and 75 & 76 for + 12V. Plugs or jacks may be placed on the end of the power supply wires to make easy interface. With both the Pl and P4 connectors and the output board wired, the total system is ready for interconnection. 1Y 14 1A 2Y 13 6Y 2A 3 12 6A B. LIGHT EMITIING DIODES C. 330 OHM RESISTORS GND 4 11VssorV~c TIL209 1/4w 3A 10 SA 3Y SY 4Y 8 4A ------<-----11t------- + SV 330 fl A. SN7S492N MOS-LED DRIVER (OPEN COLLECTOR) -, I COMPONENTS PARTS I SN7S492N 1 - SN7S492N DRIVER I 1 - 14-16 PIN DIP SOCKET 4 - TIL209 LED'S 3 s 8 14 4 - 330 fl RESISTORS D. SCHEMATIC Figure 3-10. Alternative LED Output Display 3-12 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 UNPACKING AND CHECKING THE MICROCOMPUTER (TM 990/lOOM-1) UNPACKING AND CHECKING THE MICROCOMPUTER (TM990/100M-1) It is very important to realize that the microcomputer module has MOS (metal- oxide-semiconductor) integrated circuits on it. These circuits are particularly sensitive to static charge and can be damaged permanently if such charge is discharged through their internal circuitry. Therefore, make sure to ground out all body static charge to workbench, table, desk or the like before handling the microcomputer board or any components that go onto it. After unpacking the TM990/100M-1 module from its carton and examining it for any damage due to shipping, compare it to Figure 3-12 to determine the correct location of all parts. Additional detail is available in the user's guide shipped with the board. Make sure 3<1111111 that EPROM TIBUG Monitor (TM990/401-1) units are in the U42 and U44 positions on the board. Make sure that the RAM integrated circuits are in the U32, 34, 36, and 38 positions. TM99/100M 0> P1 CONNECTOR i:: i:: z in " + lTOPI 'j + 2 4 10 20 30 40 50 60 70 74 76 80 90 100 DDDDDDDDDDDDDDDDDDDDDODDDDDDDDODDDODODDDOOOODOODDO EDGE CONNECTOR BANANA PLUGS (SUGGEST COLOR CODING) THESE AS PER TABLE VOLTAGE P1 PIN* SUGGESTED PLUG COLORS +5V 3,4 RED +12V 75, 76 BLUE -12V 73, 74 GREEN GND 1, 2 BLACK *ON BOARD, ODD-NUMBERED PADS ARE DIRECTLY BENEATH EVEN-NUMBERED PADS. Figure 3-11. Power Supply Hookup for 9901 lOOM-1 Microcomputer CAUTION Before connecting the power supply to Pl, use a volt-ohmmeter to venfY that correct voltages are present as shown in Figure J-11. 9900 FAMILY SYSTEMS DESIGN 3-13 UNPACKING AND CHECKING THE A First Encounter: Getting Your Hands on a 9900 MICROCOMPUTER (TM 990/lOOM-1) a: UJ _J _J 0 a: !z: 0 t) Cf) Z N :::io c... Oi= z <( og a: z I::> t):::? ..... 3 z :::? ~8 <( UJ a: <( C'l c... c... <( a: ~ UJ a: ~ I N 0 O'l O'l (/) :::? I- 0 I- a: ' 0 0 (/) (/) a: a: UJ :::; UJ t) _J _J 0 0 a: [l_ a: 0 I- z a: t) 0 t) ~ 0 0 O'l O'l (/) :::? I- Figure 3-12. TM 9901 JOOM-1 Module as Shipped 3-14 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 CONNECTING THE MICROTERMINAL/ OPERATING THE MICROCOMPUTER Compare the board to Figure 3-12 & 3-13. Make sure that the jumpers are in the following positions: jUMPER POSITION JUMPER POSITION Jl Pl-18 J4 08,08 J2 2708 J7 EIA J3 08,08 Jl1 OPEN They assure that memory locations are identified correctly and that the microterminal interfaces correctly. CONNECTING THE MICROTERMINAL TM990/301 The microterminal (Figure 3-2) should be examined to verify there is no damage due to shipment. It will be connected to the microcomputer through P2 on Figure 3-12. Jumpers J13, J14, and J15 must be installed on the TM990/100M-1 board in order to supply power to the microterminal. Using the extra jumpers provided, short pins on the board at J13, J14, and J15 (Figure 3-13). Attach the plug on the microterminal cable to the P2 connector on the board. OPERATING THE MICROCOMPUTER Check once more that all wiring is correct for the output board (Figure 3-9), the power connector (Figure 3-11) and the jumpers, then follow these steps: Step 1 Begin with connectors to Pl or P4 disconnected Step 2 Turn on power supplies and verify that all voltages are correct at the connector for Pl. Turn off power supplies. Step 3 Connect the power supply connector to Pl. Make sure edge connector has the word "TOP" showing. Turn on ~ 12V supply first, then + 12V, then + 5V. Step 4 Verify the voltages of+ 5V, -12V, and + 12V on the board printed wiring connections near the edge of the board between P2 and P3. Adjust power supplies or verify trouble if these are not correct. Step 5 Verify the voltages of these terminals: J13 +5V Jl4 + 12V J15 -12V If these are incorrect, correct the problem. Step 6 Turn off power supplies. With the top edge of connector for P4 in correct position, connect output board to P4, turn on power supplies in same sequence as before, -12V, + 12V, +5V. The total setup should now look like Figure 3-14 and the microcomputer is now ready to perform the task; all that's required is to tell it what to do. 9900 FAMILY SYSTEMS DESIGN 3-15 CONNECTING THE MICROTERMINAL/ A First Encounter: Getting Your Hands on a 9900 OPERATING THE MICROCOMPUTER - - - - - - - - - J13 -----J14 MICROTERMINAL USE ---J15 ~3 ........ J10 ........ J9 MULTIDROP --Ja INTERFACE --J6 -Js TMS 2708/16 EPROM SELECT Figure 3-13. Jumpers used on TM 9901 JOOM-1 Board for Option Selection 3-16 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 CONNECTING THE MICROTERMINAL/ OPERATING THE MICROCOMPUTER 0 a: ~ 5 5 0 3...- Figure 3-14. Total System Connected 9900 FAMILY SYSTEMS DESIGN 3-17 TELLING THE MICROCOMPUTER A First Encounter: Getting Your Hands on a 9900 WHAT TO DO TELLING THE MICROCOMPUTER WHAT TO DO The microcomputer is told what to do through the microterminal keyboard. This is shown in Figure 3-15. Initial conditions are necessary so Step 7 starts everything at an initial point. Step 7 Figure 3-1 and Figure 3-12 identify the RESET switch. Switch it all the way to the right (facing the toggle). Now depress the CLR (clear) key on the microterminal. Nothing will be on the display but to verify that it is working, press several of the number keys. The numbers pressed will appear in the display. Now press the CLR key again on the micro terminal. As we depress selected keys on the microterminal, the microcomputer is being given instructions - a step by step sequence of things to do to perform the first encounter task. The microcomputer is being programmed to do a job. In order for the microcomputer to do its task according to the instructions given, it must also do many things dictated by other instructions that are stored in sequence in the TIBUG Monitor read-only memory (ROM). The program that performs the first encounter task is stored in the random access memory of the microcomputer and used in sequence. As a result, as the microcomputer accomplishes the task for which it is programmed, it performs each of the steps dictated by the "main program" in the RAM and by TIBUG in ROM. There are only a few keys used on the microterminal for the first encounter. Identify these on Figure 3-15 and on the microterminal. Three of these are: ™. (enter memory address) is used to display a specific memory address and give the user the ability to change the contents of that location. ~ (enter memory data) changes the contents of the memory location and ~(enter memory data and increment) changes the contents of the memory location and advances the address by two. Note that Figure 3-15 identifies the information given by the display. There are two banks of 4 digits each that are displayed. The left 4 digits display the address register (memory address) and the right 4 digits display the data in the data register (data to be stored in memory, being read from memory, or being operated on by the microcomputer). It is of no concern at the moment but both of these 4 digit registers are identifymg the value of their data in hexadecimal code. Suffice it to say at this time that each hexadecimal digit represents 4 bits of data for a number that has a value represented by 16 bits. Each hexadecimal digit can have at any one time an alphanumeric value of any one of the following: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. The decimal value of these numbers are shown in Figure 3-16 as they occur in the place value position of the 4 bit display. Hexadecimal numbers will be identified with a subscript of 16 in the text, e.g., 02E016 or 010016 whenever there is need to avoid confusion. 3-18 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 TELLING THE MICROCOMPUTER WHAT TO DO ADDRESS DATA ~~, TEXAS INSTRUMENTS Microterminal TM 990/301 H/S D•H H•D RUN DDDDD EWP EPC EST ECRU DDDDD DWP DPC DST DCRU 3... DDDDD EMA EMO EMDI CLR DDDDD 0 1 2 3 The display of the microterminal is divided into two 4 hexadecimal DDDDD 4 5 6 7 digit banks. The left bank dis- plays address register informa- DDDDD 8 9 A B tion and the right bank displays data registers. DDDDD C D E F/- D DD DD Figure 3-15. Microterminal Keyboard and Display Every program starts at a particular place in the RAM memory. The first encounter program will start at memory location identified by the hexadecimal address FEOO. This is a 16 bit address which in machine code looks like this: 1111 1110 0000 0000 (F = 15; E = 14; 0 = O; 0 = 0) and from Figure 3-16 has a decimal value of 61,440 + 3584 + 0 + 0 = 65,024. The program starts at memory location 65,024. To start the sequence of instruction steps for out first encounter, the starting address is entered and the ~ (enter memory address) key is depressed on the microterminal. This is program Step 2 in Step 8. To help verify the steps the display data is also recorded. Step 8 Display KEYSTROKES ADDRESS DATA 0.M i. mm mm FEOO 2. ~ FEOO XXXX (X = Don't care) 3. mm m rn FEOO 02EO 9900 FAMILY SYSTEMS DESIGN 3-19 TELLING THE MICROCOMPUTER A First Encounter: Getting Your Hands on a 9900 WHAT TO DO This keystroke at Step 3 is a hexadecimal code - an instruction - that is telling the microcomputer to load a register with data. The data, however, is at the next address location. Therefore, with the next keystroke ~ (enter memory data and increment), the instruction 02EO is stored at address location FEOO and the next memory address for an instruction is brought into the display by incrementing (advancing) the FEOO address by 2 (the reason for advancing by 2 will become clear as more is learned about the 9900 microprocessor). Step 9 KEYSTROKE An DRESS DATA ~3 4.~ FE02 xxxx MSB LSB 163 2 1 16 16 16° BITS 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEX DEC HEX DEC HEX DEC HEX DEC 0 0 0 0 0 0 0 0 1 4 096 1 256 1 16 1 1 2 8 192 2 512 2 32 2 2 3 12 288 3 768 3 48 3 3 4 16 384 4 1 024 4 64 4 4 5 20 480 5 1 280 5 80 5 5 6 24 576 6 1 536 6 96 6 6 7 28 672 7 1 792 7 112 7 7 8 32 768 8 2 048 8 128 8 8 9 36 864 9 2 304 9 144 9 9 A 40 960 A 2 560 A 160 A 10 B 45 056 B 2 816 B 176 B 11 c 49 152 c 3 072 c 192 c 12 D 53 248 D 3 328 D 208 D 13 E 57 344 E 3 584 E 224 E 14 F 61 440 F 3 840 F 240 F 15 To convert a number from hexadecimal, add the decimal equivalents for each hexadecimal digit. For example, 7A82 16 would equal in decimal 28,672 + 2,560 + 128 + 2. To convert decimal to hexadecimal find the nearest number in the above table less than or equal to the number being converted. Set down the hexadecimal equivalent then subtract its decimal number from the original decimal number. Using the remainder(s), repeat this process. For example: 31,36210 = 700016 + 269010 7000 2,69010 =A0016 + 13010 AOO 13010 = 8016 + 210 80 210= 216 2 7A8216 Figure 3-16. Place Value of Hexadecimal Digits in Significant Bit Positions 3-20 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 TELLING THE MICROCOMPUTER WHAT TO DO Program Step 4 of operating Step 9 shows this. Memory location identified by address FE02 is now ready for the data that will be put into the register identified by the instruction 02EO at location FEOO. The data is FF20. 5. m m mw FE02 FF20 6.~ FE04 xxxx Program Step 6 has now advanced to the next memory location which is awaiting the next instruction which is keystroked in by program Step 7. 1. w mw m FE04 0201 Step JO 3...- Continue now to program steps through the end of the program. Note how the address memory location advances by 2 each time ~ is pressed. This is how the program will be followed when it is run. The starting address FEOO will be loaded into the program counter. The program counter will then count by 2 and advance the microcomputer through each program step as the instructions are completed. KEYSTROKE ADDRESS DATA 8. ~ FE06 xxxx 9.mmmm FE06 FE2E 10. ~ FE08 xxxx 11. w m w m FE08 020C 12. ~ FEOA xxxx u. w m m w FEOA 0120 14. ~ FEOC xxxx 15. m m w w FEOC *ldOO 16. ~ FEOE xxxx 11. w mm m FEOE 0691 18. ~ FElO xxxx 19. m m w w FElO lEOO 20. ~ FE12 xxxx 2i. w m m m FE12 0691 22. ~ FE14 xxxx 23. m m w m FE14 *ldOl 24. ~ FE16 xxxx 25. w m m m FE16 0691 26. ~ FE18 xxxx 21. m m w m FE18 lEOl 28. ~ FElA xxxx 29. w m m m FElA 0691 30. ~ FElC xxxx 31. m m w m FElC *ld02 *As displayed on 301 Terminal 9900 FAMILY SYSTEMS DESIGN 3-21 TELLING THE MICROCOMPUTER A First Encounter: Getting Your Hands on a 9900 WHAT TO DO KEYSTROKE An DRESS DATA 32. ~ FElE xxxx 33. w w rn DJ FElE 0691 34. ~ FE20 xxxx 35. DJ rn w rn FE20 1E02 36. ~ FE22 xxxx 37. w w rn DJ FE22 0691 38. ~ FE24 xxxx 39. DJ rn w rn FE24 *ld03 40.~ FE26 xxxx .... 3 4 L w w rn DJ FE26 0691 42. ~ FE28 xxxx 43. DJ rn w rn FE28 1E03 44.~ FE2A xxxx 45. w w rn DJ FE2A 0691 46. ~ FE2C xxxx 47. DJ [[] ITJ ITJ FE2C lOEF 48. ~ FE2E xxxx 49. DJ rn w rn FE2E 1F04 50.~ FE30 xxxx 51. DJ rn w rn FE30 1305 52. ~ FE32 xxxx 53. w rn w rn FE32 0203 54.~ FE34 xxxx 55. ITJ ITJ ITJ ITJ . FE34 FFFF 56.~ FE36 xxxx 57. w w w rn FE36 0603 58.~ FE38 xxxx 59. DJ []] ITJ ITJ FE38 16FE 60.~ FE3A xxxx 6L w rn rn m FE3A *045b 62.~ FE3C xxxx 63. w rn w rn FE3C 0203 64.~ FE3E xxxx 65. rn rn rn rn FE3E 3FFF 66.~ FE40 xxxx 67. w w w rn FE40 0603 68.~ FE42 xxxx 69. DJ []] ITJ ITJ FE42 16FE 70.~ FE44 xxxx 7L w rn rn m FE44 *045b 72.~ FE46 xxxx 3-22 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 TELLING THE MICROCOMPUTER WHAT TO DO Step 11 All the program steps are now entered. It remains to run the program, that is, send the microcomputer through its sequenced steps to determine if it will accomplish the task. Recall, that the system must be set to the initial conditions and to the starting point. This means that the system must start at memory address FEOO because that is where the first instruction is located. Inside the microcomputer there is a register (a temporary storage location for 16 bits) that always contains the address of an instruction. It was previously noted that as the memory location of instructions was incremented by 2 as the program was entered, so also will the program counter be incremented by 2 by the microcomputer to go to the 3...- next instruction. Therefore, the initial conditions are accomplished by loading the program counter with the address location FEOO. This is accomplished by an ~ key on the microterminal. The ~ (enter program counter) key changes the value of the program counter. It will enter into the program counter the value that is in the data register of the microterminal display. The ~ (display program counter) key on the microterminal is depressed to determine if the correct value has been entered into the program counter because it displays the current value of the program counter. The @IBJ key is depressed to begin execution of the program starting with the address in the program counter. To run the program, go through Steps 1 thru 5. KEYSTROKE AnDRESS DATA 1. [fill] 2. mm rn rn FEOO 3.~ FEOO 4.~ FEOO 5. [@HJ run VO ILA! The first encounter task is being accomplished. Switching the toggle switch will change the rate of the segment display. Under program control output logic levels on a set of output lines have been set to a "1", held for a time, set to a "O", held for a time, etc. in a particular sequence. The delay between "ls" and "Os" also is under program control. Such output levels then have been interfaced to driver circuits to accomplish a given task - in this case lighting LED segments of a display. 9900 FAMILY SYSTEMS DESIGN 3-23 HOW WAS IT DONE? A First Encounter: Getting Your Hands on a 9900 Step 12 To stop the program, depress ill@ . The RESET switch on the microcomputer could also be pressed. (However, in doing so, to return to the program, go through the initial five steps of running the program at the end of operating Step 10.) The program may be started again by depressing ~ after it was halted by M Step 13 If for some reason the first encounter task is not being accomplished after completing Step JO, the program can be checked by entering FEOO, the beginning address and depress ~ . The contents of memory and the instruction at FEOO will be displayed. ~3 Each memory location can then be examined by depressing ~ and reading the display. In this manner, the program can be examined for an error. When the error is located, the correct data can be entered as it was in the original program and I@ is pressed. The program can then be run by returning to the initial sequence of operating Step 11. The program may be entered at any valid address by entering the address and pressing ~ and then proceeding step by step with ~. There is no need to go back to the beginning address each time. HOW WAS IT DONE? The question naturally arises - how was this task accomplished by the microcomputer, and more importantly, how was the task taken from idea to the actual program? How does one know what to tell the microcomputer to do? Of course, this will take a great deal of study of this book and much operation of systems, starting with the TM990/100M-1 microcomputer. The way the idea is turned into a program for the first encounter is covered in the remaining part of this chapter. This is a good foundation for building knowledge of the 9900 microprocessor, applying the 990/ lOOM microcomputer to many other tasks, and understanding the use of the 9900 in solving other types of problems. 3-24 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 BACK TO BASICS BACK TO BASICS The process of understanding how the task was taken from idea to instructions for the microcomputer begins by returning to some basic concepts to assure that these are understood. Recall that Figure 3-4 identified the functional blocks of our microcomputer. The central processing unit includes the 9900 microprocessor. Examining Figure 3-5 further and the functional block diagram of Figure 3-17 shows that the 990/lOOM microcomputer is bus oriented. Recall that a bus is one or more conductors running in parallel which are used for sending information. The 9900 microprocessor sends an address to memory, to identify data required, on the 15-bit address bus. It receives data from memory on a 3<11( 16-bit data bus. It should be noted that the same 15-bit address bus goes to the input/output interface units. The address bus is used either to send an address to memory or an address to input I output, not both at the same time. When the signal MEMEN is a logic low, the address bus is for memory. If the address bus is not for memory then it can be used by I/O. When the address is for I/O, the selection of which lines will be inputs or outputs is under control of the 9900. ADDRESS BUS 15 BITS (CRU) CRUIN CRUOUT CRUCLK IAO -{>---- BUFFER 3 Figure 3-17. Functional Diagram of TM 990 I 1OOM-1 Microcomputer 9900 FAMILY SYSTEMS DESIGN 3-25 BACK TO BASICS A First Encounter: Getting Your Hands on a 9900 Therefore, lines to accept data as input, or to deliver output data are selected by address bits in the same fashion that address bits locate data in a memory. Examination of the architecture of the 9900 microcomputer in Figure 3-18 reveals, as in Figure 3-17, the address bus, the data bus, signals for the CRU (the Communications Register Unit is an I/O interface for the 9900 architecture), signals for interrupt, control signals and master timing signals. Each of these are external signals. Further examination of internal parts is required to expand on more basic concepts, with emphasis on the ones that are used for the first encounter task. REGISTERS Recall that a register is a temporary storage unit for digital information. Inside the 9900 there are these types of registers: a memory address register, a source data register (data register), an instruction register, an interrupt register, some auxiliary registers like T 1 and T2, and the registers that will be most applicable to the first encounter - the program counter, the workspace register, the status register and a shift register used as part of the hardware to select the input and output terminals. Additional parts include: 1) the ALU - it is the arithmetic and logic unit that performs arithmetic functions, logic and comparisons. 2) Multiplexers that direct the data over the correct path as a result of signals from the control ROM and control circuitry. 3) Timing circuits so that all operations are synchronized by the master timing. Every time a piece of information is required to be stored in memory or retrieved (fetched) from memory, the memory must be told where the data is located or to be located. The memory address register holds the address to be put on the address bus for this purpose. Data fetched from memory is received either by the source data register and distributed by the 9900 microprocessor as required, or by the instruction register when it is an instruction. The instruction is decoded and transmitted to the control ROM which sequences through microinstructions previously programmed into the control ROM to execute the instruction. The instruction might be "Increment register 1 by two". Instruction steps take the data from register 1 to the ALU which adds "2" and returns the data to register 1. 3-26 9900 FAMILY SYSTEMS DESIGN A First Encounter: BACK TO BASICS Getting Your Hands on a 9900 INTERRUPT CODE ADDRESS BUS INTREO ICO-ICJ AO-A14 15 MEMORY ADDRESS REGISTER Tl 16 T2 PROGRAM COUNTER WORKSPACE REGISTER CONTROL HOLD A HOLDA LOAD ALU wr READY CONTROL WAIT LOGIC ~ OBIN RESET IAG CRUCLK 'cRu cpl-4>4 MASTER TIMING CRUOUT D0-015 CRUIN CRU DATA BUS Figure 3-18. Architecture of 9900 Microprocessor 9900 FAMILY SYSTEMS DESIGN 3-27 BACK TO BASICS A First Encounter: Getting Your Hands on a 9900 Two registers of significant concern for the first encounter task are the status register and the workspace register. The status register is just what the name implies. The 9900 microprocessor continually checks on how things are going (the status) by following instructions that command it to check various bits of the status register. Figure 3-19 shows the bits of the status register. 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 STO ST1 ST2 ST3 ST4 STS ST6 not used (=0) ST12 ST13 ST14 ST15 L> A> c 0 p x Interrupt Mask Figure 3-19. Status Register ... 3 Each bit of the first 7 bits is concerned with identifying that a particular operation or event has or has not occurred as shown here. BIT PURPOSE BIT PURPOSE 0 Logical Greater Than 4 Overflow 1 Arithmetic Greater Than 5 Parity 2 Equal 6 XOP 3 Carry 12-15 Interrupt Mask The last 4 bits are concerned with the interrupt signals and a priority code associated with the interrupts. The first encounter uses bit 2, the "equals" status bit to change the time delay in the LED sequence. WORKSPACE The workspace register is the same as the other registers, but it is used in a special way. As the 9900 microprocessor and the microcomputer step through program instructions, there is a need to have more registers than those available on the 9900. Instead of providing these registers in the 9900, a file of registers is set up in memory and a reference to this file saved in the workspace register. One of the rules in setting up this file is that it will always contain 16 registers in 16 contiguous (one following another in sequence) memory words. The workspace register on the 9900 is called the workspace pointer because, as shown in Figure 3-20, it contains the address of the first memory word in the contiguous register file, referred to for the application of the 9900 and in this book as "workspace registers" or just "workspace". The i;egister file can be located anywhere within RAM that seems appropriate. In the total available memory space, there are certain reserved spaces for RAM, others for ROM, and others for special instructions. Therefore, the register file can only be set up in certain portions of memory. So, where 020016 to 021E16 are the 16 locations shown in Ft'gurr; 3-20a, with the workspace pointer being 020016 , the file could have started at 0300 16 and extended to 03 lE16 as long as these are allowable locations in the overall memory matrix. The workspace pointer would contain 0300 16 in the second case. 3-28 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 BACK TO BASICS 9900 MEMORY ---- ---- MEMORY ADDRESS (HEXADECIMAL) WORKSPACE POINTER -- -------- 01FC 1--------- --- o 2 o 01b I 01FE FILE REGISTER 0 0200 (WORKSPACE REGISTER) II 0202 II 0204 II 3 0206 II 4 0208 3~ 020A 6 020C II 7 020E FILE OF REGISTERS CALLED 8 0210 WORKSPACE 0212 10 0214 11 0216 12 0218 13 021A II 14 021C 15 021E 0220 --------- ~----------~ -- 0222 0224 Figure 3-20a. Workspace Registers WORKSPACE POINTER 0 FILE REGISTER 0 020016 INSTRUCTION REGISTER (SAYS I NEED DATA FROM REGISTER 7) L. 2x7 FILE REGISTER ADDRESS BUS Figure 3-20b. Locating Specific Register 9900 FAMILY SYSTEMS DESIGN 3-29 SBZANDSBO A First Encounter: Getting Your Hands on a 9900 INSTRUCTIONS To locate a specific register in the workspace file, the 9900 microprocessor adds the register number to the workspace pointer address to obtain the address of the specific register in the file that is required. (It actually adds 2R, where R is the register number, so that the addresses advance by even numbers_. The odd number addresses are used when the word contents are to be processed in 8-bit bytes.) For example, if register 7 contains the information required by the 9900 microprocessor, then the address 020E in Figure 3-20a is obtained by adding 14 to the workspace pointer at 020016 • This is shown in Figure 3-20b. In like fashion, if the workspace pointer contained 0300 16 , then adding 14 to 030016 gives 030E16 the address ofregister 7, the 7th register down in the file. Recall that to accomplish the first encounter task, logic levels on output lines had to be set to a "1" or a '.'O" in order for the LED drivers to turn on or turn-off the LED segment respectively. Recall, also, that the particular output lines could be selected. To understand how this is done, refer to Figure 3-21. This figure is divided into three bounded regions; the TMS 9900, Memory, and the TMS 9901. The output line from the 9900 microprocessor that will do the setting is the line "CRUOUT." It is coupled to the TMS 9901, the programmable systems interface. The TMS 9901 contains more functional parts to handle the interrupt code and interrupt input signals but for now the part that is important is that shown in Figure 3-21. The portion shown is a demultiplexer. The data appearing at CRUOUT is strobed by CRUCLK into latches feeding the output pins. The particular latch and the particular output line is selected by the code that exists on the select bit lines S0 , S1 , S2 , S3 , and S4 , which, as shown in Fi/ure 3-21, are the address lines A10 through A14 • The code on S0 through S4 , and the CRU logic selects the output latch and line that is to be set. The "1" or "O" on CRUOUT does the setting. The latching occurs when CRUCLK strobes the data in. SBZ AND SBO INSTRUCTIONS Enough basics have now been covered to begin understanding several of the important instructions for the first encounter task. Figure '3-21 will again be used and will be followed from left to right and top to bottom starting with the upper left corner. At a particular step in the program, controlled by the program counter, the instruction address (the bit contents of the program counter) is sent to memory over the address bus to obtain the instruction. Memory is read and the instruction is received by the 9900 on the data bus and placed in the instruction register. Via the control ROM and the control logic, the instruction is interpreted as an SBO instruction - "set CRU bit to one." The 9900 is designed so that it generates the correct S0 -S 4 address for the TMS9901 that selects the output line to be set to a "1" by the instruction. However, as indicated in Figure 3-21, first an ALU operation must occur before the correct address is obtained. The ALU adds the contents of one of the registers in the file, workspace register 12 (WR12), to a portion of the instruction, SBO. This portion of the SBO instruction is identified as DISP 3-30 9900 FAMILY SYSTEMS DESIGN A First Encounter: SBZANDSBO Getting Your Hands on a 9900 INSTRUCTIONS (meaning displacement) in Figure 3-21. It identifies the specific line to be used in the 9901 for the output. Eight bits are used for the signed displacement (7 and a sign). Bits 3 through 14 are used from the workspace register 12. After the ALU operation, the address is sent out on the address bus. Because the MEMEN line is not active, this tells the 9901 that the address is for I/O. All 15 address bits are there; however, only A3 through Ai 4 are used for the effective CRU address. Aio through Ai4 provide S0 through S4 for the 9901, while bits Ao through A9 are used for decoding additional l/O as shown in Figure 3-17. Ao, Ai, and A2 are set to zero for all CRU data transfer operations. I TMS 9900 I MEMORY TMS 9901 3-c I P.C. ADDRESS BUS INSTRUCTION I DATA BUS I l.R. OP DISP I I CONTROL ROM I I ADDRESS WORKSPACE REGISTER I CONTROL BUS I 3 14 WR12 CRU I LOGIC ~ LOGIC 0 T H E R DATA BUS 1/0 SET TO "I" FOR SBO TO "O" FORSBZ ADDRESS BUS A"-A" EFFECTIVE CRU BIT ADDRESS (ONLY BITS 3-14 FROM WR12 USED) CRUOUT CRUCLK Figure 3-21. CR U Concept - Single Bit Output SBO or SBZ on CR UOUT. 9900 FAMILY SYSTEMS DESIGN 3-31 SBZANDSBO A First Encounter: Getting Your Hands on a 9900 INSTRUCTIONS I/O SELECTION The codes required on S0 through S4 that select a specific output or input in the 9901 are shown in Figure 3-22. To make it convenient, the P0 line will be used for bit zero of the output or input,.P 1 for bit one, P 2 for bit 2, P 3 for bit 3 and P 4 for bit 4. Therefore, to select the line for P 0 , the code on S0 through S4 must be 1 0000. Rather than starting at select bit 0, the output sequence is started at select bit 16. Adding 32 10 (base ten) to the contents of the file register 12 accomplishes this. This is 1016 in Hex code times two, to shift it into bits 3 through 14. What do the contents of register 12 indicate? They identify the particular 9901 used. Referring back to Figure 3-17, it is noted that several I/O units are connected to the .. 3 address bus of the microcomputer TM990/ lOOM-1. In order for the decoder to activate the correct CE signal to enable the right I/O, a base address is assigned to each I/O unit. The software base address for the 9901 on the microcomputer is 010016 • The hardware base address is 0080 16 • Figure 3-23 summarizes the ALU operation. Workspace register 12 contains the software base address of the 9901 on board the microcomputer. The signed displacement of+ 1016 is located in the instruction register as part of the SBO instruction. These two pieces are added together by the ALU and the result placed in the address register. Note that the ALU uses only the bits from 3 to 14 of the software base address to get the hardware base address, adds the displacement, and that the effective CRU address is bits 0 through 14. Bit 15 becomes a "don't care" bit. SELECT BIT INPUTS OUTPUTS 9 0 0 0 0 15 0 1 16 0 0 0 0 PolN PoOUT 17 0 0 0 P1IN P10UT 18 0 0 0 P2IN P20UT 19 0 0 1 P3IN P30UT 20 0 0 0 P4IN P40UT 21 0 0 1 PslN PsOUT 22 0 0 P61N P60UT 23 0 1 P1IN P10UT 24 0 0 0 Pa IN Pa OUT 25 0 0 P9IN P90UT 26 0 0 P10IN P1 00UT 27 0 1 1 P11IN P11 0UT 28 0 0 P12IN P120UT 29 0 1 P13IN P130UT 30 0 P1 4 1N P140UT 31 1 P1slN P1sOUT Figure 3-22. 110 Selection in TMS 9901 3-32 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 SBZAND SBO INSTRUCTIONS MSB LSB ADDRESS BITNO. 0 3 I4 6 1 Is 9 10 11 I 12 13 14 15 WR12 Io Io I o Io I o I o I o I Io I o I o I o I o I o I o Io I 0100 .. (SOFTWARE BASE ADDRESS) I- - - - - - - A, THRU A,. - - - - - - - I PORTION USED BY ALU I I I I I I I I I I I I I ~~!~;WARE 0 0 0 0 1 0 0 0 0 . 0 0 0 BASE ADDRESS) SIGNED I8 9 10 11 I12 13 14 15 g~~~g~MENT C~I~ro-r; I I I I I I I I I 0 0 0 1 0 0 0 0 3<11111 ADDED WHAT'S IN SIGN BIT POSITION 8 IS EXTENDED THRU MSB o I3 I1 a I 11 2 4 5 -6 9 10 12 13 14 15 -1 0090 16 (CRU BIT ADDRESS) ADDRESS REGISTER I I I I I I I I I I I I I I I I . 0 . 0 . 0 0 0 0o_:J 0 1 0 0 1 O O O (BITSOTHRU14) SET TO "O" FOR ALL EFFECTIVE CRU ADDRESS NEW SOFTWARE ~~~~~12:N~I- _ _ _ _ _ _ _ _ _ _ _ _ _ _____ 1 BASE ADDRESS 1 1 WR 12 I 0 I 1 I 2 I 0 I 0120,. L---- - - - ' - - - - - - - ' - - - - - - - . L - - - - _ _ ...J (BITS 0 THRU 15) Figure 3-23. Generating the Output Line Address for the 9901 Recall that the software base address assigned to the 9901 is 010016 but this is to be changed by the added displacement of 1016 . If all of WR 12 were used, the sum would be 011016. Because the signed displacement addition occurs with bit 15 neglected, the effective CRU address sent to the 9901 for bits A0 through A14 is 009016 , the hardware base address of 008016 plus the 1016 displacement. Had bit 15 not been neglected, the sum would appear as shifted over one bit position or 0120 16 . Additional displacement will have to be added to the 1016 displacement to obtain the correct code for P 1 , P 2 and P 3 shown in Figure 3-22. To be able to add a displacement of "O" for the zero bit, 1 for the one bit, i for the two bit, 120 16 is used as the software base address in workspace register 12 right from the start. From the past discussion, it should be quite clear now that one of the 32 outputs or inputs can be selected by including this information with the SBO instruction, and that a particular 9901 (if there were more than one) is selected by programming the correct base address into the workspace register 12. Referring back to Figure 3-21, a SBZ - "Set CRU bit to Zero" - instruction is the same as the SBO instruction except that the output latch is now set to a "O" rather than a "l". Note in particular in both of these instructions that only one bit is set at a time. An instruction must be included for each bit to be set when using SBO and SBZ. 9900 FAMILY SYSTEMS DESIGN 3-33 TB INSTRUCTION A First Encounter: Getting Your Hands on a 9900 TB INSTRUCTION Besides setting logic levels on output pins, an additional system requirement for the first encounter task is to receive an input on an input line. One way of accomplishing this is to have the 9900 microprocessor look at a selected input line, bring the information present at a specified time into the 9900 and then examine the information, or test it, to determine if the information was a "1" or a "O". The TB instruction, "Test CRU Bit", accomplishes bringing the information into the 9900. Subsequent instructions are added to determine if the information was a " 1" or a "O" . .... 3 TMS9900 MEMORY TMS9901 ADDRESS P.C. INST. ADDR. INSTRUCTION BUS I DATA BUS l.R. DISP CONTROL ROM ADDRESS BUS WORKSPACE REGISTER I I WR12 ,--, I CONTROL LOGIC 3 14 I CRU LOGIC I 0 I T I I ~ H I I E I I R I DATA BUS I 1 110 I I I I : I ADDRESS BUS A,,-A,. I I SO-S4 LOAD BIT 2 WITH EFFECTIVE CRU BIT ADDRESS I I VALUE OF INPUT (ONLY BITS 3-14 FROM WR12 USED) BIT BIT 0 1 2 3". CRUIN IIIII STATUS REGISTER CE RSTl -;p Figure 3-24. CR U Concept-Single Bit TB Input on CR UIN 3-34 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 IDEA TO FLOWCHART The selection of the particular line in the 1/0 unit is the first concern. Figure 3-24 shows that this is done in the same way as just explained for the SBO and SBZ instructions. The same portions of the 9901 are used as for the SBO or SBZ instructions except now these portions are a data selector. Data is selected from one of multiple input lines and sent to the 9900 microprocessor along the CRUIN line. The value of the information on the line is placed in bit 2 position of the status register. As discussed previously for the status register, instructions must follow the TB instruction that will examine bit 2 of the status register to determine what to do if this bit is a '' 1" and what to do if it is a "O". Conditional jump instructions are used to make the decision based on the value of the data. Note again that this is done one bit at a time. Accomplishing a TB instruction requires that a base address be given for the particular 3 <111111 input or output line desired. This hardware base address adjusted to a software base address is placed in workspace register 12. With the TB instruction, a displacement is given that identifies the particular line which needs to be sampled. This again is the same as for SBO. The line selected provides data straight through to the CRUIN line - there are no latches, as with the output data. Thus, the basic concepts studied have shown the means of getting data to the output and bringing data in from an input - one bit at a time. They have shown how data is located, read, transferred, stored, and operated on arithmetically. With this, it should be possible now to get the first encounter idea into a sequence of steps - a programfor the microcomputer to follow. IDEA TO FLOWCHART Bringing the idea from concept to program begins with a concept level diagram as shown in Figure 3-25. It has been decided that the microcomputer is to do the first encounter task; turn on and off 4 lights in sequence, with a time delay between each light activation. LOGICAL 1 A IS TIME DELAY CONTROLLED BY S1 S1 ~ ..l.. LOGICAL 0 -;r MICROCOMPUTER LIGHTS 1/0 PO 1/.0 P1 1/0 P2 1/0 P3 TIME___. Figure 3-25. Concept Level Diagram 9900 FAMILY SYSTEMS DESIGN 3-35 FLOWCHARTS A First Encounter: Getting Your Hands on a 9900 The time delay is to be under control of an external switch. Understanding the basic concepts of the microcomputer led to the discussion that output lines could be selected and set to standard TIL logic levels to control drivers that would light the lights. In like fashion, a standard TIL logic level signal could be brought to the microcomputer as an input and examined. With this information, a decision could be made to vary the time delay. If the input is a "1," the lights would go on and off at a fast sequence. If the input is a "O," the sequence rate would be slow. Obviously, other mechanical decisions also were made, such as: 1) The lights would be segments of a 7 segment light emitting diode numerical display ... 3 because of the compatible packaging and ease of availability. 2) The microcomputer output pins, I/O identification and light number to 7 segment display segment were set as follows: 9901 990/JOOM 110 Light No. Display Segment Note P4 Connector 20 Po 1 f 22 P1 2 b 14 P2 3 e 16 p3 4 c 18 p4 (These pin identifications are obtained from the schematics in the TM990/ lOOM User's Guide and data sheet information on the TIL303.) The microterminal TM990/301 was selected as the unit to use for communication with the microcomputer because of its low cost and ease of use. Terminals such as a TTY and a 743 KSR can be used and an application shown in Chapter 9 takes up this type interface. FLOWCHARTS The problem solution proceeds from concept to program by constructing a well defined flowchart to follow in an organized fashion while generating the sequence of steps required for the microcomputer to complete the task. Figure 3-26 is such a flowchart of the first encounter task. 3-36 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 FLOWCHARTS y INITIATE t WAIT L_ _r TURN ON TURN ON LAMP #1 LAMP #3 l WAIT WAIT I TURN OFF TURN OFF LAMP #1 LAMP #3 1 WAIT WAIT WAIT • l TURN ON TURN ON LAMP #2 LAMP #4 l WAIT WAIT l TURN OFF TURN OFF LAMP #2 LAMP #4 l Figure 3-26. Flowchart 9900 FAMILY SYSTEMS DESIGN 3-37 FLOWCHARTS A First Encounter: Getting Your Hands on a 9900 From START, which requires initial conditions, and a signal to begin - INITIATE - the task is diagrammed. Each light is turned on, the time delay occurs, the light is turned off, the time delay occurs, the next light is turned on, etc. The sequence continues until all lights have been turned on and off and the program begins again. wAIT SUBROUTINE Note the time delay is identified as WAIT and it occurs over and over again in the sequence. Because of this, separate steps will be written for this sequence only one time rather than repeating it over and over in the program. In this manner, the main sequence of steps, the main program, can be directed to this identified set of steps, called a subroutine, by an instruction. The main program is then said to branch to the subroutine ~3 until it completes the steps in the subroutine, then it returns to the main program. In simpler terms, the WAIT block of the flowchart requires a given number of program steps, say X. WAIT occurs 8 times in the flowchart. Instead of rewriting the X steps 8 times in the program, the X steps are written once, given the name WAIT, and referred to 8 times. Because WAIT is a subroutine, a separate flowchart (Figure 3-27) is generated for it. In addition, the time delay is to be varied by the switch S1 , therefore, different steps are followed if the switch is "on" with a value of a logical "1" or "off" with a value of a logical "O". Note that when the subroutine WAIT is encountered, the first thing that occurs is to find out the position of the switch. Is it a logical "1" or a logical "O?" A decision is made on the basis of what is found. "Yes, the switch is on," (logical "1") makes the time delay short and the sequence fast. "No, the switch is off," (logical "O") makes the time delay long and the sequence slow: There are a number of ways to provide a time delay. This flowchart uses one of the simplest - load a register with a number, keep subtracting one (decrementing) from the number until the number is zero. The number of cycles it takes to get the number to zero times the time for each cycle is the time delay. Larger numbers, longer counts, provide longer delays. Each arm of the flowchart contains the same type of sequence, loading the number; decrementing; checking for zero; if not zero, jumping back and decrementing again; if zero, returning to the main program. Note that in the flowchart there is a branch decision and a branch decision with a jump back or a loop. The program runs in this loop until it comes to a condition where it can get out of the loop or "exit from the loop." 3-38 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 FLOWCHARTS SUBROUTINE ]UMP Special things happen when a subroutine such as WAIT is encountered in the main program. Figure 3-28 diagrams the steps. The main program has executed from Step 1 to Step 5. At Step 6, the computer encounters the instruction telling it to branch to subroutine A and do subroutine A. Therefore, in order to return to the correct location in the main program after executing the subroutine, the branch instruction at Step 6 also· tells the computer to remember the address of Step 7. 3...ill TIME YES NO "1" "O" LOAD LOAD DEC REMENTER DECREMENTER WITH WITH 3FFF,. FFFF,. TIME2 TIME 1 DECREMENT DECREMENT NO NO Figure 3-27. WAIT Subroutine 9900 FAMILY SYSTEMS DESIGN 3-39 FLOWCHARTS A First Encounter: Getting Your Hands on a 9900 The subroutine is executed through Step A-8. Whereupon the computer encounters an instruction at Step A-9 that tells it to return to the Step 7 address which it remembered at Step 6. In this fashion, each subroutine can be executed and program control returned to the main program. Of course, there are branches that can occur from a subroutine to another subroutine but the principle is the same. MAIN PROGRAM SUBROUTINE A STEP 1 STEP A-1 ~3 3 A-2 A-3 4 A-4 BRANCH TO A-5 6 SUBROUTINE A A-6 A-7 8 A-8 9 GO BACK 10 TO MAIN A-9 PROGRAM 11 Figure 3-28. Branch to Subroutine The instruction from the TM990/ IOOM microcomputer instruction set that accomplishes the branch to a subroutine is called Branch and Link. This is called a "subroutine jump" instruction and will be identified by the letters BL and some additional information that tells the location of the address of the first instruction of the subroutine. In addition, recall that a register file is to be set up for general registers. Well, register 11 of this file (WR 11) is the storage place used to remember the main program· address that is returned to after executing the subroutine. The return instruction from the subroutine used is called an unconditional branch instruction. It is identified by Branch. Since the contents of register 11 must be returned to the program counter to return from a subroutine, this instruction will be identified as B* 11. Note that the file register 11 must be reserved for this use by the programmer, otherwise its contents are likely to be changed at the wrong time and the computer misled into a wrong sequence. 3-40 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 FLOWCHARTS A Loop WITHIN THE WAIT SUBROUTINE Within the WAIT subroutine is another common reoccurring concept - a loop. However, before examining this program sequence further, it would be beneficial to clearly understand the meaning of the blocks in the flow charts. The general meaning of the most commonly used blocks is shown in Figure 3-29. There is a symbol for the entry to or exit from a program (or for an off-page connection). This is identified with an appropriate symbol or label - START and STOP in this example. Rectangles identify operations. Inside the rectangle is an appropriate abbreviated statement to describe the operation. Decisions are identified with a diamond. Since programmed logic occurs in sequence, these blocks are relatively simple. A two-state decision answers a question of yes or no, true or false, etc. A three-state decision answers a comparison question of 3 ..... greater than, equal to, or less than (of course, there could be further mixtures of these). So decision blocks have appropriate questions identifying them. In the WAIT subroutine of Figure 3-27, the first decision is "Is the switch ON?," and the consequences have already been discussed. The second decision has the question "The quantity examined - is it equal to zero?" Within this program sequence, if the quantity is not equal to zero, then the program goes through the same path again. ENTRY (OFF PAGE CONNECTION) ABBREVIATED ABBREVIATED STATEMENT STATEMENT OPERATION DECISION YES SUBPROGRAM LABEL EXIT (OFF PAGE CONNECTION) Figure 3-29. Common Flow Chart Blocks 9900 FAMILY SYSTEMS DESIGN 3-41 LOADING A REGISTER A First Encounter: Getting Your Hands on a 9900 FOR THE TIME DELAY The program loop is accomplished by a branch instruction from the instruction set called a conditional jump instruction. The conditional jump causes the microcomputer program to branch to a specified program step depending on the condition of certain bits in the status register. Recall in Figure 3-19 that the status bits were identified and that the "equals bit" - bit 2 - was going to be used to change the time delay sequence. Therefore, the decision block in the program is really asking, "Is bit 2 of the status register set to a "1"?" The status bit 2 is set to 1 by the program step before the decision block in Figure 3-27 - the decrement step. An instruction Decrement (by One) causes a named file register to have one subtracted from its contents, comparison of the result to zero and the .... 3 setting of the appropriate status bits (0-4) of the status register. When the register contents are equal to zero, the "equals" status bit (2) will be set to a "1". When the status bit 2 is not set to a "1 ", the program must return to the decrement instruction and subtract one again from the register. JNE (label) is the conditional jump instruction that will be used to accomplish the loop. It is activated by the "equals bit" being "O". The program will jump to a point ahead of the decrement step which will be identified with an appropriate label. In the program this label must be included with the JNE (Jump if not equal) instruction. A similar type of conditional jump instruction is used to answer the question of the switch in the first decision block of the WAIT subroutine. However, in this case, Jump if Equal OEQ (label)), with the appropriate label will be used. Now the conditional jump will occur if the equal bit is set to a "1 ". Recall, this is the type instruction previously referred to that must follow the TB instruction so that the status bit can be examined and a decision made. The number of steps in the decrement block is now the only remaining portion of the subroutine which has not been discussed. LOADING A REGISTER FOR THE TIME DELAY Assume that the switch is "ON" in the WAIT routine. A logical "1" is the input to the microcomputer. The TB instruction identifies the logical "1" and it sets the equals bit 2 of the status register to a "1" as previously described. The JEQ instruction jumps to a selected (labeled) instruction which loads a selected file register with a number, 3FFF16 • As a 16 bit binary number, it is 0011 1111 1111 1111. No jump occurs in the program if the switch is inputting a logical "O". The program just proceeds to the next step. 3-42 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 WHERE DOES THE PROGRAM START? Well, how does the data get loaded into the selected file register? Simply enough with a load instruction which is one of the data transfer instructions. Load Immediate (file register number), 3FFF16 will tell the microcomputer to load the hexadecimal number 3FFF16 into the selected register. What actually happens is that two memory words must be used for this instruction. The first word provides the operation code and register number and the second word the operand or data to be operated on. For the addressing mode used for the Load Immediate instruction, the word following the instruction LI 3, will contain the data to be put into register 3, 3FFF16 • The programmer must remember that a memory word location (PC+ 2) is used for the 3FFF16 data when the instruction is located at PC. Following on then, new data is placed into the same register by a new Load Immediate 3.,.. instruction. For example, for a longer time delay, the file register R3 is loaded with FFFF16 • The instruction LI 3, FFFF16 accomplishes this. WHERE DOES THE PROGRAM START? Most of the information is now in hand to write the program. The question is, "Where does the program start"? Recall that when the program was entered into the microcomputer through the microterminal, FE00 16 was chosen as the starting memory location. How was this decided? The first step in the decision is to determine what words are available in memory - what addresses can be used. Figure 3-30 is reproduced from the TM 990/lOOM Users Guide. There are address locations from 0000 16 to FFFE16 for 65,536 bytes (8-bit pieces), or 32,768 16-bit word locations. This is commonly called the address space. Word address locations move by an increment of 2, byte locations by 1. The incrementing of the program counter by 2 was previously noted. This is the reason. Recall that the TM 990/lOOM microcomputer has 256 16-bit words of RAM into which the program is going to be placed and it also has 1024 16-bit words of ROM, or EPROM in this case. The EPROM is the TIBUG monitor that provides the necessary pre-programmed instructions that were referred to for accepting input and output data. The 256 words of RAM occupy address space from FE00 16 to FFFE 16 as shown in Figure 3-30. The EPROM address space is from 0000 16 through 07FE 16 which is address space that is dedicated for this purpose and not available for change by the first encounter program. Notice that within this space are interrupt and XOP vectors. These are of no concern at this time. Since not all the available memory sockets are filled, address space from 0800 16 through FDFE16 does not have memory cells - it is unpopulated. 9900 FAMILY SYSTEMS DESIGN 3-43 WHERE DOES THE A First Encounter: Getting Your Hands on a 9900 PROGRAM START? It would seem that all the address spaces in RAM from FE00 16 to FFFE 16 are available. However, as shown in Figure J-30, 40 words of RAM must be reserved for use by the TIBUG monitor and additional space is necessary for interrupts. Thus, the available space is from FE00 16 to FF66 16 • Obviously, some analysis of the possible length of the program in number of steps must be made, as well as some estimate of the number of file register blocks of 16 (workspaces) that will be used. This will determine whether adequate address space is available or whether additional memory space must be populated. The first encounter assumptions are as follows: ..... 3 1. The program will be less than 96 steps long - 96 words or 192 bytes. 2. Only one workspace will be required. (16 contiguous words) - - - - BYTE 0000 MEMORY BYTE 0001 ADDRESS INTERRUPT VECTORS 1=~ FIRST XOP VECTORS 0040 EPROM 1048 DEDICATED 007E TMS2708 WORD MEMORY 1KX16 EPROM ) Tl BUG lOOSO MONITOR 07FE 0800 ) SECOND EPROM ~ 1048 TMS2708 FF68 INT3, ( WORD 1KX16 } WP AT FF68 OFFE ) EPROM FF88---_-_-_-_-_-_-_-_-_-_-_-_--l 2-WORD INST AT FF88 lj 1000 FFBC INT4 ....._ } WP AT FF8C • ~~:o:'.'l------------1 2-WORD INST AT FFAC • MEMORY ' - • EXPANSION FFFE1-:-----+-----___J } SECOND RAM ( 256 TMS4042·2 ('WORD x ....... -- USER AVAILABLE FDFE 256 16 J RAM ............................. - RAM ...... RAM ~ST ! ....... ........ ....... TMS4042·2 ....... x 256 16 ...... ' ....... WORD ....... RAM RESERVED 40 WORDS FOR TIBUG MONITOR WORKSPACE FILES AND RESTART VECTORS AT FFFC AND FFFE Figure 3-30. Memory Map 3-44 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 WRITING THE PROGRAM On this basis, the starting address of the program is chosen as FE00 16 . The workspace file register could have been chosen to start at 16 words away from FF6616 • However, since there is plenty of space, it is placed at FF20 16 , leaving the room from FE0016 to FFlE 16 as the space for the program (144 words): WRITING THE PROGRAM Refer now to the flowchart in Figure 3-26 as the basis for writing the program. To help in the organization of the program, a form shown in Table 3-1 will be used. Note that it has a column for addresses, for machine code, for a label, for the assembly language statement and for comments. Each of these columns will be filled in as needed as the 3 FF20 and Step 2 has the operand to be loaded. The greater than (>) sign identifies the data as hexadecimal. The program must be able to branch to the subroutine WAIT when that routine is called by the program. Therefore, the starting address of the WAIT subroutine must be loaded into a file register which then will be referenced when the address is needed. Step 3 of the program accomplishes this with a Load Immediate instruction and register 1 is chosen to hold the address. Note that the program address is incrementing by two. Step 3 is: Step MC L ASSY. LANG -3- LI 1,>XXXX 9900 FAMILY SYSTEMS DESIGN 3-45 WAIT SUBROUTINE CALL A First Encounter: Getting Your Hands on a 9900 Note that the specific address cannot be put in at this time - not until the location is known. Step 4 is the step for loading the operand. Recall that a reference needs to be established for the particular 9901 1/0 interface unit to be used by the microcomputer. This was referred to as the CRU base address for the chosen 9901. Register 12 of the file register is the one that must contain the CRU base address, therefore, it must be loaded with 012016 , the software base address of the 9901 in the TM990/100M microcomputer. Step 5 of the program is for this purpose. Step MC L Assy. Lang. -5- LI 12, >0120 ~3 Again Step 6 must be added because of the immediate addressing. All initial conditions are now complete and the flowchart now moves to the start of the light sequence. Light # 1 must be turned on. Recall from Figure 3-25 that light # 1 is connected to 1/0 output 0 (P0 ). Therefore, 1/0-0 on the 9901 must be set to a "l". This is accomplished with the SBO instruction of Step 7. Recall, this instruction was previously discussed in detail. Step 7 looks like this: Step MC L Assy. Lang. -7- BEGIN SBOO Note that this instruction is labeled BEGIN. This is done because the program will jump back to this address location after the complete sequence of the first encounter task is completed. The label BEGIN provides an easy reference to this location. WAIT SUBROUTINE CALL The first encounter task as defined now requires the light # 1 be held on for the time delay represented by the subroutine WAIT. Therefore, the program must be directed to the first address of the subroutine. This first address is contained in the file register 1 (workspace register 1) because Step J and Step 4 accomplished this. Recall the discussion on the WAIT subroutine (Figure 3-28). The main program must be directed to the subroutine (the main program "calls" the subroutine) but it must also remember where it is in the main program so it can return to the correct location. The Branch and Link to register 1 of Step 8 accomplishes this. Step A MC L Assy. Lang. 8 FEOE BL *1 3-46 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 RETURN FROM WAIT SUBROUTINE At the same time the address of the next step in the program, Step 9 is being saved in register 11. However, note that there is a new symbol in the assembly language instruction. The asterisk (*) means that an indirect addressing mode is used. That means that file register 1 (WRl) does not contain operand information but contains the address of an operand to be used for further processing. That is exactly what has been put into register 1 - the address of the first instruction of the WAIT subroutine. Therefore, an indirect addressing mode is used. Why is that important? When the machine code for an instruction is constructed a little later (this will be done by hand but normally it would be done by a computer under control of a program called an assembler), an identifying code for the addressing mode must be used in the format for each instruction. Figure 3-31 shows how the 16 bits of the machine code are arranged for the various types of instructions. Much more discussion of these formats is contained in Chapters 5 and 6. For the purpose here, format 6 is the one of particular interest for the Branch and Link instruction. Note that for format 6 the first 10 bits are for the operation code, bits 10 and 11 are a Ts field, and bits 12 thru 15 are an S field for identifying the address of the source information. Note that the code for Ts defines the addressing mode for the instruction. 01 will be entered in this field for bits 10 and 11 for the Branch and Link instruction because this is the code for indirect addressing. 0001 will be the code for the S field because register 1 contains the source address. RETURN FROM WAIT SUBROUTINE The end of the subroutine will return the microcomputer to the main program at Step 9 because this is the address saved in register 11. Step 9, according to the flowchart of Figure 3-26, must now turn light # 1 off. The instruction is: Step A MC L Assy. Lang. -9- FElO SBZO Since I I 0 port 0 was set to a "1" in order to turn the light on, now it is set to a "O" to turn the light off. • Time delay subroutine WAIT is called for again for the next step and again the Branch and Link instruction is used. Thus, Step 10 is: Step A MC L Assy. Lang. 10 FE12 BL *1 9900 FAMILY SYSTEMS DESIGN 3-47 WAIT SUBROUTINE A First Encounter: Getting Your Hands on a 9900 Upon return from the WAIT subroutine light # 2 is turned on, the WAIT routine occurs, light # 2 is turned off, the WAIT routine occurs and the process continues until light # 4 is turned off and the time delay is complete. These steps are shown in Table 3-1 and carry the program through Step 22. The program will return to Step 23 after the time delay. The flowchart indicates a return to the beginning of the sequence. Recall that this was labeled BEGIN. Therefore, Step 23 is a jump instruction that jumps the program back to the address of the instruction labeled BEGIN. The assembly language instruction is simple enough: Step MC L Assy. Lang. ~3 23 JMPBEGIN This instruction is called an unconditional jump instruction because there are no decisions involved - just the direction to "go to" a specified place. There is no return instruction address saved in register 11 and no testing of status bits. All the program steps in the flowchart of Figure 3-26 are now complete. What remains is to define the steps in the subroutine WAIT. Figure 3-27 is used for this purpose. WAIT SUBROUTINE The address at Step 24, FE2E 16 , is the one that must be loaded into register 1 at Step 3 because it is the first instruction of the subroutine. The flowchart identifies this step as a decision block. Is the switch on for a logical "1" or is it off for a logical "O"? The input line must be tested to determine this. A TB instruction, examining 1/0 pin P4 , is used for this purpose. This instruction is Step 24: Step A MC L Assy. Lang. 24 FE2E TB4 This is the Test Bit instruction discussed previously. Recall that when the input line is tested by the instruction it sets the "equals" bit, bit 2 of the status register to the value of the input. In order to make the decision called for in the flowchart, an instruction that e.xamines bit 2 of the status register must follow. This will be a conditional jump instruction because if the status bit is a "l'', the time delay is to be the shortest and the sequence fast. Correspondingly, the sequence would be slow and the time delay long for a status bit 2 of "O". Chapters 5 and 6 identify the jump instructions. JEQ is the one selected which says that the program will jump to a new location if the "equals" bit is set to a "1", otherwise, the program will continue on to the next step. The instruction is: 3-48 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 WAIT SUBROUTINE Step A MC L Assy. Lang. 25 FEJO JEQTIME Convenient labels have been placed on the flowchart of Figure 3-27. The branch jumped to in Step 25 is labeled TIME. This branch will be executed in a moment. For now, assume that the "equals" bit is set to "O" and the program continues. The next step is to load a register so that it can be decremented to produce the time delay. In this branch, this must be the largest value for the longest delay and the slowest sequence. Another file register must be selected. Register 3 is chosen and the load instruction is as follows: Step A MC L Assy. Lang. 3..._ 26 FE32 LI 3, >FFFF This is the same as previous Load Immediate instructions and another word must be allowed for the value to be loaded. Thus, Step 27 at FE34. One must now be subtracted from the value. There is an instruction called Decrement (by one) and, of course, it must tell what value to be decremented. In this case, the contents of R3. Thus, Step 28 is: Step A MC L Assy. Lang. ·zr FE3 TIMEl DEC3 The flowchart shows the decrement as an operation. In addition, as mentioned previously, the value in register 3 is compared to zero and the greater than, equal, carry or overflow status bits are set accordingly. This is found in the discussion on the instructions in Chapter 5 and 6. The decision that follows is made on the basis again of examining the "equals" bit. The flow chart shows that if the "equals" bit is not set, the program will loop back and be decremented again as previously discussed. Therefore, a label, TIME 1, is placed on the instruction at FE36 to tell the program the location of the jump. The jump occurs this time if the "equals" bit is not set, using the instruction Jump if Not Equal, and looks like: Step A MC L Assy. Lang. 29 FE38 JNE TIMEl 9900 FAMILY SYSTEMS DESIGN 3-49 WAIT SUBROUTINE A First Encounter: Getting Your Hands on a 9900 When the file register has been decremented to zero, the equals bit will be set and the program is ready to return to the main program. Recall that register 11 contains the address (location) for the return. The branch instruction used for the return is Branch and Step 30 is: Step A MC L Assy. Lang. 31) FE3A B *11 Note this again is an indirect addressing mode. TIME BRANCH ~3 The only remaining portion of the flowchart that must be programmed is the TIME branch. In this branch, the time delay is shorter to make the sequence faster. R3, the same register, is loaded with a smaller value, 3FFF16 • Again a Load Immediate instruction shown in Step 31 is used. Step MC L Assy. Lang. 31 TIME LI3, > 3FFF This step is labeled with TIME, and will be the location jumped to from Step 25. Step 32 is the extra word required. The register must again be decremented, therefore, the instruction is the same type as Step 28. However, the label for the location to jump to is now TIME2. Step 33 is: Step A MC L Assy. Lang. 33 FE40 TIME2 DEC 3 The same jump instruction is used in this branch as for Step 29 except the label is now TIME 2. Therefore, Step 3 4 is: Step A MC L Assy. Lang. 34 FE42 JNE TIME2 When the equals bit is set, the program must return to the main program as with the other branch. The same return instruction as Step 30 is used, as shown in Step 35. Step A MC L Assy. Lang. ~ FE44 B *11 The total program is now complete in assembly language. It is shown in Table 3-1. 3-50 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 TABLE 3-1 ASSEMBLY LANGUAGE PROGRAM Table 3-1. Assembly Language Program. (Source Code Statements) Hex Hex Machine Op Step Address Code Label Code Operand Comments. 1. FEDD LWPI > FF2D Load workspace pointer 2. FED2 with FF2D 16 3. FE04 LI 1, > FE2E Load R1 4. FED6 with 1st Address of WAIT 5. FEDS LI 12, >D102 Load R12 6. FEDA with base address of 99D1, 012D 16 7. FEDC BEGIN SBO D Set I /0 P0 (segment f) equal to one ::: 1 8. FEDE BL Branch to address in R1 (saves 3 .... next address in R11) 9. FE1D SBZ D Set 110 P0 (segment f) equal to zero 1D. FE12 BL ::: 1 Branch to address in R1 (saves next address in R11) 11. FE14 SBO ' 1 Set 1/0 P 1 (segment b) equal to one 12. FE16 BL ::: 1 Branch to address in R 1 13. FE18 SBZ 1 Set I /0 P 1 equal to zero 14. FE1A BL ::: 1 Branch to address in R1 15. FE1C SBO 2 Set 110 P2 (segment e) equal to one 16. FE1E BL ::: 1 Branch to address in R 1 17. FE2D SBZ 2 Set 1/0 P2 equal to zero 18. FE22 BL ::: 1 Branch to address in R1 19. FE24 SBO 3 Set I /0 P3 (segment c) equal to one 2D. FE26 BL ::: 1 Branch to address in R 1 21. FE28 SBZ 3 Set 1/0 P3 to equal to zero 22. FE2A BL ::: 1 Branch to address in R1 23. FE2C JMP BEGIN Jump to BEGIN 24. FE2E WAIT TB 4 Test 1/0 P4 for a "1" or a "D" 25. FE3D JEQ TIME If equals bit is set ("1 "), jump to TIME 26. FE32 LI 3, >FFFF Load R3 27. FE34 with FFFF 16 28. FE36 TIME1 DEC 3 Decrement R3 29. FE38 JNE TIME1 Jump to TIME 1 if equals bit is not set 3D. FE3A B ::: 11 Return to main program (by way of R11) 31. FE3C TIME LI 3, >3FFF Load R3 32. FE3E with 3FFF 16 33. FE40 TIME2 DEC 3 Decrement R3 34. FE42 JNE TIME2 Jump to TIME 2 if equals bit is not set 35. FE44 B ::: 11 Return to main program (by way of R11) 9900 FAMILY SYSTEMS DESIGN 3-51 WRITING A First Encounter: Getting Your Hands on a 9900 THE MACHINE CODE WRITING THE MACHINE CODE Normally the next step in programming (shown in Table 3-2) would be done by a computer as mentioned previously. However, in order to demonstrate what an Assembler Program would do and because the program input to the TM990/ lOOM microcomputer is through the microterminal, which requires the machine code, it will be a good exercise to demonstrate how to develop the machine code. If this is of no interest, this portion of the discussion can be bypassed and a jump made to the summary. As mentioned previously in Figure 3-31, there is a set format for the 16 bits of machine code that must be generated for each instruction. The formats used for the first ..... 3 encounter task are shown in Figure 3-32 for reference. Each instruction has an operation code (OP CODE) and then additional information is required in the various fields of the format. A complete discussion of the format for each instruction can be found in Chapter 6. Figure 3-33 lists the instructions used in the first encounter. The same programming form will be used as before which is summarized to this point in Table 3-1. The machine code will be filled in and several other changes made and the result will be the final program of Table 3-2. As before, continue to refer to Table 3-2 as the machine code is developed. IMMEDIATE INSTRUCTIONS The coding begins at Step 1. L WPI is an immediate instruction. Therefore, the format 8 of Figure 3-32 is used. There are two words to this instruction; the second one containing the immediate value to be loaded. In the first word, the op code occupies bits 0 through 10; register numbers, where the immediate value is going to be placed, occupy bits 12 thru 15. Bit 11 is not used. The op code is obtained from Figure 3-33 for the LWPI instruction. The filled out instruction would look like this. I 0 1 2 3 I4 5 6 7 8 9 10 11I12 13 14 15 Binary 00000010111 0 0 0 0 0 Op Code - 0 2 E 0 Machine - 0 2 E 0 Code LWPI is a special case of format 8. Bits 11-15 are not used and as such could contain anything. They are don't care conditions. Therefore, the machine code is 02EO. This is entered into Table 3-2 on the same line as LWPI as Step 1. Step 2 is the immediate value FF20, therefore, the machine code is FF2016 • 3-52 9900 FAMILY SYSTEMS DESIGN A First Encounter: WRITING Getting Your Hands on a 9900 THE MACHINE CODE FORMAT (USE) oj 1j 2J 3 I 4 Is I e I 7 I 8 I 9 l10l11 l12l13l1411s 1 (ARITH) OPCODE}Bl To 1 D 1 Ts S l 2 (JUMP) OP CODE ] SIGNED DISPLACEMENT* 3 (LOGICAL) OP CODE J D j Is_ j S 4 (CRU) OP CODE l C ] Ts ] S 5 (SHIFT) OPCODE I c w 6 (PROGRAM) OP CODE ] Is_ ] S 7 (CONTROL) OP CODE NOT USED 8 (IMMEDIATE) OP CODE IMMEDIATE VALUE T_T..:.s__.1.___ _s____, 9 (MPY, DIV,XOP) "----O_P_C_O_D_E_ _T_.___ _D_ _...... KEY B =BYTE INDICATOR S =SOURCE ADDR. (1 =BYTE, 0 =WORD) C = XFR OR SHIFT LENGTH (COUNT) T 0 = D ADDR. MODIFICATION W =WORKSPACE REGISTER NO. D =DESTINATION ADDR. "=SIGNED DISPLACEMENT OF -128 TO + 127 WORDS Ts= S ADDR. MODIFICATION NU= NOT USED Figure 3-31. Instruction Formats FORMAT I o 1 2 3 I 4 s e 7 I 8 9 1o 11 I12 13 14 1 s I 2 (JUMP) I- Op Code -1- Signed Displacement -4 6 (PROGRAM) I - Op Code _ _ __. Ts j-s-1 8 (IMMEDIATE) I- Op C o d e - - - - N U 1---w-! -----IMMEDIATE V A L U E - - - - - - CODES FORTS FIELD ADDRESSING MODE NOTES: 00 REGISTER T, = SOURCE ADDRESS MODIFICATION 01 INDIRECT S = SOURCE ADDRESS 10 INDEXED (SOR D7'0) W = WORKSPACE (FILE) REGISTER NO. 10 SYMBOLIC (DIRECT, S OR D = 0) NU = NOT USED 11 INDIRECT WITH AUTO INCREMENT SIGNED DISPLACEMENT CAN BE -128 TO + 127 WORDS Figure 3-32. Formats used for First Encounter 9900 FAMILY SYSTEMS DESIGN 3-53 WRITING A First Encounter: Getting Your Hands on a 9900 THE MACHINE CODE In like fashion, the instructions at Step 3 and Step 5 are immediate instructions, use the same format, and are coded with the appropriate register numbers. Step 4 and Step 6 are the immediate values to be loaded. Note, however, that when the program was first prepared, the first address of the WAIT subroutine was not known. Now, it is known. It is substituted for the XXXX in Table 3-1 at Step 3. Thus, the address of Step 24, FE2E is placed after the "greater than" symbol. The op code for LI is 0200 16 and since register 1 is used for Step 3, the machine code is 0201 16 while for Step 5 it is 020C because register 12 is being loaded. The machine code ~3 for Step 4 is the value FE2E 16 and for Step 6 it is 0120 16 • INSTRUCTIONS SBO, SBZ The instruction SBO at Step 7 uses a different format. This is format 2 in Figure 3-32. It has the op code in bits 0 through 7 and the signed displacement that was discussed previously when the 99011/0 unit program was examined. Recall that the CRU base address was arranged so that the bit number is the value that is put in for the signed displacement. The op code for SBO from Figure 3-33 is 1D0016 and with the first bit being zero, the machine code is: o 1 2 3 I4 s 6 1 I s 9 10 11 I 12 13 14 1s I Binary 00011101 000 0 0 0 0 0 Op Code - 1 D 0 0 Machine - 1 D 0 0 Code HEX RESULT COMPARE MNEMONIC OP CODE FORMAT TO ZERO INSTRUCTION LWPI 02EO 8 N LOAD IMMEDIATE TO WORKSPACE POINTER LI 0200 8 N LOAD IMMEDIATE BL 0680 6 N BRANCH AND LINK (WR11) B 0440 6 N BRANCH DEC 0600 6 y DECREMENT (BY ONE) SBO 1000 2 N SET CRU BIT TO ONE SBZ 1EOO 2 N SET CRU BIT TO ZERO TB 1FOO 2 N TESTCRU BIT JEO 1300 2 N JUMP EQUAL (ST2 = 1) JMP 1000 2 N JUMP UNCONDITIONAL JNE 1600 2 N JUMP NOT EQUAL (ST2 = 0) (ST2=0) Figure 3-33. Instructions used for First Encounter. 3-54 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 WRITING THE MACHINE CODE The other SBO instructions can be machine coded accordingly using the appropriate bit number. Therefore, Step 11is1D01 16 , Step 15 is 1D02 16 and Step 19 is 1D0316 • Similarly, using the op code of 1£0016 for the SBZ instructions and the appropriate bit number, Step 9 is 1£0016 , Step 13 is 1£01 16 , Step 17 is 1£0216 , and Step 21 is 1£03 16 • INSTRUCTION BL Now Step 8 brings in another new format. For the BL instruction, it is format 6. Bits 0 thru 9 contain the op code. Bits 12 through 15 are the address of the source data. Ts is a field that modifies the source address and it contains the two bits that code the addressing mode that is being used. Recall BL * 1 uses indirect addressing. Therefore, from Figure 3-32 Ts would be 01 for these 2 bits. It's important to remember that this modifies the op code into a different number for the machine code as shown below. o 1 2 3 \4 5 6 7 \8 9 10 11112 u 14 15 I Op Code 0 6 8 0 Binary 0000011010 0 0 0 0 0 0 Ts 0 1 s 0 0 0 1 Machine 0000011010 0 1 0 0 0 1 Code- (Binary) Machine 0 6 9 1 Code- (Hex) Thus, the machine code is 0691 16 and can be placed in Step 8, 10, 12, 14, 16, 18, 20 and 22, since register 1 is used in each case. MiscELLANEOUS INSTRUCTIONS Because the jump instructions fall into a class that needs special discussion, the remaining instructions will be coded first. Step 26 and Step 31 are LI instructions like Step 3 and Step 5 - the code is 0203 16 in this case because register 3 is being used. Don't forget the values of FFFF16 for Step 27 and 3FFF16 for Step 32. The TB instruction has an op code of 1F0016 and a format 2. It is just like the SBO and SBZ so that the bit must be used for the displacement. Bit 4 causes a displacement of 4, therefore, the machine code is 1F04 16 • This is Step 24. 9900 FAMILY SYSTEMS DESIGN 3-55 WRITING A First Encounter: Getting Your Hands on a 9900 THE MACHINE CODE A branch instruction similar to BL, but does not save the next address in register 11, is the instruction B. It is using the contents of register 11 for a return to the main program. The op code for Bis 0440 16 • It uses an indirect addressing mode so Ts= 01 and S is 1011 for register 11. The machine code results as follows: 0 1 2 314 5 6 718 9 10 11112 13 14 15 I Op Code 0 4 4 0 0000010001 0 0 0 0 0 0 Ts 0 1 s 1 0 1 1 ~3 Machine 0000010001 0 1 1 0 1 1 Code (Binary) Machine 0 4 5 B Code (Hex) It is entered at Step 30 and 35. The only remaining instruction besides the jump instructions is the decrement instruction DEC. From Figure 3-33 the op code is 060016 and the format is 6. Register 3 is being used, therefore, Sis 0011. The addressing mode is a register mode so Ts is 00 and there is no modification of the op code. The machine code is then 0603 16 for Step 28 and 33. }UMP INSTRUCTIONS Jump instructions use format 2 of Figure 3-32 which has an op code for bits 0 through 7 and a signed displacement in bits 8 through 15. The signed displacement means the ·number of program addresses that the program must move to arrive at the required address. For example, let AJ =present address of jump instruction An = destination address of jump instruction then, 1.) AJ + 2 D ISP =An since the program moves by increments of 2. However, for the 9900 microprocessor in the TM990/ lOOM microcomputer, the jump instruction signed displacement must be calculated from the address following the address of the jump instruction or AJ + 2. Therefore, equation (1) becomes, 2.) (AJ + 2) + 2 DISP=An Solving for DISP, gives 3.) An-(AJ+2)=DISP 2 3-56 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 WRITING THE MACHINE CODE Recall that in preparing the program of Table 3-1 labels were used for instructions so that easy reference could be made to the desired destination address for a jump instruction. Step 23 at FE2C 16 is the first jump instruction. The destination is the label BEGIN which is located at address FEOC 16 • Applying equation (3) gives (in Hex) 4.) DISP = FEOC - (FE2C + 2) 2 5.) DISP=FEOC-FE2E 2 Now, FEOC 3,... -FE2E -002216 Therefore, 6.) DISP= -22:;::: -1116 2 This means that in the jump instruction the program mov(.!s back 111 6 steps or 17 decimal steps. Now, since this is a negative number, a two's complement must be used for the code, thus -0011 COMPLEMENT FFEE ADD ONE +0001 2'S COMPLEMENT FFEF Now, only the 8 least significant bits are used along with the op code of Figure 3-33. JMP of Step 23 has an op code of 100016 . Therefore, the machine code is: 0 1 2 3 I4 5 6 7 I8 9 10 11112 13 14 15 I Op Code 1 0 0 0 Displacement- E F ~~~~~~~~~~~~~~ Machine 1 0 E F Code This machine code is entered at Step 2 3. 9900 FAMILY SYSTEMS DESIGN 3-57 WRITING A First Encounter: Getting Your Hands on a 9900 THE MACHINE CODE Step 25 has a JEQ instruction. AJ is FE30 16 . The instruction says to jump to TIME which has an address ofFE3C at Step 31, therefore, An= FE3C. Applying equation (3) gives, again in hexadecimal; DISP = FE3C ~ FE32 = 10 = 516 2 JEQ has an op-code of 1300 and the machine code then becomes: o 1 2 3 I4 5 6 7 I8 9 10 11112 13 14 15 I Op Code 1 3 0 0 Displacement - _ _ _ _ _ _ _ _0_____5__ Machine Code- 1 3 0 5 Step 25 then has 1305 as the machine code. The remaining jump instructions, JNE at Steps 29 and 34 have an op code of 160016 . Calculating the displacement from Step 29 to Step 28 and from Step 34 to Step 33, obviously is - 02 16 • The complement of - 02 is FFFD and the twos complement is FFFE. Thus the machine.code is: o 1 2 3 \ 4 s 6 7 \ 8 9 10 11112 13 14 15 I Op Code 1 6 0 0 . Displacement - _ _ _ _ _ _ _ _F_____E_ _ Machine Code- 1 6 F E Even though the labels jumped to for Steps 29 and 34 are different, the displacement is the same and, therefore, the machine code entered at these steps is the same, 16FE16 . 3-58 9900 FAMILY SYSTEMS DESIGN A First Encounter: Getting Your Hands on a 9900 SUMMARY TABLE 3-2 Every step is now coded and the program is complete. This is the program that was entered into the microcomputer via the terminal to accomplish the first encounter task. Only one comment remains. If the Table 3-1 program were run on a computer under the direction of an assembler program, certain symbols used for directives to the assembler would have to be used. The $ symbol could have been used to indicate the fact that a displacement is to be made from the jump instruction address which was identified in equation (3) as AJ. The instruction then would contain the $ symbol followed by the necessary displacement in hexadecimal. For this reason the instructions at Step 23, 2 5, 29, and 34 would have looked as follows: 3.... Step A MC L Assy. Lang. n-- FE2C lOEF JMP $-17° 25 FE30 1305 JEQ $+5 29 FE38 16FE JNE $-2 34 FE42 16FE JNE $-2 SUMMARY It has been a long discussion. However, a great deal of material has been covered and many basic concepts developed. The facts and procedures presented should provide a solid foundation for expanding an understanding of the 9900 Family of microprocessors and microcomputer component peripherals and the microcomputers which use it. Hopefully, enough examples have been presented with the first encounter task that with a minimum of effort, new real applications of the TM990/ lOOM board can be implemented. A few simple ones that can be implemented immediately with the present setup would be: A. Wire-up the necessary drivers and resistors to drive all seven-segments of the display and write a new program to make the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 come up in sequence. B. Write a program that uses the 7 segment display numbers so that they spell a word when read up-side down. Maybe more memory will be required, but that is easy to add to the TM990/100M. The next step is to implement the logic levels at the output pins into real applications of controlling de and ac voltages for control applications. An extended application in Chapter 9 using this same TM990/ lOOM board setup shows how this can be done. Persons interested can follow right into this application example to gain more insight into the details of the 9900 family of components explained in detail in the following chapters. 9900 FAMILY SYSTEMS DESIGN 3-59 TABLE 3-2: ASSEMBLY LANGUAGE PROGRAM Table 3-2. Assembly Language Program. (With Machine Code) Hex Hex Machine Op Step Address Code Label Code Operand Comments. 1. FEOO 02EO LWPI >FF20 Load workspace pointer 2. FE02 FF20 with FF20 16 3. FE04 0201 LI 1, >FE2E Load R1 4. FE06 FE2E with 1st address of WAIT 5. FE08 020C LI 12, >0102 Load 12 6. FEOA 0120 with base address of 9901, 01201 6 7. FEOC 1000 BEGIN SBO 0 Set 1/0 P0 (segment f) equal to one 8. FEOE 0691 BL •:< 1 Branch to address in R1, (saves next address in R11) 9. FE10 1 EOO SBZ 0 Set I /0 P0 (segment f) equal to zero 10. FE12 0691 BL •:< 1 Branch to address in R1 (saves next address in R11) 11 . FE14 1001 SBO 1 Set 1/0 P 1 (segment b) equal to one 12. FE16 0691 BL ::: 1 Branch to address in R1 13. FE18 1 E01 SBZ 1 Set 1/0 P1equal to zero 14. FE1A 0691 BL •:< 1 Branch to address in R1 15. FE1C 1002 SBO 2 Set 1/0 P2 (segment e) to one 16. •:< 1 FE1E 0691 BL Branch to address in R1 17. FE20 1 E02 SBZ 2 Set 1/0 P2 equal to zero 18. FE22 0691 BL •:• 1 Branch to address in R1 19 FE24 1003 SBO 3 Set 1/0 P3 (segment c) equal to one 20. FE26 0691 BL •:• 1 Branch to address in R1 21. FE28 1 E03 SBZ 3 Set 1/0 P3 equal to zero •:< 1 22. FE2A 0691 BL Branch to address in R1 23 .. FE2C 1 OEF JMP BEGIN Jump to BEGIN 24. FE2E 1 F04 WAIT TB 4 Test 1/0 P4 for a "1" or a "O" 25. FE30 1305 JEO TIME If equals bit is set ("1 "),jump to TIME 26. FE32 0203 LI 3, >FFFF Load R3 27. FE34 FFFF with FFFF 16 28. FE36 0603 TIME1 DEC 3 Decrement R3 29. FE38 16FE JNE TIME1 Jump to TIME1 if equals bit is not set 30. FE3A 0458 8 •:•11 Return to main program (by way of 11) 31. FE3C 0203 TIME LI 3, >3FFF Load R3 . 32. FE3E 3FFF with 3FFF 16 33. FE40 0603 TIME2 DEC 3 Decrement R3 34. FE42 16FE JNE TIME2 Jump to TIME2 if equals bit is not set 35. FE44 0458 8 •:< 11 Return to main program (by way of R11) 3-60 9900 FAMILY SYSTEMS DESIGN CHAPTER4 Hardware Design: Architecture and Interfacing Techniques t :~::·::::::erawww:.awwws .xwwwuxu;.wwwoxm JPJ&.mr,; as z. :I/I~ .,., " ' ";' "• ' ' ' < •I j' '~ '\ ' ~ _., , " '"I I l ' ' ,\: Hardware Design: INTRODUCTION Architecture and Interfacing Techniques INTRODUCTION Describing the 9900 system from a hardware standpoint clearly requires detailed descriptions of a large number of design features as well as the interaction between the 9900 and peripheral circuits. In this chapter, material is arranged to develop a 9900 system from the viewpoint of the 9900 microprocessor chip. In the architecture section, the concepts of instruction fetch and decode, the memory-to-microprocessor bus structures, and memory partitioning (the use of volatile and non-volatile memories) are explained. Other topics include descriptions of the registers on the microprocessor chip and the working registers, the concept of memory-to-memory architecture, timing and descriptions of interface signals. A special section covers memory in detail, especially the controls and timing, multichip memory structure, static and dynamic RAM, and DMA (direct memory access). Following the architecture and memory sections are sections devoted to the instruction set, design considerations for input/ output techniques especially in CRU development, the interrupt structure and electrical requirements. A special section devoted to the unique features of the single chip microcomputer, the TMS9940, is included at the end of the chapter. Information in this chapter flows from the most basic fundamentals to an understanding of the more complex design features of the 9900 and the chip family. When very specific and detailed information regarding pin assignments and speed is given, the TMS9900 device specifications are used. These examples will give direction and illustration for interpreting the data sheet information found in Chapter 8. The 9900 family of 16-bit microprocessors includes several device types each aimed at a specific market segment. The same basic architecture and instruction set are maintained throughout. Consider first the single-chip microprocessor which consists of an ALU (arithmetic and logic unit), a few registers, and instruction handling circuitry (Figure 4-1). There is no memory on the chip for instructions and data so it must be interfaced to memory devices, usually RAM for data (and instructions which must be modified) and ROM, PROM, or EPROM for instructions (Figure 4-2). It is often desirable to store instructions in a non-volatile memory to eliminate the requirement for loading the program into memory immediately following application of power. This is especially important in dedicated applications where the program is fixed and power off-on cycles are common occurrences. The microprocessor is connected to memory devices and external input/ output (I/O) devices via sets of signals or busses (Figure 4-2). An address bus selects a word of memory. The contents of this word will be transferred to or from the microprocessor via the data bus. Control signals required to effect the transfer of information between the microprocessor and the memory are grouped into a control bus. 4-2 9900 FAMILY SYSTEMS DESIGN Hardware Design: INTRODUCTION Architecture and Interfacing Techniques DEDICATED I REGISTERS I I I INSTRUCTION I HANDLING 1-- - - - - ----, CIRCUITRY I I I I ALU Figure 4-1. The 9900 Microprocessor The interface to external devices (1/0) may be accomplished by using the address, data and control busses. This technique is known as parallel 1/0 or memory mapped 1/0 because data is transferred in parallel and the 1/0 devices occupy locations in the memory address space. ADDRESS BUS INSTRUCTION MEMORY 9900 CONTROL BUS DATA MEMORY DATA BUS Figure 4-2. 9900 Microprocessor and Memory 9900 FAMILY SYSTEMS DESIGN 4-3 INTRODUCTION Hardware Design: Architecture and Interfacing Techniques The extension of parallel I/O is direct memory access (DMA). External hardware is employed to act as a separate special purpose processor for transferring large blocks of contiguous memory words to or from an external device (such as a disc memory). Once such a transfer is set up (via a string of instructions in the program), the DMA controller automatically synchronizes the transfer of data between the external device and memory, sharing the buses timewise with the microprocessor. The 9900 architecture includes one other important 1/0 technique. Designed primarily for single bit 1/0 transfers, the communications register unit (CRU) provides a powerful alternative to parallel, memory mapped 1/0 (Figure 4-3). The address bus is used to select one of 4096 individual input or output bits in the CRU address space. During the execution of one of the single bit CRU instructions, the processor transfers one bit in or out. Multiple bit instructions are also available which provide for transfer of up to sixteen bits via a single CRU operation. While this chapter describes primarily the basic TMS9900 16-bit microprocessor, all of the 9900 family CPU's are covered in detail in the Product Data chapter. ADDRESS BUS BIT ORIENTED PARALLEL 9900 MEMORY 1/0 1/0 (CRU) CONTROL BUS DATA BUS Figure 4-3. 9900 Bus Architecture 4-4 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and ARCHITECTURE Interfacing Techniques An overview is given here to establish design paths for microprocessor systems. Listed below are the processors in.the 9900 family. Device Technology Description TMS 9900 N-MOS 16-bit CPU 3 MHz TMS 9900-40 N-MOS 16-bit CPU 4 MHz SBP 9900A PL 16-bit CPU -55° to 125°C TMS 9980A/8 l N-MOS 16-bit CPU 40-pin package TMS 9985 N-MOS 16-bit CPU 40-pin package TMS 9940 N-MOS 16-bit CPU with 2 k on-chip ROM General purpose applications are designed around the TMS9900 device. The same is true for systems with severe environmental specs; however, a transition to the SBP9900A is made after the design is complete and the software completely debugged. The TMS9980A/81 and the TMS9985 are used where the 40-pin package is advantageous and a slightly slower speed is acceptable. The TMS9940 is a single-chip microcomputer for small special purpose controllers. 4....- At the end of this chapter and in the Product Data chapter there is detailed design data for application of the LSI (large scale integration) peripheral support circuits in the 9900 family which are available for use in 9900 microprocessor-based systems. But in order to read and understand the data presented in this chapter and in this book, an understanding of the basic fundamentals of microprocessors is needed. ARCHITECTURE BASIC MICROPROCESSOR CHIP The 9900 is an advanced 16-bit LSI microprocessor with minicomputer-like architecture and irn~tructions. It is easy to understand and easy to use. Consider first the microprocessor device itself (Figure 4-4). Operations are carried out with a set of dedicated registers, an ALU, and instruction handling circuits. As clock signals are applied, the processor will fetch an instruction word from a memory (external to the chip), will execute it, fetch another instruction, execute it and so on. In each case the instruction is saved in an instruction register (IR) on the chip. The decode circuit sets up the appropriate controls based on the content of the instruction register for a multi-step execution phase. A memory address register (MAR) is used to hold address information on the address bus. The ALU and the other registers perform their specified functions during the execute phase of the instruction cycle. MICROPROCESSOR REGISTERS There are three registers on the 9900 chip which are the key architectural features of the microprocessor (Figure 4-5). They are the workspace pointer (WP), the program counter (PC), and the status register (ST). 9900 FAMILY SYSTEMS DESIGN 4-5 ARCHITECTURE Hardware Design: Architecture and Interfacing Techniques MAR INSTRUCTION DECODE WP AND CONTROL PC IR ST [] s Figure 4-4. 9900 Functional Elements Workspace Pointer The general purpose registers for the 9900 are implemented as blocks of memory called workspaces. A workspace consists of 16 contiguous words of memory, but are general registers to the user. The workspace pointer on the 9900 chip holds the address of the first word in the workspace. After initializing the content of the WP at the beginning of a program (or subprogram), the programmer may concentrate on writing a program using the registers to hold data words or to address data elsewhere in memory. WORKSPACE POINTER PROGRAM COUNTER STATUS REGISTER Figure 4-5. Three Important Registers 4-6 9900 FAMILY SYSTEMS DE'.SIGN Hardware Design: Architecture and ARCHITECTURE Interfacing Techniques Program Counter The program counter (PC) in the 9900 is used in the conventional way to locate the next instruction to be executed. As each instruction is executed, the program counter is incremented to the next consecutive word address. Because word addresses are even numbers in the 9900, the program counter is incremented by two in_ order to address sequential instructions. If the instruction to be executed occupies two or three memory words, the program counter will be incremented to generate sequential (even) addresses to access the required number of words. At the end of execution the PC is incremented to the next even address which is the location of the next instruction. If the instruction to be executed is a jump or branch instruction, the program counter is loaded with a new address and program execution continues starting with the instruction at that location in memory. Figure 4-6 shows the program counter pointing to (addressing) instruction words in the program. Starting with location (x) the instructions are performed in sequence until a jump is encountered at (y). Processing_resumes sequentially starting at location (z) which 4,... was the address specified by the jump instruction to be placed in the program counter. Status Register The status register (ST) is the basis for decision making during program execution. Individual bits of the ST are set as flags as the result of instructions. They may thereafter be tested in the execution of conditional jump instructions. Figure 4-7 shows the status register and its flag bits. PROGRAM IN MEMORY PC "JUMP TO z" Figure 4-6. Program Counter Operation 9900 FAMILY SYSTEMS DESIGN 4-7 ARCHITECTURE Hardware Design: Architecture and Interfacing Techniques 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 RESERVED Bit Function 0 Logical "Greater Than" 1 Arithmetic "Greater Than" 2 Equal 3 Carry 4 Overflow 5 Parity 6 XOP Instruction Being Executed 12-15 Interrupt Mask Figure 4-7. Status Register The first three bits are set as a result of comparisons. Some instructions identify two operands (numbers) to be compared. If the first is greater than the second, the "greater than" bit should be set. In the 9900 there are two such conditions. First, the logical- greater-than bit considers 16-bit words as positive integers and the comparison is made accordingly. Second, the arithmetic-greater-than bit is set as the result of a comparison of two numbers which are considered in two's complement form. For example: consider the numbers A and B below as the numbers in the compare instruction C A, B: A 1000 1110 1100 0101 B 0110 1010 1100 1101 If they are 16-bit positive integers, it is clear from the most significant bits (MSB) that A is greater than B, and the logical-greater-than bit of the status register should be set to one. But as two's complement numbers, A is negative (MSB = 1) and Bis positive. Therefore the arithmetic-greater-than bit must be made zero (A is not greater than B). Since the processor has no way of knowing how the designer has used the memory words for data (integers or two's complement), two status bits must be provided for decision making. The designer can select the appropriate conditional jump instruction (testing status bit 0 or 1) because he knows what the data format is. Status bit 2, the equal bit, is set if the two words compared are equal. In many instructions, only one number is involved or a new number is determined as the result of an arithmetic operation. For these instructions status bits 0, 1 and 2 are set as the result of comparisons against zero; that is, if the single number or answer obtained is greater than zero or equal to zero. 4-8 9900 FAMILY SYSTEMS DESIGN Hardware Design: ARCHITECTURE Architecture and Interfacing Techniques MEMORY-TO-MEMORY ARCHITECTURE The 9900 family of processors employs memory-to-memory architecture in the execution of instructions. Memory-to-memory architecture is that computer organization and instruction set which enables direct modification of memory data via a single instruction. That is, a single instruction can fetch one or two operands from memory, perform an arithmetic or logical operation, and also store the result in memory. In doing so, some of the on-chip registers are used as temporary buffers in much the same manner as an accumulator is used in other systems. but instructions to load an accumulator and store the accumulator are rarely necessary in memory- to-memory architecture. A single 9900 instruction (arithmetic or logical) does the work of two or more instructions in other systems. Figure 4-8 describes the technique used by the 9900 to locate words in memory as "registers" in the workspace. Additional information is included for reference purposes. Registers 1-15 may be used for indexing (see the description of this addressing mode in Chapter 5 and 6). Register 0 may be used for a shift count. Registers 11 and 13-15 are used for subroutine techniques. Register 12 is a base value for CRU instructions. These special uses of the workspace registers are stated here as an initial evaluation of the register set. Program control and CRU instructions make use of the contents of registers 11-15; therefore, programmers and systems designers must be aware that while use of these registers is not restricted to their special functions, they should be used with caution in performing other functions. The use of these workspaces in an actual application is best described in the Software Design chapter. But the step-by-step execution of the instructions is of concern in hardware design because of the execution speed and the techniques for handling interrupts. Instruction cycles in the 9900 require memory access not only for the instruction words but also for operand addresses and actual operands (or numbers to be operated upon.) A simple add instruction requires at least four memory cycles: one to fetch the instruction, two to access the two numbers to be added, and one to store the result. As will be explained in detail later in this chapter, the execution of an add instruction may require as many as eight memory cycles (because of the addressing mode.) The execution steps are not the same for all instructions. There is, in fact, substantial variation of execution steps within any one instruction due to addressing. Tables and charts are provided in this chapter to explain the execution time of each instruction. 9900 FAMILY SYSTEMS DESIGN 4-9 ARCHITECTURE Hardware Design: Architecture and Interfacing Techniques REGISTER USE MEMORY ADDRESS REGISTER I WORKSPACE POINTER IQ WP+ 00 0 0 - OPTIONAL SHIFT WP +02 1 COUNT WP+ 04 2 WP +06 3 WP+OS 4 WP+OA 5 WP +OC 6 WP +OE 7 DATA INDEX WP+ 10 8 WP+ 12 9 WP+ 14 10 WP+ 16 11 11 - BL RETURN ADDRESS WP+ 18 12 12 - CRU BASE ADDRESS WP+ 1A 13 13 - SAVED WP WP+ 1C 14 14 - SAVED PC WP+ 1E 15 15 - SAVED ST Figure 4-8. 9900 Workspace Registers There is one additional concept regarding microp~ocessor and memory interfacing to be introduced at this time: it is the way in which data is stored in the memory. Figure 4-9 shows the bit numbering for a general 16-bit data word or instruction. Instructions and 16-bit data words are always located at even addresses. Since the memory is byte addressable, even and odd bytes are the left and right half word~ in the 16-bit memory organization and have even or odd addresses respectively. Memories for the TMS9900 and SBP9900A contain 16 bits perword, while the other processors in the family use 8- bit memory structures. But all use the same addressing concept: a 16-bit address describing a 64k-byte address space. MSB LSB I I o SIGN 2 3 4 5 6 7 s 9 I10 , ,, I I I I I 12 13 14 1s BIT MEMORY WORD (EVEN ADDRESSI MSB LSB MSB LSB I0 I SIGN 2 3 1I 4 5 6 I Is I I I I I 7 SIGN 9 10 11 12 13 j 14 I1s j \BIT "BIT I v v EVEN BYTE ODD BYTE Figure 4-9. Word and Byte Formats 4-10 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and ARCHITECTURE Interfacing Techniques CONTEXT SWITCHING One of the more important advantages of the workspace architecture of the 9900 is the fact that "register save and restore" operations are greatly simplified. In any interrupt processing system, provisions must be made to perform an orderly transition into a new program segment in response to an interrupt. In other microprocessor systems, the first few instructions of an interrupt service routine perform the steps of saving register contents in memory, and then loading new values into the registers. In the 9900, an interrupt cycle starts with a hardware operation to save the contents of the three key registers, the WP, PC and ST. In addition, the WP and PC must be loaded with new numbers. Figures 4-10 and 4-11 show an example of the technique. Prior to the interrupt, the WP locates the workspace (pointing to 0800), the PC locates the current instruction (pointing to 0100), and the ST contains the status as a result of the execution of the current instruction (e.g., 4000). At the end of execution, the processor tests for an interrupt condition and finding it, performs a context switch as follows. Step 1. The new WP value is fetched from the appropriate interrupt vector location in the first 3 2 words of memory. This identifies the location of the workspace assigned to the interrupt service routine. Step 2. The current values of the WP, PC and ST registers are stored in the new workspace - ST in R15, PC in R14, WP in R13 in that order. After this, the new PC value is fetched from memory (the second location of the two-word interrupt vector) and loaded into the PC. 9900 MEMORY WP 0800 PROGRAM A PC 0100 PROGRAM B ST I 4000 WORKSPACE A WORKSPACE B Figure 4-10. Before Context Switch 9900 FAMILY SYSTEMS DESIGN 4-11 MEMORY Hardware Design: Architecture and Interfacing Techniques 9900 MEMORY l ~ WP 0820 PROGRAM A PC [ 0200 ... PROGRAM B ST I I WORKSPACE A ~ WORKSPACE B 0800 R13 0102 R14 4000 R15 Figure 4-11. After Context Switch Step 3. With the context switch completed, processing resumes with the first instruction in the interrupt service routine. Processing continues in this mode until, at the end of the interrupt routine, an RTWP instruction is encountered. A "reverse" context switch now occurs to return to the previous program. Since R13, 14 and 15 contain the control register contents for the previous program, they are now transferred to the CPU which loads them into the WP, PC and ST. Processing resumes from the point at which the interrupt occurred. The obvious advantage of context switching is the reduced register-save register-restore operations required by microprocessors in an interrupt environment. The context switch is also used as a subroutine technique. This is described in Chapters 5 and 6, but the important fact is that context switching is, to the designer, a single step, when in fact several steps are performed by the microprocessor. MEMORY The 9900 is easily interfaced to any of the standard types of semiconductor memory devices. Texas Instruments provides masked ROMs, field-programmable ROMs (PROMs), and erasable PROMs (EPROMs) for non-volatile program and data storage. RAMs are available in sizes from a 64 x 8 static RAM to the 64K dynamic RAMs for use as a temporary program and data storage. 9900-compatible memory devices are listed in Chapter 2. 4-12 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MEMORY Interfacing Techniques MEMORY ORGANIZATION The 9900 instructions build a 16-bit address word which describes a 64K x 8 bit address space. A memory map for the 9900 is shown in Figure 4-12. MEMORY AREA DEFINITION ADDRESS15 MEMORY CONTENT 0 15 RESET VECTOR { 0000 0002 WP PC WP LEVEL 0 INTERRUPT LEVEL 0 INTERRUPT LEVEL 1 INTERRUPT 0004 0006 PC LEVEL 1 INTERRUPT INTERRUPT VECTORS 003C WP LEVEL151NTERRUPT 003E PC LEVEL151NTERRUPT 0040 WP XOPO 0042 PC XOPO XOP SOFTWARE TRAP VECTORS 007C WP XOP 15 007E PC XOP 15 0080 • • • GENERAL MEMORY AREA GENERAL MEMORY FOR MAY BE ANY PROGRAM, DATA, AND COMBINATION OF WORKSPACE REGISTERS PROGRAM SPACE OR WORKSPACE • • LOAD SIGNAL VECTOR { FFFC FFFE WP PC LOAD FUNCTION LOAD FUNCTION Figure 4-12. TMS 9900 Dedicated Memory Addresses 9900 FAMILY SYSTEMS DESIGN 4-13 MEMORY Hardware Design: Architecture and Interfacing Techniques RESET Vector The first two memory words are reserved for storage of the RESET vector. The RESET vector is used to load the new WP and PC whenever the CPU RESET signal occurs. The first word contains the new WP, which is the starting address of the RESET workspace. The second word contains the new PC, which is the starting address of the RESET service routine. Interrupt Vectors The next thirty memory words, 0004 16 through 003E 16 are reserved for storage of the interrupt transfer vectors for levels 1 through 15. Each interrupt level uses a word for the workspace pointer (WP) and a word for the starting address of the service routine (PC). If an interrupdevel is not used within a system, then the corresponding two memory words can be used for program or data storage. Software Trap Vectors ·4 The next thirty-two memory words, 0040 16 through 007E 16 , are used for extended- operation software trap vectors. When the CPU executes one of the 16 extended operations (XOPs), the program traps through the corresponding vector. Two words are reserved for each trap vector, with one word for the WP and one word for the PC. If an XOP instruction is not used, the corresponding vector words can be used for program or data storage. LOAD Vector The last two memory words FFFC 16 and FFFE 16 are reserved for the LOAD vector, with one word for the WP and one word for the PC. The LOAD vector is used whenever the CPU LOAD signal is active (low). Transfer Vector Storage The transfer vectors can be stored either in ROM or RAM, but either the RESET or LOAD vector should be in non-volatile memory and should point to a program in non-volatile storage to ensure proper system start-up. The restart routine should initialize any vector which is in RAM. The program can then manipulate the RAM-based vectors to alter workspace assignments or service routine entry points, while ROM-based vectors are fixed and cannot be altered. 4-14 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MEMORY Interfacing Techniques MEMORY CONTROL SIGNALS The 9900 uses three signals to control the use of the data bus and address bus during memory read or write cycles. Memory enable (MEMEN) is active low during all memory cycles. Data bus in (DBIN) is active high during memory read cycles and indicates that the CPU has disabled the output data buffers. Write enable (WE) is active low during memory write cycles and has timing compatible with the read/write (R/W) control signal for many standard RAMs. Memory Read Cycle Figure 4-13 illustrates the timing for a memory read machine cycle with no wait states. At the beginning of the machine cycle, MEMEN and DBIN become active and the valid address is output on AO-Al4. DO-D15 output drivers are disabled to avoid conflicts with input data. WE remains high for the entire machine cycle. The READY 4<1111 input is sampled on C/J 1 of clock cycle 1, and must be high if no wait states are desired. Data is sampled on C/J 1 of clock cycle 2, and set-up and hold timing requirements must be observed. A memory-read cycle is never followed by a memory-write cycle, and DO-D15 output drivers remain disabled for at least one additional clock cycle. Memory Write Cycle Figure 4-14 illustrates the timing for a memory write machine cycle with no wait states. MEMEN becomes active, and valid address and data are output at the beginning of the machine cycle. DBIN remains inactive for the complete cycle. WE goes low on C/J 1 of clock cycle 1 and goes high on C/J 1 of clock cycle 2, meeting the address and data set-up and hold timing requirements for the static RAMs listed in Chapter 2. For no wait states, READY must be high during C/J 1 of clock cycle 1. Read/Write Control with DBIN In some memory systems, particularly with dynamic RAMs, it may be desirable to have READ and WRITE control signals active during the full memory cycle. Figure 4-15 shows how the WRITE signal can be generated. Note that DBIN is high only for READ cycles; therefore, MEMEN can be NORed with DBIN to yield a WRITE signal which is high only during memory write operations. Slow Memory Control" Although most memories operate with the 9900 at the full system speed, some memories cannot properly respond within the minimum access time determined by the system clock. The system clock could be slowed down in order to lengthen the access time but the system through-put would be adversely affected since non-memory and other memory reference cycles would be unnecessarily longer. The READY and WAIT signals are used instead to synchronize the CPU with slow memories. The timing for memory-read and memory-write cycles with wait states is shown in Figures 4-16 and 4-17. 9900 FAMILY SYSTEMS DESIGN 4-15 MEMORY Hardware Design: Architecture and Interfacing Techniques w c 0 ...:11:::::> Q. z --- --- -- -- --- --- 1 N w - ... C<( .J <( ~c .J u > u ..,.4 ~ u 0 .J u ~ w i a: c c --- --- --- -- --- -- <( w c c 0 .J :11: ...::::> w Q. .J z u > u ~ u 0 .J u l --- --- - > II z Cii c I~ 0 c c u ~ u 0 ...I u w ...I u > u ~ u 0 ...I u J_ > Ii z al c I~ c ~ UJ cc Figure 4-14. Memory-Write Cycle Timing 9900 FAMILY SYSTEMS DESIGN 4-17 - MEMORY Hardware Design: Architecture and Interfacing Techniques OBIN t - - - - - + - - - - - - - - - - - - - R E A D TMS 9900 11-----WRITE Figure 4-15. Read/ Write Control Using MEMEN and DBIN The READY input is tested on 1> 1 of clock cycle 1 of memory-read and memory-write cycles. If READY= 1, no wait states are used and the data transfer is completed on the next clock cycle. If READY= 0, the processor enters the wait state on the next clock cycle and all memory control, address, and data signals maintain their current levels. The WAIT output goes high on ¢ 3 to indicate that a wait state has been entered. While in the wait state, the processor continues to sample READY on ¢ 1, and remains in the wait state until READY= 1. When READY= 1 the processor progresses to clock cycle 2 and the data transfer is completed. WAIT goes low on ¢ 3. It is important to note that READY is only tested during¢ 1, of clock cycle 1 of memory-read and memory-write cycles and wait states, and the specified set-up and hold timing requirements must be met; at any other time the READY input may assume any value. The effect of inserting wait states into memory access cycles is to extend the minimum allowable access time by one clock period for each wait state. Wait State:Control Figure 4-18 illustrates the connection of the WAIT output to the READY input to generate one wait state for a selected memory segment. The address decode circuity generates an active low signal (SLOMEM = 0) whenever the slow memory is addressed. For example, if memory addresses 80001 6 - FFFE1 6 select slow memory, SLOMEM =AO. If one wait state is required for all memory, WAIT may be connected directly to READY, causing one wait state to be generated on each memory-read or memory-write machine cycle. Referring again to Figures 4-16 and 4-17 note that the WAIT output satisfies all of the timing requirements for the READY input for a single wait state. The address decode signal is active only when a particular set of memory locations has been addressed. Figure 4-19 illustrates the generation of two wait states for selected memory by simply delaying propagation of the WAIT output to the READY input one clock cycle with a D-type flip-flop. The rising edge of¢ 2TTL is assumed to be coincident with the falling edge of the ¢ 2 clock input to the TMS 9900. 4-18 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MEMORY Interfacing Techniques w c 0 ~ ....::::> a. z i N w .J (.J > u ~ (.J 0 .J (.J t w 1- (.J ~ (.J 0 .J (.J i ... LO I! > c z c <( iii c I~ 0 c w a: Figure 4-16. Memory-Read Cycle With One Wait State 9900 FAMILY SYSTEMS DESIGN 4-19 MEMORY Hardware Design: Architecture and Interfacing Techniques ~CLOCK CYCLE 1 WAIT STATE CLOCK CYCLE 2---..j 1 2 3 n n n rt>4 I n n n I ME'MEN ~ v OBIN WI I .. 4 I I l AO-A14 ~ I VALID ADDRESS c I D0-015 ~ I VALID WRITE DATA c I READY )()(XXXXXXXXXXX IXXXXXXXXXI lXXXXX?Z>e·r €A:R5 T (/) (/) w a: c c (,) (,) .,.ra w ..I 0 > 0 > .9 :I: . ..I Q.. l1 ...c I! Ln z Cii 6 c c Figure 4-20. Memory Access Timing Calculation 4-22 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MEMORY Interfacing Techniques STATIC MEMORY Static RAMs and PROMs are easily interfaced to the 9900. A 9900 memory system using the TMS 4042-2 256 X 4 static RAM and the TMS 2708 lK X 8 EPROM is shown in Figure 4-21. Address The most-significant address bit, AO, is used to select either the EPROMs or the RAMs during memory cycles. When AO is low, the EPROMs are selected, and when AO is high, the RAMs are selected. Address lines Al through A4 are not used since the full address space of the TMS 9900 is not required in the example. The lower address bits select internal RAM or EPROM cells. Other memory systems can fully decode the address word for maximum memory expansion. Control Signals Since DBIN is also used to select the EPROMs during memory-write cycles, the 4~ EPROMs cannot inadvertently be selected and placed into output mode while the CPU is also in the output mode on the data bus. MEMEN is used to select the RAMs during either read or write cycles, and WE is used to select the read/write mode. DBIN is also used to control the RAM output bus drivers. The 9900 outputs WE three clock phases after the address, data, and MEMEN are output. As a result, the address, data, and enable-hold times are easily met. WE is enabled for one clock cycle and satisfies the minimum write pulse width requirement of 300 nanoseconds. Finally, WE is disabled one clock phase before the address, data, and other control signals and meets the TMS 4042-2 SO-nanosecond minimum data and address hold time. Loading The loads on the CPU and memory outputs are well below the maximum rated loads. As a result no buffering is required for the memory system in Figure 4-21. The TMS 4042-2 and the TMS 2708 access times are low enough to eliminate the need for wait states, and the CPU READY input is connected to Vcc· The minimum high-level input voltage of the TMS 2708 is 3 volts while the maximum high-output voltage for the TMS 9900 is 2.4 volts at the maximum specified loading. For the system in Figure 4-21, the loads on the CPU and memory outputs are well below the maximum rated load. At this loading, the TMS9900 output voltage exceeds 3 volts, so pull-up resisters are not needed. There are many other Texas Instruments static memories compatible with the TMS 9900. Most memory devices do not require wait states when used with the TMS 9900 at 3 MHz. 9900 FAMILY SYSTEMS DESIGN 4-23 MEMORY Hardware Design: Architecture and Interfacing Techniques ..--.--_1>.llJLli·nJ:VI i 1~0---~ 1----~ ~19 ~ --IE i I~ ___ g;:rK St·l:LO ___. r- 1~0---~ I---+--+-- < j IEo---~ !-------+--< ----QIE ~ '~---~ t---< g;:r .--.--Ji!:'-'-~---~...... i 1c;'!'l'\------l ----+--- ~ IE'.t.'". - - r---+-----< ----ulE ~ r:cc:::ia;;----1 t---< t- g !......,..--=-I~"'-"A' v ..--..--"~L·~Lv..,.. i lo~-----i t----i---t--- ~ 1&1,o---~ ~ .,...__-QIE § '~c: :J(J f------1 ! 0:::.-~11'---....,,.,rif :::c '° 0 (j) c; ~ 0 ::::. :T Q. "!'j ;:i;. +5 ~ ;: == __,. _,. -· n D> 3:: +5 +5 ~ 2' CD -4 CD c ~ TIM 9904 4 8 PR ~ D> m VJ --< RFGNT -·iiFGNT s ace·~ VJ ~ :E .....] ~· c tT'l ~ CD 3:: en VJ ~ t:J ~ ,, ,2 93 o;J4 ~ tT'l l VJ cs z ~ OBIN ~I V) AOl--------f ~ Ri'ii RAM ~ ~ crq READY ~ CONTROL S' ~ TMSWOO 1A CE ~ ~ (:)· ~ ~ 2QA RFA10 RFA9 :ZOB ~ ~ ~ s.. SN74LS241 ~ A9-A14 / 1A, "": 2A A1-A8 ~ l ~ V) R"rnNr ~ <:::::> v-. 2G 1G ~ ) / ---~~:· ~~i / :;1 3: RAM A9 - RAM A14 SN74LS241 tTj RAM ADDRESS LINES 3: A1-A8 0 ~ ~ N -...) ~ MEMORY Hardware Design: Architecture and Interfacing Techniques While the transparent refresh mode eliminates refresh-related system performance degradation, the system power consumption can be higher since the RAMs are refreshed more often than required. As many as one-half of the CPU machine cycles can be refresh cycles, resulting in multiple refresh cycles for each row during the refresh interval. This situation can be corrected by adding a timer to determine the start of the refresh interval and an overflow detector for the refresh row counter. When every row has been refreshed during an interval, the refresh circuit is disabled until the beginning of the next interval. Since each row is refreshed only once, the system power consumption is reduced to a minimum. Direct memory access using HOLD should guarantee that sufficient non-memory cycles are available for refresh during large block transfers. An additional refresh timer can be used to block HOLDA in order to provide periodic refresh cycles. BUFFERED MEMORY ~ 4 The TMS 9900 outputs can drive approximately two standard TTL inputs and 200 picofarads. Higher capacitive loads may be driven, but with increased rise and fall times. Many small memory systems can thus be directly connected to the CPU without buffer circuits. Larger memory systems, however, may require external bipolar buffers to drive the address or data buses because of increased loading. Texas Instruments manufactures a number of buffer circuits compatible with the TMS 9900. The SN74LS241 noninverting-octal buffer with three-state outputs is an example of a buffer circuit. A TMS 9900 memory system with address and data bus buffering is shown in Figure 4- 23. The system consists of sets of four 256 X 4 memory devices in parallel to provide the 16-bit data word. The four sets of four devices provide a total of 1024 words of memory. The memory devices can be the TMS 4042-2 NMOS static RAM. The SN74S412 octal buffer/latch is designed to provide a minimum high-level output voltage of 3.65 V. Buffered TMS 9900 memory systems containing the TMS 4 700 ROM or the TMS 2708 EPROM, for example, require input voltages in excess of the output voltages of many buffer circuits. The SN74S412 can be used to buffer the memories without the pull-up resistors needed for buffers. MEMORY p ARITY Parity or other error detection/ correction schemes are often used to minimize the effects of memory errors. Error detection schemes such as parity are used to indicate the presence of bad data, while error correction schemes correct single or multiple errors. 4-28 9900 FAMILY SYSTEMS DESIGN 5" l> :::c '°'° 0 0 ~ i g. ~ fG ~ ~ ;- -· Q. 'Tl n ;- ::e > T T 3:: 4 2G 1Y-8r A7B( A14B 7 8 T I ,g-· cn ii)m ...... -t ii) c ~ AO-A14 _ 1A-8A *5 ~ CD Q) CD (fl g. [ iE· -< SN74LS139 cs 00-3 ~ :::I .s· .. :::::s ..., (fl CS D0-31+1 c A·H A-H A·H ~A-H ~ tTl A5: . . CD 3:: ~ Ill (fl ~- 7f 0 0 :: G tTl VJ (fl ~ TMS 9f!OO 0 ~ z ~ O::l WE~------, .J\~~~ WEA rTics oo-3H ~A-H fTi cs L--:1A-H 00-314 ~A-H cs 00--3 cs A·H D0--3~ ~ rl~J·· . . . . ~ 2K WEB ~ ~ 11~·· .... ~ ~ ~ 2K 11~----- WEC cs 00-3 cs 00-3 n lcs 00-J~ Llcs oo-31- ~A-H @ §:: 2K WED . A-H . A-H A-H . . +5 ~ q~--~ :.:· ~ ~ CS 00-3 CS D0-3 CS D0-3 CS 00-3~ ~ A·H A-H A·H A-H ......... . . . . ~ ~ OBIN J: I J:rn I 1 ] l--- ] 1Cr 2G 2G 1G ~ 2G 1G 2G D0-015 1A/2Y 2A/1Y 1A/2Y 2A/1Y 1A/2Y 2A/1Y 1A/2Y 2A/1Y ~ tT'.l ~ • R/W TMS 4043-2 SN74LS241 SN74LS241 SN74LS241 SN74LS241 or ~ SN74S287 **IF SWITCH IS OPEN, RAMs ARE USED. 0 ~ t- N '° .. ~ MEMORY Hardware Design: Architecture and Interfacing Techniques The SN74LS280 parity generator/checker can be used to implement memory parity in a TMS 9900 system. The system in Figure 4-24 uses two SN74LS280 circuits to generate and to check the odd-memory parity. During memory write cycles, the generated parity bit is output to bit D16 of the memory. During memory read cycles, the parity is checked and an interrupt, PARERR, is generated if the parity is even. It should be noted that the faulty memory word will have already been used by the CPU as an op code, address, or data before the interrupt is generated. This can cause trouble in determining the exact location of the error. For example, an error in bit 8 of the CLR op code will cause the CPU to branch unconditionally. When the interrupt is serviced, there would then be no linkage to the part of the program at which the error occurred. A diagnostic routine can often isolate such errors by scanning the memory and checking parity under program control. Such a parity error in the diagnostic itself can be extremely difficult to isolate. IJlli> 4 An external address latch clocked at IAQ can be used to retain program linkage under the above circumstances. When the parity error is detected, the address latch is frozen, thus pointing to the address of the instruction during which the parity error occurred. MEMORY LAYOUT It is generally advantageous to lay out memory devices as arrays in the system. The advantages are twofold. First, positioning the devices in an orderly fashion simplifies identification of a particular memory element when troubleshooting. Second, and most important, layout of memory arrays simplifies layout, shortens interconnections, and generally allows a more compact and efficient utilization of board space. Crosstalk between adjacent lines in memory arrays is minimized by running address and data lines parallel to each other, and by running chip enable signals perpendicular to the address lines. Memory devices, particularly dynamic RAMs generally require substantially greater supply currents when addressed than otherwise. It is therefore important that all power and ground paths be as wide as possible to memory arrays. Furthermore, in order to avoid spikes in supply voltages, it is advisable to decouple supply voltages with capacitors as close as possible to the pins of the memory devices. As an example, a system containing a 4K x 16-bit array ofTMS 4051s should contain one 15 µF and one 0.05 µF capacitor for each set of four memory devices; with the large capacitors decoupling Vnn, and the small capacitors decoupling VBB· 4-30 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MEMORY Interfacing Techniques > a: 0 ~ w ~ ... ~ ...... in (Q ~ cc Cl) 6 c ~ w I- c 10 <( p- I- Cl) c ~ I- q - r <( ~ <( a: 0 -I 0 CJ z ~ Cl) > !: in + a: <( • ..J qo a: c.. <( ,...r--f 9 __). z" c ~ Cl) c ~ c.. 0 "'". J L ~ 0 c ... in 9 tO c L~ ~ -(J 0 l 10 p-~ c A c.. 0 A ~ '7 tO N tO Cl) -,. -I qo -e. " zw z Cl) > w a: a: w ... in a: <( 9 ll. 8 ~ ~ z ~ 0 iii I- 0 m m :::> c -- c.. ..J :::> 0 CJ a: a: - c.. ~ a: I- C!J Cll CJ wzO ::E ~ I- 0 ..J I- ~CJ Figure 4-24. Memory Parity Generator Checker 9900 FAMILY SYSTEMS DESIGN 4-31 INSTRUCTION EXECUTION Hardware Design: Architecture and Interfacing Techniques INSTRUCTION EXECUTION Execution time for an instruction is a function of the clock frequency, the number of clock cycles, the number of memory accesses and the number of wait states if required for slower memories. The following tables list the number of clock cycles required to execute each instruction if no wait states are required. The number of memory accesses is also given so that the extra clock cycles can be calculated for the number of wait states required. A wait state is entered when the ready signal from the memory does not go high within one clock period after initiation of a memory cycle. For example: The clock frequency for the TMS 9900 is 3 MHz. From the calculation of maximum access time for no wait states, the memory access time must be less than 512 ns. One wait state (of 3.33 ns duration) will be required for memories with access times between 512 ns and 845 ns, two wait states will be required if the access time is between 845 ns and 1.178 µ sec, and so on. TIMING From Figure 4-25, the first execution time table, an add instruction (A) using direct register addressing for both operands requires 14 clock cycles if there are no wait states required. For other addressing modes, the number of clock cycles increases to a maximum of 30. If the memory requires one wait state per access, an additional four clock periods will be required since there are four memory cycles in the execution of an add instruction. For the TMS 9900 running at 3 MHz, 14 clock periods will take 4.667 microseconds; 30 clock periods will take 10.0 microseconds. The number of memory cycles is from 4 up to 8 depending upon addressing mode (3 to 7 for compare, C). Use the tables in the following manner. Assuming one wait state, a clock frequency of 3 MHz, and an instruction with complex addressing, the tables can be used to determine the execution time for the instruction A *Rl,@ LIST is 26 clock cycles for fetch and execution and 6 clock cycles for wait states, or 32 x .333 microseconds which is 10.667 microseconds. Figures 4-26, 27 and 28 give the rest of the execution time data, always by number of clock cycles (assuming no wait states) and memory cycles. 4-32 9900 FAMILY SYSTEMS DESIGN Hardware Design: INSTRUCTION EXECUTION Architecture and Interfacing Techniques INSTRUCTIONS A, Ct, S, SOC, SZC, MOV Destination Source Address Address R "'R ':'R+ @LIST @TABLE (R) R 14 18 22 22 22 ':'R 18 22 26 26 26 Clock ':'R+ 22 26 30 30 30 Cycles @LIST 22 26 30 30 30 @TABLE (R) 22 26 30 30 30 R 4 5 6 5 6 ':'R 5 6 7 6 7 Memory "'R+ 6 7 8 7 8 Cycles @LIST 5 6 7 6 7 @TABLE (R) 6 7 8 7 8 R 3 4 5 4 5 tMemory ':'R 4 5 6 5 6 Cycles ':'R+ 5 6 7 6 7 for C @LIST 4 5 6 5 6 instr. @TABLE (R) 5 5 6 7 6 Figure 4-25. INSTRUCTIONS: AB, CBtt, SB. SOCB, SZCB, MOVB Destination Source Address Address R ':'R ':'R+ @LIST @TABLE (R) R 14 18 20 22 22 ·~R 18 22 24 26 26 Clock ':'R+ 20 24 26 28 28 Cycles @LIST 22 26 28 28 28 @TABLE (R) 22 26 28 28 28 R 4 5 6 5 6 ':'R 5 6 7 6 7 Memory ':'R+ 6 7 8 7 8 Cycles @LIST 5 6 7 6 7 @TABLE (R) 6 7 8 7 8 R 3 4 5 4 5 ttMemory ':'R 4 5 6 5 6 Cycles '~R + 5 6 7 6 7 for CB @LIST 4 5 6 5 6 instr. @TABLE (R) 5 6 7 6 7 Figure 4-26. 9900 FAMILY SYSTEMS DESIGN 4-33 INSTRUCTION EXECUTION Hardware Design: Architecture and Interfacing Techniques INSTRUCTIONS LDCR, STCR LDCR Addressing Bit Count, C Mode 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 R 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 ':'R 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 Clock ~·R + 28 30 32 34 36 38 40 42 46 48 50 52 54 56 58 60 Cycles @LIST 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 @TABLE (R) 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 R 3 3 ':'R 4 4 Memory ':'R+ 5 5 Cycles @LIST 4 4 @TABLE (R) 5 5 STCR Addressing Bit Count, C Mode 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 R 42 42 42 42 42 42 42 44 58 58 58 58 58 58 58 60 ':'R 46 46 46 46 46 46 46 48 62 62 62 62 62 62 62 64 Clock ·:·R+ 48 48 48 48 48 48 48 50 66 66 66 66 66 66 66 68 Cycles @LIST 50 50 50 50 50 50 50 52 66 66 66 66 66 66 66 68 @TABLE (R) 50 50 50 50 50 50 50 52 66 66 66 66 66 66 66 68 R 4 4 ':'R 5 5 Memory ':'R .. 6 6 Cycles @LIST 5 5 @TABLE (R) 6 6 Figure 4-27. 4-34 9900 FAMILY SYSTEMS DESIGN Hardware Design: Arcllitecture and INSTRUCTION EXECUTION Interfacing Techniques Clock Cycles Memory Cycles Instruction R •:•R ·:·R+ @LIST, @TABLE (R) R •:•R •:•R+ @LIST @TABLE (R) ABS MSB=O 12 16 20 20 20 2 3 4 3 4 MSB= 1 14 18 22 22 22 3 4 5 4 5 B 8 12 16 16 16 2 3 4 3 4 BL 12 16 20 20 20 3 4 5 4 5 BLWP 26 30 34 34 34 6 7 8 7 8 CLR 10 14 18 18 18 3 4 5 4 5 DEC 10 14 18 18 18 3 4 5 4 5 DECT 10 14 18 18 18 3 4 5 4 5 INC 10 14 18 18 18 3 4 5 4 5 INCT 10 14 18 18 18 3 4 5 4 5 INV 10 14 18 18 18 3 4 5 4 5 NEG 12 16 20 20 20 3 4 5 4 5 SETO 10 14 18 18 18 3 4 5 4 5 SWPB 10 14 18 18 18 3 4 5 4 5 XOP 36 40 44 44 44 8 9 8 9 8 XOR 14 18 22 22 22 4 5 6 5 6 Figure 4-28. CYCLIC OPERATION ·An example of a machine cycle sequence is illustrated in Figure 4-29. For an add instruction the machine cycles alternate between memory cycles and ALU cycles. The first cycle is always a memory read cycle to fetch the instruction and the second is always an ALU cycle to decode the instruction. Each machine cycle requires two clock cycles, thus the 7 machine cycles shown for the add instruction require 14 clock cycles. A R1, R2 1 Memory Read Instruction Fetch 2 ALU Decode Opcode 3· Memory Read Fetch (WR1) 4 ALU Set Up 5 Memory Read Fetch (WR2) 6 ALU Addition 7 Memory Write Store Result in WR2 and Increment PC Figure 4-29. Machine Cycles for an Add Instruction 9900 FAMILY SYSTEMS DESIGN 4-35 INSTRUCTION EXECUTION Hardware Design: Architecture and Interfacing Techniques The 9900 performs its functions under control of a 4-phase clock and, fundamentally, performs instruction fetch and execution cycles. Figure 4-30 illustrates the step-by-step procedure the 9900 uses to execute an add instruction. From previous cycles, the workspace pointer has been loaded with the number 0800, and the program counter contains the number 0100. Step 1. The first step in any instruction cycle is to fetch the instruction. This is accomplished by gating the content of the program counter into the memory address register. The output of the memory address register is the address bus which is connected to the memory. In this case, word number 0100 is read from the memory and placed in the instruction register on the 9900 chip. From this point, the ones and zeros of the instruction register control the sequence of microcode stored in the microcontrol read only memory on the 9900 chip. These microsteps become the execution phase of the instruction. ~ 4 Step 2. At this point, the microcontrol shifts to the execution of an add instruction; the first operand must be obtained from memory. In order to do this, the workspace pointer and a portion of the instruction word (the source operand register number) are added together via the ALU and placed in the memory address register. Step 3. The address 0802 is the result (in this example), and being supplied to the memory produces on the data bus the content of memory word 0802 which is the binary equivalent of 25. This number must be stored in a temporary register on the 9900 chip, in this case the Tl register. Step 4. Now a second operand must be fetched. Again the workspace pointer is added to the content of that portion of the instruction word which is the destination register identifier. The sum of these two is 0804 for register two, and this number is placed in memory address register and goes out on the address bus. Step 5. Memory word 0804 is read and the number 10 is brought into the 9900 chip. The register which stores the second operand is called the source data register or S register. Step 6. At this point the two operands have been loaded into registers on the 9900 chip and may be added by the ALU to produce the result. Register Tl containing 25 is added to the register S which contains 10 and the sum, 35, replaces the 10 in the S register and is placed on the data bus via the S register. Step 7. The address bus still contains the number 0804 which was the address of the second operand and is the location in memory where the result is to be stored. So at this point in the cycle, a memory write cycle is initiated and the binary equivalent of 35 is stored in memory location 0804. At the conclusion of this memory cycle the program counter is incremented by two to point to the next sequential memory word, which is the instruction to be executed next. 4-36 9900 FAMILY SYSTEMS DESIGN Hardware Design: INSTRUCTION EXECUTION Architecture and Interfacing Techniques CPU MEMORY PC MAR INSTRUCTION •I...__ 0_10_0_16_ _, .-11010 0000 1000 0001 CYCLE 1: FETCH INSTRUCTION 1010 00 00 0001 INSTR. REGISTER WP IR 080016 1010 00 0010 ALU CYCLE 2: SET-UP MAR 08021 6 Figure 4-JOa. Add Instruction Cycle 9900 FAMILY SYSTEMS DESIGN 4-37 INSTRUCTION EXECUTION Hardware Design: Architecture and Interfacing Techniques CPU MEMORY MAR OPERAND CYCLE 3: 16 .___o_s_o2__ _:------11•~1 0000 0000 0010 0101 FETCH FIRST OPERAND T1 002516 WP JR 1010 00 0010 CYCLE 4: X2 SET-UP ALU MAR Figure 4-JOb. Add /nstructiof? Cycle 4-38 9900 FAMILY SYSTEMS DESIGN Hardware Design: INSTRUCTION EXECUTION Architecture and Interfacing Techniques CPU MEMORY MAR OPERAND 0000 0001 0000 CYCLE 5: ...__o_so_4_1b_;---t--.. ..... 1 0000 FETCH SECOND OPERAND s 00101b T1 S (BEFORE) CYCLE 6: ADD ALU S (AFTER) PC MAR RESULT 010216 080416 ~I 0000 0000 I 0011 0101 CYCLE 7: f STORE ( RESULT SB Figure 4-JOc. Add Instruction Cycle 9900 FAMILY SYSTEMS DESIGN 4-39 INSTRUCTION EXECUTION Hardware Design: Architecture and Interfacing Techniques After all steps have been done, the processor checks to see if there is any pending interrupt operations to be performed and, if not, fetches the next instruction and the cycle continues. In the event that an interrupt signal were present, the processor would proceed to the appropriate interrupt service routine and continue execution from that point. Interrupts are described in detail in a special section of this chapter. Each operation performed by the 9900 consists of a sequence of machine cycles. In each machine cycle the processor performs a data transfer with memory or with CRU and/or an arithmetic or logical operation internally with the ALU. A detailed discussion of the machine cycles for each instruction is included at the end of the chapter. Each ALU machine cycle is two clock cycles long. In an ALU cycle no external data transfer occurs, but the ALU performs an arithmetic or logical operation on two operands contained internally. The function of the memory read cycle is to transfer a word of data contained in the memory to the processor. An ALU operation may be performed during the memory read cycle. Memory read cycles are a minimum of two clock cycles long. The memory write cycle is identical to the memory read cycle except that data is written rather than read from memory. Each CRU output machine cycle is two clock cycles long. In addition to outputting a bit of CRU data, an ALU operation may also be performed internally. The CRU input cycle is identical to the CRU output cycle except that one bit of data is input rather than output. Machine Cycle Limits Table 4-1 lists information which will be useful for system design. The maximum number of consecutive memory-read cycles is used to calculate the maximum latency for the TMS 9900 to enter the hold state since the hold state is only entered from ALU, CRU input, or CRU output machine cycles. The minimum frequency of consecutive memory I non-memory cycle sequences occurs when the DIV instruction is executed. This number is used to ensure that the refresh rate meets specifications when the transparent-refresh mode described in the memory section is used since memory is refreshed in this mode each time an ALU or CRU cycle follows a memory cycle. Figure 4-31 shows the logic to generate a pulse for each memory access cycle. Consecutive cycle timing is shown in Figure 4-32. 4-40 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INSTRUCTION EXECUTION Interfacing Techniques Table 4-1. Machine Cycle Limits MINIMUM MAXIMUM Consecutive Memory Read Cycles 3 Consecutive Memory Write Cycles 1 Consecutive ALU Cycles 1 51 Consecutive CRU Cycles 1 16 Frequency of Consecutive 5 pairs memory I non-memory cycle (64 machine pairs (used for transparent cycles during refresh) DIV.) vcc MEMEN Q t - - - - MEMCY ~TTL WAIT 11------t K Q1----...., Figure 4-31. Memory Cycle Pulse Generation MEMEN READY ~------------------._ WAIT MEMCY ----...J Figure 4-32. Memory Cycle Pulse Timing 9900 FAMILY SYSTEMS DESIGN 4-41 INPUT /OUTPUT Hardware Design: Architecture and Interfacing Techniques INPUT /OUTPUT The 9900 has three 1/0 modes: direct memory access (DMA), memory mapped, and communications register unit (CRU). This multi-mode capability enables the designer to optimize a 9900 1/0 system to match a specific application. One or all modes can be used, as shown in Figure 4-33. ADDRESS BUS MEMORY SYSTEM MAPPED OMA MEMORY 1/0 RUCLK TMS 9900 CRU RUOUT • COMMUNICATIONS REGISTER UNIT· CRU • MEMORY MAPPED 110 • DIRECT MEMORY ACCESS· OMA Figure 4-33. 9900 I I 0 Capability DIRECT MEMORY ACCESS DMA is used for high-speed block data transfer when CPU interaction is undesirable or not required. The DMA control circuitry can be relatively complex and expensive when compared to other 1/0 methods. However, a special interface device, the TMS 9911, is available for DMA control. The 9900 controls CRU-based 1/0 transfers between the memory and peripheral devices. Data must pass through the CPU during these program-driven 1/0 transfers, and the CPU may need to be synchronized with the 1/0 device by interrupts or status- bit polling. Some 1/0 devices, such as disk units, transfer large amounts of data to or from memory. Program driven 1/0 can require relatively large response times, high program overhead, or complex programming techniques. Consequently, direct memory access (DMA) is used to permit the 1/0 device to transfer data to or from memory without CPU intervention. DMA can result in a high 1/0 response time and system throughput, especially for block data transfers. The DMA control circuitry is somewhat more expensive and complex than the economical CRU 1/0 circuitry and should therefore be used only when required. 4-42 9900 FAMILY SYSTEMS DESIGN Hardware Design: INPUT /OUTPUT Architecture and Interfacing Techniques The 9900-based DMA can occur in the same modes as dynamic memory refresh: block, or cycle stealing. The block and cycle stealing modes, however, use the CPU HOLD capability and are more commonly used. The I/O device holds HOLD active (low) when a DMA transfer needs to occur. At the beginning of the next available non-memory cycle, the CPU enters the hold state and raises HOLDA to acknowledge the HOLD request. The maximum latency time between the hold request and the hold acknowledge is equal to three clock cycles plus three memory cycles. The minimum latency time is equal to one clock cycle. A 3-megahertz system with no wait cycles has a maximum hold latency of nine clock cycles or 3 microseconds and a minimum hold latency of one clock cycle or 0.3 microseconds. When HOLDA goes high, the CPU address bus, data bus, DBIN, MEMEN, and WE are in the high-impedance state to allow the 1/0 device to use the memory bus. The 1/0 device must then generate the proper address, data, and control signals and timing to transfer data to or from the memory as shown in Figure 4-34. Thus the DMA device has 4 ..... control of the memory bus when the TMS 9900 enters the hold state (HOLDA= 1), and may perform memory accesses without intervention by the microprocessor. Since DMA operations, in effect remove the 9900 from control while memory accesses are being performed, no further discussion is provided in this manual. Because the lines shown in Figure 4-34 go into high impedance when HOLDA= 1, the DMA controller must force these signals to the proper levels. The 1/0 device can use the memory bus for one transfer (cycle-stealing mode) or for multiple transfers (block mode). At the end of the DMA transfer, the 110 device releases HOLD and normal CPU operation proceeds. The 9900 HOLD and HOLDA timing are shown in-Figure 4-35. MEMORY MAPPED I I 0 Memory mapped 1/0 permits 1/0 data to be addressed as memory with parallel data transfer through the system data bus. Memory mapped 1/0 requires a memory bus compatible interface; that is, the device is addressed in the same manner as a memory, thus the interface is identical to that of memory. Figure 4-36 shows a memory mapped 1/0 interface with eight latched outputs and eight buffered inputs. In using memory mapped 1/0 for output only, care must be taken in developing the output device strobe to ensure it is not enabled during the initial read of the memory address, since the 9900 family of processors first reads, then writes data to a memory location in write operations. This can be effectively accomplished by using the processor write control signal WE in decoding the output address. 9900 FAMILY SYSTEMS DESIGN 4-43 INPUT /OUTPUT Hardware Design: Architecture and Interfacing Techniques CRU AO-A14 --1 D0-015 7 MEMEN OBIN ...... SYSTEM MEMORY WE WAIT READY TMS 9900 REQUEST HOLD HOLDA GRANT R rl}rt R rt ADDRESS ""OMA DATA 3-STATE MEMEN CONTROL OBIN WE OMA CONTROLLER Figure 4.,.34. DMA Bus Control ., •2 ~~'----­ AO-A14 :::X'----------J---- c=::=:: roo1s :::JC.---------t------y----~i.:L----~ ~------------- ITIM 99061 Q3 0 co 0 04 w J: as u CRUOUTt-----t1--------------------11~ D .... ct Q6 -' RESET ~f--.+-------------a----~ CLEAR 07 RESET Figure 4-37. Latched CR U Interface 4-46 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INPUT /OUTPUT Interfacing Techniques MEMORY ABC O OTHER ABC CRU SN74LS138 INPUT } 6 CIRCUITS 0 TMS 9900 _+s_--1 G1 7 o------.-n s G2A ffi SN74LS151 2 OR 3 SN74LS251 CCI (TIM9905) 4 CRUIN ------------------1 Y 5 6 7 Figure 4-38. Multiplexer CR U Interface TTL Inputs. The SN74LS151 and TIM 9905 (SN74LS251) octal multiplexers are used for CRU inputs as shown in Figure 4.;J8. The multiplexers are continuously enabled with CRUIN equal to the addressed input. The TIM 9905 should be used for larger systems since its three-state outputs permit simple "wire-ORing" of parallel-input multiplexers. Expanding CRU I/O A CRU interface with eight inputs and eight outputs is shown in Figure 4-39 using the TMS 9901. An expanded interface with 16 inputs and 16 outputs is shown in Figure 4- 40 using TTL devices. The CRU inputs and outputs can be expanded up to 4096 inputs and 4096 outputs by decoding the complete CRU address. Larger I/O requirements can be satisfied by using memory mapped 1/0 or by using a CRU bank switch, which is set and reset under program control. When reset, the lower CRU I/O bank is selected, and when set, the upper CRU I/O bank is selected. In actual system applications, however, only the exact number of interface bits required need to be implemented. It is not necessary to have a 16-bit CRU output register to interface a 10-bit device. CRU Machine Cycles Each CRU operation consists of one or more CRU output or CRU input machine cycles, each of which is two clock cycles long. As shown in Table 4-2, five instructions (LDCR, STCR, SBO, SBZ, TB) transfer data to or from the 9900 with CRU machine cycles, and five external control instructions (IDLE, RSET, CKOF, CKON, LREX) generate control signals with CRU output machine cycles. 9900 FAMILY SYSTEMS DESIGN 4-47 INPUT /OUTPUT Hardware Design: Architecture and Interfacing Techniques CRUCLK CRUOUT CRUIN TMS 9900 A10-A14 INTERRUPT 1/F INTERRUPTS (61 TMS 9901 0 7 0 7 81NPUTS --- •••••• 8 OUTPUTS Figure 4-39. 8-Bit CRU Interface > a: 0 :E w :E ADDRESS 1----------tCRUIN A11 1-----------tCRUOUT A11 TMS9900 CPU y D G D SN74LS251 SN74LS251 SN74LS259 SN74LS259 ITIM99051 (TIM 99051 (TIM 99061 (TIM99061 ao J ...... t 0 7 0 7 00 07 07 J . +,/ INPUTS INPUTS OUTPUTS OUTPUTS 8-15 0-7 0-7 8-15 Figure 4-40. 16-Bit CRU Interface 4-48 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INPUT /OUTPUT Interfacing Techniques Table 4-2. Instructions Generating CR U Cycles NUMBER OF TYPE OF DATA INSTRUCTION AO-A2 CRU CYCLES CRU CYCLES TRANSFER LDCR 1-16 Output 000 Yes STCR 1-16 Input 000 Yes SBO 1 Output 000 Yes SBZ 1 Output 000 Yes TB 1 Input 000 Yes IDLE 1 Output 010 No RSET 1 Output 011 No CKOF 1 Output 101 No CKON 1 Output 110 No LREX 1 Ou put 111 No Figure 4-41 shows the timing for CRU output machine cycles. Address (AO-A14) and data (CRUOUT) are output on c[>2 of clock cycle 1. One clock cycle later, the 9900 4 .._. outputs a pulse on CRUCLK for V2 clock cycle. Thus, CRUCLK can be used as a strobe, since address and data are stable during the pulse. Referring again to Table 4-2, it is important to note that output data is transferred only when AO-A2 = 000. Otherwise, no data transfer should occur, and AO-A2 should be decoded to determine which external control instruction is being executed. These external control instructions may be used to perform simple control operations. The generation of control strobes for external instructions and a data transfer strobe (OUTCLK) is illustrated in Figure 4-42. If none of the external control instructions is used, AO-A2 need not be decoded for data transfer since they will always equal 000. CLOCK I CLOCK I I CYCLE 1 CYCLE 2 1 1.__I1.___JL_ <1>2 _fL__fL__J'L 3 ....J""L_J"1.._ 4 _fL__f"L_ AO· A14 :::><' CRU BIT ADDRESS n x: z CRUCLK ----.Jll.___ 5~ I!:~ Sf O CRUOUT :x CRU DATA OUT n x:: Figure 4-41. CR U Output Machine Cycle Timing 9900 FAMILY SYSTEMS DESIGN 4-49 INPUT /OUTPUT Hardware Design: Architecture and Interfacing Techniques TO MEMORY AND CRU 15 Y7 LREX 5 3 A B CirnF AO·A14 AO-A2 c CRON SN74LS138 RSE'r TMS 9900 mrr CRUCLK Gl OUTCLK (TO CRU) G2A G2B Figure 4-42. CR U Control Strobe Generation The timing for CRU input machine cycles is shown in Figure 4-43. The address is output at the beginning of the first clock cycle. The CRUIN data input is sampled on l of clock cycle 2. Thus, CRU input is accomplished by simply multiplexing the addressed bit onto the CRUIN input. AO-A2 will always be 000, and may be ignored. CRU input machine cycles cannot be differentiated from ALU cycles by external logic, thus no operations (such as clearing interrupts) other than CRU input should be performed during CRU input machine cycles. I CLOCK I CLOCK I CYCLE 1 l____fl__Jl__ CYCLE 2 S1__f1___fl__ __n____fL_Jl_ __JL.....__JL__ AO· A14 z 0 I- ~ j:: ct CRUIN ~ ~Lji)3-- ~ ffi Q. INPUT BIT m 0 Figure 4-43. CR U Input Machine Cycle Timing 4-50 9900 FAMILY SYSTEMS DESIGN Hardware Design: INPUT /OUTPUT Architecture and Interfacing Techniques CRU Data Transfer In order to transfer data from a memory location to an external latch in the Communications Register Unit, or to transfer data from a CRU multiplexer to memory, special instructions must be used. The CRU instructions are: SBO Set bit to one (output) SBZ Set bit to zero (output) TB Test bit (input) LDCR Load n bits to.CRU (output) STCR Receive n bits from CRU (input) These instructions always use the address bus to identify the bit or bits to be transferred, but they make the actual transfer of data over the dedicated CRU lines, CRUIN and CRUOUT. Addressing of the CRU bits is accomplished by adding a portion of the instruction word to a CRU base address register. The use of such a base address technique allows one program segment to service any number of identical 1/0 devices. For example: five TMS 9902's each with its own assigned base address can be operated from a single program, provided the base address register is properly set at the beginning. In the 9900, workspace register 12 is the CRU software base address register. All CRU instructions use the contents of this register in addressing individual CRU bits. The CRU hardware base address is defined by bits 3-14 of the current WR12 when CRU data transfer is performed. Bits 0-2 and bit 15 of WR12 are ignored for CRU address determination. For single-bit CRU instructions (SBO, SBZ, TB), the address of the CRU bit to or from which data is transferred is determined as shown in Figure 4-44. Bits 8-15 of the machine code instruction contain a signed displacement. This signed displacement is added to the CRU hardware base address (bits 3-14 ofWR12). The result of this addition is output on A3-A14 during the CRU output or the CRU input machine cycle. For example, assume the instruction "SBO 9" is executed when WR12 contains a value of 104016• The machine code for "SBO 9" is 1D0916 and the signed displacement is 000916 • The CRU hardware base address is 082016 (bits 0-2 and bit 15 are ignored). Thus, the effective CRU bit address is 0820 16 + 000916 = 0829 16 , and this value is output on AO-A14 during the CRU output machine cycle. As a second example, assume that the instruction TB - 32 is executed when WR12 = 10016 • The effective CRU address is 8016 • (CRU hardware base)+ FFE0 16 (signed displacement)= 60 16 • Thus, the TB - 32 instruction in this example causes the value of the CRU input bit at address 6016 to be transferred to bit 2 of the status register. This bit is tested in the execution of the JEQ or JNE instructions; if it is a one, the PC will be loaded with a new value (JEQ instruction). 9900 FAMILY SYSTEMS DESIGN 4-51 INPUT /OUTPUT Hardware Design: Architecture and Interfacing Techniques 0 1 2 I3 4 8 5 6 I7 8 2 9 10 I 11 12 0 13 14 15 - - - - HARDWARE BASE SOFTWARE BASE ADDRESS I I I I x x x DON'T CARE 1 1 o I I 0I 0 I0 I 1 I 0 I 0 I0 I 0 I 0 I I 0 x W12 ADDRESS 8 + 9 10 11 12 13 14 15 , , , , I: I I I I I I I I 0 0 0 1 0 0 1 SIGNED DISPLACEMENT BIT 8 SIGN J l EXTENDED '""-? 0 1 2 I3 4 5 6 I7 8 9 10 I 11 12 13 14 I I ol olo I 1 I 0 I 0 I 0 I 0 I 0 I 1I0 I 1I0I0 I 1 I ADDRESS BUS '---v----A--------~v,-------~/ SET TO ZERO EFFECTIVE CRU BIT ADDRESS FOR ALL CRU OPERATIONS Figure 4-44. TMS 9900 Single-Bit CR U Address Development LDCR Instruction The LDCR may transfer from 1 to 16 bits of output data with each instruction. Output of each bit is performed by a CRU output machine cycle; thus, the number of CRU output machine cycles performed by an LDCR instruction is equal to the number of bits to be transferred. As an example, assume that the instruction "LDCR @600,10" is executed, and that WR12 = 80016 and the memory word at address 600 contains the bit pattern shown in Figure 4-45. In the first CRU output machine cycle the least significant bit of the operand (a) is output on CRUOUT. In each successive machine cycle the address is incremented by one and the next least-significant bit of the operand is output on CRUOUT, until 10 bits have been output. It is important to note that the CRU base address is unaltered by the LDCR instruction, even though the address is incremented as each successive bit is output. STCR Instruction The STCR instruction causes from 1 to 16 bits of CRU data to be transferred into memory. Each bit is input by a CRU input machine cycle. Consider the circuit shown in Figure 4-46. The CRU interface logic multiplexes input signals m-t onto the CRUIN line for addresses 200w207 16 • If WR12 = 40016 when the instruction "STCR@ 602,6" is executed, the operation is performed as shown in Figure 4-47. At the end of the instruction, the six LSBs of memory byte 602 are loaded with m- r. The upper bits of the operand are forced to zero. 4-52 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INPUT /OUTPUT Interfacing Techniques Memory Address 600 ""lp_o_ _ n _m __1 _k_i__,i,,....&-,Ih_g_f_e_d_ _ c_b_ _,_I ~ 7 8 15 WR12 I0 0 0 0 1 o o o lo o o o o o o o I 0 7 8 15 4 0 0 CRU Base Address= 40015 AO· A14 CRUOUT CRUCLK Figure 4-45. Multiple-Bit CR U Output A3 _M A5 SN74LS251 A6 ITIM9905) A7 ~ SEL200 _1' J DO m Ail I Dl A9 A14 A D2 0 AlO A13 DJ p B All A12 c D4 q D5 ~ CRUIN y D6 D7 Figure 4-46. Example CR U Input Circuit 9900 FAMILY SYSTEMS DESIGN 4-53 INPUT /OUTPUT Hardware Design: Architecture and Interfacing Techniques WR12 I 0 o o o o 1 o olo o o o o o o ol 0 7 8 15 2 0 0 CRU BASE ADDRESS =- 20016 AO A14 ~ 200 x 201 x 202 x 203 x 204 x 205 x== CRUIN m n 0 p q MEMORY ADDRESS 602 O I0 O r q p o n ml 7 Figure 4-47. Multiple-Bit CR U Input CRU Paper Tape Reader Interface CRU interface circuits are used to interface data and control lines from external devices to the 9900. This section describes an example interface from a paper tape reader. The paper tape reader is assumed to have the following characteristics: 1. It generates a TTL-level active-high signal (SPROCKET HOLE) on detection of a sprocket hole on the paper tape. 2. It generates an 8-bit TTL active-low data which stays valid during SPROCKET HOLE= 1. 3. It responds to a TTL-level active-high command (Paper Tape RUN) signal by turning on when PTRUN = 1 and turning off when PTRUN = 0. 4-54 9900 FAMILY SYSTEMS DESIGN Hardware Design: INPUT /OUTPUT Architecture and Interfacing Techniques Figure 4-48 illustrates the circuitry to interface the reader to the CRU. The interface is selected when PTRSEL = O; PTRSEL is decoded from the AO-All address outputs from the 9900. Thus, the output of the SN74LS251 is active only when PTRSEL = 0; otherwise, the output is in high impedance and other devices may drive CRUIN. The data inputs are selected by Al2-Al4 and inverted, resulting in active high data input on CRUIN. The positive transition of SPROCKET HOLE causes PTRINT to go low. PTRINT is the active low interrupt from the interface. PTRINT is set high, clearing the interrupt, whenever a CRU output machine cycle is executed and the address causes PTRSEL to be active. When a one is output, PTRUN is set, enabling the reader, and the reader is disabled when a zero is output to the device. Thus, any time PTRUN is set or reset, the interrupt is automatically cleared. +5 ___P_T_R_U_N_---4 Q PR D CRUOUT ~ SN74LS74 a CLR +5 PTRSEL CRU l/F DA TAO DO DATA1 01 CRUIN DATA2 02 w SN74LS251 DATA INPUTS DATA3 D3 FROM PAPER TIM 99051 DATA4 D4 DECODED PAPER TAPE READER DATA5 05 s n--1----------PT_R~S_E,--.L } TAPE READER ADDRESS (DECODED FROM AO- A11) DATA6 D6 DATA7 07 c B A A14 } ..___ _4 -_ _ _ _ _ _ 13 A_ __ ADDRESS BUS A12 +5 D a y, PAPER TAPE READER SN74LS74 INTERRUPT SPROCKET HOLE - - - - - - - u Ot----+-------PT_R_l_N_T_ } (TO INTERRUPT CLR PROCESSOR) Figure 4-48. Paper Tape Reader Interface 9900 FAMILY SYSTEMS DESIGN 4-55 INPUT /OUTPUT Hardware Design: Architecture and Interfacing Techniques The software routine in Figure 4-49 controls the paper-tape reader interface described above. It is a re-entrant procedure that can be shared by several readers. The assumptions are that: 1. Each reader has its own workspace which is set up on the trap location for that reader's interrupt. 2. The workspace registers are allocated as shown in Figure 4-50. 3. The CRU input bits 0- 7 (relative to CRU base) are reader data. CRU output bit 0 controls PTRUN and clears the interrupt. 4. The most significant byte of R9 =End of File Code. 5. R 10 = Overflow Count 6. Rl 1 =Data Table Pointer Address. The procedure has two entry points. It is entered by a calling routine at PTRBEG to ~4 start the reader and it returns control to that routine. It is entered at PTRINT via interrupt to read a character. The return in this case is to the interrupted program. The control program may be used by any number of paper-tape reader interfaces, as long as each interface has a separate interrupt level and workspace. As each reader issues an interrupt, the 9900 will process the interrupt beginning at location PTRINT. However, the workspace unique to the interrupting device is used. The organization of memory to control two paper tape readers is shown in Figure 4-50. The interrupt- transfer vector causes the appropriate WP value to be loaded. In both cases PTRINT, the entry point for the control program, is loaded into the PC. PTRINT STCR *R11, 8 CB *R11+, R9 JEQ PTREND DEC R10 JEQ PTREND PTRBEG SBO PTRUN RTWP PTREND SBZ PT RUN LI R10, MAXCOUNT RTWP Figure 4-49. Paper Tape Reader Control Program 4-56 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INPUT /OUTPUT Interfacing Techniques MEMORY ADDRESS MEMORY CONTENTS CRU I I LEVEL 4 WP LEVEL 4 PC 16 18 PTRWPl PTRINT .._..___ l LEVEL 4 INT I I I I 1~ LEVEL 5 WP 20 PTRWP2 1-- LEVEL 5 INT I I LEVEL 5 PC 22 PTRINT I- I I ..... r-- }~ i-- t-- PAPER TAPE t-- t-- READER 1 t-- (PTRll t-- PTRINT ~I - t-- ..__ PAPER TAPE I I READER CONTROL I I PROGRAM I I i} I I I I PTRWP2 f4-- .~ PAPER TAPE READER2 (PTR21 UJ u 67µsec JNE LOOP1 SBO 7 RXOP2 SBO 9 Blank Panel MOV @EIGHT (13),1 Load Address (Old R8-R 1) MOV @NINE (13),2 Load Length (Old R9-R2) LOOP2 LDCR *1+ ,7 Output Char SBO 8 Data Present 4'411111 WAIT TB 0 Wait for Data Taken JEQ Wait SBZ 8 DEC 2 Decrement Count JNE LOOP2 Loop Until Through SBZ 9 Unblank Panel RTWP Return Figure 4-52. Burroughs SELF-SCAN® Display Control Program INTERRUPTS The TMS 9900 provides fifteen maskable interrupt levels in addition to the RESET and LOAD functions. The CPU has a priority ranking system to resolve conflicts between simultaneous interrupts and a level mask to disable lower priority interrupts. Once an interrupt is recognized, the CPU performs a vectored context switch to the interrupt service routine. The RESET and LOAD functions are initiated by external input signals. 9900 FAMILY SYSTEMS DESIGN 4-59 INTERRUPTS Hardware Design: Architecture and Interfacing Techniques RESET The RESET signal is normally used to initialize the CPU following a power-up. When active (low), the RESET signal inhibits WE and CRUCLK, places the CPU memory bus and control signals in a high-impedance state, and resets the CPU. When the RESET signal is released, the CPU fetches the restart vector from locations 0000 and 0002, stores the old WP, PC, and ST into the new workspace, resets all status bits to zero and starts execution at the new PC. The RESET signal must be held _active for a minimum of three clock cycles. The RESET machine cycle sequence is shown in Figure 4-53. A convenient method of generating the RESET signal is to use the Schmitt-triggered D- input of the TIM9904 clock generator. An RC network connected to the D-input maintains an active RESET signal for a short time immediately following the power-on, as shown in Figure 4-5 4. CYCLE TYPE FUNCTION Loop While Reset is Active 1 ALU Set Up 2 ALU Set Up 3 Memory Fetch New WP, Move Status To T Reg, Clear Status 4 ALU Set Up 5 Memory Store Status 6 ALU Set Up 7 Memory Store PC 8 ALU Set Up 9 Memory Store WP 10 ALU Set Up 11 Memory Fetch New PC 12 ALU Set Up MAR for Next Instruction Figure 4-53. RESET Machine Cycles 4-60 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INTERRUPTS Interfacing Techniques +5 TIM 9904 (SN74LS362) *RAND C VALUES SHOULD ~> R CLOCK TMS 9900 BE CALCULATED AS FUNCTION RESET _L GENERATOR CPU OF Vee RISE TIME. l Ta L I ._, D a RE5ET c Figure 4-54. RESET Generation LOAD The LOAD signal is normally used to implement a restart ROM loader or front panel functions. When active (low), the LOAD signal causes the CPU to perform a non- maskable interrupt. The LOAD signal can be used to terminate a CPU idle state. The LO AD signal should be active for one instruction period. Since there is no standard TMS 9900 instruction period, IAQ should be used to determine instruction boundaries. If the LOAD signal is active during the time that the RESET signal is released, the CPU will perform the LOAD function immediately after the RESET function is completed. The CPU performs the LOAD function by fetching the LOAD vector from addresses FFFC 16 and FFFE 16 , storing the old WP, PC, and ST in the new workspace, and starting the LOAD service routine at the new PC, as shown in Figure 4-55. An example of the use of the LOAD signal is a bootstrap ROM loader. When the LOAD signal is enabled, the CPU enters the service routine, transfers a program from peripheral storage to RAM, and then transfers control to the loaded program. Figure 4-56 illustrates the generation of the LOAD signal for one instruction period. 9900 FAMILY SYSTEMS DESIGN 4-61 INTERRUPTS Hardware Design: Architecture and Interfacing Techniques CYCLE TYPE FUNCTION ALU Set Up 2 Memory Read Fetch New WP 3 ALU Set Up 4 Memory Write Store Status 5 ALU Set Up 6 Memory Write Store PC 7 ALU Set Up 8 Memory Write Store WP 9 ALU Set Up 10 Memory Read Fetch New PC ·4 11 ALU Set Up MAR for Next Instruction Figure 4-55. LOAD Machine Cycle Sequence +5 _Q_ .~. a +5 ---- D D a TMS 9900 Y..SN74LS74 Y..SN74LS74 CPU LOADCK -i> a ...... a LOAD CL CL I~ ? +5 IAQ Figure 4-56. LOAD Generation 4-62 9900 FAMILY SYSTEMS DESIGN Hardware Design: INTERRUPTS Architecture and Interfacing Techniques BASIC MACHINE CYCLE The interrelationship between the LOAD and RESET signals and the general operation of the 9900 and execution of instructions may best be shown by the flow diagram in Figure 4-57. An orderly starting procedure involves the holding of the RESET line low when power is applied to the chip. After application of power and after the clock has begun to run, the internal instruction control circuitry checks to see if the RESET line is held low, and, if the answer is "yes", will stay in a loop as shown in the diagram. When the RESET line goes high, it is no longer active and a level zero interrupt is taken in which the RESET vector, the numbers to fill the workspace pointer and program counter registers, are fetched from memory locations zero and two. Furthermore, the previous values of the workspace pointer, program counter and status register are stored in the new workspace, although these values are random numbers immediately following power up. Following this, the interrupt mask is set to zero to mask all other interrupts. The next decision is regarding the LOAD line. If this particular line is active, or low, then immediately there will be another context switch in which the LOAD vector will be brought in from the last two locations in memory, FFFC16 and FFFE16 , and loaded into the workspace pointer and program counter respectively. If the LOAD is not active, the 9900 proceeds directly to an instruction acquisition cycle. In either case, the very next step is to fetch the instruction from the memory and execute it. Following this, the program counter is updated and a sequence of checks made regarding the LOAD, XOP, and interrupt conditions. First is the check for the LOAD line. If this is active, the LOAD context switch will occur. If not, there will be a test to see if the instruction just executed was an XOP or BLWP. If not, the interrupt request line will be checked. If there is not an interrupt request, and the last instruction was not an idle instruction, the machine may proceed to fetch the next instruction and continue. In the event that the last instruction executed was an XOP or BLWP, the 9900 will ignore the interrupt request line and will proceed to fetch a new instruction. This insures that at least one instruction of a subprogram that is entered via a context switch will be executed before another context switch may occur, such as an interrupt. In the event that the interrupt request line is active following the execution of a normal instruction, a test is made to determine that the interrupt is valid, that is to say, "Is the interrupt mask set to allow this interrupt." If the interrupt is not allowed, the processor proceeds to fetch the next instruction. In the event that it is allowed, a context switch will be made and the interrupt vector from the appropriate locations in the first 32 words of memory will be fetched and the workspace pointer and program counter will be loaded with the new numbers. As a part of this context switch, the interrupt mask is set to a level one less than the interrupt just taken. This is to insure that no lower priority interrupt may occur during the servicing of the current interrupt cycle. Notice further that in this diagram that the logic is such that at least one instruction of any subprogram will be 9900 FAMILY SYSTEMS DESIGN 4-63 INTERRUPTS Hardware Design: Architecture and Interfacing Techniques executed immediately following a context switch. The only exception to this is the simultaneous presence of RESET and LOAD signals. Finally, the idle instruction will suspend instruction execution in the 9900 until an interrupt, RESET or LOAD signal occurs. MASKABLE INTERRUPTS The TMS 9900 has 16 interrupt levels with the lower 15 priority levels used for maskable interrupts. The maskable interrupts are prioritized and have transfer vectors similar to the RESET and LO AD vectors. Inte.rrupt Service A pending interrupt of unmasked priority level is serviced at the end of the current instruction cycle with two exceptions. The first instruction of a RESET, LOAD, or interrupt service routine is executed before the CPU tests the INTREQ signal. The interrupt is also inhibited for one instruction if the current instruction is a branch and ~ 4 load workspace pointer instruction (BLWP) or an extended operation (XOP). The one instruction delay permits one instruction to be completed before an interrupt context switch can occur. A LIMI instruction can be used as the first instruction in a routine to lock out higher priority maskable interrupts. The pending interrupt request should remain active until recognized by the CPU during the service routine. The interrupt request should then be cleared under program control. The CRU bit manipulation instructions can be used to recognize and clear the interrupt request. The interrupt context switch causes the interrupt vector to be fetched, the old WP, PC, and ST to be saved in the new workspace, and the new WP and PC to be loaded. Bits 12-15 of ST are loaded with a value of one less than the level of the interrupt being serviced. The old WP, PC, and ST are stored in the new workspace registers 13, 14, and 15. When the return instruction is executed, the old WP, PC, and ST are restored to the CPU. Since the ST contains the interrupt mask, the old interrupt level is also restored. Consequently, all interrupt service routines should terminate with the return instruction in order to restore the CPU to its state before the interrupt. The linkage between two interrupt service routines is shown in Figure 4-58 and the interrupt machine cycle sequence is shown in Figure 4-59. 4-64 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INTERRUPTS Interfacing Techniques INSTRUCTION ACQUISITION RESET SIGNAL CAUSES IMMEDIATE ENTRY HERE INSTRUCTION y GET RESET VECTOR (WP AND PCI FROM LOCATION 0, 2 STORE PREVIOUS PC, y WP, AND ST IN NEW WORKSPACE. SET INTERRUPT MASK (ST12-ST15)= 0 N y N N GET LOAD VECTOR (WP AND PC) FROM LOCATION FFFC15. FFFE15 GET INTERRUPT LEVEL VECTOR (WP AND PC) STORE PREVIOUS PC, WP, AND ST IN NEW STORE PREVIOUS PC, WORKSPACE. SET WP, AND ST IN NEW INTERRUPT MASK WORKSPACE. SET INTERRUPT MASK (ST12 (ST12 - ST15) = 0 -ST15) TO LEVEL-1 Figure 4-57. TMS 9900 CPU Flow Chart 9900 FAMILY SYSTEMS DESIGN 4-65 INTERRUPTS Hardware Design: Architecture and Interfacing Techniques Interrupt Signals The TMS 9900 has five inputs that control maskable interrupts. The INTREQ signal is active (low) when a maskable interrupt is pending. If INTREQ is active at the end of the instruction cycle, the CPU compares the priority code on ICO through IC3 to the interrupt mask (ST12-ST15). If the interrupt code of the pending interrupt is equal to or less than the current interrupt mask, the CPU executes a vectored interrupt; otherwise, the interrupt request is ignored. The interrupt priority codes are shown in Table 4-3. Note that the level-0 interrupt code should not be used for external interrupts since level 0 is reserved for RESET. vi TMS 9900 PC (Bl I l/JV1 PROGRAM A WP (Bl I GENERAL MEMORY I ST (Bl I PROGRAM B GENERAL MEMORY WRO WR1 WORKSPACE B r-- WR13 - WP (Al WR14 · PC (Al WR15 · ST (Al GENERAL MEMORY ~: WRO WORKSPACE A WR15 Figure 4-58. Interrupt Linkage 4-66 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INTERRUPTS Interfacing Techniques CYCLE TYPE FUNCTION 1 ALU Set Up 2 Memory Read Fetch New WP 3 ALU Set Up 4 Memory Write Store Status 5 ALU Set Up 6 Memory Write Store PC 7 ALU Set Up 8 Memory Write Store WP 9 ALU Set Up 10 Memory Read Fetch New PC 11 ALU Set Up MAR for Next Instruction Figure 4-59. Interrupt Processing Machine Cycle Sequence 4~ Figure 4-60 illustrates the use of the TMS 9901 programmable system interface for g~neration of the interrupt code from individual interrupt input lines. The TMS 9901 provides six dedicated and nine programmable latched, synchronized, and prioritized interrupts, complete with individual enabling/disabling masks. Synchronization prevents transition oflCO-IC3 while the code is being read. A single-interrupt system with an arbitrarily chosen level-7 code is shown in Figure 4-61. The single-interrupt input does not need to be synchronized since the hardwired interrupt code is always stable. Interrupt Masking The TMS 9900 uses a four-bit field in the status register, ST12 through ST15, to determine the current interrupt priority level. The interrupt mask is automatically loaded with a value of one less than the level of the maskable interrupt being serviced. The interrupt ma'sk is also affected by the load interrupt mask instruction (LIMI). Since the interrupt mask is compared to the external interrupt code before an interrupt is recognized, an interrupt service routine will not be halted due to another interrupt of lower or equal priority unless a LIMI instruction is used to alter the interrupt mask. The LIMI instruction can be used to alter the interrupt-mask level in order to disable intervening interrupt levels. At the end of the service routine, a return (RTWP) restores the interrupt mask to its value before the current interrupt occurred. 9900 FAMILY SYSTEMS DESIGN 4-67 INTERRUPTS Hardware Design: Architecture and Interfacing Techniques -"vvv ~Vee 1~,, D TIM 9904 Q CLOCK GENERATOR - ~3 ~ D ~ CRU ~ ~1-~ AO-A9 DECODE i---...i CE TMS TMS 9900 ~ 9901 CPU PSI sYSTEM A10 so IN TERRUPTS A11 ~ SI ~ A12 S2 A13 S3 1/0 PORT~- A14 S4 CRUOUT ·4 CRUCLK CRUIN RESET -RST1 Figure 4-60. System With 15 External Interrupts Table 4-3. Interrupt Priority Codes Vector Location Interrupt Mask Values To Interrupt Interrupt Level (Memory Address Device Assignment Enable Respective Interrupts Codes In Hex) (ST12 thru ST15) ICO thru IC3 (Highest priority) 0 00 Reset 0 through F* 0000 1 04 External device 1 through F 0001 2 08 2 through F 0010 3 QC 3 through F 0011 4 10 4 through F 0100 5 14 5 through F 0101 6 18 6 through F 0110 7 1C 7 through F 0111 8 20 8 through F 1000 9 24 9 through F 1001 10 28 A through F 1010 11 2C B through F 1011 12 30 C through F 1100 13 34 D through F 1101 14 38 E and F 1110 (Lowest priority) 15 3C External device F only 1111 *Level 0 can not be disabled. 4-68 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and INTERRUPTS Interfacing Techniques INTERRUPT - - - - 1 INTREO ICO TMS 9900 IC1 +5 IC2 IC3 Figure 4-61. Single-Interrupt System Note that the TMS 9900 actually generates the interrupt vector address using ICO-IC3 five clock cycles after it has sampled INTREQ and four clock cycles after it has compared the interrupt code to the interrupt mask in the status register. Thus, interrupt sources which have individual masking capability can cause erroneous operation if a command to the device to mask the interrupt occurs at a time when the interrupt is active and just after the TMS 9900 has sampled INTREQ but before the vector address has been generated using ICO-IC3. The individual interrupt masking operation can be easily allowed if the masking instruction is placed in a short subroutine which masks all interrupts with a LIMI 0 instruction before individually masking the interrupt at the device, as shown in Figure 4-62. 9900 FAMILY SYSTEMS DESIGN 4-69 INTERRUPTS Hardware Design: Architecture and Interfacing Techniques INCORRECT xxx SBO 0 SET MASK (INTERRUPT CAN OCCUR DURING SBO CAUSING ERRONEOUS yyy OPERATION) CORRECT - -- xxx BLWP 9 (WR9) = ADDRESS OF SBW (WR10) = ADDRESS OF SBl xx xx ~4 SBl LIMI 0 CLEAR STATUS MASK TO INHIBIT INTERRUPTS MOV @24(13), 12 MOVE CRU BASE ADDRESS TO WR12 SBO 0 SET MASK RTWP RETURN SBW BSS 32 SUBROUTINE WORKSPACE Figure 4-62. External Interrupt Clearing Routine Interrupt Processing Example The routine in Figure 4-63 illustrates the use of the LIMI instruction as a privileged or non-interruptable instruction. The level-5 routine sets a CRU bit and then loops until a corresponding CRU bit is true. The first instruction in the routine is completed before a higher priority interrupt can be recognized. The LIMI instruction, however, raises the CPU priority level to level 0 in order to disable all other maskable interrupts. Consequently, the level-5 routine will run to completion unless a RESET signal or a LOAD signal is generated. At the end of the routine, the RTWP instruction restores the CPU to its state before the level-5 interrupt occurred. Level 5 LIMI 0 Disable Maskable INTREOs SBO ACK Set CRU Output Bit Loop TB ROY Test CRU Input Bit JNE LOOP Loop Until Input True RTWP Return Figure 4-63. LIM/ Instruction Routine 4-70 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and ELECTRICAL REQUIREMENTS Interfacing Techniques ELECTRICAL REQUIREMENTS U NDERSTANDING THE ELECTRICAL SPECIFICATIONS A description of the interface to the 9900 would be incomplete without a set of specifications for the electrical signals which perform the functions described in the previous sections. Each pin of the 9900 may be characterized with a set of minimum and maximum voltage and current levels. In many cases, the switching characteristics, the rate of transition from the high state to the low state is also important. The detailed electrical specifications for each of the processors in the 9900 family are given in the Product Data chapter. A brief statement about the basic concepts of device characterization and data sheet specification is of value to designers with limited exposure to microprocessor and semiconductor memory products. Specifications are given in two ways. First, absolute maximum ratings are given which simply define the limits of stress which the chip can withstand without damage. (Figure 4- 64 shows the absolute maximum ratings for the TMS 9900.) The normal design 4 .. specification is the recommended operating conditions table (Figure 4-65) which specifies power supply limits, signal voltage levels, and the operating temperature range. In reading these two tables it is necessary to read the explanatory notes, one of which points out that the absolute maximum power supply voltages are specified with respect to the chip substrate or VBB (pin 1). In the normal operating conditions, all voltages are specified with respect to the Vss or ground (pins 26, 40). The four voltages given, VBB, Vcc, VDD, and Vss are not actually four power supplies, but three power supplies: + 5V, -5V, and + 12V, with Vss being the ground or reference point. ABSOLUTE MAXIMUM RATINGS OVER OPERATING FREE-AIR TEMPERATURE RANGE (UNLESS OTHERWISE NOTED)* Supply voltage, Vee (see Note 1) . -0.3 to 20 V Supply voltage, Voo (see Note 1) . -0.3 to 20 V Supply voltage, Vss lsee Note 1) . -0.3 to 20 V All input voltages (see Note 1) . . -0.3 to 20 V Output voltage (with respect to Vssl -2 V to 7 V Continuous power dissipation . . . 1.2W Operating free-air temperature range . 0°C to 70°C Storage temperature range . . . . . -55°C to 150°C •Stresses beyond those listed under "Absolute Maximum Ratings" may cause permanent damage to the device. This is a stress rating only and functional operation of the device at these or any other conditions beyond those indicated in the "Recommended Operating Conditions" section of this specification is not implied. Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability. NOTE 1: Under absolute maximum ratings voltage values are with respect to the most negative supply, V99 (substrate), unless otherwise noted. Throughout the remainder of this section, voltage values are with respect to V55. Figure 4-64. Absolute Maximum Ratings 9900 FAMILY SYSTEMS DESIGN 4-71 ELECTRICAL REQUIREMENTS Hardware Design: Architecture and Interfacing Techniques RECOMMENDED OPERATING CONDITIONS MIN NOM MAX UNIT Supply voltage, Vss -5.25 -5 -4.75 v Supply voltage, Vee 4.75 5 5.25 v Supply voltage, Voo 11.4 12 12.6 v Supply voltage, Vss 0 v High-level input voltage, V1H (all inputs except clocks) 2.2 2.4 Vee+1 v High-level clock input voltage, V1H(¢) Voo-2 Voo v Low-level input voltage, V1L (all inputs except clocks) -1 0.4 0.8 v Low-level clock input voltage, Vi L..!.<2._) -0.3 0.3 0.6 v Operating free-air temperature, TA 0 70 e Figure 4-65. Recommended Operating Conditions Input signals should be in the range from 2.2V to 6V (assuming Vcc is 5V) for the high .4 level, the nominal design point being at 2.4V. Low level input voltage should be below 0.6V (but not less than - 0.3V.) These specifications are not the same as the standard TTL specifications as far as the "worst case" design criteria are concerned. Care should be exercised when interfacing the 9900 with TTL circuits that loading of the TTL devices does not produce input voltages to the 9900 which are outside the specified range. The clock signal voltages are substantially different from the TTL standard; however, the TMS 9904 is available to provide these signals. The electrical characteristics specification, Figure 4-66. defines the current into or out of the 9900 chip at the operating voltage levels. The input current, Ii, is specified for four groups of input signals over a range of input voltages. For example, the input current for any input on the data bus (when reading data from the memory) is nominally ± 50 microamps over the input voltage range from OV to SV (when Vcc is 5V). The current is negative (flowing out of the 9900) for low levels, and positive (into the 9900) for high levels. For "worst case" design the maximum values should be used. Voltage specifications on the output pins show how the 9900 output devices drive external circuits. For the high level, VoH, the voltage will be at least 2.4V but may go as high as 5V (Vcc) under the condition of output current of 0.4 mA. (Currents flowing out of the chip are shown as negative values.) When an output signal is at the low state, the output voltage, VoL, will be no greater than 0.65V when the current flowing into the chip is 3.2 mA. Although the 1-V characteristic of the output circuit is nonlinear, a second data point is given: if the current is 2 mA, the voltage will be no greater than 0.50V. These numbers tell the designer what the output drive circuit current sinking capability is. Two standard TTL loads (1.6 mA each) can be accommodated, but the VoL level, as specified, may be as high as at 0.65V (the standard TTL specification for outputs is VoL 0.4V.) 4-72 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and ELECTRICAL REQUIREMENTS Interfacing Techniques ELECTRICAL CHARACTERISTICS OVER FULL RANGE OF RECOMMENDED OPERATING CONDITIONS (UNLESS OTHERWISE NOTED) PARAMETER TEST CONDITIONS MIN TY Pt MAX UNIT Data bus during OBIN v, = Vss to Vee ±50 ± 100 WE, MEMEN, OBIN, Address 11 Input current bus, Data bus during HOLDA v 1 = Vss 10 Vee ±50 ±100 µA Clock• V1 = -0.3 to 12.6 V ±25 ±75 Any other inputs VJ_~ V...s_s_ to V....c.c_ ±1 ± 10 VoH Higb-level output voltage lo= -0.4 mA 2.4 Vee v lo=3.2mA 0.65 VoL Low-level output voltage v lo= 2 mA 0.50 iss Supply current from Vss 0.1 1 mA 'cc Supply current from Vee 50 75 mA loo Supply current from Voo 25 45 mA Input capacitance (any inputs except Vss = -5, f = 1MHz, Ci 10 15 pF clock and data bus) unmeasured pins at Vss Clock-1 input capacitance Vss = -5, f = 1MHz, Ci(ci1) 100 150 pF unmeasured pins at Vss Vss = -5, f = 1MHz, Ci(o2) Clock-2 input capacitance 150 200 pF unmeasured pins at \/SS Vss = -5, f = 1MHz, Ci(.;>3) Clock-3 input capacitance 100 150 pF unmeasured pins at Vss Vss = -5, f = 1MHz, Ci(<,'>4) Clock-4 input capacitance 100 150 pF unmeasured pins at Vss Vss = -5, f = 1MHz, Cos Data bus capacitance 15 25 pF unmeasured pins at Vss Output capacitance (any output except Vss = -5, f = 1MHz, Ca 10 15 pF data bus) unmeasured pins at Vss t All typical values are at TA= 25°C and nominal voltages. •o.c. Component of Operating Clock Figure 4-66. Electrical Characteristics The timing of the various signals on the TMS 9900 chip is shown in Figure 4-67. The fundamental propagation time from a clock phase pulse (leading edge) to the specified output is given as tP and is typically 20 ns but is never more than 40 ns (worst case). The parameters tpLH and tpHL are the propagation delays from the appropriate clock signal to the low-to-high transition of the output (tpLH) or the high-to-low transition of the output (tpHL)· For example, the WE signal makes its high-to-low transition 20 ns after 1 clock, and makes a low-to-high transition 20 ns after the next 1 clock. Most of the output signals make transitions 20 ns after the 2 clock, and remain valid until the next 02 clock. Additional information regarding design constraints based on the electrical specifications is given in the next section. 9900 FAMILY SYSTEMS DESIGN 4-73 ELECTRICAL REQUIREMENTS Hardware Design: Architecture and Interfacing Techniques SWITCHING CHARACTERISTICS OVER FULL RANGE OF RECOMMENDED OPERATING CONDITIONS PARAMETER TEST CONDITIONS MIN TYP MAX UNIT tPLH or tPHL Propagation delay time, clocks to outputs CL= 200 pF 20 ns INPUT CLOCK ¢1 CLOCK ¢2 CLOCK <1>3 CLOCK 2 I I I II I I ...._.__ _ _ 5ns~ ~ ¢3 ______/ \~- ¢4 ---.----JI \____ Figure 4-68. TMS 9900 Typical Clock Timing 9900 FAMILY SYSTEMS DESIGN 4-75 ELECTRICAL REQUIREMENTS Hardware Design: Architecture and Interfacing Techniques TIM 9904 Clock Generator The TIM 9904 (SN74LS362) is a single-chip clock generator and driver for use with the TMS 9900. The TIM 9904 contains a crystal-controlled oscillator, waveshaping circuitry, a synchronizing flip-flop, and quad MOS/TTL drivers as shown in Figure 4-69. The clock frequency is selected by either an external crystal or by an external TTL- level oscillator input. Crystal operation requires a 16X input crystal frequency since the TIM 9904 divides the input frequency for waveshaping. For 3-megahertz operation, a 48-megahertz crystal is required. The LC tank inputs permit the use of overtone crystals. The LC network values are determined by the network resonant frequency: 1 f For less precise frequency control, a capacitor can be used instead of the crystal. The external-oscillator input can be used instead of the crystal input. The oscillator input frequency is 4X the output frequency. A 12-megahertz input oscillator frequency is required for a 3-megahertz output frequency. A 4X TTL-compatible oscillator output (OSCO UT) is provided in order to permit the derivation of other system timing signals from the crystal or oscillator frequency source. The oscillator frequency is divided by four to provide the proper frequency for each of the 4-clock phases. A high-level MOS output and an inverted TTL-compatible output is provided by each clock phase. The MOS-level clocks are used for the TMS 9900 CPU while the TTL clocks are used for system timing. The D-type flip-flop is clocked by cp3 and can be used to synchronize external signals such as a RESET. The Schmitt-triggered input permits the use of an external RC network for power-on RESET generation. The RC values are dependent on the power supply rise time and should hold RESET low for at least three clock cycles after the supply voltages reach the minimum voltages. All TIM 9904 TTL-compatible outputs have standard short circuit protection. The high-level MOS clock outputs, however, do not have short circuit protection. 4-76 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and ELECTRICAL REQUIREMENTS Interfacing Techniques TANK2 XTAL OSCIN TANK1 -·- 111 121 1181 1191 i-------1CK 0 OSCILLATOR 12 VOL r SECTION I - --, >-------+---< J 1-4 be located as close as possible to the inputs of the TMS 9900, since these signals have fast rise and fall times while driving fairly high capacitance over a wide voltage range. The 12 volt supply to the clock drivers should be decoupled with both high (15µF) and low (0.05µF) value capacitors in order to filter out high and lower frequency variations in supply voltage. Table 4-5. TMS 9900 Bipolar Support Circuits BUFFERS (3-STATE) DEVICE FUNCTION PACKAGE SN74125 QUAD Inverting Buffer 14 SN74126 QUAD Inverting Buffer 14 SN74LS240 OCTAL Inverting Buffer/Transceiver 20 SN74LS241 OCT AL Noninverting Buffer/Transceiver 20 SN74LS242 OCTAL Inverting Transceiver 14 SN74LS243 OCT AL Noninverting Transceiver 14 SN74S240 OCT AL Inverting Buffer/Transceiver 20 SN74S241 OCT AL Noninverting Buffer/Transceiver 20 SN74365 Hex Noninverting Buffer 16 SN74366 Hex Inverting Buffer 16 SN74367 Hex Noninverting Buffer 16 SN74368 Hex Inverting Buffer 16 LATCHES SN74LS259 (TIM9906) OCT AL Addressable Latch 16 SN74LS373 OCT AL Transparent Latch (3-state) 20 SN74LS412 OCT AL 1/0 Port (3-state) 24 DATA MULTIPLEXERS SN74LS151 OCT AL Multiplexer 16 SN74LS251 (TIM9905) OCT AL Multiplexer (3·state) 16 OTHER SUPPORT CIRCUITS SN74148 (TIM 9907) Priority Encoder 16 SN74LS348 (TIM9908) Priority Encoder 16 SN74LS74 Dual D·type flip-flop 14 SN74LS174 Hex D·type flip·flop 16 SN74LS175 Qual D·type flip-flop 16 SN74LS37 QUAD 2·1 nput nand Buffers 14 SN74LS362 (TIM9904) Clock Generator 20 9900 FAMILY SYSTEMS DESIGN 4-81 TMS 9940 Hardware Design Architecture and MICROCOMPUTER Interfacing Techniques All voltage inputs to the TMS 9900 should be decoupled at the device. Particular attention should be paid to the + 5 volt supply. All data and address lines are switched simultaneously. The worst-case condition occurs when all data and address signals switch to a low level simultaneously and they are each sinking 3.2 mA. It is thus possible for the supply current to vary nearly 100 mA over a 20 ns interval. Careful attention must be paid by the designer to avoid supply voltage spiking. The exact values for capacitors should be determined empirically, based on actual system layout and drive requirements. TMS 9940 MICROCOMPUTER The TMS9940 is a microcomputer chip in a 40-pin package which includes all of the elements of a computer, that is, memory, 1/0 and utilities in addition to ALU and control. Useful in a wide variety of dedicated control functions, it contains a 2k X 8 EPROM program memory and a 128 X 8 RAM for data, a 14 bit interval timer, and a multiprocessor system interface. Although the memory organization on chip is in 8 bit ~4 bytes, the instructions are the same 16-bit instructions of the 9900 family. While most of the instructions are identical to the instruction set of the 9900, there are 68 instructions in the 9940 set (as opposed to 69 in the TMS9900) including three new ones. The differences in the instruction set are illustrated by the following list of instructions. DCA Decimal Correct for BCD add DCS LIIM Decimal Correct for BCD subtract Load Interrupt mask } Added Instructions RSET CKOF CKON LREX IDLE l (external instructions in 9900) Put processor into the idle state l Deleted Instructions } Hardware in the 9940 The first three of the instructions in the above list are new instructions and are unique to the 9940 microcomputer. The DCA and DCS instructions perform decimal correct for BCD arithmetic. The LIIM instruction is a single word instruction to load the interrupt mask. (This instruction should be contrasted with the LIMI instruction of the 9900 set which performs the same function but occupies two memory words.) The idle instruction, an external instruction in the 9900 set, is now implemented in hardware. Four instructions in the list are not implemented in the 9940; they are external instructions in the 9900 set. 4-82 9900 FAMILY SYSTEMS DESIGN Hardware Design Architecture and TMS 9940 Interfacing Techniques MICROCOMPUTER PIN Ass1GNMENTS AND FUNCTIONAL CoNTROL One of the most extraordinary features of the TMS9940 is the I/O structure in which 3 2 pins of the 40-pin package are software assignable. That is, they do not perform single, predefined, hard-wired functions, but instead are under the control of the programmer in structuring input/output functions. Table 4-6 lists the functions of four specific bits in the CRU which are called configuration bits. Because these four bits are assigned specific locations in the CRU output field and are therefore addressable and accessible via CRU output instructions, the pins of the package may be dynamically reassigned during program execution. Table 4-6. Configuration Bit Functions Configuration Bit Function 0 External CRU expansion Multiprocessor 2 Clock output for sync 3 Power down Table 4-7 describes the way these four configuration bits assign the individual general- purpose I/O pins to specific functions. In effect, each of the pins may serve two or three functions, as described in the table. Table 4-8 defines the functions of addressable CRU locations. The first 256 locations, addresses 000 through OFF, are for external expansion of the general I/Oto an additional 245 (256 less 11 used for expansion). It is important to note here that these 256 bits are two fields of 256 bits each, one for input and one for output. Addresses 100 through 17F are not used, and address 180 through lDF are used internally. Notice in Table 4-8 that CRU addresses 183, 184, 185 and 186 locate the four configuration bits. It is via the setting or resetting of these individual bits that the I/O configuration is established. Four other significant features should be pointed out. One: The interrupt structure includes four levels of interrupt as opposed to the 16-level interrupt capability of the general 9900 microprocessor group. Two: There is an on-chip timer, or event counter. Three: 32 bits of CRU I/O are implemented on the chip. (Addresses lEO-lEFF) Four: A multiprocessor system interface is constructed as part of the CRU I/O. INTERRUPTS The four interrupt levels are shown in the table below. LevelO Reset Level 2 Decrementer Level 1 General Interrupt 1 Level 3 General Interrupt 2 9900 FAMILY SYSTEMS DESIGN 4-83 TMS 9940 Hardware Design Architecture and MICROCOMPUTER Interfacing Techniques Table 4-7. Configuration Bit Effects by Pin Configuration bit 0 (CR U Expansion) Pin 0 1 23 PO (general I/ 0) Al 24 Pl A2 2S P2 A3 26 P3 A4 27 P4 AS 28 PS A6 29 P6 A7 30 P7 A8 18 P8 CRUIN 17 P9 CRUOUT 16 PIO CRUCLK Configuration bit 1 (Multiprocessor) Pin 0 1 - 14 Pl I TC (Clock) 11 P12 TD (Data) Configuration bit 2 (Sync) Pin 0 1 IS P13 cf> (Clock) Configuration bit J (Power Down) Pin 0 1 10 P14 HLD -- 9 PIS HLDA 8 P16 IDLE 4-84 9900 FAMILY SYSTEMS DESIGN Hardware Design Architecture and TMS 9940 Interfacing Techniques MICROCOMPUTER Table 4-8. Functions of CR U Address CR U Addresses Contents ofRJ 2 Input Output 000-0FF 000-lFE CRU Expansion CRU Expansion 100-17F 200-2FE NA NA 180 300 Test for Interrupt 1 181 302 Test for Decrementer Clear Decrementer Interrupt 182 304 Test for Interrupt 2 183 306 Set Configuration Bit 0 184 308 Set Configuration Bit 1 185 30A Set Configuration Bit 2 186 30C Set Configuration Bit 3 187-18F 30E-31E NA NA 190-19D 320-33A Read Decrementer Value Load Decrementer Value 19E 33C TE (Timer /Event Cntr) 19F 33E lAO-lAF 340-35E Read MPS! Value Load MPS! Value 4~ lBO-lBF 360-37E Read Flag Register Set Flag Register lCO-lDF 380-3BE Set 1/0 Direction for PO-P31 lEO-lFF 3C0-3FE PO-P31 Input Data PO-P31 Output Data The 9940 implements interrupts using the same context switch concept of the 9900. Thus, the interrupt vectors for the four interrupt levels must be stored in the first 16 words of the 9940's program memory. As is described in a subsequent paragraph, the decrementer acts like a counter in an external piece of hardware in that after the contents of the circuit have been decremented to zero an interrupt signals the processor to perform a context switch and perform whatever function was programmed as the service routine for the decrementer. The reset, INT 1, and INT 2 interrupt signals are available to external hardware. Since there is no INTREQ (interrupt request) signal input for the 9940, an interrupt input must be set and remain set until acknowledged. In fact, the acknowledgement of an interrupt must include instructions to reset holding flip-flops (if used) via CRU operations. In the 9940, the interrupt input may be masked (as in all 9900 processors) but there are specific CRU bits which, if tested, will reveal pending interrupts which are not being serviced. Thus, the programmer may wish to mask interrupts but still be aware (via TB instructions to CRU locations 180, 181and182 as shown in Table 4-8) of the interrupt input status. 9900 FAMILY SYSTEMS DESIGN 4-85 TMS 9940 Hardware Design Architecture and MICROCOMPUTER Interfacing Techniques DEC REMENTER A timer/event counter is implemented on the 9940.chip to introduce interrupts after a predefined time period or number of events. A set of dedicated CRU addresses define the location of decrementer input and output registers. A value may be loaded into the decrementer via an LDCR instruction which loads CRU locations 19016 - 19D 16 • Likewise, the current value of the decrementer may be read via an STCR instruction identifying the same CRU field. When the decrementer contents count down to zero, an interrupt is issued. The context switch thus activated automatically clears the interrupt request. As a timer, the decrementer counts down at the rate of 1I30 of the oscillator frequency. With a clock frequency of 5 MHz, the time interval for counting is six microseconds. As an event counter, the decrementer is first loaded with a value and it then counts down (one bit for each positive transition on pin 7) until it reaches zero. An interrupt is then issued. cRu IMPLEMENTATION One of the most important features of the 9940 is the manner in which the CRU is used to perform pin assignments and functional control as well as input and output. The major impact is that the external devices and some of the internal devices are under direct control of the programmer via CRU instructions. The major emphasis (see Table 4-7) is as follows. 3 2 bits of input - on-chip multiplexer 32 bits of output - on-chip flip-flops 32-bit register defining signal direction (in or out) for the assignable pins 16-bit flag register - may be written or read 14-bit "clock" register-for loading the decrementer 14-bit "read" register-for reading the decrementer 16-bit shift register for receiving instructions in a multiprocessor application, or used for sending 16-bit information over the MPSI data line to other processors 14-bit decrementer (used as a timer or counter) 256-bit CRU expansion (input and output) 4-86 9900 FAMILY SYSTEMS DESIGN Hardware Design TMS 9940 Architecture and Interfacing Techniques MICROCOMPUTER Pin assignments may be explained by showing the basic application concept, that of using the 32 bits of internal CRU. Here the only decision is one of signal direction. It is possible to set the configuration once during initialization and never change it. But this limits the total number of I/O signals to 32. It is permissible to change the signal direction of each pin as needed, thus obtaining full utilization of the 32 inputs and 3 2 outputs. The pins themselves (labelled PO-P31 in Table 4-8) serve as a dynamically configurable bidirectional CRU port. Data is addressed in the CRU address field lEO to lFF. Direction control is established by writing a logical one for output or zero for input to the appropriate address( es) in the CR U field 1C0-1 D F. Reading the addresses assigned for output is permissible and allows the program to interrogate or determine the status of the on-chip CRU output flip-flops Functional assignments of the first 18 I/O signals may be accomplished as a "configuring" of the pins. As shown in Table 4-8, eighteen additional signals may pass through the pins corresponding to PO-Pl 7. By setting configuration bit 0 for example, signals PO-PlO are no longer available to external hardware. Instead, the CRU expansion signals, Al-A8 and CRU controls, are available. Configuring may be accomplished by the following code. LI R12,>200 Set CR U hardware base address at 10016 SBO >83 Add 83 16 to set CRU bit 183 16 (The LI instruction must set R12 to two times the hardware base address because the LSB is ignored.) MULTIPROCESSOR SYSTEM INTERFACE (MPSI) A two-wire communication technique is provided so that the 9940 may exchange 16-bit data and/ or instructions with. other CPU's in a multiprocessor application. This capability allows the RAM to be used as an instruction memory for short subprograms downloaded from another processor. Since the technique is based on the CRU concept, the 9940 will easily interface with the processors in the 9900 family. In order to use this feature, configuration bit 1 must first be set via LI R12, >200 SBO >84 Then the information flows in from an external processor and is clocked by the external processor so that this operation is completely transparent to the CPU. The sender must interrupt the receiver to cause reading of the input word via LI R12, > 340 Address the MPSI register STCR @BUFF, 0 Store 16 bits in memory location BUFF Refer to Table 4-7 for CRU addresses of this and other functions. 9900 FAMILY SYSTEMS DESIGN 4-87 TMS 9940 Hardware Design: Architecture and MICROCOMPUTER Interfacing Techniques To send data out over the MPSI the 9940 must first have configuration bit 1 set, and then it simply executes LDCR @BUFF, 0 to send out 16 bits of data from memory location BUFF. The switch into and out of "send" status is automatic. Table 4-9. TMS 9940 Configurable Pins CRU CRU Pin General Address Address/or Alternate Configuration CRUAddress Number 110 Data 110 Direction Control Function Bit of Conjig. Bit 23 PO lEO lCO Al 0 183 24 Pl lEl lCl A2 0 183 2S P2 1E2 1C2 A3 0 183 26 P3 1E3 1C3 A4 0 183 27 P4 1E4 1C4 AS 0 183 28 PS lES lCS A6 0 183 29 P6 1E6 1C6 A7 0 183 30 P7 1E7 1C7 A8 0 183 18 P8 1E8 1C8 CRUIN 0 183 17 P9 1E9 1C9 CRUOUT 0 183 16 PIO lEA lCA CRUCLK 0 183 - 14 Pl! lEB lCB TC 1 184 11 Pl2 !EC ICC TD 1 184 IS Pl3 lED lCD L 2 18S 10 Pl4 IEE ICE HLD 3 186 -- 9 PIS lEF lCF HLDA -- 3 186 8 Pl6 lFO IDO IDLE 3 186 7 Pl7 lFl IDl EC - 19E 6 Pl8 1F2 ID2 s Pl9 1F3 ID3 4 P20 lF4 ID4 3 P21 IFS IDS 2 P22 1F6 ID6 1 P23 1F7 ID7 31 P24 1F8 ID8 32 P2S 1F9 ID9 33 P26 lFA IDA 34 P27 lFB IDB 3S P28 lFC IDC 36 P29 l,FD IDD 38 P30 lFE IDE 39 P31 lFF IDF SUMMARY The 9940 is a powerful member of the 9900 family with execution techniques which are actually faster than the TMS9900. In fact, because of its higher speed clock (5 MHz) and a fast on-chip execution microcycle for register location, the average throughput is 20% faster than the standard 9900 devices. The assignability of the package pins via software adds a new dimension to microprocessor technology for improved flexibility and performance. For detailed information on this part, see the 9940 section of Chapter 8. 4-88 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques COMPLETE LISTING OF MACHINE CYCLES In order to complete the description of instruction execution, the individual instruction execution cycles are given in this section. Each machine cycle consists of two or more clock cycles (depending upon addressing mode) as defined herein. (Note: These machine cycles apply equally to the TMS 9980A/81 microprocessor, with the exception of the memory cycle as detailed below.) The 9900 family machine cycles are divided into three categories described in the following paragraphs. MACHINE CYCLES ALU Cycle The ALU cycle performs an internal operation of the microprocessor. The memory interface control signals and CRU interface control signals are not affected by the execution of an ALU cycle, which takes two clock cycles to execute. Memory Cycle The memory cycle primarily performs a data transfer between the microprocessor and the external memory device. Appropriate memory bus control signals are generated by the microprocessor as a result of a memory cycle execution. The memory cycle takes 2 + W (where Wis the number of wait states) clock cycles to execute. In the TMS 9980A/81, which has an 8-bit data bus, the memory cycle is composed of two data transfers to move a complete 16-bit word. The TMS 9980A/8 l memory cycle takes 4 + 2W (where Wis the number of wait states) clock cycles to execute. For the TMS.9980A/81 the following machine cycle sequences replace the memory sequences used in the instruction discussion. CYCLE Memory read/write AB Address of most significant byte (A 13 = 0) DB Most significant byte 2 Memory read/write AB Address ofleast significant byte (A13=1) DB Least significant byte CRU Cycle The CRU cycle performs a bit transfer between the microprocessor and I/O devices. It takes two clock cycles to execute. The address of the CRU bit is set up during the first clock cycle. For an input operation the CRUIN Jine is sampled by the microprocessor during the second clock cycle. For an output operation the data bit is set up on the CRUOUT line at the same time the address is set up. The CRUCLK line is pulsed during the second clock cycle of the CRU output cycle. Please refer to the specific 99XX microprocessor data manual for timing diagrams. 9900 FAMILY SYSTEMS DESIGN 4-89 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques The 9900 executes its operations under the control of a microprogrammed control ROM. Each microinstruction specifies a machine cycle. A microprogram specifies a sequence of machine cycles. The 9900 executes a specific sequence of machine cycles for a specific operation. These sequences are detailed on the following pages. The information can be used by the systems designers to determine the bus contents and other interface behavior at various instants during a certain 9900 operation. This description is maintained at the address bus (AD) and data bus (DB) levels. 9900 MACHINE CYCLE SEQUENCES Most 9900 instructions execution consists of two parts: 1) the data derivation and 2) operation execution. The data derivation sequence depends on the addressing mode for the data. Since the addressing modes are common to all instructions, the data derivation sequence is the same for the same addressing mode, regardless of the instruction. Therefore, the data derivation sequences are described first. These are then referred to in appropriate sequence in the instruction execution description. TERMS AND DEFINITIONS The following terms are used in describing the instructions of the 9900: TERM DEFINITION B Byte Indicator (1 =byte, 0 =word) C Bit count D Destination address register DA Destination address IOP Immediate operand PC Program counter Result Result of operation performed by instruction S Source address register SA Source address ST Status register STn Bit n of status register SD Source data register internal to the TMS 9900 microprocessor* W Works pace register SRn Workspace register n (n) Contents of n Ns Number of machine cycles to derive source operand Nd Number of machine cycles to derive destination operand AB Address Bus of the TMS 9900 DB Data Bus of the TMS 9900 NC No change from previous cycle *Note: The contents of the SD register remain latched at the last value written by the processor unless changed by the ALU. Therefore, during all memory read or ALU machine cycles the SD register and hence the data bus will contain the operand last written to the data bus by the CPU or the results of the last ALU cycle to have loaded the SD register. 4-90 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques DATA DERIVATION SEQUENCE Workspace Register CYCLE TYPE DESCRIPTION Memory read AB Workspace register address DB = Operand Workspace Register Indirect CYCLE TYPE DESCRIPTION 1 Memory read AB Workspace register address DB Workspace register contents 2 ALU AB NC DB SD 3 Memory read AB Workspace register content DB Operand Workspace Register Indirect Auto-Increment (Byte-Operand) CYCLE TYPE DESCRIPTION Memory read AB Workspace register address DB Workspace register contents 2 ALU AB NC DB SD 3 Memory write AB Wotkspace register address DB (WRn)+l 4 Memory read AB Workspace register contents DB Operand Workspace Register Indirect Auto-Increment (Word Operand) CYCLE TYPE DESCRIPTION 1 Memory read AB Workspace register address DB Workspace register contents 2 ALU AB NC DB SD 3 ALU AB NC DB SD 4 Memory write AB Workspace register address DB (WRn)+2 5 Memory read AB Workspace register contents DB Operand 9900 FAMILY SYSTEMS DESIGN 4-91 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques Symbolic CYCLE TYPE DESCRIPTION ALU AB NC DB SD 2 ALU AB NC DB SD 3 Memory read AB PC+2 DB Symbolic address 4 ALU AB NC DB 000016 5 Memory read AB Symbolic address DB Operand Indexed CYCLE TYPE DESCRIPTION 1 Memory read AB Works pace register address DB Workspace register contents 2 ALU AB NC ~4 DB SD 3 Memory read AB PC+2 DB Symbolic address 4 ALU AB PC+2 DB Workspace register contents 5 Memory read AB Symbolic address+ (WRn) DB Operand INSTRUCTION EXECUTION SEQUENCE A, AB, C, CB, S, SB, SOC, SOCB, SZC, SZCB, MOV, MOVB, COC, CZC, XOR CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate sequence for source data (Note 1) addressing mode, from the data derivation sequences 3+Ns ALU AB= NC DB= SD Nd Insert appropriate sequence for destination (Note 2, 3) data addressing mode from the data derivation sequences 4+Ns+Nd ALU AB NC DB SD 5+Ns+Nd Memory write AB DA (Note4) DB Result 4-92 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques NOTES: 1) Since the memory operations of the 9900 microprocessor family fetch or store 16-bit words, the source and the destination data fetched for byte operations are 16-bit words. The ALU operates on the specified bytes of these words and modifies the appropriate byte in the destination word. The adjacent byte in the destination word remains unaltered. At the completion of the instruction, the destination word, consisting of the modified byte and the adjacent unmodified byte, is stored in a single- memory write operation. 2) For MOVB instruction the destination data word (16 bits) is fetched. The specified byte in the destination word is replaced with the specified byte of the source-data word. The resultant destination word is then stored at the destination address. 3) For MOV instruction the destination data word (16 bits) is fetched although not used. 4) For C, CB, COC, CZC instructions cycle 5 + Ns + Nct above is an ALU cycle with AB=DA and DB=SD. MPY (Multiply) CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data (multiplier) addressing mode 3+Ns ALU AB NC DB SD 4+Ns Memory read AB Workspace register address DB Workspace register contents 5+Ns ALU AB NC DB SD 6+Ns ALU AB NC DB Multiplier 7+Ns Multiply the two operands 16ALU AB NC DB MSH of partial product 24+Ns Memory write AB Works pace register address DB MSH of the product 25+Ns ALU AB DA+2 DB MSH of product 26+Ns Memory write AB DA+2 DB LSH of the product 9900 FAMILY SYSTEMS DESIGN 4-93 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques DIV (Divide) CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data (divisor) addressing mode 3+Ns ALU AB NC DB SD 4+Ns Memory read AB Address of workspace register DB Contents of workspace register S+Ns ALU (Check overflow) AB= NC DB = Divisor 6+Ns ALU (Skip if overflow to next instruction fetch) AB NC DB SD ~4 7+Ns Memory read AB DA+2 DB Contents of DA+ 2 B+Ns ALU AB NC DB SD 9+Ns ALU AB NC DB SD Divide sequence consisting of Ni cycles AB NC where 48:S:Ni:S:32. Ni is data dependent DB SD lO+Ns+Ni ALU AB NC DB SD 11 +Ns+Ni Memory write AB Workspace register address DB Quotient 12+Ns+Ni ALU AB DA+2 DB Quotient 13+Ns+Ni Memory write AB DA+2 DB Remainder XOP CYCLE TYPE DESCRIPTION Memory read AB = PC DB = Instruction ALU Instruction decode AB NC DB= SD Ns Insert appropriate data derivation sequence according to the source data addressing mode 3+Ns ALU AB NC DB SD 4+Ns ALU AB NC DB SA S+Ns ALU AB NC DB SD 6+Ns Memory read AB 401s+4 x D DB New workspace pointer 4-94 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques CYCLE TYPE DESCRIPTION 7+Ns ALU AB NC DB SA 8+Ns Memory write AB Address of WRl 1 DB SA 9+Ns ALU AB Address ofWR15 DB SA lO+Ns Memory write AB Address of workspace register 15 DB Status register contents ll+Ns ALU AB NC DB PC+2 12+Ns Memory write AB Address of workspace register 14 DB PC+2 13+Ns ALU AB Address ofWR13 DB SD 14+Ns Memory write AB Address of workspace register 13 DB WP 15+Ns ALU AB NC DB SD 16+Ns Memory read AB 421 6 +4xD 4...- DB New PC 17+Ns ALU AB NC DB SD CLR, SETO, INV, NEG, INC, INCT, DEC, DECT, SWPB CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data addressing mode 3+Ns ALU AB NC DB SD 4+Ns Memory write AB Source data address DB Modified source data Note: The operand is fetched for CLR and SETO although not used. ABS CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data addressing mode 3+Ns ALU Test source data AB= NC DB= SD 4+Ns ALU Jump to 5' + Ns if data positive AB NC DB = SD 9900 FAMILY SYSTEMS DESIGN 4-95 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques CYCLE TYPE DESCRIPTION S+ns ALU Negate source AB NC DB SD 6+Ns Memory write AB Source data address DB Modified source data S'+Ns ALU AB NC DB SD x CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert the appropriate data derivation sequence according to the source data addressing mode ~4 3+Ns ALU AB NC DB SD Note: Add sequence for the instruction specified by the operand. B CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data addressing mode 3+Ns ALU AB NC DB SD Note: The source data is fetched, although it is not used. BL CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data addressing mode 3+Ns ALU AB NC DB SD 4+Ns ALU AB Address ofWRl l DB SD S+Ns Memory write AB Address of WRl 1 DB PC+2 Note: The source data is fetched although it is not used. 4-96 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques BLWP CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data addressing mode 3+Ns ALU AB NC DB SD 4+Ns ALU AB Address ofWR15 DB NC 5+Ns Memory write AB Address of workspace register 15 DB Status register contents 6+Ns ALU AB NC DB PC+2 7+Ns Memory write AB Address of workspace register 14 DB PC+2 S+Ns ALU AB Address or workspace register 13 4<11\f DB SD 9+Ns Memory write AB Address of workspace register 13 DB WP lO+Ns ALU AB NC DB SD ll+Ns Memory read AB Address of new PC DB New PC 12+Ns ALU AB NC DB SD LDCR CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence 3+Ns ALU AB NC DB SD 4+Ns ALU AB NC DB SD 5+Ns ALU AB Address ofWR12 DB SD 6+Ns ALU AB Address ofWR12 DB SD 7+Ns Memory read AB Address of WR12 DB Contents ofWR12 S+Ns ALU AB NC DB SD c Shift next bit onto CRUOUT line. AB Address + 2 Increments C Times Enable CRUCLK. Increment CRU bit DB SD address on AB. Iterate this sequence C times, where C is number of bits to be transferred. 9+Ns+C ALU AB NC DB SD 9900 FAMILY SYSTEMS DESIGN 4-97 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques STCR CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD Ns Insert appropriate data derivation sequence according to the source data addressing mode 3+Ns ALU AB NC DB SD 4+Ns Memory read AB Address ofWR12 DB Contents ofWR12 S+Ns ALU AB NC DB SD 6+Ns ALU AB NC DB SD c Input selected CRU bit. Increment CRU AB Address + 2 C times bit address. Iterate this sequence C times DB SD ~4 where C is the number of CRU bits to be input. 7+Ns+C ALU AB NC DB SD 8+Ns+C ALU AB NC DB SD C' Right adjust (with zero fill) byte (if C<8) AB NC or word (if 8 < C < 16). DB SD C' = 8-C-1 if C::::; 8 = 16-C if 8 < C::::; 16 9+Ns+C+C' ALU AB NC DB SD lO+Ns+C+C' ALU AB NC DB SD 11 +Ns+C+C' ALU AB Source address DB SD 12+Ns+C+C' Memory write AB Source address DB l/O data Note: For STCR instruction the 16-bit word at the source address is fetched. If the number of CRU bits to be transferred is < 8, the CRU data is right justified (with zero fill) in the specified byte of the source word and source data word thus modified is then stored back in memory. If the bits to be transferred is > 8 then the source data fetched is not used. The CRU data in this case is right justified in 16-bit word which is then stored at the source address. 4-98 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques SBZ, SBO CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 ALU AB NC DB SD 4 Memory read AB Address ofWR12 DB Contents of WR12 5 ALU AB NC DB SD 6 CRU Set CRUOUT = 0 for SBZ = 1 for SBO AB= CRU Bit Address Enable CRUCLK TB CYCLE TYPE DESCRIPTION I 1 Memory read AB PC 4.,.. DB Instruction 2 ALU AB NC DB SD 3 ALU AB NC DB SD 4 Memory read AB Address ofWR12 DB Contents ofWR12 5 ALU AB NC DB SD 6 CRU Set ST(2) = CRUIN AB Address ofCRU bit DB = SD JEQ, JGT, JH, JHE, JL, JLE, JLT, JMP, JNC, JNE, JNO, JOC, JOP CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 ALU Skip to cycle # 5 if TMS 9900 status satisfies the specified jump con,dition AB NC DB SD 4 ALU AB NC DB Displacement value 5 ALU AB NC DB SD 9900 FAMILY SYSTEMS DESIGN 4-99 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques SRA, SLA, SRL, SRC CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 Memory read AB Address of the workspace register DB Contents of the workspace register 4 ALU Skip to cycle #9 if C =I= 0 C = Shift count AB NC DB SD 5 ALU AB NC DB SD 6 Memory read AB Address ofWRO DB Contents ofWRO 7 ALU AB Source address DB SD 8 ALU AB NC ~4 DB SD 9 AB NC DB SD c Shift the contents of the specified workspace register in the specified direction by the specified number of bits. Set appropriate status bits. 9+C Memory write AB = Address of the workspace register DB = Result lO+C ALU Increment PC AB NC DB= SD AI, ANDI, ORI CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 ALU AB NC DB SD 4 Memory read AB Address of workspace register DB Contents of workspace register 5 Memory read AB PC+2 DB Immediate operand 6 ALU AB NC DB SD 7 Memory write AB Address of workspace register DB Result of instruction 4-100 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques CI CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB NC 3 Memory read AB Address of workspace register DB Contents of workspace register 4 ALU AB NC DB SD 5 Memory read AB PC+2 DB Immediate operand 6 ALU AB NC DB SD 7 ALU AB NC DB SD LI CYCLE TYPE DESCRIPTION 1 Memory read AB PC 4 .... DB Instruction 2 ALU AB NC DB SD 3 ALU AB NC DB SD 4 Memory read AB PC+2 DB Immediate operand 5 ALU AB Address of workspace register DB SD 6 Memory write AB Address of workspace register DB Immediate operand LWPI CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 ALU AB NC DB SD 4 Memory read AB PC+2 DB Immediate operand 5 ALU AB NC DB SD LIMI CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 ALU AB NC DB SD 4 Memory read AB PC+2 DB Immediate data 9900 FAMILY SYSTEMS DESIGN 4-101 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques CYCLE TYPE DESCRIPTION 5 ALU AB NC DB SD 6 ALU AB NC DB SD 7 ALU AB NC DB SD STWP,STST CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 ALU AB Address of workspace register DB sp 4 Memory write AB Address of the workspace register DB TMS 9900 internal register contents (WP or ST) ..... 4 CKON, CKOF, LREX, RSET CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction 2 ALU AB NC DB SD ALU AB NC DB SD 4 CRU Enable CRUCLK AB External instruction code DB SD 5 ALU AB NC DB SD 6 ALU AB NC DB SD IDLE CYCLE TYPE DESCRIPTION Memory read AB PC DB Instruction AJ-.U AB NC DB SD ALU AB NC DB SD 4 CRU Enable CRUCLK AB Idle code DB SD 5 ALU AB NC DB SD 6 ALU AB NC DB NC 4-102 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques RTWP CYCLE TYPE DESCRIPTION 1 Memory read AB PC DB Instruction 2 ALU AB NC DB SD 3 ALU WP+30 4 Memory read AB Address ofWR15 DB StatusoLD 5 Memory read AB Address of WR 14 DB PCoLD 6 Memory read AB Address ofWR13 DB WPoLD 7 ALU AB NC DB SD MACHINE-CYCLE SEQUENCE IN RESPONSE TO EXTERNAL STIMULI RESET 4<1111 CYCLE TYPE DESCRIPTION 1* ALU AB NC DB SD 2 ALU AB NC DB SD 3 ALU AB 0 DB 0 4 Memory read AB 0 DB Workspace pointer 5 ALU AB NC DB Status 6 Memory write AB Address of WR15 DB Contents of Status register 7 ALU AB NC DB PC 8 Memory write AB Address of workspace r~gister 14 DB PC+2 9 ALU AB Address ofWR13 DB SD 10 Memory write AB Address of workspace register 13 DB WP 11 ALU AB NC DB SD 12 Memory read AB 2 DB New PC 13 ALU AB NC DB SD *Occurs immediately after RESET is released following a minimum 3 cycle RESET 9900 FAMILY SYSTEMS DESIGN 4-103 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques LOAD CYCLE TYPE DESCRIPTION 1* ALU AB NC DB SD Memory read AB FFFC16 DB Contents of FFFC 16 ALU AB NC DB Status 4 Memory write AB Address of WR15 DB Contents of status register 5 ALU AB NC DB PC 6 Memory write AB Address of WR 14 DB PC+2 ALU AB Address of WR 13 DB SD Memory write AB Address of workspace register 13 DB WP ~4 9 ALU AB NC DB SD 10 Memory read AB FFFE DB New PC 11 ALU AB NC DB SD *Occurs immediately after last clock cycle of preceding instruction. Psuedo Instructions NOP Same asJMP RT Same as B with indirect thru Register 11. 4-104 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques Interrupts CYCLE TYPE DESCRIPTION 1* ALU AB NC DB SD 2 Memory read AB Address of interrupt vector DB WP 3 ALU AB NC DB Status 4 Memory write AB Address of WR15 DB Status 5 ALU AB NC DB PC 6 Memory write AB Address of WR 14 DB PC+2 7 ALU AB Address ofWR13 DB SD 8 Memory write AB Address of WR 13 DB WP 9 ALU AB NC 4~ DB SD 10 Memory read AB Address of second word of interrupt vector DB New PC 11 ALU AB NC DB SD *Occurs immediately after last clock cycle of preceding instruction TIMING The timing of the ALU, CRU, and memory cycles is shown in Figures 4-77, 78 and 79. Figure 4-80 shows the TMS9980A/81 memory cycle. - - - - - A L U CYCLE - - - - - - - . - . . - ALU CYCLE --------~ WRITE READ WRITE !READ ALU INTERNAL ALU INTERNAL RESULT REGISTERS/ ALU OPERATION RESULT REGISTERS/ ALU OPERATION INTO CONST ANTS INTO CONSTANTS INTERNAL ONTO INTERNAL ONTO REGISTERS ALU REGISTERS ALU INPUT INPUT BUSES BUSES Figure 4-77. ALU Cycle 9900 FAMILY SYSTEMS DESIGN 4-105 MACHINE CYCLES Hardware Design: Architecture and Interfacing Techniques I,. CRU CYCLE OUTPUT ., I ,I .. CRU CYCLE INPUT I •I I I I Ti I T2 I Ti T2 I Ti T2 Ti I I I I CRUOUT - - - : I x I I I x__----.---1;;_-...,..-x ! I I CRUCLK I lr\1 I, I I I I I 1 I I I I 1 I I 1 I : I CRUIN :xxXxxxxxXxxxxXxxxxxXxxxxX:Xxxxxl)xxxxxXzx 1 I 9 I __--.--I I I I I I I I 1 I I I I I x x: '. 1 '4. A's ='.X I I I I : Figure 4-78. CR U Cycle. READ WRITE MEMORY CYCLE I Tl MEMORY CYCLE T 2 Tl T2 I I MEMEN ~-------"-----------X~-----------'-- Ao · A14 ~-----V-AL_1o_ _ _ _ _ _ _ _ _x\.-_____ vA_L_10_ _ _ _ _..;.__ I I OBIN _l__j I \.__ _ _ _ _ _ _ _ _ _...;..._ WE I I I \. ~ I I I \___/1 I 1 READY J\-'-----1',------------.\ I {_____. . ;. I _ 1 I I I CE WAIT ---'--------"-------~-------,...-------"- DATA Do· 015 Figure 4-79. TMS 9900 Memory Cycle (No Wait States) 4-106 9900 FAMILY SYSTEMS DESIGN Hardware Design: Architecture and MACHINE CYCLES Interfacing Techniques ------WRITE ------t•Ml•11------ A13 AO-A12 ===:x-----~---------~.....Jx_~ _______________x___~~- OBIN READY DO. 07 ===x- CPU WRITE DATA x CPU WRITE DATA x INPUT MODE I RD\ INPUT MODE I RD \ INPUT Figure 4-80. TMS 9980A I 81 Memory Cycle (No Wait States) 9900 FAMILY SYSTEMS DESIGN 4-107 CHAPTERS Software Design: Programming Methods and Techniques 9900 ARCHITECTURE Software Design: Programming Methods and Techniques 9900 ARCHITECTURE The 9900 system is illustrated in Figure 5-1. The major subsystems are the 9900 processor, the memory for program and data storage, and input and output devices for external communicatioii and control. The processor controls the fetching of data and instructions from memory or input devices and the transferring of data from one location to another. The data and instructions are transferred 16 bits at a time in groups called words. These words are addressed or located by signals on the 15 address lines Ao through A 14 (called the address bus). A 15 binary bit address will select one of 32, 768 memory words. 1 l I l • INPUT DATA TO AND MEMORY AND ) FROM EXTERNAL v- OUTPUT SYSTEMS > ?"\ Ai-A14 ADDRESS DATAAND INSTRUCTIONS A. 9900 Do-Dis Figure 5-1. General 9900 System Structure Internally, the processor generates a 16 bit address but the least significant bit, A 15 , is not sent to the memory. Each word is further broken down into two 8 bit groups called bytes as shown in Figure 5-2. The first 8 bit byte of a word is located at an even address (A15 = 0). The second 8 bit byte is located at an odd address (A15 = 1). The byte selection is done internally in the processor once the full 16 bit data word is obtained from one of the 32, 768 word locations in memory. Byte addressing is used only on instructions that perform byte operations; most 9900 instructions are word operations. The processor contains certain basic elements as shown in Figure 5-3. The timing and control section is of primary interest to the hardware designer who must make certain that all system events occur in the correct order and at the correct time. The software designer is interested in what operations the ALU provides and the registers that determine the instruction and data addresses. These registers are the program counter, the status register, and the workspace pointer. In addition, the instruction register is of interest in understanding the basic instruction cycle of the processor. The 9900 contains other registers such as data address registers, ALU scratchpad registers, and so on. The processor also provides hardware to decode instructions, control the ALU operation, and to control the CRU input and outputs. These components all work together to provide the basic instruction fetch and execution cycle of the processor. 5-2 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods 9900 ARCHITECTURE and Techniques MOST SIGNIFICANT LEAST SIGNIFICANT 8 BIT BYTE 8 BIT BYTE (EVEN ADDRESS, A, 5 = 0) (ODD ADDRESS, A 1s = 1) I 1 1 1 II 1 1 1 1 1 1 I 0 I 1 2 3 4 s 6 1ls'9 10 11 12 13 14 1sj MOST I SIGNIFICANT \ LEAST SIGNIFICANT BIT BIT 16 BIT WORD (ADDRESSED BY 14 MOST SIGNIFICANT ADDRESS BITS) Figure 5-2. 9900 Words and Bytes ADDRESS LINES (15 BITS) DATA INSTRUCTION ADDRESS ADDRESS WORKSPACE POINTER PROGRAM COUNTER WP REGISTER PC REGISTER (16 BITS) (16 BITS) DECODER AND STATUS REGISTER TIMING ST INSTRUCTION ARITHMETIC-LOGIC REGISTER IR UNIT ALU INSTRUCTIONS DATA DATA LINES Figure 5-3. Basic 9900 Elements. 9900 FAMILY SYSTEMS DESIGN S-3 9900 ARCHITECTURE Software Design: Programming Methods and Techniques INSTRUCTION REGISTER AND CYCLE The instruction cycle that is performed over and over again by the processor consists of the following basic operations: 1) Instruction Fetch - the contents of the program counter are sent out on the address lines and a memory read is performed. The 16 bit instruction operation code word is sent from the memory along the data lines D 0 through D 15 and is latched in the processor instruction register. 2) Instruction Execution - The instruction is decoded and executed. Usually, the address of the data to be operated on (source data) is generated and a memory read cycle is performed to get the data into the processor. Then a destination address is generated and a memory write cycle is performed to store the result of the operation at a de.sired destination memory location. 3) The contents of the program counter are changed to indicate the address of the next instruction and the processor returns to the instruction fetch operation. This sequence is repeated continually as long as power is supplied to the processor. The number of memory references required in the instruction operation depends on the format that is used for the instruction. Instructions can have one of 9 such formats as illustrated in Figure 5-4. The instruction code indicates to the processor how many memory references are required to get all the information needed by the instruction. The first memory read obtains the instruction code which determines which operation is to be performed and how the data is located. A second and possibly a third memory read may be required to obtain values or addresses for the data to be used in this operation. An immediate instruction (format 8) consists of two successive memory words: the first for the instruction code and a second word that contains the data constant to be used. Other instruction formats contain a Ts and/ or a T d field to indicate the existence of data addresses as part of the instruction. If a Ts or Ta two bit field contains a 10 2 , the address of the source or destination locations or both will be contained in the one or two memory locations immediately following the instruction code word as illustrated in Figure 5-5. In these cases, one or two additional memory reads are required to fetch these addresses for use by the instruction to locate data in memory. Obviously, the more memory references required to get all of the instruction, the longer the execution time for that instruction. The programmer also needs to be aware of the number of words of memory required for each instruction in order to estimate program memory requirements. S-4 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods 9900 ARCHITECTURE and Techniques Instruction Format Instruction Coding Fields* 1 (Arithmetic) D s 2 Qump/CRU) CODE DISPLACEMENT 3 (Logical) CODE D Ts s 4 (CRU) CODE c Ts s 5 (Shift) CODE c w 6 (Program) CODE s Ts 5<1111 7 (Control) CODE 0000 I 8 (Immediate) CODE I I 00 w 9 (Multiply, CODE D Ts s Divide, & Extended Operation) *The Fields are defined as follows: CODE - Indicates the bits defining the operation code B - Byte/Word Indicator (Single bit) D - Workspace Register of the destination code (4 bits) T d - Addressing mode of the destination operand (2 bits) S - Workspace Register of the source operand (4 bits) Ts - Addressing mode of the source operand (2 bits) C - Shift or Bit count (4 bits) W - Indicates Workspace Register to be used (4 bits) Figure 5-4. 9900 Instruction Formats 9900 FAMILY SYSTEMS DESIGN 5-5 9900 ARCHITECTURE Software Design: Programming Methods and Techniques ADDRESS WORD ADDRESS WORD Td Ts Td Ts (PC) CODE I10 I D I I s 00 (PC) CODE I 10 I D I I s 10 (PC)+ 2 SOURCE DATA ADDRESS (PC)+ 2 SOURCE DATA ADDRESS (PC)+ 4 NEXT INSTRUCTION (PC)+ 4 DESTINATION ADDRESS (PC)+ 6 NEXT INSTRUCTION TWO WORD INSTRUCTION THREE WORD INSTRUCTION (PC) MEANS: CONTENTS OF THE PROGRAM COUNTER Figure 5-5. Example Memory Requirements far Format 1 Instroctions. PROGRAM COUNTER (PC) The program counter, abbreviated PC, contains the address of the instruction to be executed as illustrated in Figure 5-6. Normally, after executing an instruction, the contents of the program counter are incremented by two to locate the next instruction word in sequence in memory. The programmer can control the contents of the program counter (and thus control w.here the next instruction is to be found) by using branch or jump instructions. These instructions offer the alternatives of taking the next instruction in sequence or jumping to another part of program memory for the next instruction. PROGRAM COUNTER INSIDE PROCESSOR OUTSIDE PROCESSOR ADDRESS OF THE INSTRUCTION MEMORY READ SIGNAL Figure 5-6. Purpose of the Program Counter 5-6 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods 9900 ARCHITECTURE and Techniques STATUS REGISTER (ST) The purpose of the status register is to store the general arithmetic and logic conditions that result from the execution of each instruction. This information lets the programmer know if the last operation caused a result equal to or greater than some reference number (often zero). It includes the information regarding the sign of the result (was it a negative or a positive number), the parity of the result (an odd or even number of one bits), and if a carry or overflow occurred (indicating that the 16 bit word length was insufficient to hold the result). The status register also contains a 4 bit code known as the interrupt mask which defines which of 16 hardware subsystem interrupt signals will be recognized and responded to by the processor. The information contained in the status register is defined in Figure 5- 7. 0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I I Interrupt Mask Status Register Bit 0 LGT Logical Greater Than - set in a comparison of an unsigned number with a smaller unsigned number. AGT Arthmetic Greater Than - set when one signed number is compared with another that is less positive (nearer to -32,768). 2 EQ Equal - set when the two words or two bytes being compared are equal. 3 c CatTy - set by carry out of most significant bit of a word or byte in a shift or arithmetic operation. 4 ov Overflow - set when the result of an arthmetic operation is too large or too small to be correctly represented in 2's complement form. OV is set in addition if the most significant bit of the two operands are equal and the most significant bit of the sum is different from the destination operand most significant bit. OV is set in subtraction if the most significant bits of the operands are not equal and the most significant bit of the result is different from the most significant bit of the destination operand. In single operand instructions affecting OV, the OV is set if the most significant bit of the operand is changed by the instruction. 5 OP Odd Paniy - set when there is an odd number of bits set to one in the result. 6 x Extended Operation - set when the PC and WP registers have been to set to values of the transfer vector words during the execution of an extended operation. 7-11 Reserved for special Model 990/10 computer applications. 12-15 IntetTupt Mask - All interrupts of level equal to or less than mask value are enabled. Figure 5-7. TMS9900 Status Register Contents 9900 FAMILY SYSTEMS DESIGN 5-7 9900 ARCHITECTURE Software Design: Programming Methods and Techniques WORKSPACE POINTER (WP) This register addresses the first word in a group of 16 consecutive memory words called a workspace as illustrated in Figur~ 5-8. These workspace words are called workspace registers and are treated by the processor as if they were registers on the processor chip. These workspace registers can be used as accumulators for arithmetic operations or for storage of often used data. When the workspace register contains the data used by the instruction, the Ts or Tct fields in the instruction format (see Figure 5-4) are 00. This way of locating instruction operands is an addressing mode called workspace register addressing. The workspace register can also be used to store the address of the data to be used instead of storing the data itself. In this case the Ts or Tct fields of the instruction code or format will be 01. This type of addressing (method of data location) is known as register indirect addressing. Workspace registers 1 through 15 can also be used to store the base addres·s to which an offset will be added to determine a data address. This type of addressing is called indexed addressing and the Ts or T ct fields for this type of addressing will be a 10. Some of the workspace registers are reserved for specific tasks as shown in Figure 5-8. If a certain type of subroutine branch called a branch and link (BL) is performed, register 11 is used to save the contents of the program counter at the time of the branch. In another type of subroutine branch, the branch and link workspace (BLWP) instruction, registers 13, 14, and 15, are used to save the values of WP, PC, and ST registers, respective! y, that were in the processor at the time the branch instruction occurred. These registers then allow the programmer to return to the situation or program context that existed prior to the branch. Register 12 is used to form the address of certain input and output bits that make up part of the communications register unit (CRU) subsystem. REGISTER USE MEMORY ADDRESS REGISTER I WORKSPACE POINTER 1l) WP+ 00 0 -------------OPTIONALSHIFT WP +02 1 COUNT WP +04 2 WP +06 3 WP +08 4 WP+OA 5 WP +OC 6 WP+OE 7 DATA INDEX WP+ 10 8 OR WP+ 12 9 ADDRESSES CAPA~BILITY WP+ 14 10 WP+ 16 11 ---1---------BLRETURNADDRESS WP+ 18 12 - - - - - - - - - - - - - C R U BASE ADDRESS WP+ 1A 13 - - - - - - - - - - - - - S A V E D WP WP+ 1C 14 - - - - - - - - - - - --SAVED PC WP+ 1E 15 - - - - ---------SAVEDST Figure 5-8. 9900 Workspace Structure 5-8 9900 FAMILY SYSTEMS DESIGN Software Design: 9900 ARCHITECTURE Programming Methods and Techniques The relationships between the workspace registers and the instruction operations must be understood by the programmer to effectively utilize the 9900. Much of the addressing of data involves the use of workspace registers and branch and input/ output instructions must use the dedicated registers 11 through 15. The use of the workspace in performing the basic program functions offered by the 9900 will be covered in detail throughout this chapter. PROGRAM ENVIRONMENT OR CONTEXT The contents of the three processor registers (PC, WP, and ST) completely define the status of the system program at any given time. As illustrated in Figur~ 5-9, the program counter keeps track of that part of the system program currently being executed by specifying the current instruction location. The status register keeps track of the logical and arithmetic conditions that result from the execution of each instruction. The workspace pointer keeps track of the location in memory of the sixteen general purpose workspace registers currently being used by the program. The contents of the processor and workspace registers define the current program environment or context of the system. A change in the contents of these registers will change the environment to a new part of program memory and a new workspace area. Thus, the system will be switched to a new environment or program context by such a change. Similarly, by restoring the contents of PC, WP, and ST to original values, the program environment will be switched back to the original context and continue executing in the original program environment. MEMORY I l PC ..... CURRENT PROGRAM SUBPROGRAM SEGMENT BEING EXECUTED I~ WPI I ST I WORKSPACE t CURRENT WORKSPACE BEING USED Figure 5-9. Program Context 9900 FAMILY SYSTEMS DESIGN 5-9 MEMORY ORGANIZATION Software Design: Programming Methods and Techniques MEMORY ORGANIZATION The 9900 system memory must provide storage locations for the system program and subprograms and storage for system data. Since the physical devices used for storing instructions are often a different type of memory device from those used to store data, the program is usually stored in consecutive blocks of memory separate from the blocks of data. This is illustrated in Figure 5-10. Also shown in Figure 5-10 are groups of memory locations that must be reserved for program and workspace addresses used by certain subprograms. Thus, the memory is subdivided into three types of storage locations: program memory, data memory, and reserved or dedicated memory. ADDRESS MEMORY _I_ 000016 PROCESSOR INTERRUPT REGISTERS TRANSFER VECTORS 003E 16 RESERVED MEMORY PROGRAM LOCATIONS 004016 EXTENDED COUNTER OPERATION TRANSFER VECTORS OO?E16 STATUS REGISTER 008016 INSTRUCTIONS PROGRAM OF STORAGE ~s PROGRAM MODULE 1 ROM WORKSPACE POINTER PROGRAM MODULE 2 ) "> WORKSPACE 1 WORKSPACE 2 ) "> RAM DATA GROUP 1 DATA GROUP 2 WORKSPACE 3 ') LOAD "' TRANSFER VECTOR Figure 5-10. 9900 Memory Organization 5-10 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods MEMORY ORGANIZATION and Techniques RAM/ROM PARTITIONING The program storage should be non-volatile so that the system program is not lost when the system power is turned off. Further, it is often desirable for the program memory to be a read-only memory or ROM. High volume read-only memory devices are mask programmable by the manufacturer. Alternatively, the program storage can be placed in a programmable read only memory (PROM). These devices may be economically programmed in smaller quantities. Programming may be performed by the user or by the distributor of the devices. Since both PROM and ROM devices provide word storage in consecutive addresses and the processor executes programs by going through instructions in sequence, the instructions that comprise a given subprogram should be placed in consecutive addresses in a block of memory words called a program module. It is not necessary that all program modules be adjacent to each other in memory, though certainly it is reasonable to do so. System data storage, excluding input/ output registers, provide storage for data being processed by the system program. These storage locations are usually located in consecutive blocks of memory. Since the data memory must provide both read and write capability, it is often called read-write memory. A more common terminology is random access memory or RAM, though this is somewhat misleading, since the program memory in ROM may also be randomly accessed. S ~x~ >l~__ __:!- o_P_ER_A_ND _ ___, I I REGISTER 6 ....__ ---L_____~ ~ _ < / 1 I I I I I I WORKSPACE 1 I II FOR SUB- R13 ... - - - - - - - ~L~P- - - - - - - - _J I ROUTINE R141-------------1..._ - - _ ...:._ _ _ ~L~~ _ _ _ _ _ _ _ _ _j_ J R15 ~ _ _ _ _ _ _ _ OLDS2._ _______ j Figure 5-15. Execution of BLWP Instruction (BLWP @TVAL) 5-22 9900 FAMILY SYSTEMS DESIGN Software Design: SUBROUTINE TECHNIQUES Programming Methods and Techniques . !™ q i Extendeµ operation instructi~ms (XOP) offer a means of expanding the 9900 instruction set. The implementation of an XOP is similar to the execution of a BLWP; the instructions tjiffer only in the location of the transfer vector and in the parameter passing feature offered by the XOP. The execution of an XOP is illustrated in Figure 5-16 and consists of the following events: 1) Identify the XQP number (N) and locate a transfer vector in memory at the address 004016 + 4X N. 2) Use the transfer vector word one as the new workspace pointer value and the second word of the vector as the new program counter value. 3) Save the old contents of WP, PC, and ST in new workspace registers 13, 14, and is, respectively. 4) Store the effective address of the source operand in new workspace register 11. Thus, XOP initiates a context switch with the added benefit ofdirect passr!zg of a parameter address to the new workspace (register 11). By using an assembler directive DXOP, the user can define a mnemonic string to present one of the 16 XOP transfer vectors. This mnemonic can then be used in the program as a user defined instruction, improving the clarity of the program coding. For example, to define XOP 15 as the mnemonic SAMPL, the following directive can be used: DXOP SAMPL, 15 Then, instead of using the standard XOP entry in the program: XOP @PARAM, 15 The programmer can insert the newly defined mnemonic: SAMPL @PARAM The XOP call is a software trap to a user-defined routine~ It functions as though the routine were a single instruction added to the 9900 set of operation codes, hence the name "extended operation." 9900 FAMILY SYSTEMS DESIGN S-23 SUBROUTINE TECHNIQUES Software Design: Programming Methods and Techniques RESERVED MEMORY 0000 KEY: 0040 - - BEFORE XOP - - AFTERXOP 40 + 4 x 15 = 007C NEW WP VALUE 007E NEW PC VALUE (SUB2) "_, ~-- "" -- ______ 9900 I GENERAL MEMORY ",, " - . ,. , ,.1..___ PROGRAM COUNTER ___,.I- - - -1 I I MAIN PROGRAM XOP @PARAM, 15 ,___ _ __ STATUS _ ___, REGISTER I- - ,I I I "~ I su~~~~~NE !"""' t---------- =W==OR=K=S=PA=C=E=P=O=IN=TE=R==i- 1 =1 RTWP /· PA RAM SOURCE OPERAND . I ADDRESS I I I I / / RO I I PR~~~AM (/ WORKSPACE 1 R15 1-------------1 I ;/ I 11 f I I I I RO JI I I I I XOP15 I I Rl 1 STORES SOURCE ADDRESS .._ - - - 1 I tIt WORKSPACE I I R13 ... - - - - - - - - - ~LD~p - - - - - - - - - R141----------1. _ - _ _ _ _ _ _ ~ ~D~ _ _ _ _ _ _ _ _ _ JI_ Rl 5 .,_ - - - - - - - - - Q.LD....§T - - - - - - - - - Figure 5-16. Execution of XOP Instruction (XOP @PARAM, 15) 5-24 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods SUBROUTINE TECHNIQUES and Techniques p ARAMETER p ASSING Most subroutines require access to data generated by the calling procedure. Different subroutine call types mandate different parameter passing techniques. All three types of subroutine calls, BL, BLWP, and XOP, transfer the old contents of the program counter to the called procedure. This return linkage provides a powerful tool for parameter passing as illustrated in Figure 5-17. A parameter list can be assembled in a block of words following the call and accessed through the old program counter by workspace register indirect autoincrement addressing. Regardless of the number of parameters used in any given call, the program counter must be incremented past the whole list, so that the return will be to the next instruction in the calling program. A subroutine call using only one of two passed parameters is shown in the following example: 0200 BL @ANG Call Subroutine ANG 0202 FLAGl DATA > 0 Parameter 1 is 000016 0204 FLAG2 DATA > 1 Parameter 2 is 000116 0600 ANG MOV *11 + ,3 Move Parameter 1 into R3 0602 c 3,2 Compare Parameter 1 to contents of R2 0604 JEQ FIRSTEQ Try next test if equal 0606 INCT Rll Move Return PC past parameter 2 0608 B *11 Return 060A FIRSTEQ The subroutine ANG checks the first parameter against the contents of R2. If an inequality is found, the branch to continue the routine at FIRSTEQ is not taken. The move instruction which loaded parameter 1 into the workspace increments the program counter in Rll by 2 so that register 11 now points to parameter 2. The INCT instruction is required to increment the program counter value in Rl 1 past parameter 2 to point to the next instruction in the calling program. When parameters are passed in this way using the program counter, good programming practice dictates that they be constants or addresses only and not variables. Variable quantities should be stored in memory external to program code. To 'nest' variable data in program code causes in-line code modification, which would produce code that would be inoperative if stored in ROM. · The example above dealt with the BL subroutine call, though the same technique can be applied to BLWP or XOP calls. These calls store the program counter in workspace register 14, so the indirect address register must be 14 instead of 11. 9900 FAMILY SYSTEMS DESIGN 5-25 SUBROUTINE TECHNIQUES Software Design: Programming Methods and Techniques KEY: - - - - BEFORE CALL - - - - AFTER CALL GENERAL AUTOINCREMENT INDIRECT MEMORY ADDRESS 9900 MAIN SUBROUTINE CALL --- PROGRAM COUNTER ~- i PROGRAM PARAMETER 1 .._ / / / ' PARAMETER 2 \ / / I \ / WORKSPACE POINTER NEXT INSTRUCTION ._,\~/ / /" /' I I/ I/ I SUBROUTINE 1 FIRST INSTRUCTION .$ / 'I ~ I/ EXECUTION OF *11 + (BL CALL) or * 14 + (CONTEXT SWITCH) I I PROGRAM I I/ Y" / '/" I 7~DDRESS OF NEXT PARAMETE R I /" + I RO OLD PC I SUBROUTINE WORKSPACE OLD PC VALUE / ; /2 STORED INS UBPROGRAM WORKSPACE: R1 1 FOR BL CALL: R14 FOR BLWP OR XOP OR INTERRUPT ~------- _, I Figure 5-17. Parameter Passing Using Old Program Counter Value. Another method of parameter passing is used when a context switch occurs. Both BLWP and XOP cause the old contents of the workspace pointer to be stored in the new workspace register 13. By using register 13 in the called procedure, access is gained to parameters'in the old workspace as illustrated in Figure 5-18. Direct a~cess to old register 0 is provided, but to use other parts of the old workspace, indexed addressing provides the most convenient access to old registers 1 through 15 without changing the old workspace pointer value~ For example, to move the contents of old workspace register 2 to new workspace register 5, the following instruction can be used: MOV @R2*2(13),R$ which causes the address of the operand to be the contents of register 13 plus 4, which is the address of old workspace register 2. Similarly, to move the contents of old workspace register 7 to old workspace register 6: MOV @R7*2(13), @R6*2(13) 5-26 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods SUBROUTINE TECHNIQUES and Techniques GENERAL MEMORY KEY: - - - BEFORE CALL AFTER CALL MAIN SUBROUTINE CALL --- - INDEXED ADDRESSING PROGRAM NEXT INSTRUCTION 9900 - -1 - - -- - PROGRAM COUNTER FIRST INSTRUCTION ~·- - SUBROUTINE I /I._ _w_o_R_Ks_P_1\c_E_P_o_1N_TE_R__.I- - 1 / / I RO / I / R1 / I MAIN PROGRAM R2 WORKSPACE // I R3 i--~~~~--1....____ ,..........._~ / I I 1------------< JI'/ R/ , /coLD WP) + 6 = ADDRESS OF OLD R3 GENERATED BY ~~~~D ADDRESSING' I I SUBROUTINE WORKSPACE I RO R13 / , t-----OL_D_W_P-VA-L-UE---1~ - - 2' (OLD REGISTER NUMBER) = 2x3 TO ACCESS OLD R3 - - - Figure 5-18. Parameter Passing through Old Workspace Pointer - - OLD WP VALUE- - - - - - :I _j A final type of parameter passing applies only to XOP context switches. The single argument of an XOP call specifies the effective address of a source operand. This form of parameter passing avoids the risk of changing the old PC and WP. The overhead of changing the WP and PC pointers is also avoided to increase execution speed. As an example, if XOP 9 has been defined as FADD by a DXOP directive, the call: FADD @LIST causes the address stored at location LIST to be placed in register 11 of the subroutine workspace. Then, workspace register indirect addressing can access the parameter. For example, if in the FADD subroutine it is desired that the parameter be incremented by two, the following instruction would be used. INCT *11 The use of the parameter through its address in register 11 is straightforward and doesn't interfere with the return linkage. This type of parameter passing has already been illustrated in Figure 5-16. 9900 FAMILY SYSTEMS DESIGN 5-27 SUBROUTINE TECHNIQUES Software Design: Programming Methods and Techniques MULTIPLE LEVEL SHARED WORKSPACE SUBROUTINES Since the BL instruction always reloads the workspace register 11, special steps must be taken to insure that the information in register 11 is not overstored. In the case of multiple levels of BL called subroutines, routines which call other routines before returning to the main program, a pushdown stack should be established to save intermediate return linkage. To create a return linkage stack for multiple levels of subroutines which share a workspace, the following procedure is employed: 1) Allocate one workspace register to the stack pointer function. 2) For each subroutine, "push" the contents of workspace register 11 before the next call, and "pop" the stack to restore the register 11 contents after each call is complete. An example of a stack manipulation code following this procedure to push and pop return linkage is as follows, with register 5 acting as a stack pointer: Subroutine code before next level call DECT MOV 5 11, *5 Decrement Stack Pointer Load return PC onto Stack } Push Operation BL @SUBNXT Call next level of subroutine MOV *5+, 11 After return, restore current ! return address and restore stack pointer Pop Operation This code allows the current subroutine to call subroutine SUBNXT without destroying the current subroutine's return linkage. The main program employs a standard BL call, and the lowest level routine would not use the stack, since its register 11 would not be replaced with a subsequent BL call. An example of this stack operation procedure with 3 nested subroutines is illustrated in Figure 5-19. SHARED WoRKSPACE MAPPING Software systems for small computers must efficiently utilize available memory. This section presents an organized technique for sharing workspaces between subroutines to reduce system memory requirements. 5-28 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods SUBROUTINE TECHNIQUES and Techniques ms f I j aI CONTROL PROGRAM ~j BL @SUB1 ___. SUB1 PUSH R11 TO STACK TO SAVE LINK 1 BL @SUB2 __..SUB2 POP STACK PUSH R11 TO RESTORE TO STACK LINK 1 TO TO SAVE R11 LINK 2 RET BL @SUB3 POPSTACK TO RESTORE LINK 2 TO R11 Ii --1>-SUB3 1 I 1--------1 LINK 3 1---R-ET----t RET Figure 5-19. Stack Operations in Nested Subroutines. The first step in system development is to write a main program and its associated subroutines with totally independent workspaces. Avoidance of shared workspaces at the start can prevent the undesirable aspect of destruction of critical data, including return linkage. After independent software is written, the programmer begins the process of identifying potential shared workspaces. First, the relationship between called and calling procedures is summarized graphically as shown in Figure 5-20. This graph represents the fact that procedure A can call either procedure B or C. Procedure B may call Dor E, while E can call Dor G, and so on throughout the graph. Having identified routine relationships, Figure 5-20 can be changed to a form that reflects subroutine levels. All procedures at the same level are called from a higher level and may call routines at a lower level. 9900 FAMILY SYSTEMS DESIGN 5-29 SUBROUTINE TECHNIQUES Software Design: Programming Methods and Techniques Thus, Figure 5-20 would be changed to the form illustrated in Figure 5-21. This information is equivalent to the information contained in Figure 5-20, but it clarifies the relationship between procedures. The routines on a particular level can never call another routine at the same or at a higher level. Thus, all routines at the same level can share a common workspace since return linkage will not be overstored by a subsequent call. Therefore, for the example described in Figures 5-20 and 5-21, five independent workspaces will suffice for a software system of eight procedures, saving 3 workspaces or 48 words of memory. By employing this simple technique, the software designer can write efficient code with an assurance of the integrety of return linkage. Figure 5-20. Graphical Representation of Interrelation of Calls RE-ENTRANT PROGRAMMING Re-entrant programming is a technique that allows one set of program code to be executed on multiple data sets concurrently. To be re-entrant, program code must have the following characteristics: 1) All data contained in a re-entrant routine must be common to all procedures which call it, and must be read-only to all using procedures. 2) All data unique to calling routines must be stored and used in a workspace unique to the calling procedure. 3) Re-entrant code must not alter data or instructions within its code during execution. Re-entrant coding is a general programming technique that has many applications. Device service routines which control the operations of several similar units should be re-entrant. By passing a CRU base address with other unique data to a re-entrant service subprogram, any one of a group of calling procedures can access such a multi-purpose I/O routine, thereby saving system memory requirements. This is a case in which one routine is used for several applications at random time intervals. A re-entrant subroutine is so loosely coupled to its calling procedure that a re-entrant routine can be interrupted during execution, used on different data, and return to complete the original process without losing data integrity. Since re-entrant code is immune to problems with data resulting from interrupts, it finds application in interrupt service routines, commonly called procedures, in a multiprogramming environment such as assemblers or in real- time control applications. 5-30 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods SUBROUTINE TECHNIQUES and Techniques LEVEL 0 LEVEL 1 LEVEL 2 LEVEL 3 LEVEL 4 Figure 5-21. Levels of Subroutine Calls Figure 5-22 illustrates a program flow in which subroutine A must be re-entrant. The alternative to writing subroutine A in re-entrant code is to make two copies of A, one for each time A can be executed concurrently. The re-entrant approach is more efficient in memory usage than is the multiple copy approach. In this program flow, the main program calls its first level subroutine which in turn calls subroutine A as a second level subroutine. During execution of routine A, an interrupt occurs, which in this example the interrupt handler program sequence calls several routines, including routine A. If A 5 <1111111111 employs re-entrant programming, the same words of code can implement routine A for both parts of the program flow. MAIN PROGRAM r-----, I I I PROGRAM I INTERRUPT SUBROUTINES I HANDLER I _ _ _ _ _ _JI INTERRUPT RETURN Figure 5-22. Interrupt Requiring Re-entrant Programming As an example of re-entrant coding, consider the problem of forming a starting and an ending address for a block of data to be operated on by a subroutine. Register 1 is to hold the starting address, register 2 is to hold the ending address, and register 3 is to hold the current data address within the block. 9900 FAMILY SYSTEMS DESIGN 5-31 SUBROUTINE TECHNIQUES Software Design: Programming Methods and Techniques This structure is in a subroutine that must be re-entrant, i.e., one that can be called concurrently by two different program segments as illustrated in Figure 5-22. Different program segments that use this subroutine will probably be dealing with blocks at different starting addresses and of different sizes. For example, the main program stream may be operating on a block of 10 words starting at address 100016 while the interrupt handler may have to operate on a 32 word block starting at address 200016 • Forming the starting and ending addresses as follows: BLKLN EQU 32 LI 1,> 1000 Load Rl with starting address LI 2,2*BLKLN Load R2 with 2x (words in block) A 1,2 Form end address for block (101416 ) would not result in re-entrant code. This sequence would be correct for the main program stream but is not correct for the interrupt handler stream. The code can be made to work for both streams by not placing the load immediates in the subroutine itself but by placing them in the program stream that calls the subroutine. Then, when either the main program or the interrupt handler gets ready to call the subroutine, the starting address and ending address can be established within the workspace for that environment. The subroutine can then concentrate on' performing its manipulations,. without being concerned with the address initialization process. Suppose that this addressing scheme is used in a subroutine that clears a block of memory words. Figure 5- 23 shows the re-entrant and non-re-entrant forms of this subroutine. The re-entrant form can be used in the situation of Figure 5-22 since execution depends on the workspace being used. The subroutine can be executing with the registers 1 through 3 of the main program when an interrupt occurs. The interrupt handler uses a different workspace so when it calls the CLEAR subroutine, new starting and ending addresses are used, without affecting where the subroutine was in the main program execution. Then, when the subroutine and interrupt handler have been executed and the context is switched back to the main program, the subroutine will continue executing with the values in registers 2 and 3 of the main program environment. This is not true of the non-re-entrant code. By moving the contents of the interrupt register 1 to the FIN location, the number of blocks to be cleared by the main program execution CLEAR subroutine could be changed, if the interrupt occurs after the MOV 1, @FIN instruction. Because the value FIN is unique for each calling program or computed in the subroutine, the code may not properly be re-entered. That is, it should not be used when an interrupting procedure may execute the same code. The re-entrant version could be used by any number of interrupting procedures without affecting execution results in either the main program or the interrupting program environments. Entrance to the routine would be performed by executing a BL@ CLRLUP. 5-32 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods PROGRAMMING TASKS and Techniques Re-Entrant Coding MOV 1,3 Set R3 at first address of block A 1,2 Compute end address and place in R2 COM c 3,2 Address past end? JH PRET If so, return CLR *3+ Else, clear word and go to next address JMP COM Jump to continue clearing PRET B *11 Return Non-Re-entrant Coding CLRLUP MOV 1,3 Set R3 at first address of block MOV l,@FIN Set up first address in FIN A 2,@FIN Compute final address and store at FIN COM c 3,@FIN Address past end? JH PRET If so, return CLR *3+ Else, clear word and go to next address JMP COM Jump to continue clearing PRET B *11 Return Figure 5-23. Subroutine Example of Re-entrant Coding. PROGRAMMING TASKS The programming techniques of workspace and subroutine usage, program loops, macros, and data representation must be applied to the development of programs and subprograms to perform the basic system functions of state initialization, pattern recognition, arithmetic, and input/ output. Each of these system functions represents a programming task that involves programming structures peculiar to each function. This section discusses the basic requirements of the software for each function and presents some of the programming approaches that are used to meet those requirements. INITIALIZATION When the system is first turned on, the first few instructions encountered must initialize the state of the system to a desired predetermined starting state. The system initialization procedure is usually started by the RESET or LOAD functions. Similarly, as the system enters a subprogram or a new program sequence, the state of certain memory locations must be initialized to a desired starting state. Further, in developing the software, the transfer vectors and other program constants must be initialized by the assembly language software. The assembly language directives available for this purpose include the equate (EQU) and the data (DATA) directives. The application of these directives to the problem of initializing the reserved memory locations and program constants are covered in detail under the assembler directive discussion in Chapter 7. 9900 FAMILY SYSTEMS DESIGN 5-33. PROGRAMMING TASKS Software Design: Programming Methods and Techniques Usually the first part of any program is the initialization of the system. The LWPI instruction is used to initialize the workspace pointer (WP register) to define the location of the 16 workspace registers. If the workspace of a program sequence is to be located at a starting address of 40016 , the following instruction will initialize the workspace pointer to that value: LWPI >0400 Under the interrupts discussion the use of the LIMI (load interrupt mask immediate) instruction to esta?lish which interrupts would be responded to was covered. For example, if the programmer wants to disable all interrupts above level 7 for a program segment, the following instruction must be used at the first of the segment: LIMI 7 Similarly, the load immediate (LI) instruction is used to initialize values in workspace registers. The LI can be followed by MOV instructions to further initialize other memory locations. As an example, to initialize register 3 and memory location TEST to the value OOFF16, the following instructions can be used: LI 3, >OOFF MOV 3,@TEST In some initialization sequences several registers have to be initialized to the same value, such as zero. For example, if 10 consecutive memory words starting at location 100016 are to be cleared (zeroed) then a program loop is suggested. One possible implementation of this initialization task would be: LI 2,> 1000 Set R2 to the starting address 100016 LI 3, > 1OOA Set R3 to the address past the last data location to be cleared LOOP CLR *2+ Clear data, increment the address by two c 2,3 Is address past the 10th data location JNE LOOP If not jump to LOOP to continue clears else go the next sequence of instructions In this data initialization program segment, like most program segments, registers must be initialized to establish program limits, addresses, and other conditions. In this sequence register 2 was initialized to the starting data address and register 3 was initialized to indicate the first word address after the 10th data word to be cleared. Had this loop been implemented with a loop counter, the register acting as a loop counter would have been initialized to 10. 5-34 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods PROGRAMMING TASKS and Techniques Generally, most program initialization tasks can be handled by using a combination of the techniques presented in this section. The immediate load instructions are the most commonly used operations in performing the initialization operation, followed by the use of assembler initialization directives to establish vectors and other data constant initialization. MASKING AND TESTING In many cases only certain portions of a word are of interest. The program segment may be examining or modifying a single bit or a group of bits. The bits that are not involved in the operation must be masked off so that they will not affect status bits and thus affect program decisions. There are several ways of approaching this masking and single bit testing problem. If a single 1/0 bit is to be examined or modified, the simplest approach is to use the CRU single bit instruction SBO, SBZ, or TB to perform the desired operation. This is possible only if the hardware has been set up to address the desired bit as a CRU bit. If the bit is not accessible through CRU addressing, one of the selective masking instructions must be used. The set to ones or zeroes instructions (SOC, SOCB, SZC, and SZCB) can be used to selectively set or clear bits. The compare ones or zeroes corresponding instructions (COC and CZC) can be used to test selected bits. Of course 5-111111 these instructions can be used to test or change single or multiple bits. An alternative single bit approach is to use the circulate instruction (SRC) to get the desired bit into the carry status bit for examination or changing. To see how these non-CRU masking instructions are used, consider the task of examining the value of bit 12 of the data of workspace register 1. The mask is contained in location MASK which will contain all zeroes in all bits except for bit 12 which will contain a one. Thus, location MASK will contain 0008 16 • Then, the instruction: CZC @MASK, 1 will set the equal status bit if bit 12 of Rl contains a zero. The instruction: COC @MASK, 1 will set the equal status bit if bit 12 of Rl contains a one. In these cases, the JEQ or JNE instructions can be used to test the equal status bit after the comparison. Alternatively, the instruction: SRC 1,4 will cause bit 12 to be in the carry flip flop. However, this instruction will change the contents of Rl by moving all bits to the right 4 positions. The JC or JNC instructions are used to test the bit value in the carry status bit. 9900 FAMILY SYSTEMS DESIGN 5-35 PROGRAMMING TASKS Software Design: Programming Methods and Techniques To selectively set bit 12 of Rl, any of the following instructions could be used: ORI l,>0008 SOC @MASK,l To selectively clear bit 12 of Rl, either or the following instructions could be used: ANDI l,> FFF7 or: SZC @MASK,l If groups of bits are to be changed or examined, the above techniques can be used if all bits are to be ones or zeroes. For example, if bit 13 ofregister 2 is to be tested, the following instructions would jump to point Pl in the program if bit 13 of R2 is one: ANDI 2,> 0004 Zero all bits but bit 13 of R2; compare to 0 JNE Pl If EQ = 0, bit 13 was one and jump to point Pl A more complicated test would be to check bits 13 and 15 of R3. A jump to P2 is to be made if both of these bits are one. The following instructions would accomplish this test and program decision: HS DATA 5 coc @H5,3 Compare to 5 to see if both bits are one. JEQ P2 If they are, jump to point P2. Thus, a combination of masks (ANDI) compares, and conditional jumps can be used to examine all features of system words and react appropriately. If a group of bits is to be examined or modified arithmetically, a slightly different approach may be used. If for example the least four bits of Rl are to be compared to 8, one approach would be to provide a copy of the R 1 contents in R2. Then the first 12 bits · of R2 are zeroed with: ANDI 2,>000F S-36 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods PROGRAMMING TASKS and Techniques or with: SZC @MASKl,2 where the contents of location MASKl are FFF016 • Then, the contents of R2 can be compared to 8. The entire sequence would then be: MOV 1,2 ANDI 2,>F CI 2,8 JLT Pl Sequence of instructions to handle case where least four bits of Rl (and R2) are greater than or equal to 8 Pl Sequence of instructions to handle case where least four bits of Rl (and R2) are less than 8 This technique is useful in Decimal to Binary or Binary to Decimal number conversion and in implementing BCD (Binary Coded Decimal) arithmetic. Of the techniques that can be used in masking and testing, the ANDI, ORI, SOC, and SZC instructions change the word they operate on. The Compare techniques, CZC and COC, do not affect the words being operated on but they do affect the status bits. Often, when part of a word is modified (such as portion of the word is zeroed by an ANDI instruction) the word must later be reassembled after all bit group operations have been completed. The programmer should see that such operations are performed on copies of the word so that further masking operations use the original word. As an example, if a word is to be broken down into four bit groups (to implement BCD arithmetic), at least four copies of the word are required or four accumulators must be used. If register 1 contains the master copy, and registers 2 through 5 contain the four bit groups, the following sequence of instructions would generate the desired four bit groupings in the four accumulators from the master copy in register 1: MOV @MASTER,1 Move word to be separated into Rl MOV 1,2 Move a copy of the word into MOV 1,3 accumulators R2 through RS MOV 1,4 MOV 1,5 ANDI 2,> OOOF Mask all but least four bits in R2 ANDI 3,> OOFO Mask all but next four bits in R3 ANDI 4,> OFOO Mask all but next four bits in R4 ANDI 5,> FOOO Mask all but most significant four bits in RS 9900 FAMILY SYSTEMS DESIGN S-37 PROGRAMMING TASKS Software Design: Programming Methods and Techniques With this program sequence, the original word can be broken into bit groups for further testing and modification. Rl still contains the original word for reference and further manipulation. However, by using ANDI mask instructions, several memory words are required to hold intermediate results. This would not have been necessary if compare (selective bit) instn-!ctions had been used. The specific application usually dictates which approach is to be used. ARITHMETIC OPERATIO NS Basic arithmetic can be performed with addition and subtraction, though certain operations such as multi-word arithmetic require the use of shift instructions and conditional branch instructions such as the jump on carry or jump on greater than. Multi-Precision Arithmetic The 9900 arithmetic instructions perform mathematical functions on 16 bit words. For applications that require a greater numerical accuracy or a larger number (the 16 bit word can hold a magnitude number from 0 to 65 ,535), multiple word numbers must be used. The basic arithmetic instructions must then be used in such a way as to implement the desired mathematical functions on these multiple word numbers. This section deals with techniques for treating several words as a single binary value, that is, extended precision arithmetic. A 16 bit two's complement word can represent a signed value in the range - 32, 768 to + 32,767. The negate (NEG) and absolute value (ABS) instructions provide fast conversion between positive and negative 16 bit words. For sign conversion on binary values represented by multiple words, special conversion techniques are required. The process for converting a three word positive value to its negative or two's complement value is shown in Figure 5-24. The three word number is stored in registers 0, 1, and 2 of the workspace. The complementing procedure is to form the one's complement of the three word number using the invert (INV) instruction and then to add 1 to the result. The JNC instructions in the program check to see if a carry is to be propagated from a less significant word to a more significant word in the process of adding one to the three word number. If carries occur, the addition is handled by the increment (INC) instruction. Conversion of a number to its absolute value is accomplished by checking the sign bit (most significant bit) and executing the negate routine (COMP) on negative values. 5-38 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods PROGRAMMING TASKS and Techniques Memory Structure Register 0 Register 1 Register 2 = A (48 bit number) Procedure: 1) Form l's complement of A, using the invert (INV) instruction. 2) Convert the l's complement of A to the two's complement of A by adding 1 to the l's complement of A. 2's complement of A = l's complement of A + 1 Program: COMP INV 0 Complement contents of RO INV Complement contents of Rl NEG 2 Negate contents of R2 JNC EXIT If no carry operation is complete, return INC 1 If carry, add one to contents of Rl JNC EXIT If no carry operation is complete, return INC 0 If carry, add one to contents of RO EXIT RT Return Figure 5-24. Process to form the Negative ofA(-A). The process of adding or subtracting two multi-word numbers is to perform the 5 -1111 operation on the least significant words, then on the next most significant words with the previous carry or borrow, and so on until the complete result is formed. Subtraction could be performed by first using the negate procedure of Figure 5-24 on the value to be subtracted and then adding this two's complement result to the other number. Multiple word multiplication can be handled by using the 9900 multiply (MPY) instruction to provide 3 2 bit partial products and then adding all partial products to achieve the final desired product. The procedure is illustrated in Figure 5-25 for multiplication of one 3 2 bit number by a second 32 bit number. The multiplication of a 16 bit number by a second 16 bit number is performed by the MPY instruction. Thus, four applications of the MPY would form the required four partial products. Then, by adding these products in the correct positions, the 64 bit product is formed. The basic memory structure used by the example in Figure 5-25 can be understood by looking at the operation of the MPY instruction. The accumulator or destination operand must be a workspace register. Then, the product is stored in two successive workspace registers, the most significant 16 bits in the destination workspace register and the least significant 16 bits in the next workspace register. The source operand which specifies the multiplier may be specified with any addressing mode, though the example of Figure 5-25 uses register addressing for this operand. Thus, the instruction: MPY 1,8 multiples the contents of register 1 by the contents of register 8 and places the 32 bit product in registers 8 and 9. While the multiplier register 1 contents are unchanged, the multiplicand register 8 contents are changed to the most significant part of the product. 9900 FAMILY SYSTEMS DESIGN S-39 PROGRAMMING TASKS Software Design: Programming Methods and Techniques Thus, there must be several copies of each multiplicand to be able to form several partial products. In 32 bit by 32 bit multiplication, there are two multipliers (Bo in register 0 and B1 in register 1) and two multiplicands. Since each multiplicand is involved in two partial products, there must be two copies of each multiplicand. In Figure 5-2~ the copies of the Ao multiplicand are saved in registers 4 and 6 and the copies of the A 1 multiplicand are saved in registers 2 and 8. Then, the following four MPY instructions form the four required partial products: MULTMPY 1,8 Form the A 1 xB 1 product in R8 and R9 MPY 1,4 Form the B1 xA0 product in R4 and RS MPY 0,2 Form the B0 xA 1 product in R2 and R3 MPY 0,6 Form the B0 xA0 product in R6 and R7 Which can be followed by the additions to form the complete 64 bit product in registers 6 through 9: A 3,5 Add two of three 16 bit groups in positions 216 to 231 JNC PO If no carry, add in R8 contents INC 7 If carry, add one to R7 accumulator PO A 5,8 Finish adding 216 to 231 bits JNC Pl If no carry, procede to next position adds INC 7 If carry, add one to R7 accumulator Pl A 2,4 Add part of 232 to 247 bits in R2 and R4 JNC P2 If no carry, procede to rest of addition INC 6 If carry, add 1 to R6 accumulator P2 A 4,7 Finish adding 232 to 247 bits JNC FIN If no carry, operation is complete INC 6 If carry, add one to R6 accumulator FIN RT return The process illustrated by Figure 5-25 is for multiplication of two 32 bit magnitude numbers. Multiplication of negative numbers can be handled with the same program by converting all numbers to their absolute value, saving the sign. Then, after the magnitude multiplication is complete, the sign of the product is the exclusive OR of the multiplier and multiplicand sign bits. If desired, the product can be complemented or negated and stored in two's complement form. 5-40 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods PROGRAMMING TASKS and Techniques Basis of Procedure: A x B = (A.ix2 16 + A1 ) x (B 0 x2 16 + B1 ) = Where multiplying by 2n implies shifting the number n positions to the left with respect to a number multiplied by 2° or 1. Memory Structure: 263 247 231 21s 20 I I I I I I I I I I R4,R6 I R2,RB 11 Ao A, I I 111 I I I I RO R1 I x lj Bo Ii I 81 I initial conditions I I RB I R9 I I II I I I :I A1xB 1 Partial 1 I Product (MPY 1, B) I I R2 I R3 I s-. I I + lI A1xB 0 Partial 111 Product I 11 (MPY 0, 2) I I I R4 I R5 I I + lI I AoxB, Partial j I Product I1 (MPY1,4) I I I I R6 I R7 I +'II I AoxBo Partial 11 Product I: I I sum all partial products I R6 I R7 I RB I R9 I II 111 I 111 I 1 1 1 I 11 I 64 Bit Product Figure 5-25. Multiple Precision Multiplication 9900 FAMILY SYSTEMS DESIGN 5-41 PROGRAMMING TASKS Software Design: Programming Methods and Techniques Floating Point Arithmetic If the system requires the ability to represent fractional numerical quantities instead of integer numbers, a method must be defined that will provide for the location of the radix point of such numbers. Just ~s the decimal point of 75.39 defines a quantity: 7xl0 1 + 5x10° + 3x10- 1 + 9x10- 2 the binary point in 101.01 defines a quantity: lx2 2 + Ox2 1 + lx2° + Ox2- 1 + lx2- 2 Although a group of bits can be configured in many ways to define a floating point number, most floating point representations share the following characteristics: 1) Floating point numbers are represented as a fraction and an exponent (mantissa and characteristic). 2) The fraction is by convention normalized to lie in the range Y2< F< 1, e.g., the binary point lies to the left of the first one bit. 3) The exponent defines the power of 2 by which the fraction is multiplied to evaluate the floating point number. Possible floating point representatives include: 8 BIT EXPONENT FRACTION FRACTION 24 BIT FRACTION and: 16 BIT EXPONENT MU~TIPLE WORD FRA~TION When addition or subtraction of two floating point numbers is performed, the following operations must be performed: 1) Equalize exponents; increment the exponent of the smaller quantity until it is the same as the larger exponent. With each exponent increment, shift the corresponding fraction to the right with zero fill from the left. 5-42 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods INPUT /OUTPUT and Techniques 2) Add or subtract the fractions as required. If a carry results from an addition, the sum fraction is shifted right, shifting the carry into the fraction, and the exponent is incremented. If the difference resulting from the subtraction is not normalized (zero in first bit position) the fraction must be shifted left until a one is in the leftmost position. With each left shift, the resultant exponent is decremented. Floating point multiplication can be performed by multiplying the fractions and adding the exponents. Similarly, floating point division can be performed by dividing the fractions and subtracting the exponents. After such an operation the fraction must be normalized and the exponents must be checked for overflow or underflow. Signed numbers can be handled in the same way that the multiplication of signed integers is handled. INPUT /OUTPUT The most fundamental and necessary instructions of a processor are its input and output instructions and techniques. Without input and output, the system would not be able to control or communicate with the external world, and as a result would be of no use. There are two general ways of implementing input and output operations. One obvious approach is to use special input and output instructions that are interpreted by the hardware to apply to the input and output devices. The 9900 instructions that provide 5...._ this capability are the CRU or communications register unit instructions (SBO, SBZ, TB, LDCR, and STCR) and the input and output hardware that respond to these instructions make up the communications register unit. Another approach to inputting and outputting information is to simply treat the input and output devices as one of the system memory locations, in which case any of the 9900 instructions can be used in accessing these locations. This approach is called memory mapped input/ output, since the devices are assigned a portion of the available memory addresses, and the hardware must decode the appropriate address to activate a given device. Each of these approaches has its advantages and disadvantages, and the programmer must be aware of these trade- offs in order to provide an optimum approach to system input/output. MEMORY MAPPED INPUT I OUTPUT The principle advantages of using memory mapped input/ output are: 1) The full instruction set is available for manipulating the data in the input/output device. 2) The hardware is straightforward, since address decoding and device timing signals are required for RAM and ROM memory anyway and these can be simply extended to handle the 1/0 subsystem as well. 3) Transfers of information are made 8 or 16 bits at a time, offering a high bit rate transfer. 9900 FAMILY SYSTEMS DESIGN S-43 INPUT /OUTPUT Software Design: Programming Methods and Techniques The disadvantages of memory mapped I/Oare: 1) Since some of the 'memory' locations are being used by input or output devices, less memory is available for instructions and general data storage. 2) Bit transfers must be made 8 or 16 bits at a time. This is wasteful if a given device can handle a single or a few bits at a time. 3) It is a more expensive technique in terms of pinouts, board space, and layout time. 4) The hardware interface must accomodate the full width memory bus. The most commonly used instruction in memory mapped I/O operation is the MOV instruction to effect data transfers. However, it is quite possible to set up an input output subsystem as general purpose storage or as a workspace and perform shifts, additions, multiplications, logical operations, and so on, on the data contained in the I/O subsystem. Generally, if I/O transfers are to be made 8 or 16 bits at a time and if the system is not memory bound (memory is needed for program and system data), memory mapped I/O is often used. Certainly, if performing arithmetic, logic, or other instructions directly on input/output data is required or advantageous, memory mapped I/O must be used. If single or multiple bit transfers are all that is required, and transfer rate is not critical, then memory mapped I/O has no advantage over CRU I/O. CRU I/O hardware is normally simpler and less expensive. CRu INPUT I OUTPUT The CRU instructions provide for single bit transfers with the SBO (set bit to one), SBZ (set bit to zero), and TB (test bit) instructions. Multiple bit transfers with the bits transferred one at a time are possible using the LDCR (load communications register) and STCR (store communications register) instructions. The advantages of the CRU instruction approach to I/Oare: 1) Any number of bits (up to 16) can be transferred with the appropriate CRU instruction. Thus, the designer can set up the data transfer to exactly meet the requirements of the subsystem being serviced. This is especially useful in control situations where single sense bits are to be examined and single on-off output control signals are needed. 2) No memory locations are used by the subsystem. The CRU instructions can access 4096 input and 4096 output bits (which is equivalent to 256 data words) in addition to the 65,536 memory bytes. The disadvantages of the CRU I/O are: 1) Only data transfers are provided. Arithmetic, logical or other operations must be performed on the data after it has been moved to one of the general data storage locations in RAM. 2) The hardware must include the capability to decode and implement the CRU transfers; however, the added IC complexity is more than offset by reduced package size. 3) Single bit transfer speed may be too slow for some applications. 5-44 9900 FAMILY SYSTEMS DESIGN Software Design: Programming Methods INPUT /OUTPUT and Techniques INPUT I OUTPUT METHODS There are three ways that an input/ output transfer can be handled- or initiated. The processor can be interrupted, causing the program to jump to a subroutine that handles the input/ output task. The program can encounter. an instruction to transfer data from an input location or to an output location, for the purpose of displaying results, actuating control elements, or inputting system status. The processor can be bypassed entirely and the data transferred directly to or from system memory, using direct memory access. Interrupt Driver Input/Output If the timing of input/ output transfer is to be controlled by an external system, then the interrupt driven I/ 0 method must be used. This approach is used in inputting data when the time of input is random. The external system inputs the data and signals the processor with an interrupt to indicate that data is in one of the 9900 system input registers. The 9900 responds by performing a context switch to a subprogram that will process the data in that register. The interrupt driven approach may also be used in outputting data when the processor needs to know when the data has been taken by an external system. Once the external system takes the data, it can signal the processor with an interrupt signal. The processor responds by performing a context switch to a subprogram that will then send more data to that output location. 5 ..... The interrupt driven I/ 0 procedure provides a mechanism of implementing a communications sequence known as handshaking. This communications protocol is illustrated in Figure 5-26. In the input mode, the data-present signal latches the 9900 system input register and serves as the interrupt signal. If desired the processor's reading of the contents of that register can be used to generate the data-taken signal. Upon receiving the data taken signal, the external system can then send more data to the 9900 system. In the output mode, the register write operation that sends data to the output register in the 9900 system can be used as a data-present signal to the external system. When the external system takes this data, it can use an interrupt signal to notify the 9900 that the register is ready to receive more data. The interrupt driven approach has the main advantage of providing a means of setting up a handshaking communications with another system. It can handle data communications that occur at random or unpredictable times. The main disadvantage of this type of I/O is that it does involve the processor, slowing down its work on main system programs and subprograms. Further, since a context switch is involved in responding to an interrupt, such an approach may require more memory than one of the other two approaches. 9900 FAMILY SYSTEMS DESIGN 5-45 INPUT /OUTPUT Software Design: Programming Methods and Techniques INTERRUPT -- ~ DATA-PRESENT -- 9900 SYSTEM r INPUT REGISTER READ l ~ !\,. DATA DATA-TAKEN EXTERNAL SYSTEM REGISTER ...... ~ SIGNAL Figure 5-26a. Handshaking Input Transfer. INTERRUPT -- DATA-TAKEN 9900 SYSTEM [ OUTPUT REGISTER j DATA V' \ EXTERNAL SYSTEM OUTPUT WRITE SIGNAL DATA-PRESENT -- ~ Figure 5-26b. Handshaking Output Transfer. Programmed Input/ Output The simplest method of I/O is the programmed l/O. The times and conditions under which inputs and outputs are to occur are controlled by the system program. For example, the processor may update a display memory whenever the display is to be changed. The program determines the new information to be displayed and then outputs this information to the display storage locations. Similarly, the program may require information about the status of a subsystem in order to determine subsequent operations. Such status may be the condition of threshold detectors, the status of serial data transmission or reception, or some other system condition. When the program encounters a point at which it needs to check such status words, it simply inputs the desired word. Of course, as in all l/O methods, the input or output operations can be handled by either CRU instructions or through standard MOV or other instructions in memory mapped II 0 devices. The programmed input/output method is a high speed, low hardware cost approach to input/output, since no subroutine overhead is involved. However, it does not handle the random input situation very well, unless the program is devoted solely to waiting for the next signal input to occur. Even then, the program may not check for input occurrence and perform the desired input instruction before the external system sends new data, destroying the old data. 5-46 9900 FAMILY SYSTEMS DESIGN CHAPTER6 Instruction Set 6~ SOFTWARE FEATURES Instruction Set OFTHE9900 SOFTWARE FEATURES OF THE 9900 In order to understand the operation of the 9900 instructions, the basic software features of the 9900 must be understood. These features include the processor-memory interrelationships, the available addressing modes, the terminology and formats used in the 9900 assembly language, and the interrupt and subroutine procedures used by the 9900. PROCESSOR REGISTERS AND SYSTEM MEMORY There are three registers in the 9900 that are of interest to the programmer; their functions are illustrated in Figure 6-1: Program Counter-This register contains the address of the instruction to be executed by the 9900. This instruction address can point to or locate an instruction anywhere in system memory, though instructions normally are not placed in the first 64 words of memory. These locations are reserved for interrupt and extended operation transfer vectors. Workspace Pointer-This register contains the address of the first word of a group of 16 consecutive words of memory called a workspace. The workspace can be located anywhere in memory that is not already dedicated to transfer vector or program storage. These 16 workspace words are called workspace registers 0 through 15, and are treated by the 9900 processor as data registers much as other processors treat on-chip data registers for high access storage requirements. "'6 Status Register-The status register stores the summary of the results of processor operations, including such information as the arithmetic or logical relation of the result . to some reference data, whether or not the result can be completely contained in a 16-bit data word, and the parity of the result. The last bits of the status register contain the system interrupt mask which determines which interrupts will be responded to. These three 16-bit registers completely define the current state of the processor: what part of the overall program is being executed, where the general purpose workspace is located in memory, and what the current status of operations and the interrupt system is. This information completely defines the current program environment or context of the system. A change in the program counter contents and workspace register contents switches the program environment or context to a new part of program memory with a new workspace area. Performing such a context switch or change in program environment is a very efficient method of handling subroutine jumps to subprograms that require the use of a majority of the workspace registers. 6-2 9900 FAMILY SYSTEMS DESIGN Instruction Set SOFTWARE FEATURES OFTHE9900 Program Counter Figure 6-1 illustrates the use of the three processor registers. The program counter is the pointer which locates the instruction to be executed. All instructions require one or more 16-bit words and are always located at even addresses. Multiple word instructions include one 16-bit operation word and one or two 16-bit operand addresses. Two of the processors in the 9900 family (TMS9900, SBP9900) employ a 16-bit data bus and receive the instructions 16 bits at a time. The other processors (TMS9980A/81, TMS9985, TMS9940) use an 8-bit data bus and require extra memory cycles to fetch instructions. In both cases the even and odd bytes are located at even and odd addresses respectively as illustrated in Figure 6-2. In addition, data may be stored as 16-bit words located at even addresses or as 8-bit bytes at either even or odd addresses. Workspace The workspace is a set of 16 contiguous words of memory, the first of which is located by the workspace pointer. The individual 16-bit words, called workspace registers, are located at even addresses (see Figure 6-1). All of the registers are available for use as general registers; however, some instructions make use of certain registers as illustrated in Figure 6-3. Care should be exercised when using these registers for data or addresses not related to their special functions. SYSTEM I 9900 PROCESSOR MEMORY REGISTERS (16 BIT WORDS) 6.. TRANSFER VECTORS A 0 THROUGH Ai 4 (64 WORDS) PROGRAM COUNTER (ADDRESS OF INSTRUCTION) 32,768 WORDS PROGRAM WORKSPACE POINTER A0 THROUGH A14 16 BITS (ADDRESS OF WORKSPACE REGISTER 0) RO R1 'T 16 STATUS REGISTER WORD 16 BITS WORK- SPACE ~'-v-" STATUS INTERRUPT MASK R15 _j_ Figure 6-1. 9900 System Memory and Processor Registers. 9900 FAMILY SYSTEMS DESIGN 6-3 SOFTWARE FEATURES Instruction Set OFTHE9900 Status Register The status register contents for the 9900 are defined in Figure 6-4. The 9900 interrupt mask is a 4-bit code, allowing the specification of 16 levels of interrupt. Interrupt levels equal to or less than the mask value will be acknowledged and responded to by the 9900. The 9940 status register is similar, except the interrupt mask occupies bits 14 and 15 of the status register, providing for four interrupt levels in the 9940. MOST SIGNIFICANT LEAST SIGNIFICANT 8 BIT BYTE 8 BIT BYTE (EVEN ADDRESS, A1s = 0) (ODD ADDRESS, A1s = 1) I 0 4 6 7 I 8 9 10 11 12 13 14 151 I t MOST t LEAST SIGNIFICANT SIGNIFICANT BIT BIT 16 BIT WORD (ADDRESSED BY 15 MOST SIGNIFICANT ADDRESS BITS) Figure 6-2. Word and Byte Definition. PROCESSOR REGISTERS WORKSPACE WORKSPACE POINTER (WP) .. 6 I SHIFT COUNT o /'- - - - - - - - - - - - - \,-- - - - - - - - - - - I ADDRESS OF FIRST --'WORD OF WORKSPACE PROGRAM COUNTER (PC) DATA OR I I ADDR ~ ADDRESS OF INSTRUCTION STATUS REGISTER (ST) INDEX CAPABILITY SUMMARY OF EFFECT OF PROGRAM OPERATIONS (SEE FIGURE 6-4) RTN ADDR 11 BL SUBROUTINE CALL RETURN ADDRESS CRU BASE 12 CRU BASE STOREDWSP 13 LOG. OF CALLING PROG. WORK SPACE STORED PC 14 LOG. OF NEXT WORD AFTER CALL STORED ST 15 STATUS OF CALLING PROGRAM Figure 6-3. Workspace Register Utilization. 6-4 9900 FAMILY SYSTEMS DESIGN Instruction Set SOFTWARE FEATURES OFTHE9900 Status 2 3 4 5 6 7 8 9 10 11 12 "13 14 15 Register L> A> EO C OV OP X INTERRUPT MASK Bit 0 LGT - Logical Greater Than-set in a comparison of an unsigned number with a smaller unsigned number. AGT - An.thmetic Greater Than-set when one signed number is compared with another that is less positive (nearer to -32,768). 2 EQ - Equal-set when the two words or two bytes being compared are equal. 3 C Carry-set by carry out of most significant bit of a word or byte in a shift or arithmetic operation. 4 OV Overflow-set when the result of an arithmetic; operation is too large or too small to be correctly represented in 2's complement form.OV is set in addition ifthe most significant bit of the two operands are equal and the most significant bit of the sum is different from the destination operand most significant bit. OV is set in subtraction if the most significant bits of the operands are not equal and the most significant bit of 6..il the result is different from the most significant bit of the destination operand. In single operand instructions affecting OV, the OV is set if the most significant bit of the operand is changed by the instruction. 5 OP Odd Pan'ty-set when there is an odd number of bits set to one in the result. 6 x Extended Operation-set when the PC and WP registers have been to set to values of the transfer vector words during the execution of an extended operation. 7-11 Reserved for special Model 990/ 10 computer applications. 12-15 Interrupt Mask-All interrupts of level equal to or less than mask value are enabled. Figure 6-4. 9900 Status Register Contents 9900 FAMILY SYSTEMS DESIGN 6-5 SOFTWARE FEATURES Instruction Set OFTHE9900 ADDRESSING MODES The 9900 supports five general purpose addressing modes or methods of specifying the location of a memory word: Workspace Register Addressing The data or address to be used by the instruction is contained in the workspace register number specified in the operand field of the instruction. For example, if the programmer wishes to decrement the contents of workspace register 2, the format of the decrement instruction would be: DEC 2 The memory address of the word to be used by the instruction is computed as follows: REGISTER R (PC)~(WP)+2R~ This type of addressing is used to access the often used data contained in the workspace. Workspace Register Indirect Addressing The address of the data to be used by the instruction is contained in the workspace register specified in the operand field (the workspace register number is preceded by an asterisk). This type of addressing is used to establish data counters so the programmer can sequence through data stored in successive locations in memory. If register 3 contains the address of the data word to be used, the following instruction would be used .. 6 to clear (CLR) that data word: CLR *3 In this instruction the contents of register 3 would not be changed, but the data word addressed by the contents of register 3 would be cleared (set to all zeroes - 000 16 ). The word address is computed as follows for this type of addressing: REGISTER R ___..,_I OPERAND Workspace Register Indirect Addressing With Autoincrement- This addressing mode locates the data word in the same way that workspace register indirect addressing does, with the added feature of incrementing the contents of the address register after the instruction has been completed. The address in the register is incremented by one if a byte operation is performed and by two if a word operation is performed. Thus, to set up a true data counter to clear a group of successive words in memory whose address will be contained in register 3, the following instruction would be used: CLR *3+ 6-6 9900 FAMILY SYSTEMS DESIGN Instruction Set SOFTWARE FEATURES OFTHE9900 where the asterisk(*) indicates the workspace register indirect addressing feature and the plus ( +) indicates the autoincrementing feature. With this type of addressing, the following computations occur: REGISTER R (PC) (WP)+ 2R OPERAND WORD+2 BYTE+ 1 Symbolic or Direct Addressing The address of the memory word is contained in the operand field of the instruction and is contained in program memory (ROM) in the word immediately following the operation code word for the instruction. For example, to clear the memory word at address 100016 , the following format would be used: CLR @>1000 where the at sign (@) indicates direct addressing and the greater than (>) sign indicates a base 16 (hexadecimal) constant. Alternatively, the data word to be cleared could be named with a symbolic name such as COUNT and then the instruction would be: CLR @COUNT and if COUNT is later equated to 100016 , this instruction would clear the data word at address 100016 • The instruction would occupy two words of program memory: (PC) 04C016 Operation Code for Clear (PC)+ 2 Address of Data The address of the memory word is thus contained in the instruction itself and is located by the program counter. Since this address is part of the instruction, it cannot be modified by the program. As a result, this type of addressing is used for program variables that occupy a single memory word such as program counters, data masks, and so on. The address computations for direct addressing are as follows: (PC)~ (PC)+2~ ADDRESS H OPERAND 9900 FAMILY SYSTEMS DESIGN 6-7 SOFTWARE FEATURES Instruction Set OFTHE9900 Indexed Addressing Indexed addressing is a combination of symbolic and register indirect addressing. It provides for address modification since part of the address is contained in the workspace register used as an index register. Registers 1 through 15 can be used as index registers. The memory word address is obtained by adding the contents of the index register specified to the constant contained in the instruction: REGISTER R (WP)+ INDEXED (PC) INSTRUCTION 2R VALUE OPERAND BASE (PC)+2 ADDRESS Thus, to locate the data word whose address is two words down from the address contained in register 5, and to clear this memory word, the following instruction is used: CLR @4(5) This instruction will cause the processor to add 4 to the contents of register 5 to generate the desired address. Alternatively, a symbolic name could be used for the instruction constant: CLR @DISP(5) with the value for the symbol DISP defined elsewhere in the assembly language program. Special Addressing Modes Three additional types of special purpose addressing are used by the 9900. Immediate Addressing Immediate addressing instructions contain the data to be used as a part of the instruction. In these instructions the first word is the instruction operation code and the second word of the instruction is the data to be used: (PC) -...J INSTRUCTION (PC)+ 2 -1 IMMEDIATE VALUE 6-8 9900 FAMILY SYSTEMS DESIGN Instruction Set SOFTWARE FEATURES OFTHE9900 Program Counter Relative Addressing Conditional branch or jump instructions use a form of program counter relative addressing. In such instructions the address of the instruction to be branched to is relative to the location of the branch instruction. The instruction includes a signed displacement with a value between - 128 and + 127. The branch address is the value of the program counter plus two plus twice the displacement. For example, if LOOP is the label at location 1016 and the instruction: JMP LOOP is at location 18 16 , the displacement in the instruction machine code generated by the assembler will be - 5 or FB 16 . This value is obtained by adding two to the current program counter: 1816+2=1A16 and subtracting from this result the location of LOOP: 1A16 -1016 = A16 = 10 decimal. The displacement of 5 is one-half this value of 10 and it is negative since LOOP is 5 words prior to the 1816 + 2 location. CR U Addressing CRU addressing uses the number contained in bits 3 through 14 of register 12 to form a hardware base address: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I I I I I I I I I I I I R12 CRU Hardware Base address= Contents of R12 divided by 2 Thus if R12 contains 0400 16 (the software base address), bits 3 through 14 will be 020016 . This hardware base address is used to indicate the starting CRU bit address for multiple bit CRU transfer instructions (STCR and LDCR). It is added to the displacement contained in single bit CRU instructions (TB, SBO, SBZ) to form the CRU bit address for these instructions. For example, to set CRU bit 208 to a one, with register 12 containing 40016 , the following CRU instruction would be used: SBO 8 so that the CRU bit address is 200 16 +8. = 208 16 • 9900 FAMILY SYSTEMS DESIGN 6-9 ASSEMBLY LANGUAGE Instruction Set PROGRAMMING INFORMATION ASSEMBLY LANGUAGE PROGRAMMING INFORMATION t In order to understand the instruction descriptions and applications the assembly language nomenclature must be understood. Assembly language is a readily understood language in which the 9900 instructions can be written. The machine code that results from the assembly of ptograms written in this language is called object code. Such object code may be absolute or relocatable, depending on the assembly language coding. Relocatable code is that which can be loaded into any block of memory desired, without reassembling or without changing program operation. Such code has its address information relative to the first instruction of the assembly language program so that once a loader program specifies the location of this first instruction, the address of all instructions are adjusted to be consistent with this location. Absolute code contains absolute addresses which cannot be changed by the loader or any operation other than reassembling the program. Generally, relocatable code is preferable since it allows the program modules to be located anywhere in memory of the final system. AssEMBLY LANGUAGE FORMATS The general assembly language source statements consist of four fields as follows: LABEL MNEMONIC OPERANDS COMMENT The first three fields must occur within the first 60 character positions of the source record. At least one blank must be inserted between fields. Label Field ·6 The label consists of from one to six characters, beginning with an alphabetic character in character position one of the source record. The label field is terminated by at least one blank. When the assembler encounters a label in an instruction it assigns the current value of the location counter to the label symbol. This is the value associated with the label symbol and is the address of the instruction in memory. If a label is not used, character position 1 may be a blank, or an asterisk. Mnemonic or Opcode Field This field contains the mnemonic code of one of the instructions, one of the assembly language directives, or a symbol representing one of the program defined operations. This field begins after the last blank following the label field. Examples of instruction mnemonics include A for addition and MOV for data movement. The mnemonic field is required since it identifies which operation is to be performed. Operands Field The operands specify the memory locations of the data to be used by the instruction. This field begins following the last blank that follows the mnemonic field. The memory locations can be specified by using constants, symbols, or expressions, to describe one of several addressing modes available. These are summarized in Figure 6-5. tExcerpts from Model 990computer TMS 9900 Microprocessor Assembly Language Programmer's Guide. 6-10 9900 FAMILY SYSTEMS DESIGN -0 5' I -0 0 en 0 'Tl 2 ;i:.. a c;· ~ :::s ~ Type of Operand Memory Location MOV Instruction Result Tdor T. en !!. rJl Addressing Fonnat Specified Example Coding Field Code -< ...., rJl t'I'.l Workspace n Workspace Register n MOV 3,5 R3-R5 00 ~ rJl Register Rn t:l t'I'.l Workspace *n Address given by the MOV *3,*5 M(R3) - M(R5) 01 rJl 0 Register contents of workspace z Indirect register n M(Rn) ~ ~· Workspace *n+ As in register Indirect; MOV *3+,*5+ M(R3) - M(R5) 11 ~ ~ Register address register Rn is R3+2-R3 Indirect, incremented after the R5+2-R5 9'- Autoincrement $Jt operation (by one for ~ byte operations, by two for word operations) 1-rj ~(/) > §= ~ Symbolic @exp Address is given by MOV @ONE,@10 M(ONE) - M(lO) 10 ocn ()~ ~- Memory value of exp. ~~ M(exp) ;pto ~ ~ Indexed @exp(n) Address is the sum of the MOV @2(3), @DP(5) M(R3 + 2) - M(R5 +DP) 10 ~~ ~~ ""' Memory contents of Rn and the value of exp ~;p M(Rn+exp) Zz ()() Notes: ~c z> I n is the number of the workspace register: O~n~ 15; n may not be 0 for indexed addressing. ~Cl ~~ exp is a symbol, number, or expression The T d and T. fields are two bit portions of the instruction machine code. There are also S and D four bit fields, which are filled in with the four bit code for n. n is 0 for symbolic or direct addressing. ~ ~ ~ ~I I 0z ""... Instruction Set ASSEMBLY LANGUAGE PROGRAMMING INFORMATION Comments Field Comments can be entered after the last blank that follows the operands field. If the first character position of the source statement contains an asterisk (*), the entire source statement is a comment. Comments are listed in the source portion of the assembler listing, but have no affect on the object code. TERMS AND SYMBOLS Symbols are used in the label field, the operator field, and the operand field. A symbol is a string of alphanumeric characters, beginning with an alphabetic character. Terms are used in the operand fields of instructions and assembler directives. A term is a decimal or hexadecimal constant, an absolute assembly-time constant, or a label having an absolute value. Expressions can also be used in the operand fields of instructions and assembler directives. Constants Constants can be decimal integers (written as a string of numerals) in the range of -32,768 to + 65,535. For example: 257 Constants can also be hexadecimal integers (a string of hexadecimal digits preceded by > ). For example: >09AF ..-6 ASCII character constants can be used by enclosing the desired character string in single quotes. For example: 'DX'= 445816 'R'+005216 Throughout this book the subscript 16 is used to denote base 16 numbers. For example, the hexadecimal number 09AF will be written 09AF 16• Symbols Symbols must begin with an alphabetic character and contain no blanks. Only the first six characters of a symbol are processed by the assembler. The assembler predefines the dollar sign ($) to represent the current location in the program. A given symbol can be used as a label only once, since it is the symbolic name of the address of the instruction. Symbols defined with the DXOP directive are used in the OPCODE field. Any symbol in the OPERANDS field must have been used as a label or defined by a REF directive. 6-12 9900 FAMILY SYSTEMS DESIGN Instruction Set ASSEMBLY LANGUAGE PROGRAMMING INFORMATION Expressions Expressio'ns are used in the OPERANDS fields of assembly language statements. An expression is a term or a series of terms separated by the following arithmetic operations: + addition - subtraction * multiplication I division The operator precedence is +, - , *, I (left to right). The expression must not contain any imbedded blanks or extended operation defined (DXOP directive defined) symbols. Unary minus (a minus sign in front of a number or symbol) is performed first and then the expression is evaluated from left to right. An example of the use of the unary minus in an expression is: LABEL+TABLE+ (-INC) which has the effect of the expression: LABEL+ TABLE - INC The relocatability of an expression is a function of the relocatability of the symbols and constants that make up the expression. An expression is relocatable when the number of relocatable symbols or constants added to the expression is one greater than the number 6<1111 of relocatable symbols or constants subtracted from the expressions. All other expressions are absolute. The expression given earlier would be relocatable if the three symbols in the expression are all relocatable. The following are examples of valid expressions. BLUE+l 2*16+ RED 440/2-RED SURVEY OF THE 9900 INSTRUCTION SET The 9900 instructions can be grouped into the following general categories: data transfer, arithmetic, comparison, logical, shift, branch, and CR U input/ output operations. The list of all instructions and their effect on status bits is given in Figure 6-6. 9900 FAMILY SYSTEMS DESIGN 6-13 ASSEMBLY LANGUAGE Instruction Set PROGRAMMING INFORMATION Mnemonic L>'A> EQ c OV OP x Mnemonic L> A> EQ c ov OP x A x x x x x DIV x AB x x x x x x IDLE ABS x x x x x INC x x x x x AI x x x x x INCT x x x x x ANDI x x x INV x x x B JEQ BL ]GT BLWP JH c x x x JHE CB x x x x JL CI x x x JLE CKOF JLT CKON JMP CLR JNC coc x JNE czc x JNO DEC x x x x x JOC DECT x x x x x ]OP LDCR x x x SBZ LI x x x SETO LIMI SLA x x x x x LREX soc x x x LWPI SOCB x x x x MOV x x x SRA x x x x MOVB x x x x SRC x x x x MPY SRL x x x x ... 6 NEG x x x x x STCR x x x ORI x x x STST RSET STWP RTWP x x x x x x x SWPB s x x x x x szc x x x SB x x x x x x SZCB x x x x SBO TB x x 2 2 2 2 2 2 2 XOP 2 2 2 2 2 2 2 XOR x x x Notes: 1. When an LDCR or STCR instruction transfers eight bits or less, the OP bit is set or reset as in byte instructions. Otherwise these instructions do not affect the OP bit. 2. The X instruction does not affect any status bit; the instruction executed by the X instruction sets status bits normally for that instruction. When an XOP instruction is implemented by software, the XOP bit is set, and the subroutine sets status bits normally. Figure 6-6. Status Bits Affected by Instructions 6-14 9900 FAMILY SYSTEMS DESIGN Instruction Set ASSEMBLY LANGUAGE PROGRAMMING INFORMATION Data Transfer Instructions Load- used to initialize processor or workspace registers to a desired value. Move- used to move words or bytes from one memory location to another. Store- used to store the status or workspace pointer registers in a workspace register. Arithmetic Instructions Addition and Subtraction-perform addition or subtraction of signed or unsigned binary words or bytes stored in memory. Negate and Absolute Value-changes the sign or takes the absolute value of data words in memory. Increment and Decrement-Adds or subtracts 1or2 from the specified data words in memory. Multiply-Performs unsigned integer multiplication of a word in memory with a workspace register word to form a 32 bit product stored in two successive workspace register locations. Divide-Divides a 32 bit unsigned integer dividend (contained in two successive workspace registers) by a memory word with the 16 bit quotient and 16 bit remainder stored in place of the dividend. Compare Instructions 6~ These instructions provide for masked or unmasked comparison of one memory word or byte to another or a workspace register word to a 16 bit constant. Logical Instructions OR and AND-masked or unmasked OR and AND operations on corresponding bits of two memory words. A workspace register word can be ORed or ANDed with a 16 bit constant. Complement and Clear - The bits of a selected memory word can be complemented, or cleared or set to ones. Exclusive OR-A workspace register word can be exclusive ORed with another memory word on a bit by bit basis. Set Bits Corresponding-Set bits to one (SOC) or to zero (SZC) whose positions correspond to one positions in a reference word. 9900 FAMILY SYSTEMS DESIGN 6-15 ASSEMBLY LANGUAGE Instruction Set PROGRAMMING INFORMATION Shift Instructions A workspace register can be shifted arithmetically or logically to the right. The registers can be shifted to the left (filling in vacated positions with zeroes) or circulated to the right. The shifts and circulates can be from 1 to 16 bit positions. Branch Instructions The branch instructions and the JMP Gump) instruction unconditionally branch to different parts of the program memory. If a branch occurs, the PC register will be changed to the value specified by the operand of the branch instruction. In subroutine branching the old value of the PC is saved when the branch occurs and then is restored when the return instruction is executed. The conditional jump instructions test certain status bits to determine if jump is to occur. When a jump is made' the PC is loaded with the sum of its previous value and a displacement value specified in the operand portion of the instruction. Control/CRU Instructions These instructions provide for transferring data to and from the communications register input/output unit (CRU) using the CRUIN, CRUOUT and CRUCLK pins of the 9900. INSTRUCTION DESCRIPTIONS The information provided for each instruction in the next section of this chapter is as follows: .6 Name of the instruction. Mnemonic for the instruction. Assembly language and machine code formats. Description of the operation of the instruction. Effect of the instruction on the Status Bits. Examples. Applications. The format descriptions and examples are written without the label or comment fields for simplicity. Labels and comments fields can be used in any instruction if desired. 6-16 9900 FAMILY SYSTEMS DESIGN Instruction Set ASSEMBLY LANGUAGE PROGRAMMING INFORMATION Each instruction involves one or two operand fields which are written with the following symbols: G-Any addressing mode is permitted except I (Immediate). R-Workspace register addressing. exp-A symbol or expression used to indicate a location. value-a value to be used in immediate addressing. cnt-A count value for shifts and CRU instructions. CRU-CRU (Communications Register Unit) bit addressing. The instruction operation is described in written and equation form. In the equation form, an arrow(--) is used to indicate a transfer of data and a colon (:) is used to indicate a comparison. In comparisons, the operands are not-changed. In transfers, the source operand (indicated with the subscripts) is not changed while the destination operand (indicated with the subscript d) is changed. For operands specified by the symbol G, the M(G) nomenclature is used to denote the memory word specified by G. MB(G) is used to denote the memory byte specified by G. Thus, transferring the memory word contents addressed by Gs to the memory word location specified by Gd and comparing the source (Gs) data to zero during the transfer, can be described as: M(Gs) - M(Gd) M(Gs):O 6 .... which is the operation performed by the MOV instruction: MOV A specific example of this instruction could be: MOV @ONE,3 which moves the contents of the memory word addressed by the value of the symbol ONE to the contents of workspace register 3: M(ONE)-R3 M(ONE): 0 9900 FAMILY SYSTEMS DESIGN 6-17 Instruction Set DATA TRANSFER INSTRUCTIONS The MOV instructions are used to transfer data from one part of the system to another part. The LOAD instructions are us~d to initialize registers to desired values. The STORE instructions provide for saving the status register (ST) or the workspace pointer (WP) in a spec;ified workspace register. LOAD IMMEDIATE Format: LI R,value LI 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 .1 0 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 0 I 0 I 0 I 0 I I ~ I (0200+R) 0:5R:515 Operation: The 16 bit data value in the word immediately following the instruction is loaded into the specified workspace register R. value-R immediate operand: 0 Affect on Status: LGT,AGT, EQ Examples: LI 7,5 5 -R7 LI 8,>FF OOFF 16 - R 8 Applications: The LI instruction is used to initialize a workspace register with a program constant such as a counter value or data mask. LOAD INTERRUPT MASK IMMEDIATE Format: LIMI value LIMI I I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 I 0 I 0 I 0 I 0 I 0 I 1 I 1 I 0 I 0 I 0 I 0 I 0 I 0 I 0 I 0 (0300) Operation The low order 4 bit value (bits 12-15) in the word immediately following the instruction is loaded into the interrupt mask portion of the status register: BITS ST I 0 I 1 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9 I 10 I 11 IIIII 12 13 14 15 4 BIT VALUE Ajfec~ on Status: Interrupt mask code only Example: LIMI 5 Enables interrupt levels 0 through 5 Application: The LIMI instruction is used to initialize the interrupt mask to control which system interrupts will be recognized. 6-18 9900 FAMILY SYSTEMS DESIGN LWP~ov Instruction Set LOAD WORKSPACE POINTER IMMEDIATE LWPI Format: LWPI value I I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 1 I 1 I 1 I 0 I 0 I 0 I 0 I 0 (02EO) Operation: The 16 bit value contained in the word immediately following the instruction is loaded into the workspace pointer (WP): value~WP Affect on Status: None Example: LWPI >0500 Causes 0500 16 to be loaded into the WP. Application: L WPI is used to establish the workspace memory area for a section of the program. MOVEWoRn MOV 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 1 I 1 I 0 I 0 I~ Id I ~ I I ;s I I ~ I I (C---) Operation: The word in the location specified by Gs is transferred to the location specified by Gd, without affecting the data stored in the Gs location. During the transfer, 6.....il the word (Gs data) is compared to 0 with the result of the comparison stored in the status I register: M(G.)- M(Gd) M(G.):O Status Bits Affected: LGT, AGT, and EQ Examples: MOV R1,R3 R1-R3, R1:0 MOV *R1,R3 M(R1)-R3, M(R1):0 MOV @ONES,*1 M(ONES)-M(R1), M(ONES):O MOV @2(5),3 M(R5 + 2)-R3, M(R5 + 2):0 MOV *R1 +,*R2+ M(R1)-M(R2), M(R1):0, (R1)+2-R1, (R2)+2-R2 Application: MOV is used to transfer data from one part of the system to another part. 9900 FAMILY SYSTEMS DESIGN 6-19 Instruction Set .MOVB MOVE BYTE MOVB 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 1 I 1 I 0 I 1 I ~d I I ~ I I ~s I I ~ I (D---) Operation: The Byte addressed by Gs is transferred to the byte location specified by Gd. If G is workspace register addressing, the most significant byte is selected. Otherwise, even addresses select the most significant byte; odd addresses select the least significant byte. During the transfer, the source byte is compared to zero and the results of the comparison are stored in the status register. MB(Gs)---+-MB(Gd) MB(G.):O Status Bits Affected· LGT, AGT, EQ, OP Examples: MOV8 @>1C14,3 MOV8 *8,4 These instructions would have the following example affects: Memory Contents Contents Location Initially After Transfer 1C14 2016 2016 R3 5428 2028 RS 2123 2123 2123 1040 1040 ~6 R4 OAOC 400C The underlined data are the bytes selected. Application: MOVB is used to transfer 8 bit bytes from one byte location to another. 6-20 9900 FAMILY SYSTEMS DESIGN Instruction Set SWPB/srsT SWAP BYTES SWPB Format: SWPB G 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 1 I 0 I 1 I 1 I ~s I I ~ I (06CO +Ts 'S) Operation: The most significant byte and the least significant bytes of the word at the memory location specified by G are exchanged. Affect on Status: None Before After Example: SWPB 3 R3 Contents: F302 02F3 Application: Used to interchange bytes if needed for subsequent byte operations. STORE STATUS Format: STST R STST 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ~ 1 1 1 1 1 1 1 1 1 1 1 1 1 (02CO+R) lo o o o o o 1 o 1 1 o ol 0:5R:515 Operation: The contents of the status register are stored in the workspace register specified: 6-- ST-R Affect on Status: None Example: STST 3 ST is transferred to R3 Application: STST is used to save the status for later reference. 9900 FAMILY SYSTEMS DESIGN 6-21 Instruction Set STWP STORE WoRKSPACE POINTER Format: STWP R STWP 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 jo o o o o o 1 o 1 o 1 ol '~ 1 1 1 1 1 1 1 1 1 1 1 1 (02AO+R) I 0:5R:515 Operation: The contents of the workspace pointer are stored in the workspace register specified: WP-R Affect on Status: None Example: STWP 3 WP is transferred into R3 Appliation: STWP is used to save the workspace pointer for later reference. ~6 6-22 9900 FAMILY SYSTEMS DESIGN Instruction Set A ARITHMETIC INSTRUCTIONS These instructions perform the following basic arithmetic operations: addition (byte or word), subtraction (byte or word), multiplication, division, negation, and absolute value. More complicated mathematical functions must be developed using these basic operations. The basic instruction set will be adequate for many system requirements. Ann WoRDS A 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 1 I 0 I 1 I 0 I~ Id I ~ I I; I s I ~ I I (A---) Operation: The data located at the address specified by Gs is added to the data located at the address specified by Gd. The resulting sum is placed in the Gd location and is compared to zero: M(G.) + M(Gd) - M(Gd) M(G.) + M(Gd):O Status Bits Affected: LGT, AGT, EQ, C, OV Examples: A 5,@TABLE R5 + M(TABLE) -M(TABLE) A 3, *2 R3 + M(R2) -M(R2) with the sums compared to 0 in each case. Binary addition affects on status bits can be understood by studying the following examples: M(Gs) M(G2120,@>2123 Memory Data Before Data After Location Addition Addition 2120 F320 F320 2123 2106 21F9 ,. The underlined entries are the addressed and changed bytes. 6 Application: AB is one of the byte operations available on the 9900. These can be useful when dealing with subsystems or data that use 8 bit units, such as ASCII codes. 6-24 9900 FAMILY SYSTEMS DESIGN Instruction Set Ann IMMEDIATE Format: Al R,Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 ~ 1 1 1 1 1 1 1 1 1 1 1 1 (0220+ R) lo 0 0 0 0 o 1 o o o 1 ol O:sR:s 15 Operation: The 16 bit value contained in the word immediately following the instruction is added to the contents of the workspace register specified. R+Value-R, R+Value:O Status Bits Affected· LGT, AGT, EQ, C, OV Example: Al 6, > C Adds C 16 to the contents of workspace register 6. If R6 contains 100016 , then the instruction will change its contents to 100C16 , and the LGT and AGT status bits will be set. Application: This instruction is used to add a constant to a workspace register. Such an operation is useful for adding a constant displacement to an address contained in the workspace register. SUBTRACT w ORDS s 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 1I1.1 0 I ~d I I 6 I I ;s I I ~ I I (6---) 6~ Operation: The source 16 bit data (location specified by Gs) is subtracted from the destination data (location specified by Gd) with the result placed in the destination location Gd. The result is compared to 0. M(Gd) - M(Gs)- M(Gd) M(Gd) - M(G.):O Status Bits Affected· LGT, AGT, EQ, C, OV Examples: S @OLDVAL,@NEWVAL would yield the following example results: Memory Before Subtraction After Subtraction Location Contents Contents OLDVAL 1225 1225 NEWVAL 8223 6FFE (8223·1225) All status bits affected would be set to 1 except equal which would be reset to 0. Application: Provides 16 bit binary subtraction. 9900 FAMILY SYSTEMS DESIGN 6-25 Instruction Set SB SUBTRACT BYTES SB 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I0 I 1 I 1 I 1 I~ Id I ~ I I ~s I I ~ I I (7---) Operation: The source byte addressed by Gs is subtracted from the destination byte addressed by Gd with the result placed in byte location Gd. The result is compared to 0. Even addresses select the most significant byte and odd addresses select the least significant byte. If workspace register addressing is used, the most significant byte of the register is used. MB(Gd) - MB(Gs) -MB(Gd) MB(Gd)- MB(Gs):O Status Bits Affected: LGT,AGT,C,EQ,OV,OP Format: SB *6+,1 R1 -MB(R6)-R1 R1 - MB(R6):0 R6+1-R6 This operation would have the following example result: Memory Contents Before Contents After Location Instruction Instruction R6 1210 121E 1210 3123 4123 R1 1344 F044 ~6 The underlined entries indicated the addressed and changed bytes. The LGT (logical greater than) status bit would be set to 1 while the other status bits affected would be 0. Application: SB provides byte subtraction when 8 bit operations are required by the system. 6-26 9900 FAMILY SYSTEMS DESIGN Instruction Set IN9'1NCT INCREMENT INC Format: INC G 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 1 I 1 I 0 I ;s I I ~ I (05--) Operation:· The data located at the address indicated by G is incremented and the result is placed in the G location and compared to 0. M(G) + 1 - M(G) M(G) + 1 : 0 Status Bits Affected: LGT, AGT, EQ, C, OV Examples: INC @TABL M(TABL) + 1 - M(T ABL) INC 1 (R1)+1-R1 Application: INC is used to increment byte addresses and to increment byte counters. Autoincrementing addressing on byte instructions automatically includes this operation. INCREMENT BY Two Format: INCT G INCT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 1 I 1 I 1 I ~s I I ~ I (05--) Operation: Two is added to the data at the location specified by G and the result is stored at the G location and is compared to 0: 6<1111111 M(G) + 2 - M(G) M(G) + 2: 0 Status Bits Affected: LGT, AGT, EQ, C, OV Example: INCT 5 (R5)+2-R5 Application: This can be used to increment word addresses, though autoincrementing on word instructions does this automatically. 9900 FAMILY SYSTEMS DESIGN 6-27 Instruction Set DECREMENT Format: DEC G DEC 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I0 I 0 I 0 I 0 I 0 I 1 I1 I0 I 0 I 0 I ~s I I ~ I I (06--) Operation: One is subtracted from the data at the location specified by G, the result is stored at that location and is compared to 0: M(G) - 1- - M(G) M(G)-1 : 0 Status Bits Affected· LGT, AGT, EQ, C, OV Example: DEC @TABL M(TABL) - 1 - M(TABL) Application: This instruction is most often used to decrement byte counters or to work through byte addresses in descending order. DECREMENT BY Two Format: DECT G DECT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 1 I 0 I 0 I 1 I is I I ~ I I (06--) Operation: Two is subtracted from the data at the location specified by G and the result is ... 6 stored at that location and is compared to 0: M(G) - 2 - M(G) M(G)-2: 0 Status Bits Affected- LGT, AGT, EQ, C, OV Example: DECT 3 (R3)-2-R3 Application: This instruction is used to decrement word counters and to work through word addresses in descending order. 6-28 9900 FAMILY SYSTEMS DESIGN Instruction Set NEGATE Format: NEG G NEG 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 1 I 0 I 0 I ~s I I ~ I (05--) Operation: The data at the address specified by G is replaced by its two's complement. The result is compared to 0: -M(G)-M(G) - M(G): 0 Status Bits Affected- LGT, AGT, EQ, C, OV (OV set only when operand= 8000 16 ) Example: NEG 5 - ( R 5 ) - RS If RS contained A34 216 , this instruction would cause the RS contents to changed to SCBE 16 and will cause the LGT and AGT status bits to be set to 1. Application: NEG is used to form the 2's complement of 16 bit numbers. vALUE ABSOLUTE Format: ABS G ABS 0/1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 1 I 1 I 0 I 1 I ~s I I ~ I (07---) 6 .... Operation: The data at the address specified by G is compared to 0. Then the absolute value of this data is placed in the G location: M(G): 0 IM(G)I - M(G) Status Bits Affected· LGT, AGT, EQ, OV (OV set only when.operand= 800016) Example: ABS @LIST(7) IM(R7 + LIST)I- M(R7 +LIST) If the data at R7 +LIST is FF3C16 , it will be changed to OOC416 and LGT will be set to 1. Application: This instruction is used to test the data in location G and then replace the data by its absolute value. This could be used for unsigned arithmetic algorithms such as multiplication. 9900 FAMILY SYSTEMS DESIGN 6-29 Instruction Set MPV MULTIPLY Format: MPV Gs,Rd MPV 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I0 I 0 I 1 I 1 I 1 I 0 I I ~ I I ~s I I ~ I I (3---) Operation: The 16 bit data at the address designated by Gs is multiplied by the 16 bit data contained in the specified workspace register R. The unsigned binary product (32 bits) is placed in workspace registers Rand R + 1: Gs MULTIPLIER x MULTIPLICAND PRODUCT ::5 FFFE0001,. Affect on Status: None Example: MPV @NEW,5 If the data at location NEW is OOOS 16 and RS contains 0012 16 , this instruction will cause RS to contain 000016 and R6 to contain OOSA16 • Application: MPY can be used to perform 16 bit by 16 bit binary multiplication. Several such 32 bit subproducts can be combined in such a way to perform ... 6 multiplication involving larger multipliers and multiplicands such as a 32 bit by 32 bit multiplication. 6-30 9900 FAMILY SYSTEMS DESIGN Instruction Set DIV DIVIDE DIV 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 1 I 1 I 1 I 1 I I ~ I I ~s I I ~ I (3---) Operation: The 32 bit number contained in workspace registers Ri and Ri + 1 is divided by the 16 bit data contained at the address specified by Gs. The workspace register Ri then contains the quotient and workspace Ri + 1 contains the 16 bit remainder. The division will occur only if the divisor at G is greater than the data contained in Ri: M(G) QUOTIENT REMAINDER DIVISOR DIVIDEND Affect on Status: Overflow (OV) is set if the divisor is less than the data contained in Ri. If OV is set, Ri and Ri + 1 are not changed. Example: DIV @LOC,2 If R2 contains 0 and R3 contains OOOD 16 and the data at address LOC is 0005 16 , this instruction will cause R2 to contain 0002 16 and R3 to contain 00031 6 • OV 6...._ would be 0. Application: DIV provides basic binary division of a 32 bit number by a 16 bit number. 9900 FAMILY SYSTEMS DESIGN 6-31 c Instruction Set COMPARISON INSTRUCTIONS These instructions are used to test words or bytes by comparing them with a reference constant or with another word or byte. Such operations are used in certain types of division algorithms, number conversion, and in recognition of input command or limit conditions. COMPARE WORDS c 0 1 2 3 . 4 5 6 7 8 9 10 11 12 13 14 15 I 1 I 0 I 0 I 0 I ~d I I ~ I I ~s I I ~ I (8---) Operation: The 2's complement 16 bit data addressed by Gs is compared to the 2's complement 16 bit data addressed by Gd. The contents of both locations remain unchanged. M(Gs) : M(Gd) Status Bits Affected: LGT, AGT, EQ Example: C @T1,2 This instruction has the following example results: Data at Data in Results of Comparison Location T 1 R2 LGT ACT EQ ~6 FFFF 0000 1 0 0 7FFF 0000 1 1 0 8000 0000 1 0 0 8000 7FFF 1 0 0 7FFF 7FFF 0 0 1 7FFF 8000 0 1 0 Application: The need to compare two words occurs in such system functions as division, number conversion, and pattern recognition. 6-32 9900 FAMILY SYSTEMS DESIGN Instruction Set CB COMPARE BYTES CB 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 1 I 0 I 0 I 1 I T~ I I ~ I I ~s I I ~ I I (9---) Operation: The 2's complement 8 bit byte addressed by Gs is compared to the 2's complement 8 bit byte addressed by Gct: MB(Gs) : MB(Gd) Status Bits Affected: LGT, AGT,EQ,OP OP (odd parity) is based on the number of bits in the source byte. Example: CB 1,*2 with the typical results of (assuming R2 addresses an odd byte): Results of Comparison Rl data M(R2) Data LGT ACT EQ OP FFFF FFOO 1 0 0 0 7FOO FFOO 1 1 0 1 8000 FFOO 1 0 0 1 8000 FF7F 1 0 0 1 7FOO 007F 0 0 1 1 The underlined entries indicate the byte addressed. Application: In cases where 8 bit operations are required, CB provides a means of 6~ performing byte comparisons for special conversion and recognition problems. 9900 FAMILY SYSTEMS DESIGN 6-33 Clfoc Instruction Set COMPARE IMMEDIATE Format: Cl R, Value Cl 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ~ 1 1 1 1 1 1 1 1 1 1 1 1 1 (0280+R) lo o o o o o 1 o 1 o o ol 0:5R:515 Operation: CI compares the specified workspace register contents to the value contained in the word immediately following the instruction: R: Value Status Bits Affected· LGT, AGT, EQ Example: Cl 9, > F330 If R9 contains 2183 16 , the equal (EQ) and logical greater than (LGT) bits will be 0 and arithmetic greater than (AGT) will be set to 1. Application: CI is used to test data to see if system or program limits have been met or exceeded or to recognize command words. COMPARE ONES CORRESPONDING Format: COC GsiR coc 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 1 I 0 I 0 I 0 I I ~ I I ~s I I ~ I I (2---) _...6 Operation: The data in the location addressed by Gs act as a mask for the bits to be tested in workspace register R. That is, only the bit position that contain ones in the Gs data will be checked in R. Then, if R contains ones in all the bit positi~ns selected by the Gs data, the equal (EQ) status bit will be set to 1. Status Bits Affected- EQ Example: COC @TESTBIT, 8 If R8 contains E30616 a~d location TESTBIT contains C 102 16 , TESTBIT Mask= _1100 000! 0000 0010 RS 1110 0011 0000 0110 = equal (EQ) would be set to 1 since everywhere the test mask data contains a 1 (underlined positions), R8 also contains a 1. Application: COC is used to selectively test groups of bits to check the status of certain sub-systems or to examine certain aspects of data words. 6-34 9900 FAMILY SYSTEMS DESIGN Instruction Set czc COMPARE ZEROES CORRESPONDING Format: CZC GsiR czc 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 1 I 0 I 0 I 1 I I ~ I I ;s I I ~ I I (2---) Operation: The data located in the address specified by Gs act as a mask for the bits to be tested in the specified workspace register R. That is, only the bit positions that contain ones in the Gs data are the bit positions to be checked in R. Then if R contains zeroes in all the selected bit positions, the equal (EQ) status bit will be set to 1. Status Bits Affected· EQ Examples: CZC @TESTBIT,8 If the TESTBIT location contains the value Cl02 16 and the R8 location contains 2301 16 , TESTBIT Data= 1100 0001 0000 0010 =- RB 0010 00110000 0001 x - the equal status bit would be reset to zero since not all the bits of R8 (note the X position) are zero in the positions that the TESTBIT data contains ones. Application: Similar to the COC instruction. 6~ 9900 FAMILY SYSTEMS DESIGN 6-35 Instruction Set ANDI LOGIC INSTRUCTIONS The logic instructions allow the processor to perform boolean logic for the system. Since AND, OR, INVERT, and Exclusive OR (XOR) are available, any boolean function can be performed on system data. AND IMMEDIATE Format: ANDI R,Value ANDI 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 0 I 1I 0 I 0 I I ~ I I ~!~;1~ Operation: The bits of the specified workspace register R are logically ANDed with the corresponding bits of the 16 bit binary constant value contained in the word immediately following the instruction. The 16 bit result is compared to zero and is placed in the register R: R AND Value~R R AND Value : 0 Recall that the AND operation results in 1 only if both inputs are 1. Status Bits Affected· LGT, AGT, EQ Example: ANDI 0, > 6D03 If workspace register 0 contains D2AB 16 , then (D2AB) AND (6D03) is 4003 16 : Value= 0110 1101 0000 0011 .. 6 RO = 1101 0010 1010 1011 RO AND Value= 0100 0000 0000 0011 = 40031 6 This value is placed in RO. The LGT and AGT status bits are set to 1. Application: ANDI is used to zero all bits that are not of interest and leave the selected bits (those with ones in Value) unchanged. This can be used to test single bits or isolate portions of the word, such as a four bit group. 6-36 9900 FAMILY SYSTEMS DESIGN Instruction Set ORI 0 R IMMEDIATE Format: ORI R,Value ORI I I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ~I 0 I 0I 0I 0I 0I 1I 0I 0I 1I 1I 0 ~ I . . I I . (0260 + R) O:SR:S 15 Operation: The bits of the specified workspace register Rare ORed with the corresponding bits of the 16 bit binary constant contained in the word immediately following instruction. The 16 bit result is placed in Rand is compared to zero: R OR Value-R R OR Value: 0 Recall that the OR operation results in a 1 if either of the inputs is a 1. Status Bits Affected: LGT, AGT, EQ Example: ORI 5,>6003 If RS contained D2AB16, then RS will be changed to FFAB16 : R5 = 1101 0010 1010 1011 Value= 0110 1101 0000 0011 1111 1111 1010 1011 = FFAB 16 = R5 OR Value with LGT being set to 1. Application: Used to.implement the OR logic in the system. 6 .... 9900 FAMILY SYSTEMS DESIGN 6-37 Instruction Set XORfiNv EXCLUSIVE 0 R Format: XOR XOR 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Io Io I 1 Io ' 1 Io I I ~ I I ~s I I 's I I (2---) Operation: The exclu;ive OR is performed between corresponding bits of the data addressed by Gs and the contents of workspace register Ri. The result is placed in workspace register Ri and is compared to 0: M(Gs) XOR Rd - Rd M(Gs) XOR Rd : 0 Status Bits Affected· LGT, AGT, EQ Example: XOR @CHANGE,2 If location CHANGE contains 6D03 16 and R2 contains D2AA16 , R2 will be changed to BFA9 16 : CHANGE Data= 0110 1101 0000 0011 R2 = 1101 0010 1010 1010 M(CHANGE) XOR R2 = 1011 1111 1010 1001· = BFA91 6 and the LGT status bit will be set to 1. Note that the exclusive OR operation will result in a 1 if only one of the inputs is a 1. Application: XOR is used to implement the exclusive OR logic for the system. ... 6 INVERT Format: INV G INV 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 1 1 1 1 1 1 r 1 1 0 0 0 0 0 1 0 1 0 1 Ts S (05--) I 1 1 1 Operation: The bits of the data addressed by G are replaced by their complement. The result is compared to 0 and is stored at the G location: M(G)-M(G) M(G): 0 Status Bits Affected· LGT, AGT, EQ Example: INV 11 If Rl 1 contains OOFF1 6, the instruction would change the contents to FF00 16 , causing the LGT status bit to set to 1. Application: INV is used to form the l's complement of 16 bit binary numbers, or to invert system data. 6-38 9900 FAMILY SYSTEMS DESIGN Instruction Set CLR/SETO CLEAR Format: CLR G CLR 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 0 I 1 I 1 I ~s I I ~ I I (04--) Operation: 000016 is placed in the memory location specified by G. 0000 16 - M(G) Affect on Status: None Example: CLR •:=11 would clear the contents of the location addressed by the contents of Rl 1, that is: 0000 16 - M(R11) Application: CLR is used to set problem arguments to 0 and to initialize memory locations to zero during system start-up operations. SET To ONE Format: SETO G SETO 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 1 I 1 I 0 I 0 I ~s I I ~ I I (07--) Operation: FFFF16 is placed in the memory location specified by G: FFFF16 - M(G) Affect on Status: None Example: SETO 11 6...a would cause all bits of Rll to be 1. I Application: Similar to CLR 9900 FAMILY SYSTEMS DESIGN 6-39 80 Instruction Set %ocB SET ONES CORRESPONDING soc 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 1 I 1 I 1 I 0 I I I Td I I D I I II Ts I SI I I (E---) Operation: This instruction performs the OR operation between corresponding bits of the data addressed by Gs and the data addressed by Gd. The result is compared to 0 and is placed in the Gd location: M(Gs) OR M(Gd) -M(Gct) M(Gs) OR M(Gct) : 0 Status Bits Affected: LGT, AGT, EQ Example: SOC 3,@NEW If location NEW contains AAAA16 and R3 contains FF00 16 , the contents at location NEW will be changed to FF AA16 and the LGT status bit will be set to 1. Application: Provides the OR function between any two words in memory. SET ONES CORRESPONDING, BYTE Format: SOCB GsiGd SOCB 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... 6 I 1 I 1 I 1 I 1 I ~d I I b I I ~s I I ~ I I (F---) Operation: The logical OR is performed between corresponding bits of the byte addressed by Gs and the byte addressed by Gd with the result compared to 0 and placed in location Gd: MB(Gs) OR MB(Gct) -MB(Gct) MB(Gs) OR MB(Gct): 0 Status Bits Affected· LGT, AGT, EQ, OP Example: SOCB 5,8 If RS contains F013 16 and R8 contains AA2416 , the most significant byte of R8 will be changed to F A 16 so that R8 will contain F A2416 and the LGT status bit will be set to 1. Application: The SOCB provides the logical OR function on system bytes. 6-40 9900 FAMILY SYSTEMS DESIGN Instruction Set szc SET TO ZEROES CORRESPONDING szc 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 1 I 0 I 0 I ~d I I ~ I I ~s I I ~ I I (4---) Operation: The data addressed by Gs forms a mask for this operation. The bits in the destination data (addressed by Gct) that correspond to the one bits of the source data (addressed by Gs) are cleared. The result is compared to zero and is stored in the Gct location. M(Gs) AND M(Gd) - M(Gct) M(Gs) AND M(Gct): 0 Status Bits Affected: LGT, AGT, EQ Example: SZC 5,3 If RS contains 6D0316 and R3 contains D2AA16 , this instruction will cause the R3 contents to change to 92A8 16 : R5 (Mask)= OUO U010000 OOU R3 = 1101 0010 1010 1010 Result= 1001 001Q1010 1000 = 92A8 16 with the LGT status bit set. The underlined entries indicate which bits are to be cleared. Application: SZC allows the programmer to selectively clear bits of data words. For example, when an interrupt has been serviced, the interrupt request bit can be cleared by using the SZC instruction. 6~ 9900 FAMILY SYSTEMS DESIGN 6-41 Instruction Set SZCB SET TO ZEROES CORRESPONDING, BYTES Format: SZCB GsGd SZCB 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 1 I 0 I 1 , • ~d I I ~ I I ~s I I ~ I I (5---) Operation: The byte addressed by Gs will provide a mask for clearing certain bits of the byte addressed by Gd. The bits in the Gd byte that will be cleared are the bits that are one in the Gs byte. The result is compared to zero and is placed in the Gd byte: MB(G.) AND MB(Gd)-MB(Gd) MB(G.) AND MB(Gd): 0 Status Bits Affected: LGT, AGT, EQ, OP Example: SZCB @BITS,@TEST If location BITS is an odd address which locates the data 18F016 , and location TEST contains an even address which locates the data AA24 16 , the instruction will clear the first four bits of TEST data changing it to OA2416 • Application: Provides selective clearing of bits of system bytes. ~6 6-42 9900 FAMILY SYSTEMS DESIGN Instruction Set SRA SHIFT INSTRUCTIONS These instructions are used to perform simple binary multiplication and division on words in memory and to rearrange the location of bits in the word in order to examine a given bit with the carry (C) status bit. SHIFT RIGHT ARITHMETIC Format: SRA R,Cnt SRA I I I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 I 0 I 0 I 0 I 1 I 0 I 0 I 0 I ~ I I ~ I (08--) Operation: The contents of the specified workspace register R are shifted right Cnt times, filling the vacated bit position with the sign (most significant bit) bit: The shifted number is compared to zero: 0 15 ~ I R Status Bits Affected· LGT, AGT, EQ, C Number of Shifts: Cnt (number contained in the instruction from 0 to 15) specifies the number of bits shifted unless Cnt is zero in which case the shift count is taken from the four least significant bits of workspace register 0. If both Cnt and these four bits are 0, a 16 bit position shift is performed. 6...il Example: SRA 5,2 Shift R5 2 bit positions right SRA 7,0 If RO least four bits contain 6 16 , then the second instruction will cause register 7 to be shifted 6 bit positions (Cnt in that instruction is 0): If R7 Before Shift = 1011 1010 1010 1010 = BAAA 16 R7 After Shift ~ 1111 1110 1110 1010 = FEEA16 If RS Before Shift = 0101 0101 0101 0101 = SSSS16 RS After Shift = 0001 0101 0101 0101 = 1 SSS16 After the R7 shift the LGT would be set, and Carry= 1 After the RS shift LGT and AGT would be set and Carry= 0 Application: SRA provides binary division by zcnt. 9900 FAMILY SYSTEMS DESIGN 6-43 Instruction Set SLA SHIFT LEFT ARITHMETIC Format: SLA R,Cnt SLA I I ~ I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 I 0 I 0 I 0 I 1 I 0 I 1 I 0 I I I ~ I (QA--) Operation: The· contents of workspace register R are shifted left Cnt times (or if Cnt = 0, the number of times specified by the least four bits of RO) filling the vacated positions with zeroes. The carry contains the value of the last bit shifted out to the left and the shifted number is compared to zero: 15 R 0 Status Bits Affected: LGT, AGT, EQ, C, OV Example: SLA 10,5 If workspace register 10 contains 13 5716 the instruction would change its contents to 6AE0 16 , causing the arithmetic greater than (AGT), logical greater than (LGT), and overflow (OV) bits to set. Carry would be zero, the value of the last bit shifted. Application: SLA performs binary multiplication by 2cnt .-.6 6-44 9900 FAMILY SYSTEMS DESIGN Instruction Set SRLfsRc SHIFT RIGHT LOGICAL Format: SRL R,Cnt SRL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 1 I 0 I 0 I 1 I I ~ I I I ~ I (09--) Operation: The contents of the workspace register specified by Rare shifted right Cnt times (or if Cnt = 0, the number of times specified by the least four bits or RO) filling in the vacated positions with zeroes. The carry contains the value of the last bit shifted out to the right and the shifted number is compared to zero: 0 R Status Bits Affected· LGT, AGT, ea, C Example: SRL 0,3 If RO contained FFEF16 , the contents would become lFFD16 with the AGT, LGT, and C bits set to 1: RO Before Shift = 1111 1111 1110 1111 = FFEF 16 RO After Shift = 0001 1111 1111 1101 = 1 FF016 Application: Performs binary division by 2cn t SHIFT RIGHT CIRCULAR SRC Format: SRC R,Cnt 6 ... I I I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 I 0 I 0 I 0 I 1 I 0 I 1 I 1 I ~ I I ~ I (OB--) Operation: On each shift the bit shifted out of bit 15 is shifted back into bit 0. Carry contains the value of the last bit shifted and the shifted number is compared to 0. The number of shifts to be performed is the number Cnt, or if Cnt = 0, the number contained in the least significant four bits of RO: ~--0-R~15~ Status Bits Affected· LGT, AGT, ea, C Example: SRC 2,7 If R2 initially contains FFEF16 , then after the shift it will contain DFFF16 with LGT and C set to 1. R2 Before Shift= 1111 1111 111.Q.1111 = FFEF16 R2 After Shift = 1101 1111 1111 1111 = DFFF 16 Application: SRC can be used to examine a certain bit in the data word, change the location of 4 bit groups, or swap bytes. 9900 FAMILY SYSTEMS DESIGN 6-45 Instruction Set B UNCONDITIONAL BRANCH INSTRUCTIONS These instructions give the programmer the capability of choosing to perform the next instruction in sequence or to go to some other part of the memory to get the next instruction to be executed. The branch can be a subroutine type of branch, in which case the programmer can return to the point from which the branch occurred. BRANCH Format: B Gs B 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Io o o o o I I I I I 1 I o I o I oI 1 I ;s I I 's I (04--) Operation: The Gs address is placed in the program counter, causing the next instruction to be obtained from the location specified by Gs. A!feet on Status: None Example: B ,, 3 If R3 contains 21 CC 16 , then the next instruction will be obtained from location 21 CC 16 • Application: This instruction is used to jump to another part of the program when the current task has been completed . ... 6 6-46 9900 FAMILY SYSTEMS DESIGN Instruction Set BL BRANCH AND LINK Format: BL Gs BL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 IoI oIoIoI oI 1 I1 IoI 1I o I ~s I I 's I (06--) Operation: The source address Gs is placed in the program counter and the address of the instruction following the BL instruction is saved in workspace regis~er 11. Gs-PC (Old PC)-R11 Affect on Status: None Example: BL @TRAN Assume the BL instruction is located at 320016 and the value assigned to TRAN is 200016 • PC will be loaded with the value 2000 16 (TRAN) and Rl 1 will be loaded with the value 3202 16 (old PC value). Application: This is a shared workspace subroutine jump. Both the main program and the subroutine use the same workspace registers. To get back to the main program at the branch point, the following branch instruction can be used at the end of the subroutine: B •:•11 which causes the Rll contents (old PC value) to be loaded into the program counter. 6 .... 9900 FAMILY SYSTEMS DESIGN 6-47 Instruction Set BLWP BRANCH AND LOAD WORKSPACE POINTER Format: BLWP Gs BLWP 0 1 2 ~ 4 5 6 7 8 9 10 11 12 13 14 15 Io o o o ' o I I I I 1 I o I oI oI o I ~s I I 's I I (04--) Operation: The word specified by the source Gs is loaded into the workspace pointer (WP) and the next word in memory (Gs + 2) is loaded into the program counter (PC) to cause the branch. The old workspace pointer is stored in the new workspace register 13, the old PC value is stored in the new workspace register 14, and the status register is stored in new workspace register 15: M(Gs)-WP M(Gs +2)~PC (Old WP)--+-New R13 (Old PC)--+- New R14 (Old ST)-New R15 Affect on Status: None Example: BLWP o:c3 Assuming that R3 contains 2100 16 and location 210016 contains 0500 16 and location 2102 16 contains 0100 16 , this instruction causes WP to be loaded with 050016 and PC to be loaded with 010016 • Then, location 051A16 will be loaded with the old WP value, the old PC value will be saved in location 051 C16 , and the status (ST) will be saved in location ,. 6 051 E 16 • The next instruction will be taken from address 010016 and the subroutine workspace will begin at 0500 16 (RO). BLWP and XOP do not test IREQ at the end of instruction execution. Application: This is a context switch subroutine jump with the transfer vector location specified by Gs. It uses a new workspace to save the old values of WP, PC, and ST (in the last three registers). The advantage of this subroutine jump over the BL jump is that the subroutine gets its own workspace and the main program workspace contents are not disturbed by subroutine operations. 6-48 9900 FAMILY SYSTEMS DESIGN Instruction Set XOP - . 6· ' tli EXTENDED OPERATION Format: XOP G 51 n XOP 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 1 I 0 I 1 I 1 I I ~ I I ~s I I ~ I I (2---) Operation: n specifies which extended operation transfer vector is to be used in the context switch branch from XOP to the corresponding subprogram. The effective address Gs is placed in Rl 1 of the subprogram workspace in order to pass an argument or data location to the subprogram: M(n x 4 + 0040 16 )-WP M(n x 4 + 0042 16 ) - PC (Old WP) - New R13 (Old PC) - New R14 (Old ST)-New R15 Gs-NewR11 Affect on Status: Extended Operation (X) bit is set. Example: XOP •:•1,2 Assume Rl contains 07 50 16 • WP is loaded with the word at address 48 16 (first part of transfer vector for extended operation 2) and PC is loaded with the word at address 4A16 • If location 48 16 contains 0200 16 , this will be the address of RO of the subprogram workspace. Thus, location 0236 16 (new R11) will be loaded with 0750 16 (contents of Rl in main program), location 023A16 (new Rl3) will be loaded with the old WP value, 6~ location 023C16 will be loaded with the old PC value, and location 023E16 (new R15) will be loaded with the old status value: M(48 16) - W P M(4A16 ) - P C (Old WP)- M(023A16 ) New R13 (Old PC)-M(023C1 6 ) New R14 (Old ST)-M(023E 16 ) New R15 07501 6- M(02361 6) New R11 Application: This can be used to define a subprogram that can be called by a single instruction. As a result, the programmer can define special purpose instructions to augment the standard 9900 instruction set. 9900 FAMILY SYSTEMS DESIGN 6-49 RTWP~MP Instruction Set RETURN WITH WORKSPACE POINTER RTWP Format: RTWP 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 0 I 1 I 1 I 1 I 0 I 0 I 0 I 0 I 0 I 0 I 0 I (0380) Operation: This is a return from a context switch subroutine. It occurs by restoring the WP, PC, and ST register contents by transferring the contents of subroutine workspace registers R13, Rl4, and R15, into the WP, PC, and ST registers, respectively. R13-WP R14-PC R15-ST Status Bits Affected: All (ST receives the contents of R15) Application: This is used to return from subprograms that were reached by a transfer vector operation such as an interrupt, extended operation, or BLWP instruction. UNCONDITIONAL }UMP Format: JMP EXP 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 1 I 0 I 0 I 0 I 0 I I I I Di~P I I I (10--) .,. 6 Operation: The signed displacement defined by EXP is added to the current contents of the program counter to generate the new value of the program counter. The location jumped to must be within -128 to + 127 words of the present location. Affect on Status: None Example: J MP THERE If this instruction is located at 0018 16 and THERE is the label of the instruction located at 0010 16 , then the Exp value placed in the object code would be FB (for -5). Since the Assembler makes this computation, the programmer only needs to place the appropriate label or expression in the operand field of the instruction. Application: If the subprogram to be jumped to is within 128 words of the JMP instruction location, the unconditional JMP is preferred over the unconditional branch since only one memory word (and one memory reference) is required for the JMP while two memory words and two memory cycles are required for the B instruction. Thus, the JMP instruction can be implemented faster and with less memory cost than can the B instruction. 6-50 9900 FAMILY SYSTEMS DESIGN Instruction Set x EXECUTE Format: X Gs x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 0 I 0 I 1 I 0 I 0 I 1 '. 0 I ~s I I ~ I (04--) Operation: The instruction located at the address specified by Gs is executed. Status Eris Affected· Depends on the instruction executed Example: X *11 If Rl 1 contains 200016 and location 2000 16 contains the instruction for CLR 2 then this execute instruction would clear the contents of register 2 to zero. Application: Xis useful when the instruction to be executed is dependent on a variable factor. 6.. 9900 FAMILY SYSTEMS DESIGN 6-51 Instruction Set JH, JL, JHE, JLE, JGT, JLT, JEQ, JNE, JOG, JNG, JNO, JOP CONDITIONAL JUMP INSTRUCTIONS JH These instructions perform a branching operation only if certain status bits meet the JL conditions required by the jump. These instructions allow decision making to be JHE incorporated into the program. The conditional jump instruction mnemonics are summarized in Table 6-1 along with the status bit conditions that are tested by these JLE instructions. JGT Format: Mnemonic Exp JLT 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 JEQ I 0 I 0 I 0 I 1 II C~DE I III I Dl~P I I I (1---) JNE JOG Operation: If the condition indicated by the branch mnemonic is true, the jump will occur JNG using relative addressing as was used in the unconditional JMP instruction. That is, the JNO Exp defines a displacement that is added to the current value of the program counter to JOP determine the location of the next instruction, which must be within 128 words of the jump instruction. Effect on Status Bits: None Example: C R1,R2 JNE LOOP The first instruction compares the contents of registers one and two. If they are not equal, EQ = 0 and the JNE instruction causes the branch to LOOP to be taken. If Rl .6 and R2 are equal, EQ = 1 and the branch is not taken. Table 6-1. Status Bits Tested by Instructions Mnemonic L> A> EQ c OV OP Jump if CODE* JH x x L> • EQ= 1 B JL x x L>+EQ=O A JHE x x L>+EQ=l 4 JLE x x L>+EQ=l 2 JGT x A>=l 5 JLT x x A> +EQ=O 1 JEQ x EQ=l 3 JNE x EQ=O 6 JOC x C=l 8 JNC x C=O 7 JNO x OV=O 9 JOP x OP=l c Note: In the Jump if column, a logical equation is shown in which • means the AND operation, + means the OR operation, and a line over a term means negation or inversion. *CODE is entered in the CODE field of the OPCODE to generate the machine code for the instruction. Application: Most algorithms and programs with loop counters require these instructions to decide which sequence of instructions to do next. 6-52 9900 FAMILY SYSTEMS DESIGN Instruction Set SBO CRU INSTRUCTIONS The communications register unit (CRU) performs single and multiple bit programmed input/ output for the microcomputer. All input consists of reading CRU line logic levels into memory, and all output consists of setting CRU output lines to bit values from a word or byte of memory. The CRU provides a maximum of 4096 input and 4096 output lines that may be individually selected by a 12 bit address which is located in bits 3 through 14 of workspace register 12. This address is the hardware base address for all CRU communications. SET BIT TO LOGIC ONE Format: SBO disp SBO 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I .o ' o ' o ' 1 ' 1 ' 1 ' o ' 1 J ' ' ' o1~P ' ' ' (10--) Operation: The CRU bit at disp plus the hardware base address is set to one. The hardware base address is bits 3 through 14 of workspace register 12. The value disp is a signed displacement. 1- Bit (disp +base address) Affect on Status: None Example: SBO 15 If R12 contains a software base address of 0200 16 so that the hardware base address is 6 ... 0100 16 (the hardware base address is one-half the value of the contents of R12 excluding bits 0, 1 and 2), the above instruction would set CRU line OlOF16 to a 1. Application: Output a one on a single bit CRU line. 9900 FAMILY SYSTEMS DESIGN 6-53 Instruction Set SET BIT TO LOGIC ZERO Format: SBZ dlsp SBZ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 0 I 1 I 1 I 1 I 1 I 0 I I I I D;SP I I I (1 E--) Operation: The CRU bit at disp plus the base address is reset to zero. The hardware base address is bits 3 through 14 of workspace register 12. The value disp is a signed displacement. o - Bit (disp +hardware base address) Affect on Status: None Example: SBZ 2 If R12 contains 000016 , the hardware base address is 0 so that the instruction would reset CRU line 0002 16 to zero. Application: Output a zero on a single bit CRU line. TEST BIT Format: TB disp TB 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Io o ' o ' I 1 ' 1 I 1 I 1 ' 1 I I I ' o:sP I ' I (lF--) .. 6 Operation: The CRU bit at disp plus the base address is read by setting the value of the equal (EQ) status bit to the value of the bit on the CRU line. The hardware base address is bits 3 through 14 of workspace register 12. The value disp is a signed displacement. Bit (disp +hardware base address) ____.. EQ Status Bits Affected: EQ Example: TB 4 IfR12 contains 0140 16 , the hardware base address is A0 16 (which is one-half of0140 16): R12 Contents= OOOQ 0001 0100 0000 Note that the underlined hardware base address is OA0 16 • Equal (EQ) would be made equal to the logic level on CRU line OA0 16 + 4 = CRU line OA4 16 • Application: Input the CRU bit selected. 6-54 9900 FAMILY SYSTEMS DESIGN Instruction Set LDCR LOAD CRU Format: LDCR Gs,Cnt LDCR 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I 0 I 0 I 1 I 1 I 0 I 0 I I ~ I I ~s I I ~ I (3---) Operation: Cnt specifies the number of bits to be transferred from the data located at the address specified by Gs, with the first bit transferred from the least significant bit of this data, the next bit from the next least significant bit and so on. If Cnt = 0, the number of bits transferred is 16. If the number of bits to be transferred is one to eight, the source address is a byte address. If the number of bits to be transferred is 9 to 16, the source address is a word address. The source data is compared to zero before the transfer. The destination of the first bit is the CRU line specified by the hardware base address, the second bit is transferred to the CRU line specified by the hardware base address + 1, and so on. Status Bits Affected: LGT, AGT, EQ OP (odd parity) with transfer of 8 or less bits. Example: LDCR @TOM,8 Since 8 bits are transferred, TOM is a byte address. If TOM is an even number, the most significant byte is addressed. If R12 contains 008016 , the hardware base address is 0040 16 which is the CRU lirie that will receive the first bit transferred. 004116 will be the address of the next bit transferred, and so on to the last (8th) bit transferred to CRU line 0047 16 • This transfer is shown in Figure 6-7. 6 ... 0 2 3 4 5 6 9 10 11 12 13 14 15 MEMORY ADDRESS TOM l 0 0 1 1 0 1 0 0 x x x x x x x xj CRU LINES 1 __.. - ... 3F 40 _.. -~ 41 ....... 42 ...... 43 ...... ~ 44 -- -"" 45 -- __.. ~ 0 46 47 X= NOT USED 48 LDCR @TOM,8 TOM is an even address Figure 6-7. LDCR byte transfer 9900 FAMILY SYSTEMS DESIGN 6-55 Instruction Set LDCR Application: The LDCR provides a number of bits (from 1 to 16) to be transferred from a memory word or byte to successive CRU lines, starting at the hardware base address line; the transfer begins with the least significant bit of the source field and continues to successive! y more significant bits. A further example of word versus byte transfers is given in Figure 6-8, in which a 9 bit (word addressed source) transfer is shown. 0 2 3 4 5 6 8 9 10 11 12 13 14 15 MEMORY ADDRESS TOM l x x x x x x x 1 0 1 0 1 0 1 1 1 J CRU LINES 3F l ..... - 40 _.... 41 _,. --- 42 -- _,. 0 43 -- ..... 0 44 45 -- _,. 46 X= NOT USED -- _,. 0 47 .... 48 49 LDCR @TOM,9 ~6 Figure 6-8. LDCR Word transfer 6-56 9900 FAMILY SYSTEMS DESIGN Instruction Set STCR STORE CRU Format: STCR Gs,Cnt STCR 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I0 I 0 I 1 I 1 I 0 I 1 I I ~ r I ~s I I ~ I I (3---) Operation: Cnt specifies the number of bits to be transferred from successive CRU lines (starting at the hardware base address) to the location specified by Gs, beginning with the least significant bit position and transferring successive bits to successively more significant bits. If the number of bits transferred is 8 or less, Gs is a byte address. Otherwise, Gs is a word address. If Cnt = 0, 16 bits are transferred. The bits transferred are compared to zero. If the transfer does not fill the entire memory word, the unfilled bits are reset to zero. Status Bits Affected: LGT, AGT, EQ OP for transfers of 8 bits or less Example: STCR 2, 7 Since 7 bits are to be transferred this is a byte transfer so that the bits will be transferred to the most significant byte of R2. Figure 6-9 illustrates this transfer assuming that R12 contains 9016 so that the hardware base address is 48 16 for the first bit to be transferred. Note: Bits 8-15 are unchanged if transfer is less than 8 bits. 6..i 01234 5 6 8 9 10 11 12 13 14 15 R2 l ,,. 0 1 0 1 1 0 1 0 x x x x x x x x j CRU LINES + ' • 1 ~ 0 47 48 49 1 0 4A 48 4C 0 40 4E X NOT USED 4F BIT 0 SET TO ZERO STCR 2,7 Figure 6-9. STCR Example 9900 FAMILY SYSTEMS DESIGN 6-57 CONTROL INSTRUCTIONS Instruction Set CONTROL INSTRUCTIONS The control instructions are primarily applicable to the Model 990 Computer. These instructions are RSET (Reset), IDLE, CKOF (Clock off), CKON (Clock on), LREX (restart). The Model'990/ 10 also supports the long distance addressing instructions: LDS (Load long distance source) and LDD (Long distance destination). The use of these instructions are covered in the appropriate Model 990 computer programmer's manuals. The control instructions have an affect on the 9900 signals on the address lines during the CRU Clock as shown below: Instruction Ao Ai A2 OP CODE 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 LREX H H H jo o o o o o 1 1 1 1 1 o o o o ol {03EO) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 CKOF H H L jo 0 0 0 0 o 1 1 1 1 o o o o o ol (03CO) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 CKON H L H lo o o o o o 1 1 1 o 1 o o o o ol (03AO) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 RSET L H H jo 0 0 0 0 o 1 1 o 1 1 o o o o ol (0360) 6 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 IDLE L H L lo o o o o o 1 1 o 1 o o o o o ol (0340) CRU L L L The IDLE instruction puts the 9900 in the idle condition and causes a CRUCLK output every six clock cycles to indicate this state. The processor can be removed from the idle state by 1) a RESET signal, 2) any interrupt that is enabled, or 3) a LOAD signal. For the 9900 the above instructions are referred to as external instructions, since external hardware can be designed to respond to these signals. The address signals Ao, Ai, and A 2 can be decoded and the instructions used to control external hardware. 6-58 9900 FAMILY SYSTEMS DESIGN Instruction Set SPECIAL FEATURES OF THE 9940 SPECIAL FEATURES OF THE 9940 The 9940 instruction set includes the instructions already presented. Two of these instructions are slightly different for the 9940. These are the extended operation and the load interrupt mask immediate instructions. There are two new arithmetic instructions that provide for binary coded decimal (BCD) addition and subtraction. The 9940 uses extended operations 0 through 3 to generate the load interrupt mask and the decimal arithmetic instructions. Thus, the 9940 extended operations 4 through 15 are available to the programmer. LOAD IMMEDIATE INTERRUPT MAsK Format: LllM n LllM Q:::;n:::;3 0 I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9 I 10 11 12 13 14 15 I I I I I I I 0 0 1 0 1 1 0 0 1 0 0 0 0 0 n (2C8-) Operation: The interrupt mask bits 14 and 15 of the status register are loaded with n. Subsequent to this instruction, interrupt levels greater than n will be ignored by the processor, and interrupts of level nor less will be responded to by the processor. ST I 0 I 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9 I 10 11 I I 12 13 14 15 I III Status Bits Affected- Interrupt Mask (Bits 14 and 15) 6 .... Example: LllM 2 This operation will load the interrupt mask with 2, that is bit 14 would be set to a 1 and bit 15 would be reset to zero. This would disable interrupts of level 3, but would enable other interrupt levels. Application: This instruction is used to control the 9940 interrupt system. 9900 FAMILY SYSTEMS DESIGN 6-59 Instruction Set XOP EXTENDED OPERATION Format: XOP Gs,n XOP I I I I I 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 I I I I I I I I I I I I 0 0 1 0 1 1 D Ts S (2---) Operation: n specifies the extended operation transfer vector to be used in the context switch to the extended operation subprogram. The TMS9940 restricts the range of n (4::s;n< 15) so that there are only 12 XOP's available. This is because the first four are used by the processor to implement the LIIM, DCA, and DCS instructions. The transfer vector procedure for the programmer-defined extended operations is:. M(4016 + 4xn)- (WP) M( 42 16 + 4xn)- (PC) G. (New WR11) (Old WP) (New WR13) (Old PC) (New WR14) (Old ST) (New WR15) Status Bits Affected: None Example and Applications: XOP *1,4 This instruction will cause an extended operation 4 to occur with the new workspace register 11 containing the address found in workspace register 1. The new WP value .. 6 will be obtained from 40 16 + 4 X 4 = 50 16 and the new PC value will be obtained from 5216. 6-60 9900 FAMILY SYSTEMS DESIGN Instruction Set DCA DECIMAL CORRECT ADDITION Format: DCA Gs DCA 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Io I o I 1 I o I 1 I 1 I o I o I o I o I ;s I I Is I I (2C--) Operation: The byte addressed by Gs is corrected according to the table given in Figure 6-10. This operation is a processor defined extended operation with n = 0 so that the sequence of events described under the XOP discussion will occur in executing this instruction. Status Bits Affected: LGT, AGT, EQ, C, P, and DC (Digit Carry). Example: DCA *10 This instruction would cause the byte addressed by the contents of the current workspace register 10 to be decimal adjusted in accordance with the truth table of Figure 6-10. Application: This instruction is used immediately after the binary addition of two bytes (AB instruction) to correct any decimal digits outside the BCD code range of0000 2 through 1001 2 • It also keeps decimal addition accurate by responding to digit carries. For example, if 816 is added to 816 in BCD addition, 1616 should be generated. However, if this operation is performed with binary addition, 1016 results: 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 6 .... 0 0 0 1 0 0 0 0 Digit Carry= 1 The DCA detects the digit carry and adds 0110 2 to the least significant digit to get the correct 1616· 9900 FAMILY SYSTEMS DESIGN 6-61 Instruction Set DCS DECIMAL CORRECT SUBTRACTION Format: DCS Gs DCS 0 1 2 3 4 5 6 7 8 9 I I 10 11 12 13 14 15 I I I I I I I I I I I I I I I 0 0 1 0 1 1 0 0 0 1 Ts S (2C--) Operation: The byte addressed by Gs is corrected according to the table given in Figure 6-10. This instruction is a processor defined extended operation with n = 1, so that the sequence of events described under extended operation will occur in executing this instruction. Status Bits Affected: LGT, AGT, EQ, C, P, and DC Example: DCS 3 This instruction would cause the most significant byte of register 3 to be corrected in accordance with the truth table of Figure 6-10. Application: As in the DCA instruction, this instruction extends the 9940 capability to include decimal subtraction. The programmer first performs binary subtraction on bytes (the SB instruction) and then immediately performs the DCS operation on the result byte to correct the result so that it is within the BCD code range 0000 2 through 1001 2 • 0 7 8-BIT BYTE CONTAINING RESULT I x i Y I OF BINARY ADD OR SUBTRACT MSB LSB OF 2 BCD DIGITS BYTE BEFORE EXECUTION BYTE AFTER DCA BYTE AFTER DCS c x DC y c x DC y c x DC y 0 X<10 0 Y<10 0 x 0 y - - - - 0 X<10 1 Y<10 0 x 0 Y+6 - - - - 0 X<9 0 Y~10 0 X+1 1 Y+6 - - - - 1 X<10 0 Y<10 1 X+6 0 y - - - - 1 X<10 1 Y<10 1 X+6 0 Y16 - - - - 1 X<10 0 Y2:::10 1 X+7 1 Y+6 - - - - 0 X~10 0 Y<10 1 X+6 0 y - - - - 0 Z~10 1 Y<10 1 X+6 0 Y+6 - - - - 0 X~9 0 Y2=10 1 X+7 1 Y+6 - - - - 0 x 0 y - - - - 0 X+10 1 Y+10 0 x 1 y - - - - 0 x+ 10 0 y 1 x 0 y - - - - 1 x 1 Y+10 1 x 1 y - - - - 1 x 0 y Figure 6-10. Result of DCA and DCS Instructions of the 9940. 6-62 9900 FAMILY SYSTEMS DESIGN CHAPTER 7 Program Development: Software Commands-- Descriptions and Formats 7.,. INTRODUCTION Program Development: Software Commands - Description and Formats INTRODUCTION The purpose of this chapter is to provide reference data for the various software development systems available for the 9900 family of microprocessors and microcomputers. Table 7-1 lists the sections in the chapter. One or more cards are made for those sections marked with a bullet. The section on Assembly Language programming describes the basic format for coding instructions and assembler directives. It is a general topic, applicable to all of the programming systems. Explanation of the terms, mnemonics instruction execution rules, etc. can be found in Chapters, 4, 5, and 6. The complete TM 990/402 Line-by-Line Assembler User's Guide is included because this EPROM resident software is used in Chapter 9. It should serve as an illustration of the need for some form of an assembler in writing even the simplest programs. Contrast the programming efforts of Chapter 3 with the programming efforts for the extended applications of Chapter 9, and you will appreciate the power of this LBL assembler. Reference material for the other programming systems is in the form of lists of commands and their syntax. These pages are not stand-alone documents. Software documentation is supplied with each of the programming systems and is required for full explanations of the commands and their use. Experienced designers always need assistance in recalling exact command mnemonics and their formats. Thus, this chapter supports you in any programming environment by appropriate reminders. Table 7-1 ·7 Assembly language programming and • TXDS Commands for the FS 990 PDS assembler directives • AMPL Reference data • 9900 Reference Data • POWER BASIC Commands TM 990/ 402 Line-by-Line Assembler • Cross Support reference data • TIBUG Monitor Assembler • TM 990/302 Software Development board Simulator Utilities 7-2 9900 FAMILY SYSTEMS DESIGN Assembly Language Programming: Formats and Directives 1 · ¥ · i!WH&PB# HfH H-i'l#UP J.%§1)Hfi'#H ¥44 ;g 4 .if 7... ASSEMBLY LANGUAGE Program Development: Software Commands - PROGRAMMING Description and Formats ASSEMBLY LANGUAGE PROGRAMMING An assembly language is a computer oriented language for writing programs. The TMS9900 recognizes instructions in the form of 16 bit (or longer) binary numbers, called instruction or operation codes (Opcodes). Programs could be written directly in these binary codes, but it is a tedious effort, requiring frequent reference to code tables. It is simpler to use names for the instructions, and write the programs as a sequence of these easily recognizable names (called mnemonics). Then, once the program is written in mnemonic or assembly language form, it can be converted to the corresponding binary coded form (machine language form). The assembler programs described here indicate parts of PX9ASM, TXMIRA and SDSMAC, which operate on cassette, floppy disc, and moving head disc systems respectively. Several other assemblers are available from TI which provide fewer features, but operate with much smaller memory requirements. AssEMBLY LANGUAGE APPLICATION The assembly language programming and program verificati~n through simulation or execution are the main elements involved in developing microprocessor programs. The overall program development effort consists of the following steps: Define the problem. • Flowchart the solution to the problem. • Write the assembly language program for the flowchart. • Execute the Assembler to generate the machine code. • Correct any format errors indicated by the Assembler. • Execute the corrected machine code program on a TMS9900 computer or on a Simulator to verify program operation. This program development sequence is defined in flowchart form in Figur~ 7-1. ~7 AssEMBLY LANGUAGE FORMATS The general assembly language source statements consists of four fields as follows: LABEL MNEMONIC OPERANDS COMMENT The first three fields must occur within the first 60 character positions of the source record. At least one blank must be inserted between fields. Label Field The label consists of from one to six characters, beginning with an alphabetic character in character position one of the source record. The label field is terminated by at least one blank. When the assembler encounters a label in an instruction it assigns the current value of the location counter to the label symbol. This is the value associated with the label symbol and is the address of the instruction in memory. If a label is not used, character position 1 must be a blank. 7-4 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - ASSEMBLY LANGUAGE Description and Formats PROGRAMMING DEFINE PROBLEM FLOWCHART SOLUTION CONVERT FLOWCHART TO ASSEMBLY LANGUAGE PROGRAM EXECUTE ASSEMBLER CORRECT YES PROGRAM NO EXECUTE OR SIMULATE THE PROGRAM 7... CORRECT PROGRAM YES l DEVELOPMENT COMPLETE Figure 7-1. Program Development Flowchart 9900 FAMILY SYSTEMS DESIGN 7-5 ASSEMBLY LANGUAGE Program Development: Software Commands - PROGRAMMING Description and Formats Mnemonic or Opcode Field This field contains the mnemonic code of one of the instructions, one of the assembly language directives, or a symbol representing one of the program defined operations. This field begins after the last blank following the label field. Examples of instruction mnemonics include A for addition and MOV for data movement. The mnemonic field is required since it identifies which operation is to be performed. Operands Field The operands specify the memory locations of the data to be used by the instruction. This field begins following the last blank that follows the mnemonic field. The memory locations can be specified by using constants, symbols, or expressions, to describe one of several addressing modes available. Comment Field Comments can be entered after the last blank that follows the operands field. If the first character position of the source statement contains an asterisk (*), the entire source statement is a comment. Comments are listed in the source portion of the Assembler listing, but have no affect on the object code. TERMS AND SYMBOLS Symbols are used in the label field, the operator field, and the operand field. A symbol is a string of alphanumeric characters, beginning with an alphabetic character. Terms are used in the operand fields of instructions and assembler directives. A term is a decimal or hexadecimal constant, an absolute assembly-time constant, or a label having an absolute value. Expressions can also be used in the operand fields of instructions and assembler directives. ·7 Constants Constants can be decimal integers (written as a string of numerals) in the range of - 32, 768 to +65,535. For example: 257 Constants can also be hexadecimal integers (a string of hexadecimal digits preceded by > ). For example: >09AF ASCII character constants can be used by enclosing the desired character string in single quotes. For example: 'DX' Throughout this book the subscript 16 is used to denote base 16 numbers. For example, the hexadecimal number 09AF is written 09AF16 • 7-6 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - ASSEMBLY LANGUAGE Description and Formats PROGRAMMING Symbols Symbols must begin with an alphabetic character and contain no blanks. Only the first six characters of a symbol are processed by the Assembler. The Assembler predefines the dollar sign ($) to represent the current location in the program. The symbols RO through R15 are used to represent workspace registers 0 through 15, respectively. A given symbol can be used as a label only once, since it is the symbolic name of the address of the instruction. Symbols defined with the DXOP directive are used in the OPCODE field. Any symbol in the OPERANDS field must have been used as a label or defined by a REF directive. Expressions Expressions are used in the OPERANDS fields of assembly language statements. An expression is a constant, a symbol, or a series of constants and symbols separated by the following arithmetic operators: + addition - subtraction * multiplication I division Unary minus is performed first and then the expression is evaluated from left to right. A unary minus is a minus sign (negation) in front of a number or a symbol. The expression must not contain any imbedded blanks or extended operation defined (DXOP directive) symbols. The multiplication and division operations must be used on absolute code symbols. The result of evaluating the expression up to the multiplication or division operator must be an 78000 BYTE DATA Initialize Memory TEXT These directives provide for initialization of successive 8 bit bytes of memory with numerical data (BYTE directive) or with ASCII character codes (TEXT directive). The DATA directive provides for the initialization of successive 16 bit words with numerical data. The formats are the same for all three directives: Directive Expression-list The Label and Comment are optional. The expression or value list contains the data entries for the 8 bit bytes (BYTE directive), or the 16 bit words (DATA directive), or a character string enclosed in quotes (TEXT directive). Examples of the use and effects of these directives are shown in Figure 7-2. PROGRAM LocATION DIRECTIVES These directives affect the location counter by causing the instructions to be located in specified areas of memory. AORG RORG Origin Directives DORG These directives set the address of the next instruction to the value listed in the expression field of the directive: Directive Expression The expression field is required on all except the RORG directive. It is a value or an expression (containing only previously defined symbols). This value is the address of the next instruction and is the value that is assigned to the label (if any) and to the location counter. The AORG and DORG expressions must result in an absolute value and contain no character constants. 7-10 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - ASSEMBLER DIRECTIVES Description and Formats Example Directives: KONS BYTE > 10, -1, 'A', 'B', N + 3 WDl DATA >OlFF, 3200, -'AF', 8, N + > 1000 MSGl TEXT 'EXAMPLE' AFFECTS ON MEMORY DATA: RESULTING DATA RESULTING DATA MEMORY DIRECTIVE (BINARY FORM) (HEXADECIMAL) LOCATION ENTRY KONS >10,-1 0001 0000 1111 1111 1 OFF KONS+2 'A', 'B' 0100 0001 0100 0010 4142 KNOS+4 N+3 0000 1011 x x OB-- WDl >OlFF 0000 0001 1111 1111 OlFF WD1+2 3200 0000 1100 1000 0000 OC80 WD1+4 -'AF' 1011 1110 1011 1010 BEBA WD1+6 8 0000 0000 0000 1000 0008 WD1+8 N+>lOOO 0001 0000 0000 1000 1008 MSGl 'EX' 0100 0101 0101 1000 4558 MSG1+2 'AM' 0100 0001 0101 1101 414D MSG1+4 'PL' 0101 0000 0100 1100 504C MSG1+6 'E' 0100 0101 x x 4E-- XX(--) is original unaltered data in this location. N is assumed to be previously defined as 8. Figure 7-2. Initialization Directive Examples The AORG directive causes this value to be absolute and fixed. For example: AORG > 1000 + X If X has been previously defined to have an absolute value of 6, the next instruction would be unalterably located at the address 100616 • If a label had been included, it would have been assigned this same value. The RORG directive causes this value to be relative or relocatable so that subsequent operations by the assembler or simulator can relocate the block of instructions to any desired area of memory. Thus, a relocatable block of instructions occupying memory locations 100016 to 102016 could be moved by subsequent simulator (or other software) operations to locations 200016 to 202016 • An example RORG statement is: SEGl RORG > 1000 9900 FAMILY SYSTEMS DESIGN 7-11 ASSEMBLER DIRECTIVES Program Development: Software Commands - Description and Formats This directive would cause SEG 1 and the value of the location counter (address of the next instruction) to be set to 100016 • This and all subsequent locations are relocatable. SEG2 RORG This directive would cause subsequent instructions to be at relocatable addresses. SEG 2 and the address of the next instruction would be set to the value of the location counter. The DORG directive causes the instructions to be listed but the assembler does not gen~rate object code that can be passed on to simulators or other subsystems. However, symbols defined in the dummy section would then be legitimate symbols for use in the AORG or RORG program sections. For example: DORGO The labels with the subsequent dummy section of instructions will be assigned values relative to the start of the section (the instruction immediately following this directive). No object code would be generated for this section. An RORG directive is used after a DORG or AORG section to cause the subsequent instructions to be relocatable object code. If no origin directives are included in the assembly language program, all object code is relocatable starting at (referenced to) an address of 0. BES STORAGE ALLOCATION DIRECTIVES BSS These directives reserve a block of memory (range of addresses) for data storage by advancing the location counter by the amount specified in the expression field. Thus, the instruction after the directive will be at an address equal to the expression value plus the address of the instruction just before the directive . ... 7 Basic Formats: BES Expression BSS Expression If a label is included in the BSS directive it is assigned the value of the location counter at the first_ byte if the storage block. If the label is included in the BES directive it is assigned the value of the location counter for the instruction after the block. The Expression designates the number of bytes to be reserved for storage. It is a value or an expression containing no character constants. Expressions must contain only previously defined symbols and result in an absolute value. 7-12 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - ASSEMBLER DIRECTIVES Description and Formats Examples: BUFFl BES > 10 A 16 byte buffer is provided. Had the location counter contained the value 10016 (FF16 was the address of the previous instruction), the new value of the location counter would be 110 16 , and this would be the value assigned to the symbol BUFFl. The next instruction after the buffer would be at address 11015. BUFF2 BSS 20 If the previous instruction is located at FF16, BUFF2 will be assigned the value 10016 , and the next instruction will be located at 11416 • A 20 byte area of storage with addresses 10016 through 113 16 has been reserved. Word Boundary EVEN This directive causes the location counter to be set to the next even address (beginning of the next word) if it currently contains an odd address. The basic format is: EVEN The label is assigned the value of the location counter prior to the EVEN directive. PROGRAM LISTING CONTROL DIRECTIVES These directives control the printer, titling, and listing provided by the assembler. Output Options OPTION The basic format of this directive is: OPTION Keyword-list No label is permitted. The keywords control the listing as follows: Keyword Listing XREF Print a cross reference listing. OBJ Print a hexadecimal listing of the object code. SYMT Print a symbol table with the object code. Example: OPTION XREF,SYMT Print a cross reference listing and the symbol table with the object code. 9900 FAMILY SYSTEMS DESIGN 7-13 ASSEMBLER DIRECTIVES Program Development: Software Commands - Description and Formats Advance Page PAGE This directive causes the assembly listing to continue at the top of the next page. The basic format is: PAGE Page Title TITL This directive specifies the title to be printed at the top of each page of the assembler listing. The basic format is: TITL 'String' The String is the title enclosed in single quotes. For example: TITL 'REPORT GENERATOR' LIST Source Listing Control UNL These directives control the printing of the source listing. UNL inhibits the printing of the source listing: LIST restores the listing. The basic formats are: UNL LIST Extended Operation Definition DXOP This directive names an extended operation. I ts format is: DXOP SYMBOL, Term The symbol is the desired name of the extended operation. Term is the corresponding number of the extended operation. For example: DXOP DADD,13 defines DADD as extended operation 13. Once DADD has been so defined, it can be used as the name of a new operation, just as if it were one of the standard instruction mnemonics. 7-14 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - ASSEMBLER OUTPUT Description and Formats Program Linkage Directives These directives enable program modules to be assembled separately and then integrated into an executable program. External Definition DEF This directive makes one or more symbols available to other programs for reference. Its basic format is: DEF Symbol-list Symbol-list contains the symbols to be defined by the program being assembled. For example: DEF ENTER, ANS causes the assembler to include the Symbols ENTER and ANS in the object code so that they are available to other programs. When DEF does not precede the source statements that contain the symbols, the assembler identifies the symbols as multi-defined symbols. External Reference REF This directive provides access to symbols defined in other programs. The basic format is: REF Symbol-list The Symbol-list contains the symbols to be included in the object code and used in the operand fields of subsequent source statements. For example: REF ARG1,ARG2 causes the symbols ARG 1 and ARG2 to be included in the object code so that the corresponding address can be obtained from other programs. Note: If a REF symbol is the first operand of a DATA directive causing the value of the 7.,.. symbol to be in 0 absolute location, the symbol will not be linked correctly in location 0. ASSEMBLER OUTPUT INTRODUCTION The types of information provided by Assemblers include: Source Listing - Shows the source statements and the resulting object code. Error Messages - Errors in the assembly language program are indicated. Cross Reference - Summarizes the label-definitions and program references. Object Code - Shows the object code in a tagged record format to be passed on to a computer or simulator for execution. 9900 FAMILY SYSTEMS DESIGN 7-15 ASSEMBLER OUTPUT Program Development: Software Commands - Description and Formats SOURCE LISTING Assemblers produce a source listing showing the source statements and the resulting object code. A typical listing is shown in Figure 7-3. 0229 -::- 0230 -::- DEMONSTRATE EXTERNAL REFERENCE LINKING 0231 ~~- 0232 REF EXTR 0233 02BC RORG 0234 02BC CB20 MDV @EXTR, @EXTR 02BE 0000 0290 028E' 0235 0292 28EO XOR @EXTR, 3 0294 0290' 0236 8000 AORG >BODO 0237 BODO 3220 LDCR @EXTR. 8 B002 0294' 0238 B004 0420 BLWP @EXTR BOOS B002 0239 BOOB 0223 Al 3,EXTR BODA BOOS 0240 BOOC 38AO MPY @EXTR, 2 BOOE BODA 0241 029S RORG 0242 029S C820 MDV @EXTR, @EXTR 0298 BOOE 029A 0298' 0243 029C 28EO XOR @EXTR, 3 029E 029A' 0244 CODD AORG >CODD 0245 CODD 3220 LDCR @EXTR, 8 C002 029E' 0246 C004 0420 BLWP @EXTR coos C002 0247 coos 0223 Al 3. EXTR CODA coos 0248 cooc 38AO MPY @EXTR, 2 CODE CODA Figure 7-3. Typical Source Listing. The first line available in a listing is the title line which will be blank unless a TITL directive has been used. After this line, a line for each source statement is printed. For .,,,.7 example: 0018 0156 C820 MOV @INIT+3,@3 0158 012B' 015A 0003 In this case the source statement: MOV @INIT+3,@3 produces 3 lines of object code. The source statement number 18 applies to the entire 3 line entry. Each line has its own location counter value (0156, 0158, and 015A). C820 is the OPCODE for MOV with symbolic memory addressing. 012B' is the value for INIT+ 3. 0003 is for the direct address 3. The apostrophe(') after 012B indicates this address is program-relocatable. Source statements are numbered sequentially, whether they are listed or not (listing could be prevented by using the UNLIST directive). 7-16 9900 FAMILY SYSTEMS DESIGN 9900 Ref ere nee Data 9900 Program Development: Software Commands - REFERENCE DATA Description and Formats INSTRUCTION FORMAT FORMAT (USE) OJ 1J2J3J4J5J6J7l8l9J10l11J12J13j14j15 1 (ARITH) OP CODE j BJ To D l Ts s l 2 (JUMP) l SIGNED DISPLACEMENP 3 (LOGICAL) OP CODE I D l Ts ss - 4 (CRU) OP CODE l c l Ts 5 (SHIFT) OP CODE l c w 6 (PROGRAM) OP CODE l Ts s 7 (CONTROL) OP CODE ] NOT USED OP CODE JNU w 8 (IMMEDIATE) IMMEDIATE VALUE 9 (MPY,DIV,XOP) OP CODE 1 D 1 Ts s KEY B =BYTE INDICATOR S =SOURCE ADDR. (1 =BYTE, 0 =WORD) C = XFR OR SHIFT LENGTH (COUNT) T 0 = D ADDR, MODIFICATION W =WORKSPACE REGISTER NO. D =DESTINATION ADDR. ':'=SIGNED DISPLACEMENT OF - 128 TO + 127 WORDS Ts= ADDR. MODIFICATION NU= NOT USED To/Ts FIELD CODE EFFECTIVE ADDRESS MNEMONIC 00: REGISTER WP + 2 • [S OR DJ Rn 01: INDIRECT (WP + 2 · [S OR DJ) ':'Rn 10: INDEXED (SOR D* 0) (WP+ 2 • [S OR DJ)+ (PC); PC+ PC+ 2 NUM (Rn) 1 0: SYMBOLIC (DIRECT, S OR D = 0) (PC); PC + PC + 2 NUM 11: INDIRECT WITH AUTO INCREMENT (WP + 2 ·[SOR DJ); INCREMENT EFF. ADDR. ':'Rn+ STATUS REGISTER 0 2 3 4 5 6 7 11 12 15 RESERVED I INT~~~~PT I 0 - LOGICAL GREATER THAN 5 - PARITY (ODD NO. OF BITS SET) 1 - ARITHMETIC GREATER THAN 6 - XOP IN PROGRESS 2 - EQUAL/TB INDICATOR 3 - CARRY FROM MSB INTERRUPT MASK 4- OVERFLOW F =ALL INTERRUPTS ENABLED 0 =ONLY LEVEL 0 ENABLED 7-18 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - 9900 Description and Formats REFERENCE DATA INTERRUPTS TRAP ADDR WP TRAP ADDR +2 PC LEVEL ID TRAP ADDR LEVEL ID TRAP ADDR 0 RESET 0000 8 EXTERNAL 0020 1 EXTERNAL 0004 9 EXTERNAL 0024 2 EXTERNAL 0008 10 EXTERNAL 0028 3 EXTERNAL oooc 11 EXTERNAL 002C 4 EXTERNAL 0010 12 EXTERNAL 0030 5 EXTERNAL 0014 13 EXTERNAL 0034 6 EXTERNAL 0018 14 EXTERNAL 0038 7 EXTERNAL 001C 15 EXTERNAL 003C NOTES: 1) XOP VECTORS 0-15 OCCUPY MEMORY LOCATIONS 0040-007C 2) LOAD VECTOR OCCUPIES MEMORY LOCATIONS FFFC-FFFF BLWP TRANSFERS RTWP TRANSFERS BL TRANSFER XOP TRANSFER WP+ NEWW13 CURRENT W13 +WP PC+ W11 EFF. ADDR. +NEW W11 PC+NEWW14 CURRENT W14 +PC WP+ NEWW13 ST+NEWW15 CURRENT W15 +ST PC+ NEW W14 ST+ NEWW15 1 + ST6 INSTRUCTIONS BY MNEMONIC RESULT COMPARED STATUS MNEMONIC OP CODE FORMAT TO ZERO AFFECTED INSTRUCTIONS A AOOO 1 y 0-4 ADD(WORD) AB. BOOO 1 y 0-5 ADD( BYTE) ABS 0740 6 y 0-4 ABSOLUTE VALUE Al ANDI B BL 0220 0240 0440 0680 8 8 6 6 y y N N 0-4 0-2 ADD IMMEDIATE AND IMMEDIATE BRANCH BRANCH AND LINK (W11) ,..... I BLWP 0400 6 N BRANCH LOAD WORKSPACE POINTER c 8000 1 N 0-2 COMPARE (WORD) CB 9000 1 N 0-2,5 COMPARE (BYTE) Cl 0280 8 N 0-2 COMPARE IMMEDIATE CKOF 03CO 7 N EXTERNAL CONTROL CKON 03AO 7 N EXTERNAL CONTROL CLR 04CO 6 N CLEAR OPERAND coc 2000 3 N 2 COMPARE ONES CORRESPONDING czc 2400 3 N 2 COMPARE ZEROES CORRESPONDING DEC 0600 6 y 0-4 DECREMENT (BY ONE) DECT 0640 6 y 0-4 DECREMENT (BY TWO) DIV 3COO 9 N 4 DIVIDE IDLE 0340 7 N COMPUTER IDLE INC 0580 6 y 0-4 INCREMENT (BY ONE) INCT OSCO 6 y 0-4 INCREMENT (BY TWO) INV 0540 6 y 0-2 INVERT (ONES COMPLEMENT) JEO 1300 2 N JUMP EQUAL (ST2 = 1) 9900 FAMILY SYSTEMS DESIGN 7-19 9900 Program DevelopmE.nt: Software Commands - REFERENCE DATA Description and Formats INSTRUCTIONS BY MNEMONIC JGT 1500 2 N JUMP GREATER THAN (ST1 = 1) JH 1800 2 N JUMP HIGH (STO = 1 AND ST2 = 0) JHE 1400 2 N JUMP HIGH OR EQUAL (STOOR ST2 = 1) JL 1AOO 2 N JUMP LOW (STO AND ST2 = 0) JLE 1200 2 N JUMP LOW OR EQUAL (STO = 0 OR ST2=1) JLT 1100 2 N JUMP LESS THAN (ST1 AND ST2 = 0) JMP 1000 2 N JUMP UNCONDITIONAL JNC 1700 2 N JUMP NO CARRY ~ST3 = O} JNE 1600 2 N JUMP NOT EQUAL (ST2 = 0) JNO 1900 2 N JUMP NO OVERFLOW (ST4 = 0) JOC 1800 2 N JUMP ON CARRY (ST3=1) JOP 1 coo 2 N JUMP ODD PARITY (ST5 = 1) LDCR 3000 4 y 0-2,5 LOAD CRU LI 0200 8 N 0-2 LOAD IMMEDIATE LIMI 0300 8 N 12-15 LOAD IMMEDIATE TO INTERRUPT MASK LREX 03EO 7 N 12-15 EXTERNAL CONTROL LWPI 02EO 8 N LOAD IMMEDIATE TO WORKSPACE POINTER MOV cooo 1 y 0-2 MOVE (WORD) MOVB DOOO 1 y 0-2,5 MOVE (BYTE) MPY 3800 9 N MULTIPLY NEG 0500 6 y 0-4 NEGATE (TWO'S COMPLEMENT) ORI 0260 8 y 0-2 OR IMMEDIATE RSET 0360 7 N 12-15 EXTERNAL CONTROL RTWP 0380 7 N 0-6,12-15 RETURN WORKSPACE POINTER s 6000 1 y 0-4 SUBTRACT (WORD) SB 7000 1 y 0-5 SUBTRACT (BYTE) SBO 1000 2 N SET CRU BIT TO ONE SBZ 1 EOO 2 N SET CRU BIT TO ZERO SETO 0700 6 N SET ONES SLA OAOO 5 y 0-4 SHIFT LEFT (ZERO FILL) soc EOOO 1 y 0-2 SET ONES CORRESPONDING (WORD) SOCB FOOO 1 y 0-2,5 SET ONES CORRESPONDING (BYTE) SRA 0800 5 y 0-3 SHIFT RIGHT (MSB EXTENDED) ~7 SRC 0800 5 y y 0-3 SHIFT RIGHT CIRCULAR SRL 0900 5 0-3 SHIFT RIGHT (LEADING ZERO FILL) STCR 3400 4 y 0-2,5 STORE FROM CRU STST 02CO 8 N STORE STATUS REGISTER STWP 02AO 8 N STORE WORKSPACE POINTER SWPB 06CO 6 N SWAP BYTES szc 4000 1 y 0-2 SET ZEROES CORRESPONDING (WORD) SZCB 5000 1 y 0-2,5 SET ZEREOS CORRESPONDING (BYTE) TB 1 FOO 2 N 2 TEST CRU BIT x 0480 6 N EXECUTE XOP 2COO 9 N 6 EXTENDED OPERATION XOR 2800 3 y 0-2 EXCLUSIVE OR DCA 2COO 9 N 0-3,5,7 DECIMAL CORRECT ADD DCS 2COO 9 N 0-3,5,7 DECIMAL CORRECT SUB LllM 2COO 9 N 14,15 LOAD INTERRUPT MASK ILLEGAL OP CODES 0000-01 FF;0320-033F;0780-07FF;OCOO-OFFF 7-20 9900 FAMILY SYSTEMS DESIGN Program Development: 9900 Software Commands - Description and Formats REFERENCE DATA INSTRUCTIONS BY OP CODE OP CODE MNEMONIC OP CODE MNEMONIC 0000-01 FF ILLEGAL 1000 JMP 0200 LI 1100 JLT 0220 Al 1200 JLE 0240 ANDI 1300 JEO 0260 ORI 1400 JHE 0280 Cl 1500 JGT 02AO STWP 1600 JNE 02CO STST 1700 JNC 02EO LWPI 1800 JOG 0300 LIMI 1900 JNO 0320-033F ILLEGAL 1AOO JL 0340 IDLE 1800 JH 0360 RSET 1COO JOP 0380 RTWP 1000 SBO 03AO CKON 1EOO SBZ 03CO CKOF 1FOO TB 03EO LREX 2000 coc 0400 BLWP 2400 czc 0440 B 2800 XOR 0480 x 2COO XOP 04CO CLR 3000 LDCR 0500 NEG 3400 STCR 0540 INV 3800 MPY 0580 INC 3COO DIV OSCO INCT 4000 szc 0600 DEC 5000 SZCB 0640 DECT 6000 s 0680 BL 7000 SB 06CO SWPB 8000 c 0700 SETO 9000 CB 0740 ABS AOOO A 0780-07FF ILLEGAL BOOO AB 0800 SRA cooo MOV 7~ 0900 SRL DOOO MOVB OAOO SLA EOOO soc OBOO SRC FOOD SOCB ocoo ILLEGAL PSEUDO-INSTRUCTIONS MNEMONIC PSEUDO-INSTRUCTIONS CODE GENERATED NOP NO OPERATION 1000 RT RETURN 045B 9900 FAMILY SYSTEMS DESIGN 7-21 9900 Program Development: Software Commands - REFERENCE DATA Description and Formats PIN DESCRIPTIONS PIN# FUNCTION PIN# FUNCTION PIN # FUNCTION 1 Vss 23 A1 44 03 2 Vee 24 AO 45 04 3 WAIT 25 q,4 46 05 4 LOAD 26 Vss 47 06 5 HOLDA 27 Voo 48 07 6 RESET 28 q,3 49 . 08 7 IAQ 29 OBIN 50 09 8

3E 0-6-8 FF OC ? 3F 0-7-8 CR OD @ 40 4-8 so OE Ala 41161 12- ~ SI OF Bib 42162 12-2 OLE 10 Cle 43163 12-3 DC1 11 Did 44164 12-4 DC2 12 Ele 45164 12-5 DC3 13 FIf 46166 12-6 DC4 14 Gig 47167 12-7 NAK 15 Hlh 48168 12-8 SYN 16 Iii 49169 12-9 ETB 17 JI j 4Al6A 11-1 CAN 18 Klk 4Bl6B 11-2 EM 19 Lii 4Cl6C 11-3 SUB 1A Mlm 40160 11-4 ESC 1B Nin 4El6E 11-5 FS 1C Olo 4Fl6F 11-6 GS 1D Pip 50170 11-7 RS 1E Olq 51171 11-8 us 1F Rlr 52172 11-9 SPACE 20 BLANK Sis 53173 0-2 7... 21 11-2-8 TIt 54174 0-3 22 7-8 Ulu 55175 0-4 # 23 3-8 Viv 56176 0-5 $ 24 11-3-8 Wlw 57177 0-6 % 25 0-4-8 Xix 58178 0-7 & 26 12 Yly 59179 0-8 27 5-8 Zlz 5A/7A 0-9 28 12-5-8 [ 5B 12-2-8 29 11-5-8 \ 5C 2A 11-4-8 ] 50 12-7-8 + 2B 12-6-8 /\ 5E 11-7-8 2C 0-3-8 SF 0-5-8 20 11 60 2E 12-3-8 { 7B I 2F 0-1 > 7C 0 30 0 70 1 31 1 7E 2 32 2 DEL 7F •PUNCH IN CARD ROWS 9900 FAMILY SYSTEMS DESIGN 7-23 9900 Program Development: Software Commands - REFERENCE DATA Description and Formats HEX-DECIMAL TABLE EVEN BYTE ODD BYTE HEX DEC HEX DEC HEX DEC HEX DEC 0 0 0 0 0 0 0 0 1 4,096 1 256 1 16 1 1 2 8,192 2 512 2 32 2 2 3 12,288 3 768 3 48 3 3 4 16,384 4 1,024 4 64 4 4 5 20,480 5 1,280 5 80 5 5 6 24,576 6 1,536 6 96 6 6 7 28,672 7 1,792 7 112 7 7 8 32,766 8 2,048 8 128 8 8 9 36,864 9 2,304 9 144 9 9 A 40,960 A 2,560 A 160 A 10 B 45,066 B 2,816 B 176 B 11 c 49,152 c 3,072 c 192 c 12 D 53,248 D 3,328 D 208 D 13 E 57,344 E 3,584 E 224 E 14 F 61 ,440 F 3,840 F 240 F 15 OBJECT RECORD FORMAT AND CODE TAG 1ST FIELD 2ND FIELD (WHEN REQUIRED) 6 OR 8 CHARACTERS (USASCI I) .____ _ _ 4 CHARACTERS (HEX USASCll) 1 CHARACTER (HEX USASCll) TAG FIRST FIELD SECOND FIELD MEANING 0 LENGTH OF ALL PROGRAM ID PROGRAM START RELOCATABLE CODE (8-C HARACTER) 1 ADDRESS (NOT USED) ABSOLUTE ENTRY ADDRESS 2 ADDRESS (NOT USED) RELOCATABLE ENTRY ADDRESS ~7 3 LOCATION OF LAST 6 CHARACTER EXTERNAL REFERENCE LAST USED APPEARANCE OF SYMBOL SYMBOL IN RELOCATABLE CODE 4 LOCATION OF LAST 6 CHARACTER EXTERNAL REFERENCE LAST USED APPEARANCE OF SYMBOL SYMBOL IN ABSOLUTE CODE 5 LOCATION 6 CHARACTER RELOCATABLE EXTERNAL DEFINITION SYMBOL 6 LOCATION 6 CHARACTER ABSOLUTE EXTERNAL DEFINITION SYMBOL 7 CHECKSUM FOR (NOT USED) CHECKSUM CURRENT RECORD 8 ANY VALUE (NOT USED) IGNORE CHECKSUM VALUE 9 LOAD ADDRESS (NOT USED) ABSOLUTE LOAD ADDRESS A LOAD SDDRESS (NOT USED) RELOCATABLE LOAD ADDRESS B DATA (NOT USED) ABSOLUTE DATA c DATA (NOT USED) RELOCATABLE DATA D LOAD BIAS (NOT USED) LOAD BIAS OR OFFSET (NOT A PART OF ASSEMBLER OUTPUT) E ILLEGAL F (NOT USED) (NOT USED) END OF RECORD 7-24 9900 FAMILY SYSTEMS DESIGN TM990/402 Line-by-Line Assembler User's Guide 7.... TM 990/402 LINE-BY-LINE Program Development: Software Commands- ASSEMBLER USER'S GUIDE Description and Formats GENERAL The TM 990/402 Line-By-Line Assembler (LBLA) is a standalone program that assembles into object code the 69 instructions used by the TM 990/100M/101M/180M microcomputers. Comments can be a part of the source statement; however, assembler directives are not recognized. Assembler TM 990/402-1 consists of two EPROM's and supports the TM 990/lOOM microcomputer. TM 990/ 402-2 consists of one EPROM and supports the TM 990/180M microcomputer. INSTALLATION Remove the TMS 2708 chip(s) from the package and install as follows (see Figure 1): (1) Turn off power to the TM 990/lXXM microcomputer. (2) Place the chip(s) into the proper socket(s) as shown in Figure 1. The shaded components in Figure 1 denote the LBLA EPROM's correctly placed in their sockets. The corresponding socket number (UXX number) is marked on the EPROM. NOTES 1. Place the TMS 2708(s) into the socket(s) with pin 1 in the lower left corner as denoted by a 1 on the board and on the EPROM. Be careful to prevent bending of the pins. 2. Do not r.emove EPROM's containing the monitor as shown in Figure 1. The monitor is used by the assembler. (3) Verify proper positioning in the sockets. Apply power to the microcomputer board. ~7 U•:Fi•J} LBLA ""D } NOT REQUIRED ~f CQJ I} TIBUG MONITOR "~P tQJ I } LBLA "~P [QJ I U43-/\:)<>·)::·· } LBLA , . . . ••••.•••. .•••. . •·<•:·:·.··· ·················Ill·........ ·.·•·•·• TIBUG MONITOR u·~p [QJ I} TIBUG MONITOR "~P [QJ I 0 0 (a) ON TM 990/100M (bl ON TM 990/180M Figure 1. Placement of TMS 2708 Eprom's 7-26 9900 FAMILY SYSTEMS DESIGN Program Development: TM 990/402 LINE-BY-LINE Software Commands- Description and Formats ASSEMBLER USER'S GUIDE OPERATION SETUP NOTE The examples in this guide use memory addresses obtainable in RAM on the TM 990/ lOOM microcomputer. To exemplify the TM 990/180M addressing scheme, the reader should substitute a 3 for the F in the most significant digit (left most) of a four-digit memory address in the following examples (e.g., 3EE0 16 for FEE0 16). • With the Line-By-Line Assembler EPROMs installed, call up the monitor by pressing the RESET switch in the upper left corner of the board and then pressing the A key at the terminal. •Invoke the R keyboard command and set the Program Counter (PC) to 09£616 • This is the memory address entry point for the Line-By-Line Assembler. •Invoke the E (execute) command. The assembler will execute and print the memory address (M.A.) FE0016 for the TM 990/100 or 3£0016 for the TM 990/180M. The printhead will space to the assembly language opcode input column and wait for input from the keyboard. ?R W=OBA4 P=OOOF 9E6 - - - - - LBLA ENTRY ADDRESS ?E FEOO INPUTS To AssEMBLER The Line-By-Line Assembler accepts assembly language inputs from a terminal. As each instruction is input, the assembler interprets it, places the resulting machine code in an absolute address, and prints the machine code (in hexadecimal) next to its absolute address: 7.. I FEOO 02EO LWPI >FEBO SET UP WORKSPACE ADDRESS FE02 FEBO FE04 0200 LI R0,10 SET UP COUNTER VALUE FEOB OOOA FEDS 0201 LI R1 .>FEAO ADDRESS OF VALUES IN R1 FEOA FEAO FEOC 0202 LI R2,>FEBO ADDRESS OF STORAGE AREA IN R2 FEDE FEBO FE10 CCB1 MDV +R1 + ,+R2+ MOVE VALUES TO STORAGE AREA FE12 0600 DEC RO DECREMENT COUNTER FE14 1301 JEQ >FE18 EXIT IF COUNTER = ZERO FE16 10FC JMP >FE10 LOOP BACK UNTIL 10 VALUES MOVED FE18 9900 FAMILY SYSTEMS DESIGN 7-27 TM 990/402 LINE-BY-LINE Program Development: Software Commands- ASSEMBLER USER'S GUIDE Description and Formats Use only one space between the mnemonic and the operand. If you use the comment field, use at least one space between the operand and comment. If no comment is used, complete the instruction with a space and carriage return. If a comment is used, only a carriage return is required. No loader tags are created; code is loaded in contiguous memory addresses by the assembler. The location can be changed as desired (explained in paragraph 3.2.2). Labels cannot be used. Addressing is by byte displacement Qump instructions) or by absolute memory address. NOTE Be aware that the workspace for the TIBUG monitor begins in RAM at address FFB0 16 for the TM 990/lOOM and begins at address 3FB016 for the TM 990/180M. Understand that assembled object code should not be entered at or above these addresses. Program Preparation Set up your program using flow charts with code written on a coding pad. Do not use assembler directives. Changing Absolute Load Address Code is located at the address written on the assembler output. When initialized, the assembler loads code contiguously starting at M.A. FE0016 (3E0016 for TM 990/180M). This address can be changed at any time during assembly by typing a slash (/)followed by the desired M.A.: FEBO 8081 C R1 ,R2 COMPARE VALUES FE82 1301 JEQ >FE86 IF EQUAL. SKIP ERROR ROUTINE FE84 06AO BL @>FF20 OTHERWISE DO ERROR ROUTINE ~7 FE86 FF20 FESS /FF20 CHANGE ADDRESS FF20 2FAO XOP @>FF26,14 SEND ERROR MESSAGE [See TIBUG Monitor) FF22 FF26 FF24 0458 B +R11 RETURN TO CALLING PROGRAM FF26 DADD +>DADD FF28 4552 $ERROR FOUND FF2A 524F FF2C 5220 FF2E 464F FF30 554E FF32 4420 FF34 0000 +0000 FF36 /FESS ~CHANGE ADDRESS FE86 Note that this is similar to using an AORG (absolute origin) 990 assembler directive. 7-28 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands- TM 990/402 LINE-BY-LINE Description and Formats ASSEMBLER USER'S GUIDE Entering Instructions Any of the 69 instructions applicable to the TM 990/ lXXM microcomputers can be interpreted by the Line-By-Line Assembler. The following apply: ( 1) Place one space between instruction mnemonic and operand. (2) Terminate entire instruction with a space and a carriage return. Lines with comments need only a carriage return. Character strings require two carriage returns. (3) Do not use labels; addressing is through byte displacement Qump instructions) or absolute addresses: FEBC 1B07 JNE $+1B FCBE 10EB JMP >FEBO FE90 CBA2 MDV @>FD20[R2). @>FE10[R2) FE92 FD20 FE94 FE10 FE9B (4) Register numbers are in decimal and can be predefined (preceded by an R): FE9B 020C LI 12,>DOO FE98 ODDO FE9A 020D LI R13, > FFFF FE9C FFFF FE9E (5) Jump instruction operand can be$+ n, $-n, or> M where n is a decimal value of bytes ( + 256> n> -254) and Mis a memory address in hexadecimal. The dollar sign must be followed by a sign and number OMP $is not allowed). FE20 1304 JEQ $+10 EXIT FE22 1304 JEQ $+>A EXIT FE24 1304 JEQ $+%1010 EXIT FE2B 1304 JEQ >FE30 EXIT 7.,. FE28 10FF JMP $+0 LOOP AT THIS ADDRESS[> FE28) FE2A 10FF JMP $-0 LOOP AT THIS ADDRESS (6) Absolute numerical values can be in binary, decimal, or hexadecimal. • Binary values are preceded by a percent sign(%). One to 16 ones and zeroes can follow; unspecified bits on the left will be zero filled: FE58 0204 LI R4, %10101010 >AA IN R4 FE5A OOAA FE5C OOOA +%1010 DATA STATEMENT FE5E FFFB -%1010 DATA STATEMENT FEBO 9900 FAMILY SYSTEMS DESIGN 7-29 TM 990/402 LINE-BY-LINE Program Development: Software Commands- ASSEMBLER USER'S GUIDE Description and Formats • Decimal values have no prefix in an operand: FE6C 0205 LI R5,100 LOAD COUNTER FE6E 0064 FE70 0206 LI R6,32768 SET LIMIT FE72 8000 FE74 8000 +32768 FE76 8000 -32768 FE78 7FFF +32767 FE7A 8001 -32767 FE7C FFFF -1 FE7E • Hexadecimal values are preceded by the greater-than sign(>): FE7E 02EO LWPl>FFOO SET WP ADDRESS FEBO FFOO FE82 FFFF +>FFFF DATA STATEMENT FE84 0001 +>FFFF DATA STATEMENT FE86 NOTE In operands, absolute value must be unsigned values only. However, there is a method for using the assembler to compute and assemble a negative value; this method is especially useful with the immediate instructions (e.g., AI, CI, LI). Enter the instruction using the negative value. The assembled value will be all zeroes in the last assembled word. Use the slash command (paragraph 3.2.2) to assemble at the previous address, then enter the negative value as a data statement as shown in the following example: FE1A 0201 LI R1,->100 -USE SIGNED OPERAND FE1C 0000 - SIGNED NUMBER ASSEMBLIES AS 0000 (IN M.A.>FE1C) ~7 FE1E /FE1C - SET OBJECT LOAD ADDRESS TO PREVIOUS ADDRESS FE1C FFOO ->100 - - >100(>FFOO) NOW IN M.A.>FE1 C FE1E (7) Absolute addresses are used instead of labels: FEAO CB20 MDV @>FE10,@>FEDO MOVE TO STORAGE FEA2 FE10 FEA4 FEDD FEA6 16FC JNE >FEAO LOOP BACK TO MOVE INSTRUCTION FEAB 7-30 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands- TM 990/402 LINE-BY-LINE Description and Formats ASSEMBLER USER'S GUIDE (8) Character strings are preceded by a dollar sign and are terminated with two carriage returns. FF10 4142 $ABCD 1233 FF12 4344 FF14 2020 FF16 2031 FF18 3233 FF1A 3320 - UNUSED RIGHT BYTE FILLED WITH>20 (SPACE) (9) Character strings of one or two characters can be designated by encoding the string in quotes. If not part of an operand, a plus or minus sign must precede the value. If the string is larger than two characters, the last two characters are interpreted. FEAA 3132 +'12' CHARACTERS ONE AND TWO FEAC oooc +12 VALUE OF POSITIVE TWELVE FEAE FFF4 -12 VALUE OF NEGATIVE TWELVE FEBO 0000 + +FOLLOWED BY CTRL KEY AND NULL KEY PRESSED FEB2 0202 LIR2, 'ABCD'1 ASSEMBLED LAST TWO CHARACTERS [C AND D) FEB4 4344 FEB6 0202 LI R2, 'E' CHARACTER E IN RIGHT BYTE FEB8 0045 FEBA 0202 LI R2,>E VALUE >E IN RIGHT BYTE FEBC DODE FEBE (10) Signed numerical values of up to 16 bits can be designated by preceding the value with a plus or minus sign. If more than 16 bits are entered in binary or hexadecimal, the last 16 bits entered are used. If more than 16 bits are entered in decimal, the assembled value is the same as the remainder had the number between divided by 215 (65,536 10). FE18 DOFF + 0ro11111111QQQQQQ0011111111 FE1A FF01 - 0ffi11111111QQQQQQQQ11111111 FE1C AAEE +>AAAAAAEE FE1E 8000 +32768 FE20 8001 +32769 FE22 0000 +65536 FE24 FFFF +131071 FE26 0000 +131072 FE28 8000 -32768 FE2A 8001 -32767 FE2C 7FFF -32769 FE2E 9900 FAMILY SYSTEMS DESIGN 7-31 TM 990/402 LINE-BY-LINE Program Development: Software Commands- ASSEMBLER USER'S GUIDE Description and Formats ERRORS When the assembler detects an error, it types an error symbol and readies the terminal for re-entering data at the same memory address. The following error symbols are used: • D (Displacement error). The jump instruction destination is more than + 256 or - 254 bytes away. FF38 JNC $+300•D FF38 JNC >FOOO+D FF38 1708 JNC >FF50 FF3A • R (Range error). The operand is out of range for its field: FF30 LI R44.~R FE30 0204 LI R4,200 FF32 DOCS • S (Syntax error). The instruction syntax was incorrect: FF34 MOZ+S i INCORRECT MNEMONICS FF34 MOS+S 5 FF34 CB02 MDV R2, @>FEBO FF36 FEBO EXITING TO THE MONITOR Return control to monitor by pressing the escape (ESC) key. PSEUDO-INSTRUCTIONS The TM 990/ 402 also interprets two pseudo-instructions. These pseudo-instructions are ~7 not additional instructions but actually are additional mnemonics that conveniently represent two members of the instruction set: • The NOP mnemonic can be used in place of a JMP $ + 2 instruction which is essentially a no-op (no operation). This can be used to replace an existing instruction in memory, or it can be included in code to force additional execution time in a routine. Both NOP and JMP $ + 2 assemble to the machine code 100016 • •The RT mnemonic can be used in place of a B *Rl l instruction which is a common return from a branch and link (BL) subroutine. Both RT and B *Rl 1 assemble to the machine code 045B 16 • Note the following examples: FEDD 1000 JMP $+2 JUMP TO NEXT INSTRUCTION FE02 1000 NOP ALSO ASSEMBLES TO > 1000 FE04 0458 B +R11 RETURN COMMAND FEOB 0458 RT ALSO A RETURN COMMAND 7-32 9900 FAMILY SYSTEMS DESIGN TIBUG Monitor 7.,. TIBUG Program Development: Software Commands- MONITOR Description and Formats TIBUG COMMANDS INPUT RESULTS B Execute under Breakpoint c CRU Inspect/Change D Dump Memory to Cassette/Paper Tape E Execute F Find Word/Byte in Memory H Hex Arithmetic L Load Memory from Cassette/Paper Tape M Memory Inspect/Change R Inspect/Change User WP, PC, and ST Registers s Execute in Step Mode T 1200 Baud Terminal w Inspect/Change Current User Workspace COMMAND SYNTAX CONVENTIONS CONVENTION SYMBOL EXPLANATION <> Items to be supplied by the user. The term within the angle brackets is a generic term. [ ] Optional Item - May be included or omitted at the user's discretion. Items not included in brackets are required. { } One of several optional items must be chosen. - (CR) Carriage Return /\ Space Bar LF Line Feed R or Rn Register (n = 0 to 15) WP Current User Workspace Pointer contents PC Current User Program Counter contents ST Current User Status Register contents 7-34 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands- TIBUG Description and Formats MONITOR USER ACCESSIBLE UTILITIES ' XOP FUNCTION 8 Write 1 Hexadecimal Charter to Terminal 9 Read Hexadecimal Word from Terminal 10 Write 4 Hexadecimal Characters to Terminal 11 Echo Character 12 Write 1 Character to Terminal 13 Read 1 Character from Terminal 14 Write Message to Terminal NOTE All characters are in ASCII code. TIBUG ERROR MESSAGES ERROR CONDITION 0 Invalid tag detected by the loader. 1 Checksum error detected by the loader. 2 Invalid termination character detected. 3 Null input field detected by the dump routine. 4 Invalid command entered. 9900 FAMILY SYSTEMS DESIGN 7-35 TIBUG Program Development: Software Commands- MONITOR Description and Formats COMMAND SYNTAX Execute under Breakpoint (B) B

<(CR)> CRU Inspect/Change (C) C{ 0}<(CR)> Dump Memory to Cassette/Paper Tape (D) r-MONITOR PROMPT D{ 0}{ 0 }{ 0 }IDT= Execute Command (E) E Find Command (F) F { 0} {/';-} {(CR)} Hexadecimal Arithmetic (H) H< number 1> {/';-} <(CR)> Load Memory from Cassette or Paper Tape (L) L<(CR)> Memory Inspect/Change, Memory Dump (M) Memory Inspect/Change Syntax M
<(CR)> Memory Dump Syntax M{/';- } <(CR)> Inspect/Change User WP,PC, and ST R<(CR)> Registers (R) Execute In Single Step Mode (S) s Tl 733 ASR Baud Rate (T) T Inspect/Change User Workspace (W) W [Register Number] <(CR)> 7-36 9900 FAMILY SYSTEMS DESIGN TM 990/302 Software Development Board TM990/302 SOFTWARE Program Development: Software Commands - DEVELOPMENT BOARD Description and Formats EPROM's which may be programmed by the '302 2708 2716 2516 2532 9940 SOFTWARE COMPONENTS Access Command Executive (CR) Text Editor TE Symbolic Assembler SA Debug Package DP EPROM Programmer EP Relocating Loader RL EIA Interface El I /0 Scheduler /Handler SR LUNO ASSIGNMENTS Device Logical Unit No. Dummy 0 ·7 Terminal (LOG) Audio Cassette 1 2 Audio Cassette 2 3 Second EIA Connector 4 Memory 5 7-38 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - TM990/302 SOFTWARE Description and Formats DEVELOPMENT BOARD SOFTWARE COMPONENT CALLS Text Editor TEJD(input device),(output device) Symbolic Assembler SA~(source device), (object device), (listing device) Debug Package DP~( output device) EPROM Programmer EP Relocating Loader RLJD(input device) Set Baud Rate SRJzj(nnnn) Escape ESC (return to executive) TEXT EDITOR COMMANDS D Delete lines n thru m I Insert at line n with optional auto increment by r:n K Keep buffer and print new top line in the buffer G Get buffer and print new bottom line in the buffer P Print lines n thru m 0 Flush the input file until end of input file and return to executive R Resequence input to output, n is initialized line # and m is the increment COMMAND SYNTAX Delete Lines n thru m (Rn,m) D (starting line #)[,(ending line # )] Insert After Line n with optional I (line number after which new auto increment by m (ln,m) data is entered) [,(auto increment value)] 7"4 Get Buffer (G) G Keep Buffer (K) K Print lines n thru m (Pn,m) P (first line #to be printed) [,(last line # to be printed)] Quit Text Editor (0) Q Resequence Output (Rn,m) R (initial line number) [,(increment value)] 9900 FAMILY SYSTEMS DESIGN 7-39 TM990/302 SOFTWARE Program Development: Software Commands - DEVELOPMENT BOARD Description and Formats ASSEMBLER DIRECTIVES AORG [label]~AORGt6(value).l6[comment] BSS [label]Y,BSS,t6(value ).t1[ comment] BYTE [label],t1BYTEtz5(value),(value),(value), .... ,tD[comment] DXOP [label]~DXOP~(symbol),(value).l6[comment] END [label]tbEND~(symbol)~[comment] EQU [label].l6EOU ~(expression ),tD[ comment] DATA [label]~DATA16(exp),(exp), ... ,t6[comment] EVEN [label]~EVEN~[ comment] IDT [label]~IDTb(string).l6[comment] TEXT [label]~TEXT~( - ), 'string'~[comment) DEBUG Package Verb Command SB Set Software Breakpoint and Execute IM Inspect/Change Memory IC Inspect/Change CRU IR Inspect/Change MPU Registers ST Set Software Trace RU Single Step for 1 or more instructions with or without trace OM Dump Memory .,. 7 DEBUG COMMANDS Set Breakpoint and Execute SB.tD(address) Inspect/Change Memory IM,tD(address) lnspectiChange CRU ICJD(CRU base addr.)(no. of bits) Inspect/Change MPU registers IR Set Software Trace ST~(O or 1) Run 1 or more Instructions RU~(no. of instructions in decimal) ·Dump Memory DM~(starting addr.),(ending addr.) 7-40 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - TM990/302 SOFTWARE Description and Formats DEVELOPMENT BOARD EPROM PROGRAMMING CRU ASSIGNMENTS CRU BASE ADDRESS 16 INPUT /OUTPUT FUNCTION 1710 1/0 EPROM DATA BIT 0 1712 1/0 1714 1/0 1716 1/0 1718 1/0 171A 1/0 171C 1/0 171E 1/0 EPROM DATA BIT 7 1720 0 EPROM ADDRESS LSB 1722 0 1724 0 1726 0 1728 0 172A 0 172C 0 172E 0 1730 0 1732 0 1734 0 1736 0 1738 0 EPROM ADDRESS MSB 173A 0 EPROM PROGRAM ENABLE 173E 0 EPROM PROGRAMMING PULSE 7.,. EPROM PROGRAMMING RESPONSES PP = Program EPROM RE= Read EPROM to Memory CE = Compare EPROM to Memory Memory Bounds: MEM BOS? (start addr.),(stop addr.) EPROM Start addr: EPROM START? (start addr.) Programming Mode: MODE? P(parallel) or l(in line) Starting Byte: ST byte? (0 or 1 if P above) 9900 FAMILY SYSTEMS DESIGN 7-41 TM990/302 SOFTWARE Program Development: Software Commands - DEVELOPMENT BOARD Description and Formats PREDEFINED CRU ADDRESSES FOR 1/0 DEVICES Device CRU Address Users Terminal (9902) 8016 Timer (9901) 10016 1 EIA Interface (9902) 18016 Recorder 1 Forward 170016 Recorder 2 Forward/9940 Flag 1 170216 Recorder 2 Write Data/9940 Flag 2 170416 Recorder 1 Read Data/9940 Flag 3 170616 Personality Card Code Bit 0 170816 Personality Card Code Bit 1 170A16 Personality Card Code Bit 2 170C16 Switch Code Bit 170E16 EPROM Data 171016 - 171 E16 EPROM Address 172016 - 173816 EPROM Program Enable 173A16 EPROM Programming Pulse 173C16 ~1 7-42 9900 FAMILY SYSTEMS DESIGN TXDS Commands for FS 990 Software Development System 7· TXDS SUPPORT MANUALS Program Development: Software Commands - Description and Formats Examples of manuals available in support of the TXDS System: TXDS PROGRAMMER'S GUIDE (#946258-9701) This manual enables the user to employ the Terminal Executive Development System (TXDS) in conjunction with the TX990 Operating System and the Model 990/4 and 990/10 Computer System hardware configuration to develop, improve, change, or maintain (1) the user's customized Operating System and the user's applications programs or (2) any other type of user-produced programs (e.g., the user's own supervisor call processors or the user's own utility programs). It is assumed the reader is familiar with the Model 990 Computer System assembly language and the concepts of the TX990 Operating System. The sections and appendixes of this manual are organized as follows: Introduction - Provides a general description of the TXDS utility programs and their-capabilities. Also includes a description of the control functions of the TXDS Control Program. II Loading and Executing a Program - Provides a step-by-step procedure for loading and executing (1) each of the TXDS and TX990 Operating System utility programs and (2) a user program. Also describes the TXDS Control Program and how to correctly respond to its prompts. III Verification of Operation - Provides several short step-by-step procedures to checkout proper operation of the TXDS software. IV Creating and Editing Program Source Code - Describes the capabilities of the TXEDIT utility program and how the user can employ those capa~ilities to edit or generate the text of source programs and object programs. V Assembling Source Programs - Describes how the user can employ the TXMIRA utility program to assemble source files (i.e., source code programs). VI TX990 Cross Reference (TXXREF) Utility Program - Describes how the user 7 can employ the TXXREF utility program to produce a listing of each user-defined symbol in a 990 assembly source program along with the line numbers on which the symbol is defined and all of the line numbers on which the symbol is referenced. VII Linking Object Modules - Describes how the user can employ the TXDS Linker utility program to form a single object module from a set of independently assembled object modules (in the form of object code or compressed object code.) VIII TXDS Copy Concatenate (TXCCAT) Utility Program - Describes how the user can employ the TXCCAT utility program to copy one to three files to a single output file. IX TXDS Standalone Debug Monitor (TXDBUG) Utility Program - Describes how the user can employ the TXDBUG utility program to debug programs which have been designed to operate in a "standalone" situation without support of an operating system. 7-44 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - TXDS SUPPORT MANUALS Description and Formats X TXDS PROM (TXPROM) Programmer Utility Program - Describes how the user can employ the TXPROM programming utility program to control the Programming Module (PROM) hardware to make customized ROMs containing user-created data or programs. XI TXDS BNPF /High Low (BNPFHL) Dump Utility Program - Describes how the user can employ the BNPFHL utility program to produce a BNPF or high/ low file format. XII TXDS IBM Diskette Conversion Utility (IBMUTL) Program - Describes how the user can employ the IBMUTL utility program to transfer standard IBM- formatted diskette datasets to TX990 Operating System files and to transfer TX990 Operating System files to standard IBM-formatted diskette datasets. XIII TXDS Assign and Release LUNO Utility Program - Describes how the operator can assign and release LUNOs in systems which do not include OCP. A Glossary - Clarifies selected words used in this TX990 Operating System Programmer's Guide. B Compressed Object Code Format - Describes the compressed object code format. C Task State Codes - Lists and describes the task state codes. D 1/0 Error Codes - List and describes the I/O error codes available to the user, when coding a program, for printout or display on a terminal device. The following documents contain additional information related to the TX990 Operating System and are referenced herein this manual: TITLE PART NUMBER Model 990 Computer TX990 Operating System Programmer's Guide 946259-9701 7... Model 990 Computer TMS9900 Microprocessor Assembly Language Programmer's Guide 943441-9701 Model 990 Computer Model FD800 Floppy Disc System Installation and Operation 945253-9701 Model 990 Computer Model 913 CRT Display Terminal Installation and Operation 943457-9701 Model 990 Computer Model 911 Video Display Terminal Installation and Operation 943423-9701 Model 990 Computer Model 733 ASR I KSR Data Terminal Installation and Operation 945259-9701 Model 990 Computer Model 804 Card Reader Installation and Operation 945262-9701 Model 990 Computer Models 306 and 588 Line Printers Installation and Operation 945261-9701 Model 990 Computer PR OM Programming Module Installation and Operation 945258-9701 990 Computer Family Systems Handbook 945250-9701 Model 990 Computer Communications Systems Installation and Operation 945409-9701 9900 FAMILY SYSTEMS DESIGN 7-45 TXDS COMMANDS FOR FS 990 Program Development: Software Commands - SOFTWARE DEVELOPMENT SYSTEM Description and Formats List of Commands and Special Keys/Characters COMMAND SYNTAX DESCRIPTION SETUP COMMANDS SL Start Line Numbers (SL) command causes line numbers to be printed with each line of text. SN Stop Line Numbers (SN) comman causes line numbers not to be printed. SP Set Print Margin (SP) command sets the right boundary for print display. SM Set Margin (SM) for Find command sets the left and right boundaries for the Find command. ST Set Tabs (ST) command sets up to five tab stops. PRINTER-MOVEMENT COMMANDS D Down (D) command moves the pointer down toward the bottom of the buffer. u Up (U) command moves the pointer up towards the first line in the buffer. T Top (T) command moves the pointer to the first line in the buffer. B Bottom (B) command moves the pointer to the last line in the buffer. EDIT COMMANDS c Change (C) command removes lines from the buffer and inserts new ones in thelr place. The new lines are input from the terminal. Insert (I) command takes input from the terminal and places the new lines into the buffer. M Move (M) command moves lines from one place in the buffer to another. R Remove (R) command deletes lines from the buffer. F Find string (F) command searches for the first occurrence of a character string in a line and replaces it with another string of characters. PRINT COMMANDS L Limits (L) command causes the first line and the last line to be displayed. p Print (P) command displays lines of text. 7-46 9900 FAMILY SYSTEMS DESIGN Program Development: TXDS COMMANDS FOR FS 990 Software Commands - Description and Formats SOFTWARE DEVELOPMENT SYSTEM List of Commands and Special Keys/Characters (Continued) COMMAND SYNTAX DESCRIPTION OUTPUT COMMANDS K Keep (K) command takes lines of text out of the buffer and puts them in the output file. Q Quit (Q) command takes lines of text out of the buffer or the input files and puts them in the output file. E An (E) command terminates without writing an EOF to the output file. TERMINATE-SEQUENCE COMMANDS Tor C Allows the user to make multiple single directional editing passes on a source or object program. SPECIAL KEYS/CHARACTERS CTRL-H Pressing the control key and the H key simultaneously on the hard copy terminal causes the terminal to backspace a character to enable rewriting over an entered character-error. RUB OUT The RUB OUT key causes the line just entered to be deleted so that a new line can replace it. CTRL-1 Pressing the control (CTRL) key and the I key simultaneously on a hard-copy terminal causes a tab stop to be entered in the input string, although only one space will be echoed on the terminal. ESC/RESET Pressing the ESCape or RESET key on the system console causes a display to be aborted. position keys When using a VDT, only the left position key (-) and the right(-) position key are recognized. The up and down 7"'- position keys cause garbage to be entered into the input string. The left position key causes characters to be deleted from the character string; a right position key causes whatever was under the cursor to be entered. DELETE LINE DELETE LINE on a VDT acts the same as a RUB OUT on a hardcopy terminal. TAB A SPACE character is echoed. The TAB is interpreted by the text editor and spaces are inserted to fill the text line to the next TAB setting. 9900 FAMILY SYSTEMS DESIGN 7-47 TXDS COMMANDS FOR FS 990 Program Development: Software Commands - SOFTWARE DEVELOPMENT SYSTEM Description and Formats TXMIRA Options OPTION DESCRIPTION Mnnnnn Overrides memory size default; default is 2400 bytes x Produce cross-reference L Produce assembly listing T Expand TEXT code on listing s Produce sorted symbol list c Produce compressed object output where n is a decimal digit TXLINK Options OPTION DESCRIPTION Mnnnnn Override default memory size, default is 11800 bytes. c Compressed object output. laaaaaaaa IDT for linked object. p Partial link desired. L Print load map and symbol list. Note: n is a decimal digit and a is an alphanumeric character. TXCCAT Options OPTION DESCRIPTION TRnnnn Truncate record to length nnnn. Flnnnn Fix records to size nnnn by padding with blanks or by truncation. SKnnnn Skip nnnn input records, prior to output. LFnn List file, page length= nn, default= 55. Slnn Space lines on listing, nn =space count, default= 0. NL Number lines on listing. RI Do not rewind input on open. RO Do not rewind output on open. Note: n is a decimal digit and the maximum field size is given by the number of n's. 7-48 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - TXDS COMMANDS FOR FS 990 Description and Formats SOFTWARE DEVELOPMENT SYSTEM TXDBUG Keyboard Commands DEBUG Commands IC Inspect Communications Register Unit (CRU) IM Inspect Memory IR Inspect AU Register (WP, PC, ST) IS Inspect Snapshot IW Inspect Workspace Registers MC Modify Communications Register Unit (CRU) MM Modify Memory MR Modify Registers MW Modify Workspace Registers SB Set Breakpoint SP Set H /W Write Protect Option SR Set Trace Region SS Set Snapshot ST Set Trace CB Clear Breakpoint CP Clear H /W Write Protect Option CR Clear Trace Region cs Clear Snapshot 7-. 9900 FAMILY SYSTEMS DESIGN 7-49 AMPL Reference Data Program Development: AMPL Software Commands - Description and Formats REFERENCE DATA EXPLANATION OF THE NOTATION USED IN THIS CARD Notation Explanation Optional [item] Bracketed item may be omitted. Items Exactly one item must be selected. item 1} { item 2 from the items in braces. Substitution ex pr Any expression may be used. 'file' File or device name required. Repetition item ... A list of items may be used. Required Replace with item. CHARACTER SET Type Characters Use Special RETURN SPACE Any printable character may be used in a quoted !"$/()':' +' string. RETURN terminates line and statement. ";" - . I:;< may separate statements. SPACE separates adjacent >?@ numbers and identifiers. Numerals O- 9 Letters A - Z,a - z NOTE: All AMPL reserved words use only upper case (UPPER CASE LOCK). SYMBOL NAMES Type Example Definition System RO Up to four alphanumeric characters; all system ETRC symbols are predefined. User-defined USRVAR Up to six alphanumeric characters; assignment defines X3 a variable. BRKADR ARRAY statement defines an array. 7~ GO PROC/FUNC statement defines a procedure/function. Program IDT. Up to six alphanumeric characters. Period after IDT label .DEF and before DEF labels, defined by LOAD command . CONSTANTS Type Example Range Decimal 10833 1 ... 32767 Hexadecimal 02A51, >2A51 >0 ... >FFFF Octal 125121 !O ... !177777 Binary < 10101001010001 <0 ... <1111111111111111 ASCII 11:::0" Instruction #XOR ':'R1 ,R9 # Keyword IAO See keyword constanttable. 9900 FAMILY SYSTEMS DESIGN 7-51 AMPL Program Development: Software Commands - REFERENCE DATA Description and Formats EXPRESSIONS Type Example Definition Subexpression (expr) Identity + expr Value of . Negation - expr Two's complement of . Target memory @addr used as word address into emulator or target memory. Proc/Func ARG expr Argument in position of call list; ARGO Argument is number of arguments in list. Proc/Func LOG expr Word of local variable array; LOG O is local variable length of local variable array. Multiplication expr1 '~expr2 Signed product (warning on overflow). Division expr1 I expr2 Signed quotient (warning on divide by zero). Remainder expr1 MOD EXPR2 Signed remainder of division (warning on divide by zero). Addition expr1 + expr2 Signed sum. Subtraction expr1 - expr2 Signed difference. NOTE: Result of relational operator is either FALSE (0) or TRUE (-1 ). Equality expr1 EQ expr2 16-bit comparison. expr1 NE expr2 Arithmetic expr1 LT expr2 Signed, 16-bit comparison. inequality expr1 LE expr2 expr1 GT expr2 expr1 GE expr2 ~7 Logical expr1 LO expr2 Unsigned, 16-bit comparison. inequality expr1 LOE expr2 expr1 HI expr2 expr1 HIE expr2 Complement NOT expr 16-bit one's complement. Conjunction expr1 AND expr2 16-bit booleah AND. expr 1 NANO expr2 16-bit boolean not AND. Disjunction expr1 OR expr2 16-bit boolean OR. expr1 XOR expr2 16-bit boolean exclusive OR. NOTE: Operators are given in order of precedence, highest to lowest. Solid lines separate precedence groups; within each group, precedence is equal and evaluation is left to right. Evaluation results in a 16-bit integer value. 7-52 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - AMPL Description and Formats REFERENCE DATA UNSIGNED ARITHMETIC Syntax Definition MPY (expr1, expr2) Low-order 16 bits of unsigned product. ':' ; high order 16 in MOR. DIV (divisor, dividend) Unsigned quotient of 32-bit number (MOR, ) over ; remainder in MOR. MOR High-order 16-bits of MPY product and of DIV dividend; remainder of DIV; unsigned carry of + and-. ARRAY DEFINITION ARRAY name(expr1 [,expr2]), ... User (previously undefined or name of deleted array) is defined as one- or two-dimension array. DISPLAY STATEMENTS expr[:f ... f] Value of expression 'LITERAL STRING' Literal string add1 [TO addr2] [:f ... f]? [:f ... f] Target memory Format specification I [:f ... f] ASCII A set default G octal O[i] binary B[i] hexadecimal H[i] symbolic s decimal D[i] instruction I unsigned U[i] name= E newline N[j] space X[j] Note: 1<=i<=9 field width 'i' digits, then two blanks i=O default field width, no trailing blanks 7~ 1<=j< =9 repeat T times j=O repeat 1O times Response to display /modify mode(?): forward step RETURN,+ replace contents back step open new address @ exit change display :f ... f DISASSEMBLER Instruction DST Destination address. operands SRC Source address. NOTE: Additional instructions of the TMS9940 (DCA, DCS, LllM, SM) will assemble correctly ( # DCA t.'RC1 #) but will disassemble as XOP instructions. See TMS9940 specifications for details. 9900 FAMILY SYSTEMS DESIGN 7-53 AMPL Program Development: Software Commands - REFERENCE DATA Description and Formats ASSIGNMENT STATEMENTS Type Example Definition Variable sym = expr User-defined or writable system symbol or REF program label. Target memory @addr = expr Put value of at target Proc/Func ARG n =expr Local copy of argument in position of call argument list. Command local LOC n = expr Word < n > of local storage array. Array A[(i1 [,i2])] = e User defined array name; zero, one, or two index expressions. NOTE: Precedence of@, ARG, and LOC may require parenthesis around following expression. COMPOUND STATEMENTS Syntax Definition BEGIN statements END Statements are executed sequentially. Use in place of any single statement syntax. CONTROL STATEMENTS IF expr is executed if is TRUE (nonzero). THEN s1 Otherwise, is executed, if included. [ELSE s2] CASE expr OF Statement at first label expression expr 1::s1; equal to is executed. If none, statement ·7 is executed, if included. exprn::sn [ELSE s] END WHILE expr While is TRUE (nonzero), is DO statement executed. REPEAT statement is executed. If FALSE (zero), UNTIL expr is executed until is TRUE. FOR var= expr1 TO expr 2[BY Value of is assigned to . expr3] is executed until is equal to DO statement ; is added to , and repeated. Default value of is 1. ESCAPE Exit from innermost enclosing WHILE, REPEAT, or FOR statement. 7-54 9900 FAMILY SYSTEMS DESIGN Program Development: AMPL Software Commands - Description and Formats REFERENCE DATA PROCEDURE/FUNCTION/FORM DEFINITION PROC name [(args[,locs])] statements END User-defined (previously FUNG name [(args[,locs])] statements END undefined or deleted procedure/function) is bound to . · < args> is the required number of arguments. < locs > is the size of local storage array. RETURN [expr] Pass control back to calling statement. In a procedure, is ignored. In a function, value of replaces the function call in the calling expression. FORM name 'prompt' [ = [ {constant } ]] ; ... END 'string' must be a previously defined procedure or function, semicolon required between prompts. PROCEDURE/FUNCTION CALLS proc name [(expr, ... )] User-defined or system procedure/function with list of argument expressions. func name [(expr, ... )] Command definition determines number of arguments required. Some system commands require quoted strings as arguments. NOTE: Procedure/functions with defined FORM when called with no arguments will prompt for arguments using the FORM. example FORM: 7.. COMMENTARY ENTRY comment, not a prompt required argument, with default value required argument, must PROMPT 1 =default value enter value default given if value not PROMPT 2= entered PROMPT 3 ':' = FORM control function keys: Next prompt: TAB,!,-+FIELD, SKIP, RETURN Previous prompt: !,~FIELD First prompt: HOME Erase value: ERASE FIELD, ERASE INPUT Redisplay default: INSERT LINE Duplicate previous value: F4 Complete form: ENTER Abort form: CMD 9900 FAMILY SYSTEMS DESIGN 7-55 AMPL Program Development: Software Commands - REFERENCE DATA Description and Formats INPUT /OUTPUT COMMANDS Syntax Definition HCRB Host computer CRU base address. HCRR (offset.width) Read host computer CRU field. HCRW (offset,width,value) Write into host CRU field. ( ~'file' }) COPY tedit id AMPL input from 'file' AMPL input from edit buffer Initialize listing device or file. Disable listing output. 'file'}) ~~: Enable listing output. Close listing device or file with LIST ({ EOF. NL Print newline. unit=OPEN no arguments - list all open units and edit buffers. initialize 'file' I 1/0 unit 0 - device 10, file IN only IN - for input only OUT - for output only 10 - for input/output REWIND - position to beginning of file EXTEND - position to end of file SEQ - auto-create sequential file REL - auto-create rel-rec file •7 g event-READ [ ( un{ { IRECT} [, { g RAPH } [ ' {~~6 'j~row l [ ' l~col J [ ' REL [,rec # J s col]] IJ]] )] no arguments - read console Read record from (unit) O - issue read ASCII DIRECT - issue read direct GRAPH - read graphics on 922 VDT VDT - read in cursor positioning mode f row - field start row f col - field start column s col - cursor start column 7-56 9900 FAMILY SYSTEMS DESIGN Program Development: AMPL Software Commands - Description and Formats REFERENCE DATA INPUT /OUTPUT COMMANDS (continued) SEO - read sequentially REL - read sepecified record rec # - record number to read /256 =cursor column after read if VDT AND 255 =event key value if VDT, else >OD for end of record, > 13 for end of file. value= EVAL [(unit)] Evaluate expression in 's buffer; if no , READ/EVAL the console. DPLY [(unit)] AMPL display unit for output to ; if no , to console. okay=MOVE Move contents of 's buffer to 's buffer (from unit, = O if moved to unit) = > FFFF if too big and not moved. REW[(unit)] Rewind (unit) - repositions, file clears console no argument - clears console Cursor ~ WRIT (unit [, { glRECT} [, { &RAPH} J ['{~~6 '{?row} [, [f col]J}] ] ) REL [, rec # J no arguments - write console Write record to (unit), O - issue write ASCII 7.,. DIRECT - issue write direct GRAPH - write graphics on 911 VDT VDT - write in cursor positioning mode f row - field start row f col - field start column SEO - write sequentially REL - read specified record rec # - record number to read /256 =cursor column after write if VDT CLSE (unit [, { EOF } J Release I /0 , UNLOAD EOF - write end-of-file mark UNLOAD - unload unit 9900 FAMILY SYSTEMS DESIGN 7-57 AMPL Program Development: Software Commands - REFERENCE DATA Description and Formats SYSTEM SYMBOLS V - variable F - function P - procedure CLR p - clear MOEL P - symbols CLSE p - 1/0 close MOR V - arithmetic COPY p - copy MIN v - minutes GRUB v - CRU base MOVE F - 1/0 buffer CRUR F - CRU read MPY F - multiply CRUW p - CRU write MSYM p - symbols DAY v - day NL p - newline DBUF p - delete buffer OPEN F - 1/0 open DELE p - delete symbol PC v - registers DIV F - divide RO-R15 v - registers DPLY p - display READ F - 1/0 read DR p - registers REW p - 1/0 rewind DST v - destination RSTR p - restore DUMP p - dump SAVE p - save EBRK p - emulator SEC v - seconds ECLK v - emulator SRC v - source EDIT F - edit ST v - register EHLT F - emulator TBRK p - trace module EINT p - emulator TEVT p - trace module EMEM v - emulator THLT F - trace module ERUN p - emulator TINT p - trace module EST F - emulator TNCE v - trace module ETB F - emulator TNE v - trace module ETBH F - emulator TRUN p - trace module ETBO v - emulator TST F - trace module ETRC p - TTB F - trace module ~7 emulator ETYP v - emulator TTBH F - trace module EVAL F - evaluate TTBN v - trace module EXIT P - exit AMPL TTBO v - trace module HCRB V - host CRU TTRC p - trace module HCRR F - CRU read USYM p - user symbols HCRW P - CRU write VRFY P - verify HR V - hour WAIT F - delay AMPL IOR1 v -1/0 WP v +register KEEP p - keep edit WRIT P - 1/0 write LIST p - list YR v - year LOAD p - load object 7-58 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - AMPL Description and Formats REFERENCE DATA EDIT Syntax Definition { 'file' } Create edit buffer with 'file'. Edit existing buffer. edit id = EDIT[( edit id [,record])] No argument creates an empty buffer. KEEP (edit id, 'file') Save edit buffer onto 'file' and delete edit buffer. DBU F (edit id) Delete edit buffer. EDIT CONTROL FUNCTION KEYS 911 913 CONTROL Function KEY KEY CHARACTER edit/ compose mode F7 F7 v quit edit mode CMD HELP x roll up F1 F1 A roll down F2 F2 B set tab F3 F3 c clear tab F4 F4 D tab TAB (shift SKIP) TAB I back tab FIELD BACK TAB T newline RETURN NEWLINE RETURN insert line unlabeled gray INSERT LINE 0 delete line ERASE INPUT DELETE LINE N erase line ERASE FIELD CLEAR w truncate line SKIP SET K insert character INS CHAR INSERT CHAR delete character DEL CHAR DELETE CHAR cursor up l u 7"'- cursor down l J cursor right ~ ~ R cursor left I,- H top of screen ---- HOME HOME 9900 FAMILY SYSTEMS DESIGN 7-59 AMPL Program Development: Software Commands - REFERENCE DATA Description and Formats GENERAL COMMANDS Syntax Definition USYM List all user symbols, procedures, functions, and arrays. DELE ('name' .... ) Delete user procedure, function, or array. SAVE ('file') Save all user defined symbols, functions, and arrays on 'file'. RSTR ('file') Restore user defined symbols, procedures, functions, and arrays from 'file'. CLR Delete all user symbols, procedures, functions and arrays. MSYM List object program labels. MOEL Delete all object program labels. EXIT Exit from AMPL back to operating system. TIMING YR Year (1976 to 1999) DAY Julian day (1 to 366) HR Hour (0 to 23) MIN Minute (0 to 59) SEC Second (0 to 59) WAIT (expr) Suspend AMPL for ':'50 milliseconds ( = 20 is one second). TARGET MEMORY COMMANDS EMEM Emulator memory mapping: 9900/9980 map BK bytes (0-> 1FFF) ~7 9940 define RAM and ROM sizes. LOAD ('file'[,bias[,IDT] [+DEF] [+REF]]]): Load object program by bias and enter program labels into table. VRFY ('file' [,bias]) Verify object program, listing differences between object and target memory. DUMP ('file' ,low,high[,start]) Dump program from target to in nonrelocatable format. 7-60 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - AMPL Description and Formats REFERENCE DATA EMULATOR CONTROL COMMANDS Syntax Definition EINT ('EMOn' L\6}L 'TMOn']]) Initialize Emulator device, clock O=prototype/ 1 =emulator. ECLK Processor clock. ETYP Processor type: -1 = TMS9940, 0 = SBP9900, 1 = TMS9900, 2 = TMS9980. ETRC ( { ~~X} [,count[,low,high]]) IAO Trace qualifier, completion break count (OFF-255), address range. EBRK ( { 2~} [+ILLA] [,address]. .. ) Address breakpoint(s) (ILLA only valid for TMS9940). ERUN Run emulation at PC, WP, ST. EST Emulation status (3 LSBits): HOLD, IDLE, Running EHLT Halt emulation, return status. ETBH (index[,{~~}]) IAQ Indexed bus signal from buffer. (TRUE if expression matches). ETB (index) Indexed address from trace buffer. ETBO, ETBN Emulator Trace buffer limits: Oldest, Newest sample indices. 7.... 9900 FAMILY SYSTEMS DESIGN 7-61 AMPL Program Development: Software Commands - REFERENCE DATA Description and Formats TRACE MODULE CONTROL Syntax Definition TINT ('TMOn') Initialize trace module. TTRC ([INT] {[±Qof~~Q1 ][±Q2 ][±Q3]} [,count[, JON }rn [± IAQ][± OBIN] ~OFF Qualify data samples, trace completion counter (OFF-255), latch option on D0-03. TEVT ({[±DO] [±01~~~02] [±03]}[,value[,mask]]) [± IAQ] [±OBIN) EXT Qualify 00-03 event (or EXTernal), and for 04-019. TBRK (count [,[,INV] [+EDGE]]]) Set event counter (OFF-FFFF), set delay counter (OFF-244), count INVerted/EDGE events. TRUN Start Trace module tracing. TST Trace module status (3 LSB's), event occurred, trace full, tracing. THLT Halt trace module, return status. TNE Number of events since last TRUN. TNCE Number of event count overflows. TTBH (index[, 1[±DO] [ [±± 01IAQ][± ][± 02 ] [± 03]}]) OBIN] D0-03 of indexed samples, (TRUE if expression matches). TTB () 04-019 indexed samples (data bus) ~7 TTBO, TTBN Trace module trace buffer limits: Oldest, Newest sample indices. TRACE MODULE INTERCONNECT TO EMULATOR QO Memory address bit 15 (TMS9940 only). DO Byte memory cycle (TMS9940 only). Q1 ,01, IAQ Instruction Acquisition. Q2,D2,DBIN DataBuslN = MR(read), MW= -DBIN(write). Q3 Emulator trace qualifier and range (ETRC). 03, External Event Emulator address breakpoint (EBRK). 04-019 Emulator data bus (bits 0-15). External Clock Emulator memory cycle clock. Control Cable Synchronizes emulation and tracing. Trace module will halt emulator for EINT ('EMOn', clock 'TMOn'). 7-62 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - AMPL Description and Formats REFERENCE DATA TARGET REGISTERS PC,WP,ST Processor registers. RO-R15 Workspace registers. DR Display all registers. CRU READ/WRITE GRUB CRU interface base address. CRUR (offset.width) Read target CRU field. CRUW (offset,width,value); Write into target CRU field KEYWORDS ARG FORM THEN GE ARRAY FUNG TO GT BEGIN IF UNTIL HI BY LOC WHILE HIE CASE MOD AND LE DO NULL NANO LO ELSE OF OR LOE END PROC XOR LT ESCAPE REPEAT NOT NE FOR RETURN EO KEYWORD CONSTANTS I DO EXT 10 02 7"4 01 EXTEND MA 03 02 GRAPH MR REF 03 IAQ MW REL OBIN IAQX N REWIND DEF IDT OFF SEQ DIRECT ILLA ON UNLOAD EDGE IN OUT VDT EOF INT 00 y ETBN INV 01 9900 FAMILY SYSTEMS DESIGN 7-63 AMPL Program Development: Software Commands - REFERENCE DATA Description and Formats ERROR MESSAGES 0 - ! UNDEFINED ERROR CODE ! 1 - 110 ERROR, OS ERROR CODE RETURNED 2 - INSUFFICIENT MEMORY TO CONTINUE 3 - ! SEGMENT VIOLATION ! 4 - 1/0 ERROR: INVALID UNIT ID 5 -1/0 ERROR: READ/WRITE VIOLATION 6 -1/0 ERROR: INSUFFICIENT MEMORY FOR OPEN 7 - ! DELETE UNIT CONTROL BLOCKS ERROR ! 8 - TOO MANY IDT DEF /REF SYMBOLS IN LOAD 9 - EXCEEDED 15 LOAD OPERATIONS SINCE LAST CLR 10 - CANNOT ALLOCATE MEMORY FOR USER SYMBOL TABLE 11 - ! ERROR IN 1/0 UNIT CHAIN POINTERS! 12 - OVERLAY ERROR 101 - VARIABLE CANNOT BE READ 102 - VARIABLE CANNOT BE WRITTEN 103 - SYMBOL IS UNDEFINED 104 - ! INVALID CODEGEN BRANCH TABLE INDEX ! 105 - INSUFFICIENT MEMORY TO COMPILE STATEMENT . 106 - SYMBOL IS DEFINED; CANNOT BE REDEFINED 107 - INSUFFICIENT MEMORY TO COMPILE PROC/FUNC 108 - INPUT RECORD CANNOT BE CLASSIFIED 109 - INPUT STRING EXCEEDS MAXIMUM ALLOWED LENGTH 110 - ! INVALID SCANNER BRANCH TABLE INDEX ! _., 7 111 - UNRECOGNIZABLE INPUT ITEM 112 - ! UNDEFINED OPERATOR ! 114 - SYMBOL NOT AN IDT /DEF /REF LOAD SYMBOL 115 - USER SYMBOL TABLE FULL 116 - CONSTANT EXCEEDS 16 BITS 117 - SYNTAX ERROR 118 - ! INVALID KEYWORD STRING LENGTH ! 119 - SYNTAX ERROR IN ONE-L.INE-ASSEMBLY STATEMENT 120 - INCORRECT NUMBER OF ARRAY SUBSCRIPTS 121 - ESCAPE SPECIFIED OUTSIDE A LOOP CONSTRUCT 122 - ARRAY REDEFINED WITH INCORRECT SUBSCRIPTS NOTE: A hexadecimal number is also printed with some error messages. Refer to the AMPL System Operation Guide for complete explanation. 7-64 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - AMPL Description and Formats REFERENCE DATA ERROR MESSAGES 201 - SYMBOL NOT FOUND TO DELETE 202 - SYMBOL CANNOT BE DELETED 203 - INVALID DISPLAY FORMAT CHARACTER FOLLOWING: 204 - NO LIST DEVICE ASSIGNED 205 - EMULATOR 1/0 ERROR CODE RETURNED 209 - INVALID INDEX INTO EMULATOR TRACE BUFFER 210 - !CANNOT ALLOCATE FORM CURRENT VALUE SEGMENT! 211 - INSUFFICIENT MEMORY TO SAVE FORM PARAMETERS 214 - INVALID RESTORE FILE 215 - INSUFFICIENT MEMORY TO COMPLETE THE RESTORE 216 - BAD TRACE OR COMPARISON MODE SELECTED 219 - TRACE MODULE 1/0 ERROR CODE RETURNED 220 - CANNOT EDIT ON THIS DEVICE TYPE 221 - TRACE INTERFACE CHANGE ILLEGAL WHILE TRACING 222 - INVALID INDEX INTO TRACE MODULE BUFFER 223 - INSUFFICIENT ARGUMENTS IN PROC/FUNC CALL 224 - STACK OVERFLOW; DELETE PROC/FUNC/ ARRAY 225 - DELETED PROC/FUNC/ ARRAY REFERENCED 226 - INSUFFICIENT ARGUMENTS IN FORM FOR PROC/FUNC 227 - ! INVALID FORM SEGMENT ID ! 228 - ! INVALID FORM CURRENT VALUE SEGMENT ID ! 229 - INVALID CHARACTER IN LOAD FILE 230 - CHECKSUM ERROR IN LOAD FILE 231 - ARITHMETIC OVERFLOW 233 - PROC/FUNC CALL ARGUMENT OUT OF RANGE 234 - INVALID "ARG" OR "LOC" INDEX FOR WRITING 235 - INVALID "ARG" OR "LOC" INDEX FOR READING 237 - ARRAY ALREADY DEFINED 238 - INVALID ARRAY DIMENSION 240 - REFERENCE TO UNDECLARED ARRAY 241 - INVALID ARRAY SUBSCRIPT 242 - ! ERROR ARRAY SEGMENT LENGTH ! 243 - DELETED IDT I DEF I REF LOAD SYMBOL REFERENCED 244 - ALL IDT /DEF /REF LOAD SYMBOLS DELETED 245 - INVALID DEVICE TYPE TO "EINT" OR "TINT" NOTE: Error messages withing exclamation marks(!) are AMPL internal system errors. Contact Texas Instruments if problem persists. ·9900 FAMILY SYSTEMS DESIGN 7-65 POWER BASIC MP307 Program Development: Software Commands - POWER BASIC Description and Formats MP 307 REFERENCE CARD FOR DEVELOPMENT AND EVALUATION BASIC This card contains a summary of all POWER BASICt statements and commands for Development and Evaluation BASIC. An explanation preceded by an asterisk C') indicates the statement or command is not supported by Evaluation BASIC. A* indicates the statement is supported only by the Development BASIC software enhancement package. COMMANDS CONtinue ':'Execution continues from last break. LIST LIST the user's POWER BASIC program. In LIST will list from specified line number through end of program or until ESC key is struck. LOAD Reads a previously recorded POWER BASIC program from an auxiliary device or configures POWER BASIC to execute a BASIC program in EPROM. LOAD reads program from 733ASR digital cassette. LOAD 1 or LOAD 2 * reads program from audio cassette drive No. 1 or No. 2. LOAD
• configures POWER BASIC to execute BASIC program in EPROM at specified address. NEW Prepare for entry of NEW POWER BASIC program or set the lower RAM memory bound after auto-sizing. NEW clears pointers of POWER BASIC and prepares for entry of new program. NEW
':' sets the lower RAM memory bound used by POWER BASIC after auto-sizing or power-up. PROGRAM Program current POWER BASIC application program into EPROM. * 7...._ RUN Begin program execution at the lowest line number. SAVEn (n is interpreted as in LOADn command) Record current user program on auxiliary device. SIZE Display current program size, variable space allocated, and available memory in bytes. t Trademark of Texas Instruments 9900 FAMILY SYSTEMS DESIGN 7-67 POWER BASIC Program Development: Software Commands - MP 307 Description and Formats EDITING The phrase "(ctrl)" indicates that the user holds down the control key while depressing the key corresponding to the character immediately following. (CR) Enter edited line. (ctrl)ln ':'Insert n blanks. (ctrl)Dn ':'Delete n characters. (ctrl)H Backspace one character. (ctrl)F Forward space one character. ln(ctrl)E Display for editing source line indicated by line number (In). (ctrl)T Toggle from one partition to the other partition (only in Evaluation BASIC). (esc) Cancel input line or break program execution. (Rubout) or (DEL) Backspace and delete character. STATEMENTS lnBAUD ':'sets baud rate of serial 1/0 port(s). lnBASE <(exp)> Sets CRU base address for subsequent CRU operations lnCALL Name [, , , , ] ':'Transfers to external subroutines. If variable is contained in parentheses, the address will be passed; otherwise, the value will be passed. lnDATA {}[{}]··· defines internal data block. In DEF FN[( [, arg 2] [, arg 3])] = ':'Defines user arithmetic function. lnDIM [, .... ] Allocates user variable space for dimensioned or array variables. In END Terminates program execution and returns to edit mode. In ERROR< In> ':'Specifies a subroutine that will be called via a GOSUB statement when an error occurs. In ESCAPE lnNOESC ':'Enables or disables the excape key to interrupt program execution (always enabled in Evaluation BASIC). 7-68 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - · POWER BASIC Description and Formats MP307 lnFOR = TO [STEP ] lnNEXT Open and close program loop. Both identify the same control variable. FOR assigns starting, ending, and optionally stepping values. lnGOSUB Transfer of control to an internal subroutine beginning at the specified line. In POP •:•Removal of most previous return address from GOSUB stack without an execution transfer. In RETURN Return from internal subroutine. lnGOTO Transfers program execution to specified line number. lnlF THEN In ELSE< statement> Causes conditional execution of the statement following THEN. ':'ELSE statements execute when IF condition is false. In IMASK< LEVEL> •:•Set interrupt mask of TMS 9900 processor to specified level. In TRAP< level> TO< In> •:•Assign interrupt level to interrupt subroutine. lnlRTN •:•Return from BASIC interrupt service routine. lnlNPUT ~var> [{}var> l ···[UJ Accesses numeric constants and strings from the keyboard into variables in the INPUT list. In [LET] = Evaluates and assigns values to variables or array elements. lnON { J THEN GOTO In [,In] ... lnON { } THEN GOSUB In [,In] ... •:•Transfers execution to the line number specified by the expression or variable. lnPRINT [,exp] ... Print (format free) the evaluated expressions. lnRANDOM [exp] •:•set the seed to the specified expression value. 1 READ {J [' { n j lJ ... Assigns values from the internal data list to variables or array elements. 9900 FAMILY SYSTEMS DESIGN 7-69 POWER BASIC Program Development: Software Commands - MP 307 Description and Formats lnREM [text] lnser~s comments. lnRESTOR [exp] Without an argument, resets pointer to beginning of data sequence; with an argument, resets pointer to line number specified. lnSTOP Terminates program execution and returns to Edit mode. lnTIME Sets, displays, or stores the 24 hour time of day clock. lnTIME , , Sets and starts clock. lnTIME Enables storing clock time into a string variable. In TIME Prints clock time as HR:MN:SD. lnUNIT ':'Designates device(s) to receive all printed output. FUNCTIONS ABS <(exp)> ':'Absolute value of expression. ASC <(string-var)> ':'Returns decimal ASCII code for first character of string variable. ATN <(exp)> Arctangent of expression in radians. BIT <(var, exp)> ':'Reads or modifies any bit within· a variable. BIT <(var, exp 1)> = Returns a 1 if bit is set and O if not set. Selected bit is set to 1 if assigned value is non-zero and to zero if the assigned value is zero . ..... 7 COS >(exp)> Cosine of the expression in radians. CRB <(exp)> Reads CRU bit as selected by CRU base+ exp. Exp is valid for - 127 thru 128. CRB <(exp 1)> =<(exp 2)> Sets or resets CRU bit as selected by CRU base+ exp 1. If exp 2 is non-zero, the bit will be set, else reset. Exp 1 is valid for - 127 thru 128. CRF <(exp)> Reads n CRU bits as selected by CRU base where exp evaluates to n. Exp·is valid for O thru 15. If exp= 0, 16 bits will be read. CRF <(exp 1)>=<(exp 2)> Sfores exp 1 bits of exp 2 to CRU lines as selected by CRU BASE. Exp 1 if valid for 0 thru 15. If exp 1 = 0, 16 bits will be stored. EXP <(exp)> ':'Raise the constant e to the power of the evaluated expression. INP <(exp)> Returns the signed integer portion of the expression. 7-70 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands - POWER BASIC Description and Formats MP 307 LOG <(exp)>. ':'Returns natural logarithm of the expression. MEM <(exp)> Reads byte from user memory at address specified by exp. Exp must be in the integer range, (0 to 65535). MEM <(exp 1)> =<(exp 2)> Stores byte exp 2 into user memory specified by exp 1. Exp 1 and exp 2 must be in the integer range. MCH <(string 1), (string 2)> ':'Returns the number of characters to which the two strings agree. NYK <(exp)> Conditionally samples the keyboard in run time mode. If exp < >0, return decimal value of last key struck and clear key register. (0 if no key struck.) If exp= 0, return a 1 if the last key struck has the same decimal value as the expression. Clear key register if TRUE, else return 0 if FALSE. RND Returns a random number between O and 1. SIN <(exp)> Sine of the expression in radians. SOR <(exp)> Square root of expression. SRH <(string 1), (string 2)> ':'Return the position of string 1 in string 2, O if not found. SYS <(exp)> ':'Obtains system parameters generated during program execution. Example: SYS(O) =INPUT control character, SYS(1) =Error code number, SYS(2) =error line number. TIC <(exp)> Returns the number of time tics less the expression value. One TIC equals 40 milliseconds (1 /25 second). STRINGS ASCII Character ASC (string-var) Conversion Function ':'Convert first character of string to ASCII numeric representation. . { } Assignment = Store string into string-var ending with a null. Character Match MCH (, ) Function ':'Return the number of characters to which the 2 strings agree. Character Search SRH (, ) Function ':'Return the position of string 1 in string 2. Zero is returned if not found. Concatenate = { } +{ }[+ {·. ·}] 9900 FAMILY SYSTEMS DESIGN 7-71 POWER BASIC Program Development: Software Commands - MP 307 Description and Formats Convert to ASCII = = #, ':'Convert exp to ASCII characters ending with a null. # string specifies a formatted conversion. Convert to Binary =, •:•convert string into binary equivalent. Var 2 receives the delimiting non-numeric character in first byte. Deletion = / •:•Delete exp characters from string-var. Insertion =I ':'Pick byte into string-var. . { } . Pick = ' Pick number of characters specified by exp into string-var ending with a nulL Replace = { } . ' Replace number of characters specified by exp of string-var with string. String Length = LEN <(string-var)> Function =LEN "string" ':'Return the length of string. INPUT OPTIONS string-var Prompt with colon and Input character data. Example: INPUT $A .... 7 Delimit expressions. Example A, B Suppress prompting or CR LF if at end of line. Examples: INPUT ;A INPUT A; #exp Allow a maximum of exp characters to be entered. Example: INPUT # 1 "Y or N';$1 %exp •:•Must enter exactly exp number of characters. Example: INPUT %4"CODE"C ? ::•upon an invalid input or entry of a control character, a GOSUB is performed to the line #. SYS(O) will be equal to - 1 if there was an invalid input. Otherwise, SYS(O) will equal the decimal equivalent of the control character. Example: INPUT ?1 OO;A 7-72 9900 FAMILY SYSTEMS DESIGN Program Development: POWER BASIC Software Commands - Description and Formats MP 307 OUTPUT OPTIONS Delimit expressions or suppress CR LF if at end of line. Examples: PRINT A; B PRINT A; Tab to next print field. Example: PRINT A, B TAB <(exp)> Tab to exp column. Example: PRINT TAB (50);A string Print string or string-var. Example: PRINT "Hl";$A(O) #exp ':'Print exp as hexadecimal in free format. Example: PRINT # 123 #,exp ':'Print exp as hexadecimal in byte format. Example: PRINT # ,50 #;exp ':'Print exp as hexadecimal in word format. Example: PRINT # ,A ':'Direct output of ASCII codes. Example: PRINT " " #string *Print under specified format where: PRINT # "9999"1 9 =digit holder PRINT # "000-00-0000"SS O= digit holder or force 0 PRINT # "$$$,$$$.OO"DLR $ = digit holder and floats $ PRINT # "SSS.0000"4':'ATN1 S =digit holder and floats sign PRINT #"<<<.00>"1 < =digit holder and float on negative >number PRINT # "990.99E"N E = sign holder after decimal PRINT # "990.99"N . =decimal point specifier PRINT # "999,990.99"N , =suppressed if before significant digit PRINT # "999,990/\ 00"1 /\ =translates to decimal point PRINT #"HI= 99"1 any other character is printed. 9900 FAMILY SYSTEMS DESIGN 7-73 POWER BASIC Program Development: Software Commands- MP 307 Description and Formats GENERAL INFORMATION ARITHMETIC OPERATIONS A=B Assignment A-B Negation or subtraction A+ B, $A+ $B Addition or string concatenation NB Multiplication A/B Division AAB Exponentiation -A Unary Minus +A Unary Plus LOGICAL OPERATORS LNOT A ':'1 's complement of integer. ALAND B ':'Bit wise AND. ALOR B ':'Bit wise OR. ALXOR B ':'Bit wise exclusive OR. RELATIONAL OPERATORS 1 ifTRUE and 0 if FALSE A=B TRUE if equal, else FALSE. A= =B ':'TRUE if approximately equal (1 E-7), else FALSE AB TRUE if greater than, else FALSE. A>=B TRUE if greater than or equal, else FALSE. A<>B TRUE if not equal, else FALSE. NOTA ':'TRUE if zero, else FALSE. AAND B ':'TRUE if both non-zero, else FALSE. AOR B ':'TRUE if either non-zero, else FALSE. OPERATOR PRECEDENCE 1. Expressions in parentheses 7. =,> 2. Exponentiation and negation 8. = =, LXOR 3. ':',/ 9. NOT, LNOT 4. + - 10. AND, LAND ' 5. <=,<> 11 . OR, LOR 6. >=,< 12. (=)ASSIGNMENT 7-74 9900 FAMILY SYSTEMS DESIGN Program Development: Software Commands- POWER BASIC Description and Formats MP307 SPECIAL CHARACTERS Separates statements typed on same line. Tail remark used for comments after program statement Equivalent to PRINT. ERROR CODES 1= SYNTAX ERROR 37= ILLEGAL DELIMITER 2= UNMATCHED PARENTHESIS 38= UNDEFINED FUNCTION 3= INVALID LINE NUMBER 39= UNDIMENSIONED VARIABLE 4= ILLEGAL VARIABLE NAME 40= UNDERFINED VARIABLE 5= TOO MANY VARIABLES 41 = EXPANSION EPROM NOT INSTALLED 6= ILLEGAL CHARACTER 42= INTERRUPT W /0 TRAP 7= EXPECTING OPERATOR 43= INVALID BAUD RATE 8= ILLEGAL FUNCTION NAME 44= TAPE READ ERROR 9= ILLEGAL FUNCTION ARGUMENT 45= EPROM VERIFY ERROR 10= STORAGE OVERFLOW 46= INVALID DEVICE NUMBER 11 = STACK OVERFLOW 12 = STACK UNDERFLOW 13 = NO SUCH LINE NUMBER 14 = EXPECTING STRING VARIABLE 15 = INVALID SCREEN COMMAND 16 = EXPECTING DIMENSIONED VARIABLE 17 = SUBSCRIPT OUT OF RANGE 18 = TWO FEW SUBSCRIPTS 19 = TOO MANY SUBSCRIPTS 20 = EXPECTING SIMPLE VARIABLE 21 = DIGITS OLJT OF RANGE (0< # of digits < 12) 22 = EXPECTING VARIABLE 7"'4 23 = READ OUT OF DATA 24 = READ TYPE DIFFERS FROM DATA TYPE 25 = SQUARE ROOT OF NEGATIVE NUMBER 26 = LOG OF NON-POSITIVE NUMBER 27 = EXPRESSION TOO COMPLEX 28 = DIVISION BY ZERO 29 = FLOATING POINT OVERFLOW 30 ==:; FIX ERROR 31 :::;: FOR WITHOUT NEXT 32 = NEXT WITHOUT FOR 33 = EXP FUNCTION HAS INVALID ARGUMENT 34 = UNNORMALIZED NUMBER 35 = PARAMETER ERROR 36 = M!SSING ASSIGNMENT OPERATOR 9900 FAMILY SY~TEMS DESIGN 7-75 Cross Support ..-7 Program Development: Software Commands - ASSEMBLER FILES Description and Formats The Cross Assembler data base which is assigned to PUNIT, is read by the FORTRAN program as the first file at execution time. It is the actual Cross Assembler program written in internal code, and it is suggested that it be assigned to a permanent disk file. INTERNAL DEFAULT DEVICE RECORD NAME UNIT TYPE LENGTH FUNCTION IUNIT 5 CR,CS 80 TMS 9900 Source Input MT,DF LUNIT 6 CS,MT 80 Listing Output OUNIT 7 CS,MT 80 TMS9900 Object Output SUNIT 10 MT,DF 80 Assembly Scratch PUNIT 11 CR,CS 80 Data Base INPUT CR-CARD READER; CS-CASSETTE TAPE; MT -MAGNETIC TAPE; DF-DISKFILE; CP- CARD PUNCH; LP-LINE PRINTER CROSS ASSEMBLER SYSTEM FILES 7"4 I 9900 FAMILY SYSTEMS DESIGN 7-77 ASSEMBLER DIRECTIVES Program Development: Software Commands - Description and Formats AORG places the expression value in the location counter, and defines the succeeding locations as absolute. ABSOLUTE ORIGIN AORG Syntax Definition: [