MC68020UM[ADI) @ ~ MC68020 ~ 32-Bit Microprocessor ~ User's Manual ® MOTOROLA ® MOTOROLA MC68020 32-BIT MICROPROCESSOR USER'S MANUAL ® MOTOROLA MC68020 32-BIT MICROPROCESSOR USER'S MAN UAL PRENTICE-HALL, Inc., Englewood Cliffs, N.J. 07632 ISBN 0-13-541418-0 ISBN 0-13-541467-9 (Limited ed.) Editorial/production supervision: Barbara A. Cassel Manufacturing buyer: Gordon Osbourne © 1984 by Motorola Inc. All rights reserved. No part. of this book may be reproduced in any form or by any means without permission in writing from the publisher. This document contains information on a new product. Specifications and information herein are subject to change without notice. Motorola reserves the right to make changes to any products herein to improve functioning or deSign. Although the information in this document has been carefully reviewed and is believed to be reliable, Motorola does not assume any liability arising out of the application or use of any product or circuit described herein; neither does it convey any license under its patent righ·ts nor the rights of others. Motorola, Inc. general policy does not recommend the use of its components in life support ap- plications where in a failure or malfunction of the component may directly threaten life or injury. Per Motorola Terms and Conditions of Sale, the user of Motorola components in life support ap- plications assumes all risk of such use and indemnifies Motorola against all damages. Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 ISBN 0-13-541418-0 ISBN 0-13-541467-9 {LIMITED ED.} 01 Prentice-Hall International Inc., London Prentice-Hall of Australia Pty. Limited, Sydney Prentice-Hall do Brasil, Ltda., Rio de Janiero Prentice-Hall Canada Inc., Toronto Prentice-Hall of India Private Limited, New Delhi Prentice-Hall of Japan, Inc., Tokyo Prentice-Hall of Southeast Asia Pte. Ltd., Singapore Whitehall Books Limited, Wellington, New Zealand TABLE OF CONTENTS Paragraph Page Number Title Number Section 1 Introduction 1.1 Data Types and Addressing Modes ........................... . 1-4 1.2 Instruction Set Overview .................................... . 1-5 1.3 Virtual Memory/Machine Concepts ........................... . 1-7 1.3.1 Virtual Memory ........................................ . 1-7 1.3.2 Virtual Machine ........................................ . 1-7 1.4 Pipelined Architecture ...................................... . 1-B Section 2 Data Organization and Addressing Capabilities 2.1 Operand Size .............................................. . 2-1 2.2 Data Organization in Registers ............................... . 2-1 2.2.1 Data Registers ......................................... . 2-1 2.2.2 Address Registers ...................................... . 2-2 2.2.3 Control Registers ...................................... . 2-2 2.3 Data Organization in Memory ................................ . 2-2 2.4 Instruction Format ......................................... . 2-4 2.5 Program/Data References ................................... . 2-5 2.6 Addressing ................................................ . 2-5 2.7 Registers: Notation Conventions ............................. . 2-5 2.B Effective Address .......................................... . 2-6 2.B.1 Register Direct Modes .................................. . 2-6 2.B.1.1 Data Register Direct ................................ . 2-6 2.8.1.2 Address Register Direct ............................. . 2-7 2.B.2 Register Indirect Modes ................................. . 2-7 2.B.2.1 Address Register Indirect ........................... . 2-7 2.B.2.2 Address Register Indirect with Postincrement .......... . 2-7 2.B.2.3 Address Register Indirect with Predecrement ........... . 2-B 2.8.2.4 Address Register Indirect with Displacement ........... . 2-B 2.B.3 Register Indirect with Index Modes ....................... . 2-B 2.B.3.1 Address Register Indirect with Index (B-Bit Displacement) . 2-9 2.B.3.2 Address Register Indirect with Index (Base Displacement) . 2-9 2.B.4 Memory Indirect ....................................... . 2-10 2.8.4.-; Memory indirect Po~i-indexed ........................ . ,., &"-1 ~ ~ I 2.B.4.2 Memory Indirect Pre-Indexed ......................... . 2-12 2.B.5 Program Counter Indirect with Displacement Mode .......... . 2-13 2.8.6 Program Counter Indirect with Index Modes ................ . 2-13 2.B.6.1 PC Indirect with Index (B-Bit Displacement) ............. . 2-14 v TABLE OF CONTENTS (Continued) Paragraph Page Number Title Number 2.8.6.2 PC Indirect with Index (Base Displacement) ............ . 2-14 2.8.7 Program Counter Memory Indirect Modes .................. . 2-15 2.8.7.1 Program Counter Memory Indirect Post-Indexed ........ . 2-16 2.8.7.2 Program Counter Memory Indirect Pre-Indexed ......... . 2-17 2.8.8 Absolute Address Modes ................................ . 2-18 2.8.8.1 Absolute Short Address ............................. . 2-18 2.8.8.2 Absolute Long Address ............................. . 2-18 2.8.9 Immediate Data: ....................................... . 2-19 2.9 Effective Address Encoding Summary ......................... . 2-19 2.10 System Stack .............................................. . 2-20 2.11 User Program Stacks ....................................... . 2-21 2.12 Queues ................................................... . 2-22 Section 3 Instruction Set Summary 3.1 Data Movement ............................................ . 3-2 3.2 Integer Arithmetic Operations ................................ . 3-2 3.3 Logical Operations ......................................... . 3-4 3.4 Shift and Rotate Operations ................................. . 3-4 3.5 Bit Manipulation Operations ................................. . 3-5 3.6 Bit Field Operations ........................................ . 3-6 3.7 Binary Coded Decimal Operations ............................ . 3-6 3.8 Program Control Operations ................................. . 3-7 3.9 System Control Operations .................................. . 3-8 3.10 Multiprocessor Operations .................................. . 3-9 Section 4 Signal Description 4.1 Function Code Signals (FCO through FC2) ...................... . 4-2 4.2 Address Bus (AO through A31) ................................ . 4-2 4.3 Data Bus (DO through D31) ................................... . 4-2 4.4 Transfer Size (SilO, Sll1) .................................... . 4-2 4.5 Asynchronous Bus Control Signals ........................... . 4-2 4.5.1 External Cycle Start (ECS) ............................... . 4-2 4.5.2 Operand Cycle Start (OCS) ............................... . 4-3 4.5.3 Read-Modify-Write Cycle (RMC) .......................... . 4-3 4.5.4 Address Strobe (AS) .................................... . 4-3 4.5.5 Data Strobe (DS) ....................................... . 4-3 4.5.6 Read/Write (R/W) ....................................... . 4-3 4.5.7 Data Buffer Enable (DB EN) .............................. . 4-3 4.5.8 Data Transfer and Size Acknowledge (DSACKO, DSACK1) ..... . 4-3 4.6 Cache Disable (CDIS) ....................................... . 4-4 vi TABLE OF CONTENTS (Continued) Paragraph Page Number Title Number 4.7 Interrupt Control Signals .................................... . 4-4 4.7.1 Interrupt Priority level (IPlO, IPl1, IPl2) ................... . 4-4 4.7.2 Interrupt Pending (lPEND) ............................... . 4-4 4.7.3 Autovector (AVEC) ..................................... . 4-4 4.8 Bus Arbitration Signals ..................................... . 4-4 4.8.1 Bus Request (BR) ...................................... . 4-4 4.8.2 Bus Grant (BG) ......................................... . 4-4 4.8.3 Bus Grant Acknowledge (BGACK) ......................... . 4-5 4.9 Bus Exception Control Signals ............................... . 4-5 4.9.1 Reset (RESET) ......................................... . 4-5 4.9.2 Halt (HALT) ........................................... . 4-5 4.9.3 Bus Error (BERR) ....................................... . 4·5 4.10 Clock (ClK) ........................ " ...................... . 4·6 4.11 Signal Summary ........................................... . 4·6 Section 5 Bus Operation 5.1 Operand Transfer Mechanism .......................... " ..... . 5·2 5.1.1 Dynamic Bus Sizing .......................... " ......... . 5-2 5.1.2 Misalignment of Bus Transfers .......... " ................ . 5-10 5.1.3 Effects of Dynamic Bus Sizing and Operand Misalignment .... . 5·14 5.1.4 Address, Size, and Data Bus Relationships ................. . 5-16 5.2 Bus Operation ............................................. . 5-18 5.2.1 Read Cycles ........................................... . 5·18 5.2.2 Write Cycle ........................................... . 5-22 5.2.3 Read-Modify-Write Cycle ................................ . 5-22 5.2.4 CPU Space Cycles ..................................... . 5-26 5.2.4.1 Interrupt Operation ................................. . 5·26 5.2.4.1.1 Interrupt levels ................................ . 5-26 5.2.4.1.2 Recognition of Interrupts ........................ . 5-27 5.2.4.1.3 Interrupt Acknowledge Sequences (lACK) .......... . 5-27 5.2.4.1.4 Spurious Interrupt .............................. . 5-31 5.2.4.1.5 lACK Generation ............................... . 5-31 5.2.4.2 Breakpoint Acknowledge Cycle ...................... . 5-31 5.2.4.3 Coprocessor Operations ................. " .......... . 5-34 5.2.5 Bus Error and Halt Operation ............................ . 5-34 5.2.5.1 Bus Error Operation ................................ . 5·34 5.2.5.2 Retry Operation .................................... . 5-35 5.2.5.3 Hail Opefalion ..................................... . 5.2.5.4 Double Bus Faults .................................. . 5-39 5.2.6 Reset Operation ....................................... . 5-41 5.2.7 Bus Arbitration ........................................ . 5-42 vii TABLE OF CONTENTS (Continued) Paragraph Page Number Title Number 5.2.7.1 Requesting the Bus ................................. . 5-46 5.2.7.2 Receiving the Bus Grant ............................. . 5-46 5.2.7.3 Acknowledgement of Mastership ..................... . 5-46 5.2.7.4 Bus Arbitration Control ............................. . 5-47 5.2.8 The Relationship of DSAGK, BERR, and HALT .............. . 5-49 5.2.9 Asynchronous versus Synchronous Operation .............. . 5-50 5.2.9.1 Asynchronous Operation ............................ . 5-50 5.2.9.2 Synchronous Operation ............................. . 5-51 Section 6 Processing States 6.1 Privilege States ............................................ . 6-1 6.1.1 Use of Privilege States .................................. . 6-2 6.1.2 Supervisor States ...................................... . 6-2 6.1.3 UserState ............................................ . 6-3 6.1.4 Change of Privilege State ................................ . 6-3 6.1.5 Address Space Types ................................... . 6-4 6.1.6 CPU Space ............................................ . 6-4 6.2 Exception Processing ....................................... . 6-4 6.2.1 Exception Vectors ...................................... . 6-5 6.2.2 Exception Stack Frame ................................. . 6-6 6.2.3 Exception Types ....................................... . 6-6 6.2.4 Exception Processing Sequence .......................... . 6-7 6.2.5 Multiple Exceptions .................................... . 6-7 6.3 Exception Processing: Detail ................................ . 6-8 6.3.1 Reset ................................................ . 6-8 6.3.2 Address Error .......................................... . 6-9 6.3.3 Bus Error ............................................. . 6-9 6.3.4 Instruction Traps ....................................... . 6-10 6.3.5 Breakpoints ........................................... . 6-10 6.3.6 Format Error .......................................... . 6-11 6.3.7 Illegal or Unimplemented Instructions ..................... . 6-11 6.3.8 Privilege Violations ......................... , ........... . 6-12 6.3.9 Tracing ............................................... . 6-13 6.3.10 Interrupts ............................................. . 6-14 6.3.11 Return From Exception ................................. . 6-15 6.4 Bus Fault Recovery ......................................... . 6-16 6.4.1 Special Status Word .................................... . 6-17 6.4.2 Completing the Bus Cycle(s) ............................. . 6-17 6.4.2.1 Completing the Bus Cycle(s) via Software .............. . 6-18 6.4.2.2 Completing the Bus Cycle(s) via RTE .................. . 6-19 6.5 MC68020 Exception Stack Frames ............................ . 6-19 viii TABLE OF CONTENTS (Continued) Paragraph Page Number Title Number 6.5.1 Normal Four Word Stack Frame .......................... . 6·19 6.5.2 Throwaway Four Word Stack Frame ....................... . 6-19 6.5.3 Normal Six Word Stack Frame ........................... . 6·20 6.5.4 Coprocessor Mid-Instruction Exception Stack Frame ........ . 6-20 6.5.5 Short Bus Cycle Fault Stack Frame ....................... . 6-21 6.5.6 Long Bus Cycle Fault Stack Frame ........................ . 6-22 6.5.7 Stack Frame Summary .................................. . 6-23 Section 7 On·Chip Cache Memory 7.1 Cache Design and Operation ................................. . 7-1 7.1.1 On-Chip Cache Organization ............................. . 7-1 7.1.2 Cache Control ......................................... . 7-2 7.1.2.1 Cache Control Register ............................. . 7-2 7.1.2.2 E - Enable Cache ................................. . 7-3 7.1.2.3 F - Freeze Cache .................................. . 7-3 7.1.2.4 CE - Clear Entry .................................. . 7-3 7.1.2.5 C - Clear Cache ................................... . 7-3 7.2 Cache Address Register ..................................... . 7-3 7.3 Cache Disable Input ........................................ . 7-4 7.4 Cache Initialization ......................................... . 7-4 Section 8 Coprocessor Interface Description 8.1 The Coprocessor Concept ................................... . 8-1 8.2 Coprocessor States ........................................ . 8-1 8.3 Coprocessor Operations .................................... . 8-2 8.4 Coprocessor BusDefinition .................................. . 8-3 8.4.1 Use of Signals ......................................... . 8-3 8.4.2 Timing ............................................... . 8-3 8.4.3 I nterprocessor Transfers ................................ . 8-4 8.4.3.1 Processor·to·Coprocessor Transfer (Write) ............. . 8-4 8.4.3.2 Coprocesor to Processor Transfer (Read) .............. . 8-4 8.5 Coprocessor Interface Registers ............................. . 8-5 8.5.1 Response Register ($00) ................................. . 8-6 8.5.2 Control Register ($02) ................................... . 8-7 8.5.3 Save Register ($04) ..................................... . 8-7 8.5.4 Restore Register ($06) ................................... . 8-7 8.5.5 Operation Word Register ($08) ............................ . 8-7 8.5.6 Command Word Register ($OA) ........................... . 8-7 8.5.7 Condition Register ($OE) ................................. . 8-8 8.5.8 Operand Register ($10) .................................. . 8-8 ix TABLE OF CONTENTS (Continued) Paragraph Page Number Title Number 8.5.9 Register Selector ($14) .................................. . 8-8 8.5.10 Instruction Address Register ($18) ........................ . 8-8 8.5.11 Operand Address Register ($1 C) .......................... . 8-9 8.6 Coprocessor Instructions ................................... . 8-9 8.6.1 General Instruction ..................................... . 8-9 8.6.2 Conditional Instructions ................................ . 8-9 8.6.2.1 Branch Instructions ................................ . 8-10 8.6.2.2 Condition Type Instructions ......................... . 8-10 8.6.3 System Control Instructions ............................. . 8-12 8.6.3.1 Coprocessor Save Instruction ........................ . 8-12 8.6.3.2 Coprocessor Restore Instruction ..................... . 8-12 8.7 Primitives/Response ........................................ . 8-13 8.7.1 Response Register: Detail ............................... . 8-14 8.7.2 Instruction Scanning ................................... . 8-15 8.8 Primitive Set .....' ......................................... . 8-16 8.8.1 Busy ................................................. . 8-16 8.8.2 Null (No Operands) ..................................... . 8-17 8.8.3 Transfer Operation Word ................................ . 8-17 8.8.4 Transfer Instruction Stream .............................. . 8-18 8.8.5 Supervisor Check ...................................... . 8-18 8.8.6 Take Exception ......... , .............................. . 8-18 8.8.6.1 Take Pre-Instruction Exception ....................... . 8-18 8.8.6.2 Take Mid-Instruction Exception ...................... . 8-19 8.8.6.3 Take Post-Instruction Exception ...................... . 8-20 8.8.7 Evaluate and Transfer Effective Address ................... . 8-20 8.8.8 Evaluate Effective Address and Transfer Data .............. . 8-20 8.8.9 Write to Previously Evaluated Effective Address ............ . 8-21 8.8.10 Take Address and Transfer Data .......................... . 8-22 8.8.11 Transfer To/From Top of Stack ........................... . 8-22 8.8.12 Transfer Registers ..................................... . 8-23 8.8.12.1 Transfer Single Main Processor Register ............... . 8-23 8.8.12.2 Transfer Main Processor Control Register .............. . 8-23 8.8.12.3 Transfer Multiple Main Processor Registers ............ . 8-23 8.8.12.4 Transfer Multiple Coprocessor Registers .............. . 8-24 8.8.13 Transfer Status Register and Program Counter ............. . 8-25 8.9 Coprocessor Interface Protocol: Detail ........................ . 8-25 8.9.1 Coprocessor Operands ................................. . 8-25 8.9.1.1 Coprocessor Types ................................. . 8-25 8.9.1.2 Operands To/From Memory .......................... . 8-26 8.9.1.2.1 Non-DMA Coprocessor .......................... . 8-26 8.9.1.2.2 DMA Coprocessor .............................. . 8-26 8.9.2 Operands To/From Processor Registers ................... . 8-26 8.10 General Type Instruction Protocol ............................ . 8-27 x TABLE OF CONTENTS (Continued) Paragraph Page Number Title Number 8.11 General and Conditional Instruction Termination ................ . 8·28 8.12 Coprocessor Internal State Frame ............................ . 8·29 8.13 Save Instruction Protocol .................................... . 8·30 8.14 Restore Instruction Protocol ................................. . 8·31 8.15 Exception Processing ....................................... . 8·31 8.15.1 Coprocessor Detected Exceptions ........................ . 8·32 8.15.2 Coprocessor Internal Exceptions ......................... . 8·32 8.15.2.1 Protocol Violation .................................. . 8·33 8.15.2.2 Illegal Commands and Conditions .................... . 8·33 8.15.2.3 Data Processing Related Exceptions .................. . 8·33 8.15.3 Coprocessor External Exceptions ........................ . 8·34 8.16 Main Processor Detected Exceptions ......................... . 8·34 8.16.1 Protocol Violation ...................................... . 8·34 8.16.2 Illegal Instruction ...................................... . 8·34 8.16.3 Trace ................... "................... '" ........ . 8·34 8.16.4 Interrupts ............................................. . 8·35 8.16.5 Address Error, Bus Error ................................. . 8·35 8.17 RESET ................................................... . 8·35 8.18 Coprocessor Instruction and Primitive Formats ................. . 8·36 8.18.1 Coprocessor Instructions ............................... . 8·36 8.18.2 Coprocessor Primitives ................................. . 8·37 Section 9 Instruction Execution Timing 9.1 Timing Estimation Factors .................................. . 9·1 9.1.1 Instruction Cache and Prefetch .......................... . 9·1 9.1.2 Operand Misalignment .................................. . 9·2 9.1.3 Concurrency .......................................... . 9·2 9.1.4 Overlap ............................................... . 9·2 9.1.5 Instruction Stream Timing Examples ...................... . 9·3 9.2 Instruction Timing Tables ................................... . 9·8 9.2.1 Fetch Effective Address ................................. . 9·11 9.2.2 Fetch Immediate Effective Address ....................... . 9·11 9.2.3 Calculate Effective Address ............................. . 9·13 9.2.4 Calculate Immediate Effective Address .................... . 9·13 9.2.5 Jump Effective Address ................................. . 9·15 9.2.6 MOVE Instruction ...................................... . 9·15 9.2.7 Special Purpose MOVE Instruction ........................ . 9·21 9.2.8 ArithmeticiLogicai Operations ........................... . 9·22 9.2.9 Immediate Arithmetic/Logical Operations .................. . 9·22 9.2.10 Binary Coded Decimal Operations ........................ . 9·23 9.2.11 Single Operand Instructions ............................. . 9·24 9.2.12 Shift/Rotate Instructions ................................ . 9·24 xi TABLE OF CONTENTS (Concluded) Paragraph Page Number Title Number 9.2.13 Bit Manipulation Instructions ............................ . 9-25 9.2.14 Bit Field Manipulation Instructions ....................... . 9-26 9.2.15 Conditional Branch Instructions .......................... . 9-26 9.2.16 Control Instructions .................................... . 9-27 9.2.17 Exception Related Instructions ........................... . 9-28 9.2.18 Save and Restore Operations ............................ . 9-28 Section 10 Electrical Specifications 10.1 Maximum Ratings .......................................... . 10-1 10.2 Thermal Characteristics - PGA Package ...................... . 10-1 10.3 Power Considerations ...................................... . 10-1 10.4 DC Electrical Characteristics ................................ . 10-2 10.5 Preliminary AC Electrical Characteristics - Clock Input ......... . 10-3 10.6 AC Electrical Characteristics - Read and Write Cycles .......... . 10-4 10.7 AC Electrical Characteristics - Typical Capacitance Derating Curves ........................................ . 10-6 Section 11 Ordering Information and Mechanical Data 11.1 Standard MC68020 Ordering Information ...................... . 11-1 11.2 Package Dimensions and Pin Assignment ..................... . 11-2 APPENDICES A Condition Codes Computation ............................... . A-1 B Instruction Set ............................................. . B-1 C Instruction Format Summary ................................ . C-1 D Advanced Topics ........................................... . D-1 E MC68020 Extensions to M68000 Family ........................ . E-1 xii LIST OF ILLUSTRATIONS Figure Page Number Title Number 1·1 MC68020 Block Diagram .................................... . 1·2 1·2 User Programming Model ................................... . 1·3 1·3 Supervisor Programming Model Supplement ................... . 1·3 1·4 Status Register ............................................ . 1·4 1·5 MC68020 Pipeline .......................................... . 1·9 2·1 Memory Operand Addressing ................................ . 2·3 2·2 Memory Data Organization .................................. . 2·3 2·3 Instruction Word General Format ............................. . 2·5 2·4 Single·Effective·Address Instruction Operation Word ............ . 2·6 4·1 Functional Signal Groups ................................... . 4·1 5·1 Relationship Between External and Internal Signals ............. . 5·1 5·2 Sample Window ........................................... . 5·2 5·3 MC68020 Interface to Various Port Sizes ....................... . 5·3 5·4 Internal Operand Representation ............................. . 5·4 5·5 Example of Long Word Transfer to Word Bus ................... . 5·6 5·6 Long Word Operand Write Timing (16·Bit Data Port) .............. . 5·7 5·7 Example of Long Word Transfer to Byte Bus .................... . 5·8 5·8 Long Word Operand Write Timing (8·Bit Data Port) ............... . 5·9 5·9 Misaligned Long Word Transfer to Word Bus Example ........... . 5·10 5·10 Misaligned Long Word Transfer to Word Bus ................... . 5·11 5·11 Example of Misaligned Word Transfer to Word Bus .............. . 5·12 5·12 Misaligned Word Transfer to Word Bus ........................ . 5·13 5·13 Misaligned Long Word Transfer to Long Word Bus ............... . 5·14 5·14 Misaligned Write Cycles to 32·Bit Data Port .................... . 5·15 5·15 Byte Data Select Generation for 16· and 32·Bit Ports ............. . 5·17 5·16 Long Word Read Cycle Flowchart ............................. . 5·18 5·17 Long·Word Read Cycle Timing (32·Bit Data Port) ................ . 5·19 5·18 Byte Read Cycle Flowchart .................................. . 5·20 5·19 Byte and Word Read Cycle Timing (32·Bit Data Port) ............. . 5·21 5·20 Write Cycle Flowchart ...................................... . 5·22 5·21 Byte and Word Write Cycle Timing (32·Bit Data Port) ............. . 5·23 5·22 Read·iviodify·Wriie Cycie Fiowc/iaft ........................... . 5·23 Read·Modify·Write Cycle Timing (32·Bit Port, CAS Instruction) ..... . 5·25 5·24 MC68020 CPU·Space Address Encoding ....................... . 5·26 5·25 Interrupt Acknowledge Sequence Flowchart .................... . 5·28 xiii LIST OF ILLUSTRATIONS (Continued) Figure Page Number Title Number 5-26 Interrupt Acknowledge Cycle Timing. . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29 5-27 Autovector Operation Timing ................................. 5-30 5-28 MC68020 Breakpoint Operation Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . 5-31 5-29 Breakpoint Acknowledge Cycle Timing (Opcode Returned). . . . . . . . . 5-32 5-30 Breakpoint Acknowledge Cycle Timing (Exception Signalled) ...... 5-33 5-31 Bus Error Timing (Exception Taken) . . . . . . . . . . . . . . . . . . . . . . . . . . .. 5-35 5-32 Delayed Bus Error (Exception Taken) . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-36 5-33 Bus Cycle Retry Timing ...................................... 5-37 5-34 Delayed Retry Operation Timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-38 5-35 Halt Operation Timing ....................................... 5-40 5-36 External Reset Operation Timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-41 5-37 Processor Generated Reset Operation. . . . . . . . . . . . . . . . . . . . . . . . . . 5-43 5-38 Bus Arbitration Flowchart for Single Request. . . . . . . . . . . . . . . . . . . . 5-44 5-39 Bus Arbitration Operation Timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45 5-40 Bus Arbitration State Diagram ................................ 5-47 5-41 Bus Arbitration (Bus Inactive) ................................. 5-48 6-1 Exception Stack Frame ......................... . . . . . . . . . . . . . 6-6 6-2 Special Status Word (SSW) ............... . . . . . . . . . . . . . . . . . . . . 6-17 6-3 Format $0 - Four Word Stack Frame .......................... 6-19 6-4 Format $1 - Throwaway Four Word Stack Frame . . . . . . . . . . . . . . . . 6-20 6-5 Format $2 - Six Word Stack Frame. . . . . . . . . . . . . . . . . . . . . . . . . . .. 6-20 6-6 Format $9 - Coprocessor Mid-Instruction Exception Stack Frame (10 Words) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 6-21 6-7 Format $A - Short Bus Cycle Fault Stack Frame (16 Words) . . . . . .. 6-21 6-8 Format $B - Long Bus Cycle Fault Stack Frame (44 Words) ....... 6-22 6-9 Stack Frame Format Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-23 7-1 MC68020 On-Chip Cache Organization ......................... 7-2 7-2 Cache Control Register .................. . . . . . . . . . . . . . . . . . . . . 7-3 7-3 Cache Address Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-3 8-1 Coprocessor System Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3 8-2 Processor-to-Coprocessor Transfer. . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4 8-3 Coprocessor-to-Processor Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5 8-4 Coprocessor Interface Register Map. . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6 8-5 Coprocessor Control Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7 8-6 Condition Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8 8-7 Coprocessor Operand Register Alignments ..................... 8-8 8-8 Coprocessor General Instruction Format. .. . . . . . . . . . . . . . .. . . . . . 8-9 8-9 Coprocessor Word Branch Instruction Format. . . . . . . . . . . . .. . . . .. 8-10 8-10 Coprocessor Long Branch Instruction Format ................... 8-10 8-11 Coprocessor Set Conditionally Instruction Format ............... 8-11 xiv LIST OF ILLUSTRATIONS (Continued) Figure Page Number Title Number 8·12 Coprocessor Decrement·and·Branch Conditionally I nstruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8·11 8·13 Coprocessor Trap Conditionally I nstruction Format .............. 8·11 8·14 Coprocessor Save I nstruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . 8·12 8·15 Coprocessor Restore Instruction Format ....................... 8·12 8·16 Coprocessor Response Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8·14 8·17 Format of Single Byte Immediate Operand. . . . . . . . . . . . . . . . . . . . . . 8·15 8·18 Format of Multi·Byte Immediate Operand. . . . . . . . . . . . . . . . . . . . . . . 8·15 8·19 Extension Word Order in General Instruction ................ . . . . 8·16 8·20 Coprocessor Pre·lnstruction Exception Stack Format. . . . . . . . . . . .. 8·19 8·21 Coprocessor Mid·lnstruction Exception Stack Format ............ 8·19 8·22 Coprocessor Post·lnstruction EXception Stack Format. . . . . . . . . . .. 8·20 8·23 Transfer Multiple Coprocessor Registers Example ............... 8·24 8·24 Protocol for Memory Operand to Non·DMA Coprocessor .......... 8·27 8·25 Protocol for Non·DMA Coprocessor Operand to Memory .......... 8·27 8·26 Protocol for Processing General Instruction . . . . . . . . . . . . . . . . . . . . . 8·28 8·27 Protocol for Processing Branch or Conditional. . . . . . . . . . . . . . . . . . . 8·28 8·28 Coprocessor Internal State Frame. . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8·29 8·29 Protocol for Processing Save Operation ........................ 8·31 8·30 Protocol for Processing Restore Operation. . . . . . . . . . . . . . . . . . . . . . 8·32 8·31 Protocol for Coprocessor Detected Exceptions .................. 8·33 8·32 Coprocessor Instruction Formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 8·36 8·33 Coprocessor Primitive Formats ............................... 8·37 9·1 Simultaneous Instruction Execution ........................... 9·2 9·2 Instruction Exeuction for Instruction Timing Purposes. . . . . . . . . . . . 9·3 9·3 Processor Activity for Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9·4 9·4 Processor Activity for Example 2 .............................. 9·6 9·5 Processor Activity for Example 3 .............................. 9·6 9·6 Processor Activity for Example 4 .............................. 9·7 10·1 RESET Test Load ........................................... 10·2 10·2 HALT Test Load. . . . . . . ... . . . .. . . . . . . . . . . . . . . . . .. . . .. .. . . . . . . 10·2 10·3 Test Loads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10·3 10·4 Clock Input Timing Diagram .................................. 10·3 10·5 Read Cycle Timing Diagram .................................. Foldout 1 10·6 Write Cycle Timing Diagram .................................. Foldout 2 10·7 Bus Arbitration Timing Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10·5 xv LIST OF ILLUSTRATIONS (Concluded) Figure Page Number Title Number 10·8 Address Capacitance Derating Curve .......................... 10·6 10·9 DS, AS, IPEND, and BG Capacitance Derating Curve. . . . . . . . . . . . . . 10·6 10·10 DBEN Capacitance Derating Curve ............................ 10·7 10·11 ECS and OCS Capacitance Derating Curve. . . . . . . . . . . . . . . . . . . . . . 10·7 10·12 RIW, FC, SIZO·SIZ1, and RMC Capacitance Derating Curve. . . . . . . . . 10·8 10·13 Data Capacitance Derating Curve. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10·8 xvi LIST OF TABLES Table Page Number Title Number 1-1 Addressing Modes. . . . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 1-2 I nstruction Set Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 2-1 Effective Address Specification Formats ....................... 2-19 2-2 IS-IllS Memory Indirection Encodings .......................... 2-20 2-3 Effective Address Encoding Summary. . . . . . . . . . . . . . . . . . . . . . . . . . 2-20 3-1 Data Movement Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 3-2 Integer Arithmetic Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 3-3 Logical Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3-4 Shift and Rotate Operations ........... . . . . . . . . . . . . . . . . . . . . . . . 3-5 3-5 Bit Manipulation Operations. . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . 3-5 3-6 Bit Field Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 3-7 Binary Coded Decimal Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6 3-8 Program Control Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7 3-9 System Control Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 3-10 Multiprocessor Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 4-1 Function Code Assignments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2 4-2 Signal Summary ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6 5-1 SIZE Output Encodings ...................................... 5-4 5-2 Address Offset Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 5-3 MC68020 Internal to External Data Bus Multiplexor. . . . . . . . . . . . . . . 5-5 5-4 DSACK Codes and Results ................................... 5-5 5-5 Memory Alignment and Port Size Influence on Bus Cycles. .. . . . . .. 5-14 5-6 Data Bus Activity for Byte, Word, and Long Word Ports. . . . . . . . . . . . 5-16 5-7 Interrupt Control Line Status for Each Requested Interrupt Level =~an:7d Corresponding Interrupt Mask Levels. . . . . . . . . . . . . . . . . . . 5-27 5-8 DSACK, BERR, and HALT Assertion Results. . . . . . . . . . . . . . . . . . . .. 5-49 6-1 Address Space Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 6-2 Exception Vector Assignments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5 6-3 Exception Groups. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . 6-8 6-4 Priviieged irlsiniCtlofis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. 5-12 6-5 Tracing Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. 6-13 xvii LIST OF TABLES (Concluded) Table Page Number Title Number 8·1 Main Processor Address Encoding. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8·5 8·2 M68000 Coprocessor Primitive Command Set. . . . . . . . . . . . . . . . . . . . 8·14 8·3 Coprocessor Valid Effective Address Codes. . . . . . . . . . . . . . . . . . . . . 8·21 8·4 Termination Processing Conditions and Actions . . . . . . . . . . . . . . . .. 8·29 8·5 Coprocessor Internal State Format Codes ...................... 8·29 9·1 Example Instruction Stream Execution Comparison. . . . . . . . . . . . . . 9·8 9·2 Instruction Timings for Timing Tables . . . . . . . . . . . . . . . . . . . . . . . . .. 9·10 9·3 Observed Instruction Timings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 9·10 xviii ® MOTOROLA MC68020 32-81T MICROPROCESSOR USER'S MAN UAL SECTION 1 INTRODUCTION The MC68020 is the first full 32-bit implementation of the M68000 Family of micro- processors from Motorola. Using VLSI technology, the MC68020 is implemented with 32-bit registers and data paths, 32-bit addresses, a rich instruction set, and versatile ad- dressing modes. The MC68020 is object code compatible with the earlier members of the M68000 Family and has the added features of new addressing modes in support of high level languages, an on-chip instruction cache, and a flexible coprocessor interface with full IEEE floating- point support (the MC68881). Also, the internal operations of this microprocessor are designed to operate in parallel, allowing multiple instructions to be executed concur- rently. The execution time of an instruction can be completely absorbed by the execution time of surrounding instructions for a net execution time of zero clock periods. The asynchronous bus structure of the MC68020 utilizes a non-multiplexed bus with 32 bits of address and 32 bits of data. The processor supports a dynamic bus sizing mechanism that allows the processor to transfer operands to or from external devices while automatically determining device port size on a cycle-by-cycle basis. The dynamic bus interface allows for simple, highly efficient access to devices of differing data bus widths, in addition to eliminating all data alignment restrictions. The resources available to the MC68020 user consist of the following: • Virtual Memory/Machine Support • Sixteen 32-Bit General-Purpose Data and Address Registers • Two 32-Bit Supervisor Stack Pointers • 32-Bit Program Counter • Five Special Purpose Control Registers • 4 Gigabyte Direct Addressing Range • 18 Addressing Modes • Memory Mapped I/O • Coprocessor Interface • High Performance On-Chip Instruction Cache • Operations on Seven Data Types • Complete Floating-Point Support via the MC68881 Coprocessor A block diagram of the MC68020 is shown in Figure 1-1. The major blocks depicted operate in a highly independent fashion that maximizes concurrency of operation while managing the essential synchronization of instruction execution and bus operation. 1-1 Sequencer Control Instruction Unit Prefetch and Decode Bus Control Controller Execution Address Instruction Unit Data Bus Bus Cache Figure 1·1. MC68020 Block Diagram The bus controller loads instructions from the data bus into the decode unit and the on· chip cache. The sequencer and control unit provide overall chip control, managing the in· ternal buses, registers, and functions of the execution unit. As shown in the programming models (Figures 1-2 and 1-3), the MG68020 has 16 32-bit general-purpose registers, a 32-bit program counter, a 16-bit status register, a 32-bit vec- tor base register, two 3·bit alternate function code registers, and two 32-bit cache handl- ing (address and control) registers. Registers 00-07 are used as data registers for bit and bit field (1 to 32 bits), byte (8-bit), word (16·bit), long word (32-bit), and quad word (64-bit) operations. Registers AO-A6 and the user, interrupt, and master stack pointers are ad- dress registers that may be used as software stack pointers or base address registers. In addition, the address registers may be used for word and long word operations. All of the 16 (00-07, AO-A7) registers may be used as index registers. The vector base register is used to determine the location of the exception vector table in memory to support multiple vector tables. The alternate function code registers allow the supervisor to access any address space. The cache registers (control - GAGR; address - CAAR) allow software manipulation of the on-chip instruction cache. Control and status accesses to the instruction cache are provided by the cache control register (CACR), while the cache address register (GAAR) holds the address for cache control functions when required. The status register (Figure 1-4) contains the interrupt priority mask (three bits) as well as the condition codes: extend (X), negative (N), zero (Z), overflow (V), and carry (C). Addi- tional control bits indicate that the processor is in the trace mode (T1 and TO), super- visorluser state (8), and masterlinterrupt state (M). 1-2 31 16 15 8 7 0 DO D1 D2 D3 Data Registers D4 D5 D6 D7 31 16 15 0 AO A1 A2 A3 Address Register A4 A5 A6 31 1615 0 I A7IUSP) User Stack Pointer 31 0 I IPC Program Counter 15 7 0 r---- L _ _ ~_ I CCR Condition Code Register Figure 1·2. User Programming Model 31 1615 o I~------------------~------------------~ I IA7' liSP) Interrupt Stack Pointer 31 1615 o I L -_ _ _ _ _ _ _ _ _ _ _ _-L-_ _ _ _ _ _ _ _ _ _ _ _....... I A7" IMSP) Master Stack Pointer 15 87 0 I~________~I__~IC~C~R) __ ~ISR Status Register 31 0 LI_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ---'I VBR Vector Base Register 31 r I- - L. -- ______ _ _=a ~3~1----------------------------------------------~0~I~A~n 2 0 SFC DFC Alternate Function Code Registers '--_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.....II . . . .t~ ...... 11 31 o ~--------------------------------------~ ICAAR Cache Address Register Figure 1·3. Supervisor Programming Model Supplement 1·3 User Byte System Byte (Condition Code Register) ---~----------~----------~~ 15 11 10 9 8 ---~----------~---------~- 12 6 5 3 2 0 Supervisor/User Zero State - Overflow Master/ Interrupt State Carry Figure 1·4. Status Register 1.1 DATA TYPES AND ADDRESSING MODES Seven basic data types are supported. These data types are: • Bits • Bit Fields (Strings of consecutive bits, 1-32 bits long) • BCD Digits (Packed: 2 digits/byte, Unpacked: 1 digit/byte) • Byte Integers (8 bits) • Word Integers (16 bits) • Long Word Integers (32 bits) • Quad Word Integers (64 bits) In addition, operations on other data types such as memory addresses, status word data, etc., are supported in the instruction set. The coprocessor mechanism allows direct sup· port of floating·point operations with the MC68881 floating·point coprocessor, as well as specialized user·defined data types and functions. The 18 addressing modes, shown in Table 1·1, include nine basic types: • Register Direct • Register Indirect • Register Indirect with Index • Memory Indirect • Program Counter Indirect with Displacement • Program Counter Indirect with Index • Program Counter Memory Indirect • Absolute • Immediate Included in the register indirect addressing modes are the capabilities to postincrement, predecrement, offset, and index. The program counter relative mode also has index and offset capabilities. Both modes are extended in the MC68020 to provide indirect reference through memory. In addition to these addressing modes, many instructions im· plicitly specify the use of the condition code register, stack pOinter, and/or program counter. 1·4 Table 1·1. Addressing Modes Addressing Modes Syntax Register Direct Data Register Direct On Address Register Direct An Register Indirect Address Register Indirect IAn) Address Register Indirect with Postincrement IAn)+ Address Register Indirect with Predecrement -IAn) Address Register Indirect with Displacement Id16,An) Register Indirect with Index Address Register Indirect with Index 18-Blt Displacement) Id8,An,Xn) Address Register Indirect with Index IBase Displacement) Ibd,An,Xn) Memory Indirect Memory Indirect Post-Indexed l[bd,AnI,Xn,od) Memory Indirect Pre-Indexed l[bd,An,Xnl,od) Program Counter Indirect with Displacement Id16,PC) Program Counter Indirect with Index PC Indirect with Index 18-Bit Displacement) Id8,PC,Xn) PC Indirect with Index IBase Displacement) Ibd,PC,Xn) Program Counter Memory Indirect PC Memory Indirect Post-Indexed l[bd,PCI,Xn,od) PC Memory Indirect Pre-Indexed l[bd,PC,Xnl,od) Absolute Absolute Short xxx.w Absolute Long xxx.L Immediate # NOTES: On = Data Register, 00-07 An = Address Register, AO-A7 d8, d16 = A twos-complement, or sign-extended displacement; added as part of the effective address calculation; size is 8 or 16 bits Id16 and d8 are 16- and 8-bit displacements); when omitted, assemblers use a value of zero. Xn = Address or data register used as an index register; form is Xn.SIZE*SCALE, where SIZE is .W or .L lindicates index register size) and SCALE is 1, 2, 4, or 8 lindex register is multiplied by SCALE); use of SIZE and! or SCALE is optional. bd = A twos-complement base displacement; when present, size can be 16 or 32 bits., ad = Outer displacement, added as part of effective address calculation after any memory indirection; use is optional with a size of 16 or 32 bits .. PC = Program Counter < data> = Immediate value of 8, 16, 0; 32 bits I ) = Effective address [ ] = Use as indirect address to long word address. 1.2 INSTRUCTION SET OVERVIEW The MC68020 instruction set is shown in Table 1·2. Special emphasis has been placed on the instruction support of structured high·level languages and sophisticated operating systems. Each instruction, with few exceptions, operates on bytes, words, and long words and most instructions can use any of the 18 addressing modes. 1-5 Table 1·2. Instruction Set Summary Mnemonic Description Mnemonic Description ABCD Add Decimal with Extend MULS Signed Multiply ADD Add MULU Unsigned Multiply ADDA Add Address NBCD Negate Decimal with Extend ADDI Add Immediate NEG Negate ADDQ Add Quick NEGX Negate with Extend ADDX Add with Extend NOP No Operation AND Logical AND NOT Logical Complement ANDI Logical AND Immediate OR Logical Inclusive OR ASL, ASR Arithmetic Shift Left and Right ORI Logical OR Immediate Bcc Branch Conditionally PACK Pack BCD BCHG Test Bit and Change PEA Push Effective Address BCLR Test Bit and Clear RESET Reset External Devices BFCHG Test Bit Field and Change ROL, ROR Rotate Left and Right BFCLR Test Bit Field and Clear ROXL, ROXR Rotate with Extend Left and Right BFEXTS Signed Bit Field Extract RTD Return and Deallocate BFEXTU Unsigned Bit Field Extract RTE Return from Exception BFFFO Bit Field Find First One RTM Return from Module BFINS Bit Field Insert RTR Return and Restore Conditon Codes BFSET Test Bit Field and Set RTS Return from Subroutine BFTST Test Bit Field SBCD Subtract Decimal with Extend BRA Branch Scc Set Conditionally BSET Test Bit and Set STOP Stop BSR Branch to Subroutine SUB Subtract BTST Test Bit SUBA Subtract Address CALLM Call Module SUBI Subtract Immediate CAS Compare and Swap Operands SUBQ Subtract Quick CAS2 Compare and Swap Dual Operands SUBX Subtract with Extend CHK Check Register Against Bound SWAP Swap Register Words CHK2 Check Register Against Upper and TAS Test Operand and Set Lower Bounds CLR Clear TRAP Trap CMP Compare TRAPcc Trap Conditionally CMPA Compare Address TRAPV Trap on Overflow CMPI Compare Immediate TST Test Operand CMPM Compare Memory to Memory UNLK Unlink CMP2 Compare Register Against Upper and UNPK Unpack BCD Lower Bounds COPROCESSOR INSTRUCTIONS DBcc Test Condition, Decrement and Branch DIVS,DIVSL Signed Divide cpBcc Branch Conditionally DIVU,DIVUL Unsigned Divide cpDBcc Test Coprocessor Condition, EOR Logical Exclusive 0 R Decrement, and Branch EORI Logical Exclusive OR Immediate cpGEN Coprocessor General Instruction EXG Exchange Registers cpRESTORE Restore Internal State of Coprocessor EXT Sign Extend cpSAVE Save Internal State of Coprocessor JMP Jump cpScc Set Conditionally cpTRAPcc T rap Conditionally JSR Jump to Subroutine LEA Load Effective Address LINK Link and Allocate LSL, LSR Logical Shift Left and Right MOVE Move MOVEA Move Address MOVE CCR Move Condition Code Register MOVE SR Move Status Register MOVE USP Move User Stack Pointer MOVEC Move Control Register MOVEM Move Multiple Registers MOVEP Move Peripheral MOVEQ Move Quick MOVES Move Alternate Address Space 1·6 1.3 VIRTUAL MEMORY/MACHINE CONCEPTS The full addressing range of the MC68020 is 4 gigabytes (4,294,967,296). However, most MC68020 systems implement a smaller physical memory. Nonetheless, by using virtual memory techniques, the system can be made to appear to have a full 4 gigabytes of physical memory available to each user program. These techniques have been used for many years in large mainframe computers and more recently in minicomputers. With the MC68020 (as with the MC68010 and MC68012), virtual memory can be fully supported in microprocessor·based systems. In a virtual memory system, a user program can be written as though it has a large amount of memory available to it when actually, only a smaller amount of memory is physically present in the system. In a similar fashion, a system can be designed in such a manner as to allow user programs to access other types of devices that are not physi- cally present in the system such as tape drives, disk drives, printers, or terminals. With proper software emulation, a physical system can be made to appear to a user program as any other M68000 computer system and the program may be given full access to all of the resources of that emulated system. Such an emulated system is called a virtual machine. 1.3.1 Virtual Memory The basic mechanism for supporting virtual memory is to provide a limited amount of high-speed physical memory that can be accessed directly by the processor while main- taining an image of a much larger "virtual" memory on secondary storage devices such as large capacity disk drives. When the processor attempts to access a location in the virtual memory map that is not resident in physical memory (referred to as a page fault), the access to that location is temporarily suspended while the necessary data is fetched from secondary storage and placed in physical memory; the suspended access is then either restarted or continued. The MC68020 uses instruction continuation to support virtual memory. In order for the MC68020 to use instruction continuation, it stores its internal state on the supervisor stack when a bus cycle is terminated with a bus error signal. It then loads the program counter with the address of the virtual memory bus error handler from the exception vec- tor table (entry number two) and resumes program execution at that new address. When the bus error exception handler routine has completed execution, an RTE instruction is executed which reloads the MC68020 with the internal state stored on the stack, re-runs the faulted bus cycle (when required), and continues the suspended instruction. Instruction continuation is crucial to the support of virtual I/O devices in memory- mapped input/output systems. Since virtual registers may be simulated in the memory map, an access to such a register will cause a fault and the function of the register can be emulated by software. 1.3.2 Virtual Machine A typical use for a virtual machine system is the development of software, such as an operating system, for a new machine also under development and not yet available for programming use. In such a system, a governing operating system emUlates the hard- ware of the prototyped system and allows the new operating system to be executed and 1-7 debugged as though it were running on the new hardware. Since the new operating system is controlled by the governing operating system, it is executed at a lower privilege level than the governing operating system. Thus, any attempts by the new operating system to use virtual resources that are not physically present (and should be emulated) are trapped to the governing operating system and handled by its software. In the MC68020, a virtual machine is fully supported by running the new operating system in the user mode. The governing operating system executes in the supervisor mode and any at· tempt by the new operating system to access supervisor resources or execute privileged instructions will cause a trap to the governing operating system. In order to fully support a virtual machine, the MC68020 must protect the supervisor resources from access by user programs. The only supervisor resource that is not fully protected on the MC68000 and MC68008 is the system byte of the status register. On the MC68000 and MC68008, the MOVE from SR instruction allows user programs to test the S bit in the status register (in addition to the Tbits and interrupt mask) and thus determine that they are running in the user mode. For full virtual machine support, an operating system must not be aware of the fact that it is running in the less privileged user mode and thus should not be allowed direct access to the S bit. For this reason, the MOVE from SR instruction on the MC68010, MC68012, and MC68020 is a privileged instruction and the MOVE from CCR (condition code register) instruction is available to allow user pro· grams direct access to the condition codes. By making the MOVE from SR instruction privileged, when the new operating system attempts to access the system byte of the status register, a trap to the governing operating system will occur, where the operation can be emulated. 1.4 PIPELINED ARCHITECTURE The MC68020 uses a three stage instruction pipe, as shown in Figure 1·5, to implement a pipelined internal architecture. The pipeline is completely internal to the microprocessor. The benefit of the pipeline is to allow concurrent operations to occur for up to three words of a single instruction or for up to three consecutive instructions. Instructions are loaded from the on·chip cache or from external memory during instruc· tion prefetch into stage B. The instructions are sequenced from stage B through stage C to D. Stage D presents a fully decoded and validated instruction to the control unit for execution. Instructions with immediate data and extension words find these words already loaded in stage C and ready for use by the control and execution units. 1·8 r- ---, I Instruction Fetch and Decode I I I Sequencer I Stage Stage Stage I D C B I I I I L - - - - - - - roo - -- - -- J Control Unit Instru ction Flow f rom Cache and Mem ory Execution Unit Figure 1·5. MC68020 Pipeline 1-9/1-10 SECTION 2 DATA ORGANIZATION AND ADDRESSING CAPABILITIES This section contains a description of the registers and the data organization of the MC68020. 2.1 OPERAND SIZE Operand sizes are defined as follows: a byte equals 8 bits, a word equals 16 bits, a long word equals 32 bits, and a quad word equals 64 bits. The operand size for each instruc- tion is either explicitly encoded in the instruction or implicitly defined by the instruction operation. The coprocessor interface allows the support of any operand size from a bit to 256 bytes. 2.2 DATA ORGANIZATION IN REGISTERS The eight data registers support data operands of 1,8,16,32, and 64 bits, addresses of 16 or 32 bits, and bit fields of 1 to 32 bits. The seven address registers and the stack pOinters support address operands of 16 or 32 bits. The six control registers (SR, VBR, SFC, DFC, CACR, and CAAR) support various data sizes depending on the register specified. Coprocessors may define unique operand sizes, and support them with on-chip registers accordingly. 2.2.1 Data Registers Each data register is 32 bits wide. Byte operands occupy the low order 8 bits, word operands the low order 16 bits, and the long word operands the entire 32 bits. The least significant bit of an integer is addressed as bit zero and the most significant bit is ad- dressed as bit 31. For bit fields, the most significant bit is addressed as bit zero and the least significant bit is addressed as the width of the field minus one. The quad word data type is two long words and is used only for 32-bit multiply and divide (signed and unsigned) instructions. Quad words may be organized in any two data registers without restrictions on order or pairing. There are no explicit instructions for the management of this data type, although the MOVEM instruction can be used to move a quad word into or out of the registers. When a data register is used as either a source or destination operand, only the ap- oropriate low order byte or word (in byte or word operations, respectively) is used or changed; the remaining high order portion is neither used nor changed. 2-1 2.2.2 Address Registers Each address register and stack pointer is 32 bits wide and holds a full 32-bit address. Address registers can not be used for byte-sized operands. Therefore, when an address register is used as a source operand, either the low order word or the entire long word operand is used, depending upon the operation size. When an address register is used as the destination operand, the entire register is affected regardless of the operation size. If the operation size is word, operands are sign extended to 32 bits before the operation is performed. Address registers may also be used to support some simple data operations. 2.2.3 Control Registers The status register (SR) is 16 bits wide with the lower byte accessed as the condition code register (CCR). Not all 16 bits of the status register are defined, and undefined bits are read as zeros and ignored when written. Operations to the condition code register are word operations; however, the upper byte is read as all zeroes and ignored when written. The cache control register (CACR) provides control and status access to the on-chip in- struction cache. The cache address register (CAAR) holds the necessary address for those cache control functions that require one. The vector base register (VBR) provides the starting address of the exception vector table. All operations involving the CACR, CAAR, and VBR are long word operations regardless of whether these registers are used as the source or destination operand. The alternate function code registers (SFC and DFC) are three bits wide and contain the address space values placed on FCO·FC2 during the operand read or write of a MOVES in- struction. All transfers to or from the alternate function code registers are long word, although the upper 29 bits are read as zeroes and ignored when written. Accesses to the control registers are privileged operations and are available only in the supervisor mode. 2.3 DATA ORGANIZATION IN MEMORY Memory is organized on a byte-addressable basis where lower addresses correspond to higher-order bytes. The address, N, of a long word datum corresponds to the address of the most significant byte of the higher-order word. The lower-order word is located at ad- dress N + 2, leaving the least significant byte at address N + 3 (see Figure 2-1). Notice that the MC68020 does not require data to be aligned on even byte boundaries (see Figure 2-22) but the most efficient data transfers occur when data is aligned on the same byte boundary as its operand size. How~ver, instruction words must be aligned on even byte boundaries. The data types supported in memory by the MC68020 are: bit and bit field data; integer data of 8, 16, or 32 bits; 32-bit addresses; and binary coded decimal data (packed and un- packed). These data types are organized in memory as shown in Figure 2-2. (The quad word is supported exclusively in the data registers.) Note that all of these data types can be accessed at any byte address. 2-2 31 23 15 7 o Long Word $00000000 Word $00000000 Word $00000002 Byte $00000000 I Byte $00000001 I Byte $00000002 1 Byte $00000003 Long Word $00000004 Word $00000004 Word $00000006 Byte $00000004 I Byte $00000005 Byte $00000006 I Byte $00000007 • • 1 1 1 • • t • • Long Word $FFFFFFFC Word $FFFFFFFC Word $FFFFFFFE Byte $FFFFFFFC I Byte $FFFFFFFD I Byte $FFFFFFFE I Byte $FFFFFFFF Figure 2·1. Memory Operand Addressing Bit Data 7 0 7 7 0 7 0 Byte n-1 6 5 4 Byte n+ 1 Byte n+ 2 Base Bit Address Number Bit Field Data Base Bit 7 0 7 Byte n-1 Byte n j.- - -Offset- -Offset- -3 -2-1 0 2 Base Width Address Byte Integer Data 7 0 7 0 7 0 7 0 Byten-1 MSB Byte n LSB Byte n+ 1 Byte n+ 2 Address Word Integer Data 7 0 7 0 7 0 7 0 7 0 Rvtf'n-l Word Integer Bvte n+2 Bvte n+3 f Address Figure 2·2. Memory Data Organization (Sheet 1 of 2) 2·3 Long Word Integer Data 7 0 7 Byte n-1 Address Packed Binary-Coded Data 7 o 7 o 7 o Byte n-1 MSD Byten+1 Byte n+2 Address Unpacked Binary-Coded Data 7 o7 o Byte n-1 xx Byte n+2 Address xx = User-Defined Value Figure 2-2. Memory Data Organization (Sheet 2 of 2) Coprocessors may implement any data types and lengths. For example, the MC68881 Floating-Point Coprocessor supports memory accesses for quad-word sized items (double-precision floating-point values). A bit datum is specified by a base address that selects one byte in memory and a bit number that selects the one bit in this byte. The most significant bit of the byte is bit number seven. A bit field datum is specified by a base address that selects one byte in memory, a bit field offset that indicates the leftmost (base) bit of the bit field in relation to the most significant bit of the base byte and a bit field width that determines how many bits to the right of the base bit are in the bit field. The most significant bit of the base byte is bit off- set 0, the least significant bit of the base byte is bit offset 7, and the least significant bit of the previous byte in memory is bit offset -1. Bit field offsets may have values in the range of - 231 to 231 - 1 and bit field widths may range between 1 and 32. 2.4 INSTRUCTION FORMAT All instructions are at least one word and up to 11 words in length as shown in Figure 2-3. The length of the instruction and the operation to be performed is determined by the first word of the instruction, the operation word. The remaining words, called extension words, further specify the instruction and operands. These words may be immediate operands, extensions to the effective address mode specified in the operation word, branch displacements, bit number or bit field specifications, special register specifica- tions, trap operands, pack/unpack constants, argument counts, or coprocessor condition codes. 2-4 15 o Operation Word (One Word, Specifies Operation and Modes) Special Operand Specifiers IIf Any, One or Two Words) Immediate Operand or Source Effective Address Extension (If Any, One to Five Words) Destination Effective Address Extension IIf Any, One to Five Words) Figure 2·3. Instruction Word General Format 2.5 PROGRAM/DATA REFERENCES The MC68020 separates memory references into two classes: program references and data references. Program references, as the name implies, are references to that section of memory that contains the program instructions. Data references refer to that section of memory that contains the program data. Generally, operand reads are from the data space. All operand writes are to the data space, except when caused by the MOVES instruction. 2.6 ADDRESSING Instructions for the MC68020 contain two kinds of information: the function to be per· formed and the location of the operand(s) on which that function is performed. The methods used to locate (or address) the operand(s) are explained in the following paragraphs. Instructions specify an operand location in one of three ways: Register Specification - The number of the register is given in the register field of the instruction. Effective Address - Use of the various effective addressing modes. Implicit Reference - The definition of certain instructions implies the use of specific registers. 2.7 REGISTERS: NOTATION CONVENTIONS Registers are identified by the following mnemonic description: An - Address register n (e.g., A3 is address register 3) Dn - Data register n (e.g., D5 is data register 5) Rn - Address or Data Register n Xn - Denotes index register n (data or address) PC - The program counter SR - The status register eeR - The condition code register: part of the status register SP - The active stack pointer; SP and A7 are equivalent names. USP - The user stack pointer (A7) ISP - The interrupt stack pointer (A7') 2·5 MSP - The master stack pointer (A7") SSP - The supervisor stack pointer, either the master (MSP) or interrupt (ISP) stack pOinter SFC - The source function code register DFC - The destination function code register VBR - The vector base register CACR - The cache control register CAAR - The cache address register The register field within an instruction specifies the register to be used. Other fields within the instruction specify whether the register selected is an address or data register and how the register is to be used. 2.8 EFFECTIVE ADDRESS Most instructions specify the location of an operand by using the effective address field (EA) in the operation word. For example, Figure 2-4 shows the general format of the single effective address instruction operation word. The effective address is composed of two 3-bit fields; the mode field and the register field. The value in the mode field selects one of the addressing modes. The register field contains the number of a register. The in- struction operand word for each instruction is located in APPENDIX C. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 Effective Address Mode Register Figure 2·4. Single·Effective·Address Instruction Operation Word The effective address field may require additional information to fully specify the operand address. This additional information, called the effective address extension, is contained in following word or words and is considered part of the instruction, as shown in Figure 2·3. Details describing the format of the extension words can be found in 2.9 EF· FECTIVE ADDRESS ENCODING SUMMARY. 2.8.1 Register Direct Modes These effective addressing (EA) modes specify that the operand is in one of sixteen general purpose registers or one of six control registers (SR, VBR, SFC, DFC, CACR, and CAAR). 2.8.1.1 DATA REGISTER DIRECT. The operand is in the data register specified by the ef- fective address register field. Generation: EA=Dn Assembler Syntax: Dn Mode: 000 31 0 Register: n r-------------------------~ Data Register: Dn ------------~.~I ___________ o_p_e_ra_n_d__________~1 2·6 2.8.1.2 ADDRESS REGISTER DIRECT. The operand is in the address register specified by the effective address register field. Generation: EA=An Assembler Syntax: An Mode: 001 31 0 Register: n r-------------------------~ Address Register: An------------.~I__________o_p_e_ra_n_d________~1 2.8.2 Register Indirect Modes These effective addressing modes specify that the operand is in memory and the con- tents of a register is used to calculate the address of the operand. 2.8.2.1 ADDRESS REGISTER INDIRECT. The address of the operand is in the address register specified by the register field. Generation: EA = (An) Assembler Syntax: (An) Mode: 010 Register: n 31 o Address Register: An ------------+1 Memory Address 31 o Memory Address: Operand 2.8.2.2 ADDRESS REGISTER INDIRECT WITH POSTINCREMENT. The address of the operand is in the address register specified by the register field. After the operand ad- dress is used, it is incremented by one, two, or four depending upon whether the size of the operand is byte, word, or long word. Coprocessors may support incrementing for any size, up to 256 bytes, of operand. If the address register is the stack pOinter and th<:' operand size is byte, the address is incremented by two rather than one to keep the stack pointer on a word boundary. Generation: EA= (An) An=An +SIZE Assembler Syntax: (An) + Mode: 011 Register: n 31 o Address Register: An ----------+1 Memory Address Operand Length (1, 2, or 4): -------------------i~ 31 o Memory Address: Operand 2-7 2.8.2.3 ADDRESS REGISTER INDIRECT WITH PREDECREMENT. The address of the operand is in the address register specified by the register field. Before the operand ad· dress is used, it is decremented by one, two, or four depending upon whether the operand size is byte, word, or long word. Coprocessors may support decrementing for any size, up to 256 bytes, of operand. If the address register is the stack pointer and the operand size is byte, the address is decremented by two rather than one to keep the stack pointer on a word boundary. Generation: An=An-SIZE EA= (An) Assembler Syntax: -(An) Mode: 100 Register: n 31 o Address Register: An------~ Memory Address Operand Length (1,2, or 4): - - - - - - - - - _ + { 31 o Memory Address: Operand 2.8.2.4 ADDRESS REGISTER INDIRECT WITH DISPLACEMENT. This addressing mode requires one word of extension. The address of the operand is the sum of the address in the address register and the sign-extended 16-bit displacement integer in the extension word. Displacements are always sign extended to 32 bits prior to being used in effective address calculations. Generation: EA = (An) + d16 Assembler Syntax: (d16,An) Mode: 101 Register: n 31 o Address Register: An ------~ Memory Address ~------,------~ 31 15 r-------....------....., Displacement: L ~i~n ~x.!.e~d..:d_ ...1.-_ _I_nt_e...=g:.-.e_r_.....J 31 o Memory Address: Operand 2.8.3 Register Indirect with Index Modes These effective addressing modes specify that the contents of an address register are used in calculating the final effective address of the operand. In addition, an index register and a displacement are also used in calculating the final address (the values are both sign extended to 32 bits before the calculation). The variations available for ad- justing the index register cause the index to be considered an "index operand". 2-8 The format of the index operand is "Xn.SIZE*SCALE". "Xn" selects any data or address register as the index register. "SIZE" specifies the index size and may be "W" for word size or "L" for long word size. "SCALE" allows the index register value to be multiplied by a value of one (no scaling), two, four, or eight. Displacements and index operands are always sign extended to 32 bits prior to being used in effective address calculations. 2.8.3.1 ADDRESS REGISTER INDIRECT WITH INDEX (8·BIT DISPLACEMENT). This ad- dressing mode requires one word of extension that contains the index register indicator (with its size selector and scaling mode), and an a-bit displacement. In this mode, the ad- dress of the operand is the sum of the address register, the sign extended displacement value in the low order eight bits of the extension word, and the sign extended contents of the index register (possibly scaled). The user must specify the displacement, the address register, and the index register in this mode. Generation: EA = (An) + (Xn) + da Assembler Syntax: (da,An,Xn.SIZE*SCALE) Mode: 110 Register: n 31 o Address Register: An ---------'~ Memory Address 31 7 o Displacement: ~ 31 ==~i~n ~x~e~d~cC == Integer t - - - - - - - _ + { o Index Sign Extended Value Register: Scale: Scale Value 31 Memory Address: Operand 2.8.3.2 ADDRESS REGISTER INDIRECT WITH INDEX (BASE DISPLACEMENn. This form of address register indirect with index requires additional extension words that contain index register indication and an optional 16- or 32-bit base displacement (which is sign extended before it is used in the effective address calculation). The address of the operand is the sum of the contents of the address register, the scaled contents of the index register and the ba.se displacement. In this mode, speCification of all three addends is optional. If none are specified, the assembler creates an effective address of zero. 2·9 Note that if an index register is specified, but not the address register, and a data register (On) is used as the index register, then a "data register indirect" access can be generated. Generation: EA = (An) + (Xn) + bd Assembler Syntax: (bd,An,Xn.SIZE * SCALE) Mode: 110 Register: n 31 o Address Register: An------+t Memory Address 31 o Base S....:ig'-n_E_x_t_e_nd_e_d_V_a_lu_e_ _~ Displacement: 1--_ _ _ 31 Index Sign Extended Value Register: Scale: Scale Value 31 Memory Address: Operand 2.8.4 Memory Indirect This addressing mode requires one to five words of extension, as detailed in 2.9 EFFEC· TIVE ADDRESS ENCODING SUMMARY. Memory indirect is distinguished from address register indirect by use of square brackets ([]) in the assembler notation. The assembler generates the appropriate indicators in the extension words when this addressing mode is selected. In this case, four user-specified values are used in the generation of the final address of the operand. An address register is used as a base register and its value can be adjusted by adding an optional base displacement. An index register specifies an index operand and finally, an outer displacement can be added to the address operand, yielding the effective address. The location of the square brackets determines the user-specified values to be used in calculating an intermediate memory address. An address operand is then fetched from that intermediate memory address and it is used in calculating the effective address. The index operand may be added in after the intermediate memory access (post-indexed) or before the intermediate memory access (pre-indexed). All four user-specified values are optional. Both the base and outer displacements may be null, word, or long word. When a displacement is null, or an element is suppressed, its value is tak~n as zero in the effective address calculation. 2-10 2.8.4.1 MEMORY INDIRECT POST·INDEXED. In this case, an intermediate indirect memory address is calculated using the base register (An) and base displacement (bd). This address is used for an indirect memory access of a long word, followed by adding the index operand (Xn.SIZE*SCALE) to the fetched address. Finally, the optional outer displacement (od) is added to yield the effective address. Generation: = EA (bd + An) + Xn.SIZE*SCALE + od Assembler Syntax: ([bd,An),Xn.SIZE*SCALE,od) Mode: 110 31 Address Register: An r-:-----M-e-m-O-r-y-A-d-d-re-s-s----=. 31 o Base Displacement: Sign Extended Value 31 Indirect Memory Address Points To 31 Value at Indirect Memory Address ,31 o Index Register: Sign Extended Value Scale: Scale Value 31 o Output Displacement: Sign Extended Value 31 Effective Address: Operand 2·11 2.8.4.2 MEMORY INDIRECT PRE·INDEXED. In this case, the index operand (Xn.SIZE*SCALE) is added to the base register (An) and base displacement (bd). This in- termediate sum is then used as an indirect address into the data space. Following the long word fetch of the operand address, the optional outer displacement (od) may be added to yield the effective address. Generation: EA = (bd + An + Xn.SIZE*SCALE) + od Assembler Syntax: ([bd,An,Xn.SIZE*SCALE],od) Mode: 110 31 ~------------------------~ Address Register: An Memory Address 31 o Base Displacement: Sign Extended Value 31 Index Register: Sign Extended Value Scale: Scale Value 31 31 Value at Indirect Memory Address 31 o Output Displacement: Sign Extended Value 31 Effective Address: Operand 2-12 2.8.5 Program Counter Indirect With Displacement Mode This addressing mode requires one word of extension. The address of the operand is the sum of the address in the program counter and the sign extended 16·bit displacement integer in the extension word. The value in the program counter is the address of the ex· tension word. The reference is classified as a program reference. Generation: EA = (PC) + d16 Assembler Syntax: (d16,PC) Mode: 111 Register: 010 31 o Program Counter: 31 15 0 Displacement: [ Sig~ ~X~~;d --,----1n-t-e-g-e-r---'I---~ 31 Memory Address: Operand 2.8.6 Program Counter Indirect with Index Modes These addressing modes are analogous to the register indirect with index modes described in 2.8.3, but the PC is used as the base register. As before, the index operand (sized and scaled) and a displacement are used in the calculation of the effective address also. Displacements and index operands are always sign extended to 32 bits prior to be· ing used in effective address calculations. PC relative accesses are always classified as program space references. 2·13 2.8.6.1 PC INDIRECT WITH INDEX (8·BIT DISPLACEMENT). The address of the operand is the sum of the address in the program counter, the sign extended displacement integer in the lower eight bits of the extension word, and the sized and scaled index operand. The value in the PC is the address of the extension word. This reference is classified as a program space reference. The user must include the displacement, the PC, and the index register when specifying this address mode. Generation: EA = (PC) + (Xn) + da Assembler Syntax: (da,PC,Xn.SIZE*SCALE) Mode: 111 RegistEir: 010 31 o Program Counter: ---------~ Address of Extension Word ~-----------.-~ r----------- 7 31 0 Displacement: L __ ~i.!!n!~~~~ _ _ Integer i----_+{ 31 0 Index Register: Sign Extended Value Scale: Scale Value 31 Memory Address: Operand 2.8.6.2 PC INDIRECT WITH INDEX (BASE DISPLACEMENT). This address mode requires additional extension words that contain the index register indication and an optional 16-or 32·bit base displacement (which is sign extended to 32 bits before being used). The address of the operand is the sum of the contents of the PC, the scaled contents of the index register, and the base displacement. In this mode, specification of all three addends is optional. However, in order to distinguish this mode from address register indirect with index (base displacement), when the user wishes to specify no PC, the assembler notation "ZPC" (zero value is taken for the PC) must be used. This allows the user to access the program space, without necessarily using the PC in calculating the effective address. Note that if ZPC and an in· dex register are specified, and a data register (On) is used, then a "data register indirect" access can be made to the program space, without using the PC. 2·14 Generation: EA = (PC) + (Xn) + bd Assembler Syntax: (bd,PC,Xn.SIZE*SCALE) Mode: 111 Register: 011 31 o Program Counter: ---------~L -_ _ _ Address __ of_ _ Extension ___ Word ~-~ 31 o Base Displacement: Sign Extended Value 31 o Index Register: Sign Extended Value Scale: Scale Value 31 Memory Address: Operand 2.8.7 Program Counter Memory Indirect Modes As in the memory indirect modes (refer to 2.8.4 Memory Indirect) the square brackets ([ ]) indicate that an intermediate access to memory is made as part of the final effective ad- dress calculation. In this case, the PC is used as a base register and its value can be adjusted by adding an optional base displacement. An index register specifies an index operand and finally, an outer displacement can be added to the address operand, yielding the effective address. The location of the square brackets determines the user-specified values to be used in calculating an intermediate memory address. An address operand is then fetched from that intermediate address and it is used in the final calculation. The index operand may be added in after the intermediate memory access (post-indexed) or before that access (pre-indexed). All four user-specified values are optional. Both the base and outer displacements may be null, word, or long word. When using null displacements, the value of zero is used in the effective address calculation. In order to specify no PC but still make program space references, the notation "ZPC" should be used in its place. 2-15 2.8.7.1 PROGRAM COUNTER MEMORY INDIRECT POST·INDEXED. An intermediate in- direct memory address is calculated by adding the PC, used as a base register, and a base displacement (bd). This address is used for an indirect memory access into program space of a long word, followed by adding the index operand (Xn.SIZE*SCALE) with the fetched address. Finally, the optional outer displacement (od) is added to yield the effec- tive address. Generation: EA = (bd + PC) + Xn.SIZE*SCALE + od Assembler Syntax: ([bd,PC],Xn.SIZE*SCALE,od) Mode: 111 Register Field: 011 31 Address Program Counter: - - - - - - - - - - . 1L -_ _ _ _ _ _ of_ _ _ _ ____ Extension Word ______ ~--~ 31 o Base Displacement: Sign Extended Value 31 Indirect Memory Address 31 Value at Indirect Memory Address in Program Space 31 Index Register: Sign Extended Value Scale Value 31 Outer Displacement: Sign Extended Value 31 Effective Address: Operand 2-16 2.8.7.2 PROGRAM COUNTER MEMORY INDIRECT PRE·INDEXED. In this case, the index operand (Xn.SIZE*SCALE) is added to the program counter and base displacement (bd). This intermediate sum is then used as an indirect address into the program space. Following the long word fetch of the new effective address, the optional outer displace· ment may be added to yield the effective address. Generation: EA = (bd + PC + Xn.SIZE*SCALE) + od Assembler Syntax: ([bd, PC,Xn.SIZE * SCALE),od) Mode: 111 Register Field: 011 31 o Program Counter: - - - - - - - - - + 1 Address of Extension Word ~----------,--~ 31 o Base Displacement: Sign Extended Value 31 Index Register: Sign Extended Value Scale Value 31 Indirect Memory Address 31 Value at Indirect Memory Address in Program Space 31 o Outer Displacement: Sign Extended Value 31 Effective Address: Operand 2·17 2.8.8 Absolute Address Modes Absolute address modes have the address of the operand in the extension word(s). 2.8.8.1 ABSOLUTE SHORT ADDRESS. This addressing mode requires one word of exten- sion. The address of the operand is in the extension word. The 16-bit address is sign ex- tended to 32 bits before it is used. Generation: EA given Assembler Syntax: xxx.W Mode: 111 Register: 000 ~1_ _ _ _ _ _ 0 Extension Word: - - - - - - - - - . . . . . :•." Sign Extended Memory Address '----------+-------. . . 31 0 Memory Address: Operand 2_8_8.2 ABSOLUTE LONG ADDRESS. This addressing mode requires two words of exten- sion. The address of the operand is developed by the concatenation of the extension words. The high order part of the address is the first extension word; the low order part of the address is the second extension word. Generation: EA given Assembler Syntax: xxx.L Mode: 111 Register: 001 15 o First Extension Word: -------~L -_ _ Address High -,-_-=---' 15 o Second Extension Word: 31 Concatenation 31 o Memory Address: Operand 2-18 2.8.9 Immediate Data This addressing mode requires one or two words of extension, depending on the size of the operation. Byte Operation - Operand is in the low order byte of the extension word Word Operation - Operand is in the extension word Long Word Operation - Operand is in two extension words; high order 16 bits are in the first extension word; low order 16 bits are in the se· cond extension word. Coprocessors may provide support for immediate data of any size with the instruction portion taking at least one word. Generation: Operand given Assembler Syntax: #xxx Mode: 111 Register: 100 2.9 EFFECTIVE ADDRESS ENCODING SUMMARY Table 2·1 details effective address extension word formats. The instruction operand ex· tension words fall into three categories: single·effective·address instruction, indexed/in· direct (brief format), and indexedlindirect (full format). The longest instruction for the MC68020 contains ten extension words. They consist of both source and destination ef· fective addresses using the full format extension word, with both base displacements and outer displacements being 32 bits. Table 2·1. Effective Address Specification Formats Single Effective Address Instruction Format 14 13 12 11 10 9 8 7 6 5 4 3 2 0 Effective Address Mode Register MC68020, Brief Format 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 I D/A I Register IWILI Scale I 0 I Displacement MC68020, Full Format 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 D/A I Register IW/L I Scale I 1 I BS I IS I BD SIZE I o I IllS Base Displacement 10, 1, or 2 Words) Outer Displacement 10, 1, or 2 Words) Field Definition Field Definition Register Index Register Number BS Base Suppress: D/A Index Register Type: 0= Base Register Added O=Dn 1 = Base Register Suppressed 1=An IS Index Suppress: W/L WordlLong Word Index Size: 0= Evaluate and Add Index Operand 0= Sign Extended Word 1 = Suppress Index Operand 1 = Lon~ Word BD SIZE Base Displacement Size: Scale Scale Factor: 00 = Heservea 00= 1 01 = Null Displacement 01 =2 10 = Word Displacement 10=4 11 = Long Displacement 11=8 IllS Indexllndirect Selection: Indirect and Indexing Operand Determined in Conjunction with Bit 6, Index Suppress 2·19 The index suppress (IS) and indexlindirect selection (IllS) fields are combined to deter- mine the type of indirection to be performed using the indexlindirect full format address- ing mode. The encodings and subsequent operations are described in Table 2-2. Table 2·2. IS·I/IS Memory Indirection Encodings Index/ IS Indirect Operation a 000 No Memory Indirection a 001 Indirect Pre-Indexed with Null Displacement a 010 Indirect Pre-Indexed with Word Displacement a all Indirect Pre-Indexed with Long Displacement a 100 Reserved a 101 Indirect Post-Indexed with Null Displacement a 110 Indirect Post-Indexed with Word Displacement a 111 Indirect Post-Indexed with Long Displacement 1 000 No Memory Indirection 1 001 Memory Indirect with Null Displacement 1 010 Memory Indirect with Word Displacement 1 011 Memory Indirect with Long Displacement 1 100-111 Reserved Table 2-3 is the encoding of the effective addressing modes discussed in the previous paragraphs. Table 2·3. Effective Address Encoding Summary Mode Register Data Register Direct 000 Reg # Address Register Direct 001 Reg # Address Register Indirect 010 Reg # Address Register Indirect with Postincrement 011 Reg # Address Register Indirect with Predecrement 100 Reg # Address Register Indirect with Displacement 101 Reg # Address Register and Memory Indirect with Index 110 Reg # Absolute Short 111 000 Absolute Long 111 001 Program Counter Indirect with Displacement 111 010 Program Counter and Memory Indirect with Index 111 011 Immediate Data 111 100 Reserved for Future Motorola Use 111 101 Reserved for Future Motorola Use 111 110 Reserved for Future Motorola Use 111 111 2.10 SYSTEM STACK Address register seven (A7) is used as the system stack pointer where anyone of three system stack registers is active at anyone time. The M and S bits of the status register determine which stack painter is used. If S = 0, the user stack pointer (USP) is the active system stack pointer and the master and interrupt stack pointers cannot be referenced. If S = 1 and M = 1, the master stack painter (MSP) is the active system stack pointer and the user and interrupt stack pointers cannot be referenced as address registers. If S = 1 and M = 0, the interrupt stack pointer (ISP) is the active system stack pointer and the user and master stack pointers cannot be referenced as address registers. (This corresponds to the MC68000, MC68008, MC68010, and MC68012 supervisor mode.) The term super- visor stack painter (SSP) refers to the master or interrupt stack pointers, depending on the state of the M bit. Each system stack fills from high to low memory. 2-20 The active system stack pointer is implicitly referenced by all instructions that use the system stack for linkage or storage allocation. The program counter is saved on the active system stack on subroutine calls and restored from the active system stack on returns. During the processing of traps and in- terrupts, both the program counter and the status register are saved on the supervisor stack (either master or interrupt). Thus, the execution of supervisor state code is not dependent on the behavior of user code or condition of the user stack, and user programs may use the user stack pointer independent of supervisor stack requirements. In order to keep data on the system stack aligned for maximum efficiency, data entry on the stack is restricted so that data is always put on the stack on a word boundary. Thus, byte data is pushed on to or pulled from the system stack as the high order byte of a word; the low order byte is unused. The MC68020 system stacking operations (e.g., stacking of exception frames, subroutine calls, etc.) always stack and unstack long word operands. The efficiency of these opera- tions is significantly increased in long word organized memory when the stack pointer is long word aligned. 2_11 USER PROGRAM STACKS Additional user program stacks can be implemented by employing the address register indirect with postincrement and predecrement addressing modes. Using an address register (AO through A6), the user may implement stacks which are filled either from high memory to low memory, or vice versa. The important considerations are: • using predecrement, the register is decremented before its contents are used as the pointer to the stack; • using postincrement, the register is incremented after its contents are used as the pOinter to the stack. Care must be exercised when mixing byte, word, and long word items in these stacks. Stack growth from high to low memory is implemented with - (An) to push data on the stack, (An) + to pull data from the stack. After either a push or a pull operation, register An points to the top item on the stack. This is illustrated as: Low Memory An -7 (Free) Top of Stack • • - 7 • Bottom of Stack High Memory 2-21 Stack growth from low to high memory is implemented with (An) + to push data on the stack, - (An) to pull data from the stack. After either a push or pull operation, register An points to the next available space on the stack. This is illustrated as: Low Memory Bottom of Stack • i.' • • Top of Stack An ---. (Free) High Memory 2.12 QUEUES User queues can also be implemented with the address register indirect with postincre- ment or predecrement addressing modes. Using a pair of address registers (two of AO through A6), the user may implement queues which are filled either from high memory to low memory, or vice versa. Because queues are pushed from one end and pulled from the other, two registers are used: the 'put' and 'get' pointers. Queue growth from low to high memory is implemented with (An) + to put data into the queue, (Am) + to get data from the queue. After a put operation, the 'put' address register points to the next available space in the queue and the unchanged 'get' address register points to the next item to be removed from the queue. After a 'get' operation, the 'get' address register points to the next item to be removed from the queue and the unchanged 'put' address register points to the next available space in the queue. This is illustrated as: Low Memory Last Get (Free) Get (Am) + ---. Next Get 7 • 7 • • Last Put Put (An) + ---. (Free) High Memory 2-22 If the queue is to be implemented as a circular buffer, the relevant address register should be checked and, if necessary, adjusted before the 'put' or 'get' operation is per- formed. The address register is adjusted by subtracting the buffer length (in bytes), pro- ducing a "wrap-around." Queue growth from high to low memory is implemented with - (An) - to put data into the queue, - (Am)-to get data from the queue. After a 'put' operation, the 'put' address register pOints to the last item put in the queue and the unchanged get address register points to the last item removed from the queue. After a 'get' operation, the 'get' address register points to the last item removed from the queue and the unchanged 'put' address register points to the last item put in the queue. This is illustrated as: Low Memory Put - (An) - L (Free) Last Put • • • Get -(Am) - Next Get Last Get (Free) High Memory If the queue is to be implemented as a circular buffer, the 'get' or 'put' operation should be performed first, and then the relevant address register should be checked and, if necessary, adjusted. The address register is adjusted by adding the buffer length (in bytes). 2-23/2-24 SECTION 3 INSTRUCTION SET SUMMARY This section contains an overview of the MC68020 instruction set. The instructions form a set of tools to perform the following operations: Data Movement Bit Field Manipulation Integer Arithmetic Binary Coded Decimal Arithmetic Logical Program Control Shift and Rotate System Control Bit Manipulation Multiprocessor Communications The complete range of instruction capabilities combined with the flexible addressing modes described previously provide a very flexible base for program development. The following notations will be used throughout this section. An = any address register, AO-A7 On = any data register, 00-07 Rn = any address or data register CCR = condition code register (lower byte of status register) cc = condition codes from SR or CCR SP = active stack pointer USP = user stack pointer SSP = supervisor stack pOinter OFC = destination function code register SFC = source function code register Rc = control register (VBR, SFC, OFC, CACR, CAAR, USP, MSP, ISP) = d displacement; d16 is a 16-bit displacement = effective address list = list of registers, e.g., 00-03 # = immediate data; a literal integer {offsetwidth} = bit field selection label = assembly program label [7] = bit 7 of respective operand [31 :24] = bits 31 through 24 of operand; i.e., high order byte of a register X = extend (X) bit in SR N = negative (N) bit in SR Z = zero (Z) bit in SR - = invert; operand is logically complemented t\ = ioyica.i AND V = logical OR e = logical exclusive OR 3-1 Dc = data register, 00-07 used during compare Du = data register, 00-07 used during update Dr, Dq = data register, remainder or quotient of divide Dh,DI = data register, high or low order 32 bits of multiply result 3.1 DATA MOVEMENT The basic means of address and data manipulation (transfer and storage) is accomplish- ed by the move (MOVE) instruction and its associated effective addressing modes. Data movement instructions allow byte,word, and long word operands to be transferred from memory to memory, memory to register, register to memory, and register to register. Ad- dress movement instructions (MOVE or MOVEA) allow word and long word operand transfers to ensure that only legal address manipulations are executed. In addition to the general MOVE instruction there are several special data movement instructions: move multiple registers (MOVEM), move peripheral data (MOVEP), move quick (MOVEQ), ex- change registers (EXG), load effective address (LEA), push effective address (PEA), link stack (LINK), unlink stack (UNLK). Table 3-1 is a summary of the data movement operations. Table 3·1. Data Movement Operations Operand Operand Instruction Syntax Size Operation EXG Rn, Rn 32 Rn - Rn LEA .An 32 - An LINK An,# 16,32 SP-4 - SP; An - ISPI; SP - An; SP + d - SP MOVE , 8,16,32 source - destination MOVEA , An 16,32-32 MOVEM list, 16,32 listed registers - destination , list 16,32-32 source - listed register MOVEP On, Id16,Anl 16,32 On[31:24] - IAn+dl; On[23:16] - IAn+d+21; On[15:8] - IAn+d+41; On[7:0] - IAn+d+61 Id16.Anl,On IAn+dl - On[31:24]; IAn+d+21 - On[23:16]; IAn+d+41 - On[15:8]; IAn+d+61 - On[7:0] MOVEQ #,On 8-32 immediate data - destination PEA 32 SP-4 - SP; - ISPI UNLK An 32 An - SP; ISPI - An; SP+4 - SP 3.2 INTEGER ARITHMETIC OPERATIONS The arithmetic operations include the four basic operations of add (ADD), subtract (SUB), multiply (MUL), and divide (DIV) as well as arithmetic compare (CMP, CMPM), clear (CLR), and negate (NEG). The ADD, CMP, and SUB instructions are available for both address and data operations, with data operations accepting all operand sizes. Address opera· tions are limited to legal address size operands (16 or 32 bits). The clear and negate in- structions may be used on all sizes of data operands. 3-2 The MUL and DIV operations are available for signed and unsigned operands using word multiply to produce a long word product, long word multiply to produce a long word or quad word product; a long word dividend with word divisor to produce a word quotient with a word remainder; and a long word or quad word dividend with long word divisor to produce long word quotient and long word remainder. Multiprecision and mixed size arithmetic can be accomplished using a set of extended instructions. These instructions are: add extended (ADDX), subtract extended (SUBX), sign extend (EXT), and negate binary with extend (NEGX). Refer to Table 3-2 for a summary of the integer arithmetic operations. Table 3-2. Integer Arithmetic Operations Operand Operand Instruction Syntax Size Operation ADD Dn, 8,16,32 source + destination - destination ,Dn 8,16,32 ADDA , An 16,32 ADDI #, 8,16,32 immediate data + destination - destination ADDO #, 8,16,32 ADDX Dn, Dn 8,16,32 source + destination + X - destination -(An), -(An) 8,16,32 CLR 8,16,32 o- destination CMP , Dn 8,16,32 destination - source CMPA ,An 16,32 CMPI #, 8,16,32 destination - immediate data CMPM (An) +, (An) + 8,16,32 destination - source CMP2 , Rn 8,16,32 lower bound< = Rn< = upper bound DIVS/DIVU , Dn 32116-16:16 destination/source - destination (signed or unsigned) , Dr:Dq 64/32-32:32 , Dq 32/32-32 DIVSLlDIVUL , Dr:Dq 32/32 - 32:32 EXT Dn 8-16 sign extended destination - destination Dn 16-32 EXTB Dn 8-32 MULS/MULU ,Dn 16x 16-32 source*destination - destination (signed or unsigned) ,DI 32x32-32 , Dh:DI 32x32-64 NEG 8,16,32 o - destination - destination NEGX 8,16,32 o - destination - X - destination SUB , Dn 8,16,32 destination - source - destination Dn, 8,16,32 SUBA , An 16,32 SUBI #, 8,16,32 destination - immediate data - destination SUBO #, 8,16,32 SUBX Dn, Dn 8,16,32 destination - source - X - destination - (An), - (An) 8,16,32 3-3 3.3 LOGICAL OPERATIONS Logical operation instructions AND, OR, EOR, and NOT are available for all sizes of in- teger data operands. A similar set of immediate instructions (ANDI, ORI, and EORI) pro- vide these logical operations with all sizes of immediate data. TST is an arithmetic com- parison of the operand with zero which is then reflected in the condition codes. Table 3-3 is a summary of the logical operations. Table 3·3. Logical Operations Operand Operand Instruction Syntax Size Operation AND , Dn 8,16,32 source 1\ destination ..... destination Dn, 8,16,32 ANDI #, 8,16,32 immediate data 1\ destination ..... destination EOR Dn, 8,16,32 source E& destination ..... destination EORI #, 8,16,32 immediate data E& destination ..... destination OR , Dn 8,16,32 source V destination ..... destination Dn, 8,16,32 ORI #, 8,16,32 immediate data V destination ..... destination NOT 8,16,32 - destination ..... destination TST 8,16,32 source - a to set condition codes 3.4 SHIFT AND ROTATE OPERATIONS Shift operations in both directions are provided by the arithmetic shift instructions ASR and ASL, and logical shift instructions LSR and LSL. The rotate instructions (with and without extend) available are ROR, ROL, ROXR, and ROXL. All shift and rotate operations can be performed on either registers or memory. Register shifts and rotates support all operand sizes and allow a shift count (from one to eight) to be specified in the instruction operation word or a shift count (modulo 64) to be specified in a register. Memory shifts and rotates are for word operands only and allow only single-bit shifts or rotates. The SWAP instruction exchanges the 16-bit halves of a register. Performance of shift/rotate instructions is enhanced so that use of the ROR or ROL instructions with a shift count of eight allows fast byte swapping. Table 3-4 is a summary of the shift and rotate operations. 3-4 Table 3·4. Shift and Rotate Operations Operand Operand Instruction Syntax Size Operation ASl On, On #, On 8,16,32 8, 16,32 16 ~ .. ~o ASR On, On 8,16,32 .~ #, On 8, 16,32 16 d I lSl On, On 8,16,32 #, On 8,16,32 ~ ... ~o 16 lSR On, On 8,16,32 #,On 8,16,32 16 04 .~ ROl On, On 8,16,32 #,On 8,16,32 16 [ 0 ... I I'" ~ ROR On, On 8, 16,32 #, On 8,16,32 16 L:i ·1 I ·m ROXl On, On 8,16,32 #, On 8, 16,32 16 m .. I I . . HiJ:=J ROXR On, On 8,16,32 #, On 8,16,32 16 ~ ·1 I .[£] SWAP On 32 I M~W I l~W I 3.5 BIT MANIPULATION OPERATIONS Bit manipulation operations are accomplished using the following instructions: bit test (BTST), bit test and set (BSET), bit test and clear (BClR), and bit test and change (BCHG). All bit manipulation operations can be performed on either registers or memory, with the bit number specified as immediate data or by the contents of a data register. Register operands are always 32 bits, while memory operands are always 8 bits. Table 3·5 is a summary of the bit manipulation operations. (Z is bit 2, the "zero" bit, of the status register.) Table 3·5. Bit Manipulation Operations Operand Operand Instruction Syntax Size Operation BCHG On, 8,32 - «bit number>of destination) - Z - bit of # , 8,32 destination BClR On, 8,32 - « bit number> of destination) - Z; #, 8,32 o - bit of destination BSH On, 8,32 - « bit number> of destination I -Z; #, 8,32 I - on of destination i BTST On, #, 8,32 8,32 - « bit number> of destination) - Z I 3·5 3.6 BIT FIELD OPERATIONS The MC68020 supports variable length bit field operations on fields of up to 32 bits. The bit field insert (BFINS) inserts a value into a bit field. Bit field extract unsigned (BFEXTU) and bit field extract signed (BFEXTS) extracts a value from the field. Bit field find first one (BFFFO) finds the first bit that is set in a bit field. Also included are instructions that are analagous to the bit manipulation operations; bit field test (BFTST), bit field test and set (BFSET), bit field test and clear (BFCLR), and bit field test and change (BFCHG). Table 3-6 is a summary of the bit field operations. Table 3·6. Bit Field Operations Operand Operand Instruction Syntax Size Operation BFCHG < ea > (offsetwidthj 1-32 - Field ...... Field BFCLR < ea > (offsetwidthj 1-32 O's ...... Field BFEXTS (offsetwidth}.On 1-32 Field ...... On; Sign Extended BFEXTU (offsetwidthj,On 1-32 Field ...... On; Zero Extended BFFFO (offsetwidth}.On 1-32 Scan for first bit set in Field; offset ...... On BFINS On, < ea > (offsetwidthj 1-32 On ...... Field BFSET (offsetwidthj 1-32 1's ...... Field BFTST (offsetwidthj 1-32 Field MSB ...... N; (OR of all bits in field) ...... Z NOTE: All bit field Instructions set the Nand Z bits as shown for BFTST before performing the specified operation. 3.7 BINARY CODED DECIMAL OPERATIONS Multiprecision arithmetic operations on binary coded decimal numbers are accomplish- ed using the following instructions: add decimal with extend (ABCD), subtract decimal with extend (SBCD), and negate decimal with extend (NBCD). PACK and UNPACK allow conversion of byte encoded numeric data, such as ASCII or EBCDIC strings, to BCD data and vice versa. Table 3-7 is a summary of the binary coded decimal operations. Table 3·7. Binary Coded Decimal Operations Operand Operand Instruction Syntax Size Operation ABCO On, On 8 source10 + destinationlO + X ...... destination - (An), - (An) 8 NBCD 8 o - destinationlO - X ...... destination PACK (An), - (An), 16 ...... 8 unpacked source + immediate data ...... packed destination # On, On, # 16 ...... 8 SBCD On, On 8 destinationlO - source10 - X ...... destination - (An), - (An) 8 UNPK (An), - (An), 8 ...... 16 packed source""" unpacked source # unpacked source + immediate data ...... On,On,# 8 ...... 16 unpacked destination 3-6 3.8 PROGRAM CONTROL OPERATIONS Program control operations are accomplished using a set of conditional and uncondi· tional branch instructions and return instructions. These instructions are summarized in Table 3·8. Table 3·8. Program Control Operations Operand Instruction Syntax Operation Conditional Bee