S12XCPUV2
S12XCPUV2
Reference Manual
CPU12/CPU12X
v01.04
04/2016
nxp.com
CPU12/CPU12X
Reference Manual
To provide the most up-to-date information, the revision of our documents on the World Wide Web will
be the most current. Your printed copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://nxp.com
The following revision history table summarizes changes contained in this document. For your
convenience, the page number designators have been linked to the appropriate location.
Revision History
Revision
Date Summary of Changes
Number
List of Paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Chapter 1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Chapter 1
Introduction
1.1 CPU Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.3 Symbols and Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3.1 Abbreviations for System Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
1.3.2 Memory and Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.3.3 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
1.3.4 Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Chapter 2
Overview
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2 Programming Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.2.1 Accumulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2.2 Index Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2.3 Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.2.4 Program Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.5 Condition Code Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.2.5.1 U Control Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.2.5.2 IPL[2:0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.2.5.3 S Control Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.2.5.4 X Mask Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.2.5.5 H Status Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.2.5.6 I Mask Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.5.7 N Status Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.5.8 Z Status Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.5.9 V Status Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.2.5.10 C Status Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.3 Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.4 Memory Organization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.5 Instruction Queue. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Chapter 3
Addressing Modes
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Chapter 4
Instruction Queue
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.2 Queue Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.2.1 CPU12 Family Queue Implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.2.2 Data Movement in the Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.2.3 No Movement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.2.4 Advance and Load from Data Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.2.5 Changes in Execution Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.2.6 Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.2.7 Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.2.8 Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.2.8.1 Short Branches. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.2.8.2 Long Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.2.8.3 Bit Condition Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.2.8.4 Loop Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.2.9 Jumps. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Chapter 5
Instruction Set Overview
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.2 Instruction Set Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.3 Load and Store Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.4 Transfer and Exchange Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Chapter 6
Instruction Glossary
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.2 Glossary Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6.3 Condition Code Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.4 Object Code Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.5 Source Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.6 Cycle-by-Cycle Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.7 Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
ABA — Add Accumulator B to Accumulator A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
ABX — Add Accumulator B to Index Register X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
ABY — Add Accumulator B to Index Register Y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
ADCA — Add with Carry to A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Chapter 8
Debugging Support
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
8.2 External Reconstruction of the Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
8.3 Instruction Queue Status Signals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
8.3.1 CPU12 Timing Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
8.3.2 CPU12X Timing Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
8.3.3 Null . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
8.3.4 ALD — Advance and Load from Data Bus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
8.3.5 INT — Interrupt Sequence Start. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
8.3.6 SEV — Start Instruction on Even Address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
8.3.7 SOD — Start Instruction on Odd Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
8.4 Queue Reconstruction (for CPU12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
8.4.1 Queue Reconstruction Registers (for CPU12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
8.4.1.1 fetch_add Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
8.4.1.2 st1_add, st1_dat Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
8.4.1.3 st2_add, st2_dat Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
8.4.1.4 st3_add, st3_dat Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
8.5 Instruction Tagging (CPU12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
8.6 Instruction Tagging (CPU12X) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Chapter 9
Fuzzy Logic Support
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
9.2 Fuzzy Logic Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
9.2.1 Fuzzification (MEM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
9.2.2 Rule Evaluation (REV and REVW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
Appendix A
Instruction Reference
A.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
A.2 Stack and Memory Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
A.3 Interrupt Vector Locations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
A.4 Notation Used in Instruction Set Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
A.5 Hexadecimal-to-Decimal Conversion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
A.6 Decimal-to-Hexadecimal Conversion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
Appendix B
CPU12V0 - CPU12V1
B.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
B.2 CPU12V1 Modifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
B.3 Source Code Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
B.4 Programmer’s Model and Stacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
B.5 Improved Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
B.6 Bus Signatures - Access Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464
Appendix C
CPU12 - CPU12X
Appendix D
CPU12XV0 - CPU12XV2
D.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
D.2 CPU12XV2 Modifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
D.3 Source Code Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
D.4 Programmer’s Model and Stacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
D.5 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
D.6 Bus Signatures - Access Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
D.7 Instruction Execution in User State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Appendix E
CPU12XV0 - CPU12XV1
E.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
E.2 CPU12XV1 Modifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
E.3 Source Code Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
E.4 Programmer’s Model and Stacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
E.5 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
E.6 Bus Signatures - Access Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Appendix F
High-Level Language Support
F.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
F.2 Data Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
F.3 Parameters and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
F.4 Register Pushes and Pulls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
F.5 Allocating and Deallocating Stack Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
F.6 Frame Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
F.7 Increment and Decrement Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
F.8 Higher Math Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
F.9 Conditional If Constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
F.10 Case and Switch Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
F.11 Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
F.12 Function Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
F.13 Instruction Set Orthogonality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
1.2 Features
The CPU12 Family is a high-speed, 16-bit processing CPU family which features a programming model
identical to that of the industry standard M68HC11 central processing unit CPU11. The CPU12 instruction
set is a proper superset of the M68HC11 instruction set, and M68HC11 source code is accepted by CPU12
assemblers with no changes. Likewise, the CPU12X instruction set is a proper superset of the CPU12
instruction set, and CPU12 source code is accepted by CPU12X assemblers with no changes1.
• Full 16-bit data paths supports efficient arithmetic operation and high-speed math execution
• Supports instructions with odd byte counts, including many single-byte instructions. This allows
much more efficient use of ROM space.
• An instruction queue buffers program information so the CPU12X has immediate access to at least
three bytes of machine code at the start of every instruction.
• Extensive set of indexed addressing capabilities, including:
— Using the stack pointer as an indexing register in all indexed operations
— Using the program counter as an indexing register in all but auto increment/decrement mode
— Accumulator offsets using A, B, or D accumulators
— Automatic index predecrement, preincrement, postdecrement, and postincrement (by –8 to +8)
1. With the exception of the Fuzzy instructions MEM, REV, REVW and WAV which are not supported on all versions of CPU12X.
1.3.3 Operators
+ —
Addition
– —
Subtraction
• —
Logical AND
+ —
Logical OR (inclusive)
⊕ —
Logical exclusive OR
× —
Multiplication
÷ —
Division
M —
Negation. One’s complement (invert each bit of M)
: —
Concatenate
Example: A : B means the 16-bit value formed by concatenating 8-bit
accumulator A with 8-bit accumulator B.
A is in the high-order position.
— Transfer
Example: (A) M means the content of accumulator A is transferred to
memory location M.
⇔ — Exchange
Example: D ⇔ X means exchange the contents of D with those of X.
1.3.4 Definitions
Logic level 1 is the voltage that corresponds to the true (1) state.
Logic level 0 is the voltage that corresponds to the false (0) state.
Set refers specifically to establishing logic level 1 on a bit or bits.
Cleared refers specifically to establishing logic level 0 on a bit or bits.
Asserted means that a signal is in active logic state. An active low signal changes from logic level 1 to
logic level 0 when asserted, and an active high signal changes from logic level 0 to logic level 1.
Negated means that an asserted signal changes logic state. An active low signal changes from logic level 0
to logic level 1 when negated, and an active high signal changes from logic level 1 to logic level 0.
ADDR is the mnemonic for address bus.
DATA is the mnemonic for data bus.
LSB means least significant bit or bits.
MSB means most significant bit or bits.
LSW means least significant word or words.
MSW means most significant word or words.
A specific bit location within a range is referred to by mnemonic and number. For example, A7 is bit 7 of
accumulator A.
A range of bit locations is referred to by mnemonic and the numbers that define the range. For example,
DATA[15:8] form the high byte of the data bus.
15 IX 0 INDEX REGISTER X
15 IY 0 INDEX REGISTER Y
15 SP 0 STACK POINTER
15 PC 0 PROGRAM COUNTER
2.2.1 Accumulators
General-purpose 8-bit accumulators A and B are used to hold operands and results of operations. Some
instructions treat the combination of these two 8-bit accumulators (A:B) as a 16-bit double
accumulator (D).
Most operations can use accumulator A or B interchangeably. However, there are a few exceptions. Add,
subtract, and compare instructions involving both A and B (ABA, SBA, and CBA) only operate in one
direction, so it is important to make certain the correct operand is in the correct accumulator. The decimal
adjust accumulator A (DAA) instruction is used after binary-coded decimal (BCD) arithmetic operations.
There is no equivalent instruction to adjust accumulator B.
The stack pointer (SP) holds the 16-bit address of the last stack location used. Normally, the SP is
initialized by one of the first instructions in an application program. The stack grows downward from the
address pointed to by the SP. Each time a byte is pushed onto the stack, the stack pointer is automatically
decremented, and each time a byte is pulled from the stack, the stack pointer is automatically incremented.
When a subroutine is called, the address of the instruction following the calling instruction is automatically
calculated and pushed onto the stack. Normally, a return-from-subroutine (RTS) or a return-from-call
(RTC) instruction is executed at the end of a subroutine. The return instruction loads the program counter
with the previously stacked return address and execution continues at that address.
When an interrupt occurs, the current instruction finishes execution. The address of the next instruction is
calculated and pushed onto the stack, all the CPU registers are pushed onto the stack, the program counter
is loaded with the address pointed to by the interrupt vector, and execution continues at that address. The
stacked registers are referred to as an interrupt stack frame. CPU12X stack frame has increased by one byte
compared to CPU12 stack frame.
NOTE
These instructions can be interrupted, and they resume execution once the
interrupt has been serviced:
• REV (fuzzy logic rule evaluation)
• REVW (fuzzy logic rule evaluation (weighted))
• WAV (weighted average)
These instructions are removed on CPU12V1, CPU12XV1 and CPU12XV2
The half-carry flag is used only for BCD arithmetic operations. The N, Z, V, and C status bits allow for
branching based on the results of a previous operation.
In some architectures, only a few instructions affect condition codes, so that multiple instructions must be
executed in order to load and test a variable. Since most instructions automatically update condition codes,
it is rarely necessary to execute an extra instruction for this purpose. The challenge in using the CPU12
Family lies in finding instructions that do not alter the condition codes. The most important of these
instructions are pushes, pulls, transfers, and exchanges.
It is always a good idea to refer to an instruction set summary (see Appendix A, “Instruction Reference”)
to check which condition codes are affected by a particular instruction.
The following paragraphs describe normal uses of the condition codes. There are other, more specialized
uses. For instance, the C status bit is used to enable weighted fuzzy logic rule evaluation. Specialized
usages are described in the relevant portions of this manual and in Chapter 6, “Instruction Glossary”.
The CPU12X extends this condition code register to a 16-Bit wide register. The lower byte is identical to
the CPU12 version. The upper byte holds three bits reflecting the current processing level. These bits allow
the nesting of interrupts, blocking interrupts of a lower priority. For details on interrupt processing refer to
the Interrupt Block Guide.
The currently unused bits are reserved for future use and should be written to zero.
2.2.5.2 IPL[2:0]
The IPL bits allow the nesting of interrupts, blocking interrupts of an equal or lower priority. The current
IPL is automatically pushed to the stack by the standard interrupt stacking procedure. The new IPL is
copied to the CCR from the Priority Level of the highest priority active interrupt request channel. The
copying takes place when the interrupt vector is fetched. The previous IPL is automatically restored by
executing the RTI instruction.
These are common examples of 8-bit and 16-bit immediate addressing modes. The size of the immediate
operand is implied by the instruction context. In the third example, the instruction implies a 16-bit
immediate value but only an 8-bit value is supplied. In this case the assembler will generate the 16-bit
value $0067 because the CPU expects a 16-bit value in the instruction stream.
Example:
BRSET FOO,#$03,THERE
In this example, extended addressing mode is used to access the operand FOO, immediate addressing
mode is used to access the mask value $03, and relative addressing mode is used to identify the destination
address of a branch in case the branch-taken conditions are met. BRSET is listed as an extended mode
instruction even though immediate and relative modes are also used.
This is a basic example of direct addressing. The value $55 is taken to be the low-order half of an address
in the range $0000 through $00FF. The high order half of the address is assumed to be 0. During execution
of this instruction, the CPU12 combines the value $55 from the instruction with the assumed value of $00
to form the address $0055, which is then used to access the data to be loaded into accumulator A.
Example:
LDX $20
In this example, the value $20 is combined with the assumed value of $00 to form the address $0020. Since
the LDX instruction requires a 16-bit value, a 16-bit word of data is read from addresses $0020 and $0021.
After execution of this instruction, the X index register will have the value from address $0020 in its
high-order half and the value from address $0021 in its low-order half.
This is a basic example of extended addressing. The value from address $F03B is loaded into the A
accumulator.
instance, using an offset of $FC with a BRCLR that accesses memory using an 8-bit indexed postbyte sets
up a loop that executes until all the bits in the specified memory byte that correspond to 1s in the mask
byte are cleared.
Source
Postbyte Comments
Code
Code (xb) rr; 00 = X, 01 = Y, 10 = SP, 11 = PC
Syntax
Indexed addressing mode instructions use a postbyte to specify index registers (X and Y), stack pointer
(SP), or program counter (PC) as the base index register and to further classify the way the effective
address is formed. A special group of instructions cause this calculated effective address to be loaded into
an index register for further calculations:
• Load stack pointer with effective address (LEAS)
• Load X with effective address (LEAX)
• Load Y with effective address (LEAY)
also require additional extension bytes in the instruction for this extra information. The majority of indexed
instructions in real programs use offsets that fit in the shortest 5-bit form of indexed addressing.
Examples:
LDAA 0,X
STAB –8,Y
For these examples, assume X has a value of $1000 and Y has a value of $2000 before execution. The 5-bit
constant offset mode does not change the value in the index register, so X will still be $1000 and Y will
still be $2000 after execution of these instructions. In the first example, A will be loaded with the value
from address $1000. In the second example, the value from the B accumulator will be stored at address
$1FF8 ($2000 –$8).
For these examples, assume X is $1000 and Y is $2000 before execution of these instructions.
NOTE
These instructions do not alter the index registers so they will still be $1000
and $2000, respectively, after the instructions.
The first instruction will load A with the value from address $10FF and the second instruction will load B
with the value from address $1FEC.
the location of a pointer to the address to be acted on. The square brackets distinguish this addressing mode
from 16-bit constant offset indexing.
Example:
LDAA [10,X]
In this example, X holds the base address of a table of pointers. Assume that X has an initial value of
$1000, and that the value $2000 is stored at addresses $100A and $100B. The instruction first adds the
value 10 to the value in X to form the address $100A. Next, an address pointer ($2000) is fetched from
memory at $100A. Then, the value stored in location $2000 is read and loaded into the A accumulator.
For a “last-used” type of stack (the stack-scheme used on the CPU12 Family), these four examples are
equivalent to common push and pull instructions.
For a “next-available” type of stack, push A onto stack (PSHA) is equivalent to store accumulator A
(STAA) 1,SP– and pull A from stack (PULA) is equivalent to load accumulator A (LDAA) 1,+SP.
In the STAA 1,–SP example, the stack pointer is pre-decremented by one and then A is stored to the
address contained in the stack pointer. Similarly the LDX 2,SP+ first loads X from the address in the stack
pointer, then post-increments SP by two.
Example:
MOVW 2,X+,4,+Y
This example demonstrates how to work with data structures larger than bytes and words. With this
instruction in a program loop, it is possible to move words of data from a list having one word per entry
into a second table that has four bytes per table element. In this example the source pointer is updated after
the data is read from memory (post-increment) while the destination pointer is updated before it is used to
access memory (pre-increment).
This instruction internally adds B to X to form the address from which A will be loaded. B and X are not
changed by this instruction. This example is similar to the following 2-instruction combination in an
M68HC11.
Examples:
ABX
LDAA 0,X
However, this 2-instruction sequence alters the index register. If this sequence was part of a loop where B
changed on each pass, the index register would have to be reloaded with the reference value on each loop
pass. The use of LDAA B,X is more efficient on the CPU12 Family.
This example is a computed GOTO. The values beginning at GO1 are addresses of potential destinations
of the jump (JMP) instruction. At the time the JMP [D,PC] instruction is executed, PC points to the address
GO1, and D holds one of the values $0000, $0002, or $0004 (determined by the program some time before
the JMP).
Assume that the value in D is $0002. The JMP instruction adds the values in D and PC to form the address
of GO2. Next the CPU12 reads the address PLACE2 from memory at GO2 and jumps to PLACE2. The
locations of PLACE1 through PLACE3 were known at the time of program assembly but the destination
of the JMP depends upon the value in D computed during program execution.
The only combinations of addressing modes that are not allowed are those with an immediate mode
destination (the operand of an immediate mode instruction is data, not an address). For indexed moves, the
reference index register may be X, Y, SP, or PC.
In the CPU12 Move instructions do not support indirect modes, 9-bit, or 16-bit offset modes requiring
extra extension bytes, while the CPU12X features all addressing modes for the source operand as well as
for the destination operand. There are special considerations when using PC-relative addressing with move
instructions.
PC-relative addressing uses the address of the location immediately following the last byte of object code
for the current instruction as a reference point. The CPU12 normally corrects for queue offset and for
instruction alignment so that queue operation is transparent to the user. However, in the CPU12X, move
instructions using PC relative addressing pose a special problem:
• Some moves have object code that is too long to fit in the queue all at one time, so the PC value
changes during execution.
This case is not handled by automatic queue pointer maintenance, but it is still possible to use PC-relative
indexing with move instructions by providing for PC offsets in source code.
A PC offset must be applied to the source address when using PC relative index addressing for the source
operand and the destination addressing mode is any of the three index addressing modes listed in Table 3-3
below:
Table 3-3. Address Offsets for MOVB/MOVW using a PC-relative source address
IDX1 +1
IDX2 +2
[IDX2] +2
These offsets compensate for the variable instruction length and are needed to identify the location of the
instruction immediately following the MOVB/MOVW instruction.
The branch if bits cleared (BRCLR) and branch if bits set (BRSET) instructions use an 8-bit mask to test
the states of bits in a memory byte. The mask is supplied with the instruction as an immediate mode value.
The memory location to be tested is specified by means of direct, extended, or indexed addressing modes.
Relative addressing mode is used to determine the branch address. A signed 8-bit offset must be supplied
with the instruction.
4.2.3 No Movement
There is no data movement in the instruction queue during the cycle. This occurs during execution of
instructions that must perform a number of internal operations, such as division instructions.
4.2.6 Exceptions
Exceptions are events that require processing outside the normal flow of instruction execution. CPU12
Family Exceptions include five types of exceptions:
• Reset (including COP, clock monitor, and pin)
• Unimplemented opcode trap
• Software interrupt instruction
• X-bit interrupts
• I-bit interrupts
All exceptions use the same microcode, but the CPU follows different execution paths for each type of
exception.
CPU12 Family exception handling is designed to minimize the effect of queue operation on context
switching. Thus, an exception vector fetch is the first part of exception processing, and fetches to refill the
queue from the address pointed to by the vector are interleaved with the stacking operations that preserve
context, so that program access time does not delay the switch. Refer to Chapter 7, “Exception Processing”
for detailed information.
4.2.7 Subroutines
The CPU can branch to (BSR), jump to (JSR), or call (CALL) subroutines. BSR and JSR are used to access
subroutines in the normal 64KB address space. The CALL instruction is intended for use in MCUs with
expanded memory capability.
BSR uses relative addressing mode to generate the effective address of the subroutine, while JSR can use
various other addressing modes. Both instructions calculate a return address, stack the address, then
perform three program word fetches to refill the queue.
Subroutines in the normal 64KB address space are terminated with a return-from-subroutine (RTS)
instruction. RTS unstacks the return address, then performs three program word fetches from that address
to refill the queue.
CALL is similar to JSR. MCUs with expanded memory treat 16KB of addresses from $8000 to $BFFF as
a memory window. An 8-bit PPAGE register switches memory pages into and out of the window. When
CALL is executed, a return address is calculated, then it and the current PPAGE value are stacked, and a
new instruction-supplied value is written to PPAGE. The subroutine address is calculated, then three
program word fetches are made from that address to refill the instruction queue.
The return-from-call (RTC) instruction is used to terminate subroutines in expanded memory. RTC
unstacks the PPAGE value and the return address, then performs three program word fetches from that
address to refill the queue.
CALL and RTC execute correctly in the normal 64KB address space, thus providing for portable code.
However, since extra execution cycles are required, routinely substituting CALL/RTC for JSR/RTS is not
recommended.
4.2.8 Branches
Branch instructions cause execution flow to change when specific pre-conditions exist. The CPU12
Family instruction set includes:
• Short conditional branches
• Long conditional branches
• Bit-condition branches
Types and conditions of branch instructions are described in Section 5.19, “Branch Instructions””. All
branch instructions affect the queue similarly, but there are differences in overall cycle counts between the
various types. Loop primitive instructions are a special type of branch instruction used to implement
counter-based loops.
4.2.9 Jumps
Jump (JMP) is the simplest change of flow instruction. JMP can use extended or indexed addressing.
Indexed operations require varying amounts of information to determine the effective address, so
instruction length varies according to the mode used, which in turn affects the amount of program
information fetched. All forms of JMP perform three program word fetches at the new address to refill the
instruction queue.
1. In the original M68HC12, the implementation of these two cycles are both program word fetches.
Store instructions copy the content of a CPU register to memory. Register/accumulator content is not
changed by the operation. Store instructions automatically update the N and Z condition code bits, which
can eliminate the need for a separate test instruction in some programs.
Table 5-1 is a summary of load and store instructions.
Load Instructions
GLDAA 1 Global Load A (M) A
GLDAB1 Global Load B (M) B
GLDD 1
Global Load D (M : M + 1) (A:B)
GLDS1 Global Load SP (M : M + 1) SPH:SPL
GLDX1 Global Load index register X (M : M + 1) XH:XL
GLDY1 Global Load index register Y (M : M + 1) YH:YL
LDAA Load A (M) A
LDAB Load B (M) B
LDD Load D (M : M + 1) (A:B)
LDS Load SP (M : M + 1) SPH:SPL
LDX Load index register X (M : M + 1) XH:XL
LDY Load index register Y (M : M + 1) YH:YL
LEAS Load effective address into SP Effective address SP
LEAX Load effective address into X Effective address X
LEAY Load effective address into Y Effective address Y
Store Instructions
GSTAA 1
Global Store A (A) M
GSTAB 1
Global Store B (B) M
GSTD 1
Global Store D (A) M, (B) M + 1
GSTS1 Global Store SP (SPH:SPL) M : M + 1
GSTX1 Global Store X (XH:XL) M : M + 1
GSTY 1 Global Store Y (YH:YL) M : M + 1
STAA Store A (A) M
STAB Store B (B) M
STD Store D (A) M, (B) M + 1
STS Store SP (SPH:SPL) M : M + 1
STX Store X (XH:XL) M : M + 1
STY Store Y (YH:YL) M : M + 1
1
CPU12X only
Transfer Instructions
TAB Transfer A to B (A) B
TAP Transfer A to CCR (A) CCR
TBA Transfer B to A (B) A
TFR Transfer register (A, B, CCR, D, X, Y, or SP)
to register A, B, CCR, D, X, Y, or SP
TPA Transfer CCR to A (CCR) A
TSX Transfer SP to X (SP) X
TSY Transfer SP to Y (SP) Y
TXS Transfer X to SP (X) SP
TYS Transfer Y to SP (Y) SP
Exchange Instructions
EXG Exchange register (A, B, CCR, D, X, Y, or SP) ⇔
to register (A, B, CCR, D, X, Y, or SP)
XGDX Exchange D with X (D) ⇔ (X)
XGDY Exchange D with Y (D) ⇔ (Y)
Sign Extension Instruction
SEX Sign extend Sign-extended (A, B, or CCR)
8-Bit operand D, X, Y, or SP
SEX1 Sign extend Sign-extended (D) X, Y
16-Bit operand
1
CPU12X only
Addition Instructions
ABA Add B to A (A) + (B) A
ABX Add B to X (B) + (X) X
ABY Add B to Y (B) + (Y) Y
ADCA Add with carry to A (A) + (M) + C A
ADCB Add with carry to B (B) + (M) + C B
ADDA Add without carry to A (A) + (M) A
ADDB Add without carry to B (B) + (M) B
ADDD Add to D (A:B) (A:B) + (M : M + 1) A : B
ADDX1 Add to X (X) + (M : M + 1) X
ADDY 1 Add to Y (Y) + (M : M + 1) Y
ADED 1 Add with carry to D (A:B) + (M : M + 1) + C A : B
ADEX1 Add with carry to X (X) + (M : M + 1) + C X
ADEY 1 Add with carry to Y (Y) + (M : M + 1) + C Y
Subtraction Instructions
SBA Subtract B from A (A) – (B) A
SBCA Subtract with borrow from A (A) – (M) – C A
SBCB Subtract with borrow from B (B) – (M) – C B
SBED 1 Subtract with borrow from D (A:B) (A:B) – (M) – C A : B
SBEX 1 Subtract with borrow from X (X) – (M) – C X
SBEY1 Subtract with borrow from Y (Y) – (M) – C Y
SUBA Subtract memory from A (A) – (M) A
SUBB Subtract memory from B (B) – (M) B
Decrement Instructions
DEC Decrement memory (M) – $01 M
DECA Decrement A (A) – $01 A
DECB Decrement B (B) – $01 B
DECW 1
Decrement memory (M : M + 1) – $0001 M : M + 1
DECX1 Decrement X (X) – $0001 X
DECY 1
Decrement Y (Y) – $0001 Y
Compare Instructions
CBA Compare A to B (A) – (B)
CMPA Compare A to memory (A) – (M)
CMPB Compare B to memory (B) – (M)
CPD Compare D to memory (16-bit) (A : B) – (M : M + 1)
CPED1 Compare D to memory with borrow (16-bit) (A : B) – (M : M + 1) – C
1
CPES Compare SP to memory with borrow (16-bit) (SP) – (M : M + 1) – C
1
CPEX Compare X to memory with borrow (16-bit) (X) – (M : M + 1) – C
CPEY1 Compare Y to memory with borrow (16-bit) (Y) – (M : M + 1) – C
CPS Compare SP to memory (16-bit) (SP) – (M : M + 1)
CPX Compare X to memory (16-bit) (X) – (M : M + 1)
CPY Compare Y to memory (16-bit) (Y) – (M : M + 1)
Test Instructions
TST Test memory for zero or minus (M) – $00
Compare Instructions
TSTA Test A for zero or minus (A) – $00
TSTB Test B for zero or minus (B) – $00
1
TSTW Test memory for zero or minus (M : M + 1) – $0000
1
TSTX Test X for zero or minus (X) – $0000
TSTY1 Test Y for zero or minus (Y) – $0000
1
CPU12X only
Multiplication Instructions
EMUL 16 by 16 multiply (unsigned) (D) × (Y) Y : D
Logical Shifts
LSL Logic shift left memory
LSLA Logic shift left A 0
LSLB Logic shift left B C b7 b0
Rotates
ROL Rotate left memory through carry
ROLA Rotate left A through carry
C b7 b0
ROLB Rotate left B through carry
ROLW1 Rotate left memory through carry
ROLX1 Rotate left X through carry
C b7 b0 b7 b0
ROLY1 Rotate left Y through carry
ROR Rotate right memory through carry
RORA Rotate right A through carry
b7 b0 C
RORB Rotate right B through carry
RORW1 Rotate right memory through carry
RORX1 Rotate right X through carry
b7 b0 b7 b0 C
RORY1 Rotate right Y through carry
1
CPU12X only
Fi X
i=1
MAX and MIN instructions use accumulator A to perform 8-bit comparisons, while EMAX and EMIN
instructions use accumulator D to perform 16-bit comparisons. The result (maximum or minimum value)
can be stored in the accumulator (EMAXD, EMIND, MAXA, MINA) or the memory address (EMAXM,
EMINM, MAXM, MINM).
Table 5-14 is a summary of minimum and maximum instructions.
Table 5-14. Minimum and Maximum Instructions
Minimum Instructions
EMIND MIN of two unsigned 16-bit values MIN ((D), (M : M + 1)) D
Result to Accumulator
EMINM MIN of two unsigned 16-bit values MIN ((D), (M : M + 1)) M : M+1
Result to Memory
MINA MIN of two unsigned 8-bit values MIN ((A), (M)) A
result to accumulator
MINM MIN of two unsigned 8-bit values MIN ((A), (M)) M
result to memory
Maximum Instructions
EMAXD MAX of two unsigned 16-bit values MAX ((D), (M : M + 1)) D
Result to Accumulator
EMAXM MAX of two unsigned 16-bit values MAX ((D), (M : M + 1)) M : M + 1
Result to Memory
MAXA MAX of two unsigned 8-bit values MAX ((A), (M)) A
Result to Accumulator
MAXM MAX of two unsigned 8-bit values MAX ((A), (M)) M
Result to Memory
size. Interpolation can be used for many purposes, including tabular fuzzy logic membership functions.
TBL uses 8-bit table entries and returns an 8-bit result; ETBL uses 16-bit table entries and returns a 16-bit
result. Use of indexed addressing mode provides great flexibility in structuring tables.
Consider each of the successive values stored in a table to be y-values for the endpoint of a line segment.
The value in the B accumulator before instruction execution begins represents the change in x from the
beginning of the line segment to the lookup point divided by total change in x from the beginning to the
end of the line segment. B is treated as an 8-bit binary fraction with radix point left of the MSB, so each
line segment is effectively divided into 256 smaller segments. During instruction execution, the change in
y between the beginning and end of the segment (a signed byte for TBL or a signed word for ETBL) is
multiplied by the content of the B accumulator to obtain an intermediate delta-y term. The result (stored
in the A accumulator by TBL, and in the D accumulator by ETBL) is the y-value of the beginning point
plus the signed intermediate delta-y value. Table 5-16 shows the table interpolation instructions.
The numeric range of short branch offset values is $80 (–128) to $7F (127) from the address of the next
memory location after the offset value.
Table 5-17 is a summary of the short branch instructions.
Unary Branches
BRA Branch always 1=1
BRN Branch never 1=0
Simple Branches
BCC Branch if carry clear C=0
BCS Branch if carry set C=1
BEQ Branch if equal Z=1
BMI Branch if minus N=1
BNE Branch if not equal Z=0
BPL Branch if plus N=0
BVC Branch if overflow clear V=0
BVS Branch if overflow set V=1
Unsigned Branches
Relation
BHI Branch if higher R>M C+Z=0
BHS Branch if higher or same R≥M C=0
BLO Branch if lower R<M C=1
BLS Branch if lower or same R≤M C+Z=1
Signed Branches
BGE Branch if greater than or equal R≥M N⊕V=0
BGT Branch if greater than R>M Z + (N ⊕ V) = 0
BLE Branch if less than or equal R≤M Z + (N ⊕ V) = 1
BLT Branch if less than R<M N⊕V=1
Unary Branches
LBRA Long branch always 1=1
LBRN Long branch never 1=0
Simple Branches
LBCC Long branch if carry clear C=0
LBCS Long branch if carry set C=1
LBEQ Long branch if equal Z=1
LBMI Long branch if minus N=1
LBNE Long branch if not equal Z=0
LBPL Long branch if plus N=0
LBVC Long branch if overflow clear V=0
LBVS Long branch if overflow set V=1
Unsigned Branches
LBHI Long branch if higher C+Z=0
LBHS Long branch if higher or same C=0
LBLO Long branch if lower Z=1
LBLS Long branch if lower or same C+Z=1
Signed Branches
LBGE Long branch if greater than or equal N⊕V=0
LBGT Long branch if greater than Z + (N ⊕ V) = 0
LBLE Long branch if less than or equal Z + (N ⊕ V) = 1
LBLT Long branch if less than N⊕V=1
return address so that execution resumes with the next instruction after CALL. For software compatibility,
CALL and RTC execute correctly on devices that do not have expanded addressing capability. Table 5-21
summarizes the jump and subroutine instructions.
to be used as a substitute for SWI in application code to better separate this from the debugging
functionality of SWI.
The RTI instruction is used to terminate all exception handlers, including interrupt service routines. RTI
first restores the CCRH (CPU12X only): CCR, B:A, X, Y, and the return address from the stack. If no other
interrupt is pending, normal execution resumes with the instruction following the last instruction that
executed prior to interrupt.
Table 5-22 is a summary of interrupt instructions.
Table 5-22. Interrupt Instructions
Mnemonic Function Operation
RTI Return (M(SP) : M(SP+1)) CCRH : CCR; SP + 2 SP
from interrupt (M(SP) : M(SP+1)) B : A; SP + 2 SP
(M(SP) : M(SP+1)) XH : XL; SP + 4 SP
(M(SP) : M(SP+1)) PCH : PCL; SP – 2 SP
(M(SP) : M(SP+1)) YH : YL; SP + 4 SP
SWI Software interrupt SP – 2 SP; RTNH : RTNL M(SP) : M(SP+1)
SP – 2 SP; YH : YL M(SP) : M(SP+1)
SP – 2 SP; XH : XL M(SP) : M(SP+1)
SP – 2 SP; B : A M(SP) : M(SP+1)
SP – 2 SP; CCRH : CCR M(SP) : M(SP+1)
SYS1 System call SP – 2 SP; RTNH : RTNL M(SP) : M(SP+1)
interrupt SP – 2 SP; YH : YL M(SP) : M(SP+1)
SP – 2 SP; XH : XL M(SP) : M(SP+1)
SP – 2 SP; B : A M(SP) : M(SP+1)
SP – 2 SP; CCRH : CCR M(SP) : M(SP+1)
TRAP Unimplemented SP – 2 SP; RTNH : RTNL M(SP) : M(SP+1)
opcode interrupt SP – 2 SP; YH : YL M(SP) : M(SP+1)
SP – 2 SP; XH : XL M(SP) : M(SP+1)
SP – 2 SP; B : A M(SP) : M(SP+1)
SP – 2 SP; CCRH : CCR M(SP) : M(SP+1)
1
CPU12XV1 and CPU12XV2 only
Addition Instructions
ABX Add B to X (B) + (X) X
ABY Add B to Y (B) + (Y) Y
Compare Instructions
CPES1 Compare SP to memory with borrow (SP) – (M : M + 1) – C
1
CPEX Compare X to memory with borrow (X) – (M : M + 1) – C
CPEY1 Compare Y to memory with borrow (Y) – (M : M + 1) – C
The wait instruction (WAI) stacks a return address and the contents of CPU registers and accumulators,
then waits for an interrupt service request; however, system clock signals continue to run.
Both STOP and WAI require that either an interrupt or a reset exception occur before normal execution of
instructions resumes. Although both instructions require the same number of clock cycles to resume
normal program execution after an interrupt service request is made, restarting after a STOP requires extra
time for the oscillator to reach operating speed.
Table 5-27. Stop and Wait Instructions
CCR Details
S X H I N Z V C
Unless high byte – – Δ – Δ Δ Δ Δ
is affected, only
low byte of register
is shown. H: A3 • B3 + B3 • R3 + R3 • A3
Set if there was a carry from bit 3;
N: Set if MSB of result is set; cleared
Z: Set if result is $00; cleared otherwi
Effect on
Condition Code Register V: A7 • B7 • R7 + A7 • B7 • R7
Status Bits Set if a two’s complement
C: A7 • B7 + B7 • R7 • R7 • Α7
Set if there was a carry from the MS
Each entry contains symbolic and textual descriptions of operation, information concerning the effect of
operation on status bits in the condition code register, and a table that describes assembler syntax, address
mode variations, and cycle-by-cycle execution of the instruction.
abc — Any one legal register designator for accumulators A or B or the CCR
abcdxys — Any one legal register designator for accumulators A or B, the CCR, the double
accumulator D, index registers X or Y, or the SP. Some assemblers may accept t2, T2,
t3, or T3 codes in certain cases of transfer and exchange
instructions, but these forms are intended for NXP use only.
abd — Any one legal register designator for accumulators A or B or the double accumulator D
abdxys — Any one legal register designator for accumulators A or B, the double accumulator D,
index register X or Y, or the SP
dxys — Any one legal register designation for the double accumulator D, index registers X or
Y, or the SP
msk8 — Any label or expression that evaluates to an 8-bit value. Some assemblers require a #
symbol before this value.
opr8i — Any label or expression that evaluates to an 8-bit immediate value
opr16i — Any label or expression that evaluates to a 16-bit immediate value
opr8a — Any label or expression that evaluates to an 8-bit value. The instruction treats this 8-bit
value as the low-order 8 bits of an address in the direct page of the 64KB address space
($00xx).
opr16a — Any label or expression that evaluates to a 16-bit value. The instruction treats this value
as an address in the 64KB address space.
oprx0_xysp — This word breaks down into one of the following alternative forms that assemble to an
8-bit indexed addressing postbyte code. These forms generate the same object code
except for the value of the postbyte code, which is designated as xb in the object code
columns of the glossary pages. As with the source forms, treat all commas, plus signs,
and minus signs as literal syntax elements. The italicized words used in these forms are
included in this key.
oprx5,xysp
oprx3,–xys
oprx3,+xys
oprx3,xys–
oprx3,xys+
abd,xysp
oprx3 — Any label or expression that evaluates to a value in the range +1 to +8
oprx5 — Any label or expression that evaluates to a 5-bit value in the range –16 to +15
oprx9 — Any label or expression that evaluates to a 9-bit value in the range –256 to +255
oprx16 — Any label or expression that evaluates to a 16-bit value. Since the CPU12 Family has
a 16-bit address bus, this can be either a signed or an unsigned value.
page — Any label or expression that evaluates to an 8-bit value. The CPU recognizes up to an
8-bit page value for memory expansion but not all MCUs from the CPU12 Family
implement all of these bits. It is the programmer’s responsibility to limit the page value
to legal values for the intended MCU system. Some assemblers require a # symbol
before this value.
rel8 — Any label or expression that refers to an address that is within –128 to +127 locations
from the next address after the last byte of object code for the current instruction. The
assembler will calculate the 8-bit signed offset and include it in the object code for this
instruction.
rel9 — Any label or expression that refers to an address that is within –256 to +255 locations
from the next address after the last byte of object code for the current instruction. The
assembler will calculate the 9-bit signed offset and include it in the object code for this
instruction. The sign bit for this 9-bit value is encoded by the assembler as a bit in the
looping postbyte (lb) of one of the loop control instructions DBEQ, DBNE, IBEQ,
IBNE, TBEQ, or TBNE. The remaining eight bits of the offset are included as an extra
byte of object code.
rel16 — Any label or expression that refers to an address anywhere in the 64KB address space.
The assembler will calculate the 16-bit signed offset between this address and the next
address after the last byte of object code for this instruction and include it in the object
code for this instruction.
trapnum — Any label or expression that evaluates to an 8-bit number in the range $30–$39 or
$40–$FF. Used for TRAP instruction.
xys — Any one legal register designation for index registers X or Y or the SP
xysp — Any one legal register designation for index registers X or Y, the SP, or the PC. The
reference point for PC-relative instructions is the next address after the last byte of
object code for the current instruction.
n — Write 8-bit PPAGE register. These cycles are used only with the CALL and RTC
instructions to write the destination value of the PPAGE register and are not visible on
the external bus. Since the PPAGE register is an internal 8-bit register, these cycles are
never stretched.
NA — Not available
O — Optional cycle. Program information is always fetched as aligned 16-bit words. When
an instruction consists of an odd number of bytes, and the first byte is misaligned, an O
cycle is used to make an additional program word access (P) cycle that maintains queue
order. In all other cases, the O cycle appears as a free (f) cycle. The $18 prebyte for page
two opcodes is treated as a special 1-byte instruction. If the prebyte is misaligned, the O
cycle is used as a program word access for the prebyte; if the prebyte is aligned, the O
cycle appears as a free cycle. If the remainder of the instruction consists of an odd
number of bytes, another O cycle is required some time before the instruction is
completed. If the O cycle for the prebyte is treated as a P cycle, any subsequent O cycle
in the same instruction is treated as an f cycle; if the O cycle for the prebyte is treated as
an f cycle, any subsequent O cycle in the same instruction is treated as a P cycle.
Optional cycles used for program word
accesses can be extended to two bus cycles if the MCU is operating with an 8-bit
external data bus and the program is stored in external memory. There can be additional
stretching when the address space is assigned to a chip-select circuit programmed for
slow memory. Optional cycles used as free cycles are never stretched.
P — Program word access. Program information is fetched as aligned 16-bit words. These
cycles are extended to two bus cycles if the MCU is operating with an 8-bit external data
bus and the program is stored externally. There can be additional stretching when the
address space is assigned to a chip-select circuit programmed for slow memory.
r — 8-bit data read. These cycles are stretched only when controlled by a chip-select circuit
programmed for slow memory.
R — 16-bit data read. These cycles are extended to two bus cycles if the MCU is operating
with an 8-bit external data bus and the corresponding data is stored in external memory.
There can be additional stretching when the address space is assigned to a chip-select
circuit programmed for slow memory. These cycles are also stretched if they correspond
to misaligned accesses to memory that is not designed for single-cycle misaligned
access.
s — Stack 8-bit data. These cycles are stretched only when controlled by a chip-select circuit
programmed for slow memory.
S — Stack 16-bit data. These cycles are extended to two bus cycles if the MCU is operating
with an 8-bit external data bus and the SP is pointing to external memory. There can be
additional stretching if the address space is assigned to a chip-select circuit programmed
for slow memory. These cycles are also stretched if they correspond to misaligned
accesses to a memory that is not designed for single cycle misaligned access. The
internal RAM is designed to allow single cycle misaligned word access.
w — 8-bit data write. These cycles are stretched only when controlled by a chip-select circuit
programmed for slow memory.
W — 16-bit data write. These cycles are extended to two bus cycles if the MCU is operating
with an 8-bit external data bus and the corresponding data is stored in external memory.
There can be additional stretching when the address space is assigned to a chip-select
circuit programmed for slow memory. These cycles are also stretched if they correspond
to misaligned access to a memory that is not designed for single-cycle misaligned
access.
u — Unstack 8-bit data. These cycles are stretched only when controlled by a chip-select
circuit programmed for slow memory.
U — Unstack 16-bit data. These cycles are extended to two bus cycles if the MCU is
operating with an 8-bit external data bus and the SP is pointing to external memory.
There can be additional stretching when the address space is assigned to a chip-select
circuit programmed for slow memory. These cycles are also stretched if they correspond
to misaligned accesses to a memory that is not designed for single-cycle misaligned
access. The internal RAM is designed to allow single-cycle misaligned word access.
V — Vector fetch. Vectors are always aligned 16-bit words. These cycles are extended to two
bus cycles if the MCU is operating with an 8-bit external data bus and the program is
stored in external memory. There can be additional stretching when the address space is
assigned to a chip-select circuit programmed for slow memory.
t — 8-bit conditional read. These cycles are either data read cycles or unused cycles,
depending on the data and flow of the REVW instruction. These cycles are stretched
only when controlled by a chip-select circuit programmed for slow memory.
T — 16-bit conditional read. These cycles are either data read cycles or free cycles,
depending on the data and flow of the REV or REVW instruction. These cycles are
extended to two bus cycles if the MCU is operating with an 8-bit external data bus and
the corresponding data is stored in external memory. There can be additional stretching
when the address space is assigned to a chip-select circuit programmed for slow
memory. These cycles are also stretched if they correspond to misaligned accesses to a
memory that is not designed for single-cycle misaligned access.
x — 8-bit conditional write. These cycles are either data write cycles or free cycles,
depending on the data and flow of the REV or REVW instruction. These cycles are only
stretched when controlled by a chip-select circuit programmed for slow memory.
PPP/P — Short branches require three cycles if taken, one cycle if not taken. Since the instruction
consists of a single word containing both an opcode and an 8-bit offset, the not-taken
case is simple — the queue advances, another program word fetch is made, and
execution continues with the next instruction. The taken case requires that the queue be
refilled so that execution can continue at a new address. First, the effective address of
the destination is determined, then the CPU performs three program word fetches from
that address.
OPPP/OPO — Long branches require four cycles if taken, three cycles if not taken. Optional cycles are
required because all long branches are page two opcodes, and thus include the $18
prebyte. The CPU treats the prebyte as a special 1-byte instruction. If the prebyte is
misaligned, the optional cycle is used to perform a program word access; if the prebyte
is aligned, the optional cycle is used to perform a free cycle. As a result, both the taken
and not-taken cases use one optional cycle for the prebyte. In the not-taken case, the
queue must advance so that execution can continue with the next instruction, and
another optional cycle is required to maintain the queue. The taken case requires that the
queue be refilled so that execution can continue at a new address. First, the effective
address of the destination is determined, then the CPU performs three program word
fetches from that address.
6.7 Glossary
This subsection contains an entry for each assembler mnemonic, in alphabetic order.
Description
Adds the content of accumulator B to the content of accumulator A and places the result in A. The
content of B is not changed. This instruction affects the H status bit so it is suitable for use in BCD
arithmetic operations. See DAA instruction for additional information.
CCR Details
S X H I N Z V C
– – Δ – Δ Δ Δ Δ
H: A3 • B3 + B3 • R3 + R3 • A3
Set if there was a carry from bit 3; cleared otherwise
N: Set if MSB of result is set; cleared otherwise
Z: Set if result is $00; cleared otherwise
V: A7 • B7 • R7 + A7 • B7 • R7
Set if a two’s complement overflow resulted from the operation; cleared otherwise
C: A7 • B7 + B7 • R7 + R7 • A7
Set if there was a carry from the MSB of the result; cleared otherwise
Description
Adds the 8-bit unsigned content of accumulator B to the content of index register X considering the
possible carry out of the low-order byte of X; places the result in X. The content of B is not changed.
This mnemonic is implemented by the LEAX B,X instruction. The LEAX instruction allows A, B, D,
or a constant to be added to X. For compatibility with the M68HC11, the mnemonic ABX is translated
into the LEAX B,X instruction by the assembler.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Adds the 8-bit unsigned content of accumulator B to the content of index register Y considering the
possible carry out of the low-order byte of Y; places the result in Y. The content of B is not changed.
This mnemonic is implemented by the LEAY B,Y instruction. The LEAY instruction allows A, B, D,
or a constant to be added to Y. For compatibility with the M68HC11, the mnemonic ABY is translated
into the LEAY B,Y instruction by the assembler.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Adds the content of accumulator A to the content of memory location M, then adds the value of the C
bit and places the result in A. This instruction affects the H status bit, so it is suitable for use in BCD
arithmetic operations. See DAA instruction for additional information.
CCR Details
S X H I N Z V C
– – Δ – Δ Δ Δ Δ
H: A3 • M3 + M3 • R3 + R3 • A3
Set if there was a carry from bit 3; cleared otherwise
N: Set if MSB of result is set; cleared otherwise
Z: Set if result is $00; cleared otherwise
V: A7 • M7 • R7 + A7 • M7 • R7
Set if two’s complement overflow resulted from the operation; cleared otherwise
C: A7 • M7 + M7 • R7 + R7 • A7
Set if the absolute value of the content of memory plus previous carry is larger than the absolute
value of the accumulator; cleared otherwise
Description
Adds the content of accumulator B to the content of memory location M, then adds the value of the C
bit and places the result in B. This instruction affects the H status bit, so it is suitable for use in BCD
arithmetic operations. See DAA instruction for additional information.
CCR Details
S X H I N Z V C
– – Δ – Δ Δ Δ Δ
H: B3 • M3 + M3 • R3 + R3 • B3
Set if there was a carry from bit 3; cleared otherwise
N: Set if MSB of result is set; cleared otherwise
Z: Set if result is $00; cleared otherwise
V: B7 • M7 • R7 + B7 • M7 • R7
Set if two’s complement overflow resulted from the operation; cleared otherwise
C: B7 • M7 + M7 • R7 + R7 • B7
Set if the absolute value of the content of memory plus previous carry is larger than the absolute
value of the accumulator; cleared otherwise
Description
Adds the content of memory location M to accumulator A and places the result in A. This instruction
affects the H status bit, so it is suitable for use in BCD arithmetic operations. See DAA instruction for
additional information.
CCR Details
S X H I N Z V C
– – Δ – Δ Δ Δ Δ
H: A3 • M3 + M3 • R3 + R3 • A3
Set if there was a carry from bit 3; cleared otherwise
N: Set if MSB of result is set; cleared otherwise
Z: Set if result is $00; cleared otherwise
V: A7 • M7 • R7 + A7 • M7 • R7
Set if two’s complement overflow resulted from the operation; cleared otherwise
C: A7 • M7 + M7 • R7 + R7 • A7
Set if there was a carry from the MSB of the result; cleared otherwise
Description
Adds the content of memory location M to accumulator B and places the result in B. This instruction
affects the H status bit, so it is suitable for use in BCD arithmetic operations. See DAA instruction for
additional information.
CCR Details
S X H I N Z V C
– – Δ – Δ Δ Δ Δ
H: B3 • M3 + M3 • R3 + R3 • B3
Set if there was a carry from bit 3; cleared otherwise
N: Set if MSB of result is set; cleared otherwise
Z: Set if result is $00; cleared otherwise
V: B7 • M7 • R7 + B7 • M7 • R7
Set if two’s complement overflow resulted from the operation; cleared otherwise
C: B7 • M7 + M7 • R7 + R7 • B7
Set if there was a carry from the MSB of the result; cleared otherwise
Description
Adds the content of memory location M concatenated with the content of memory location M +1 to
the content of double accumulator D and places the result in D. Accumulator A forms the high-order
half of 16-bit double accumulator D; accumulator B forms the low-order half.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Adds the content of index register X to the contents of memory location M : M + 1 and places the result
in X.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Adds the content of index register Y to the contents of memory location M : M + 1 and places the result
in Y.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Adds the content of accumulator A : B to the content of memory location M : M + 1, then adds the
value of the C bit and places the result in A : B.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Adds the content of index register X to the content of memory location M : M + 1, then adds the value
of the C bit and places the result in X.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Adds the content of index register Y to the content of memory location M : M + 1, then adds the value
of the C bit and places the result in Y.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Performs logical AND between the content of memory location M and the content of accumulator A.
The result is placed in A. After the operation is performed, each bit of A is the logical AND of the
corresponding bits of M and of A before the operation began.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs logical AND between the content of memory location M and the content of accumulator B.
The result is placed in B. After the operation is performed, each bit of B is the logical AND of the
corresponding bits of M and of B before the operation began.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs bitwise logical AND between the content of a mask operand and the content of the CCR. The
result is placed in the CCR. After the operation is performed, each bit of the CCR is the result of a
logical AND with the corresponding bits of the mask. To clear CCR bits, clear the corresponding mask
bits. CCR bits that correspond to ones in the mask are not changed by the ANDCC operation.
If the I mask bit is cleared, there is a 1-cycle delay before the system allows interrupt requests. This
prevents interrupts from occurring between instructions in the sequences CLI, WAI and CLI, STOP
(CLI is equivalent to ANDCC #$EF).
CCR Details
S X H I N Z V C
supervisor state
− − − user state
Condition code bits are cleared if the corresponding bit was 0 before the operation or if the
corresponding bit in the mask is 0.
Description
Performs logical AND between the content of memory location M : M + 1 and the content of index
register X. The result is placed in X. After the operation is performed, each bit of X is the logical AND
of the corresponding bits of M : M + 1 and of X before the operation began.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs logical AND between the content of memory location M : M + 1 and the content of index
register Y. The result is placed in Y. After the operation is performed, each bit of Y is the logical AND
of the corresponding bits of M : M + 1 and of Y before the operation began.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
C b7 – – – – – – b0 0
Description
Shifts all bits of memory location M one bit position to the left. Bit 0 is loaded with a 0. The C status
bit is loaded from the most significant bit of M.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 – – – – – – b0 0
Description
Shifts all bits of accumulator A one bit position to the left. Bit 0 is loaded with a 0. The C status bit is
loaded from the most significant bit of A.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 – – – – – – b0 0
Description
Shifts all bits of accumulator B one bit position to the left. Bit 0 is loaded with a 0. The C status bit is
loaded from the most significant bit of B.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 – – – – – – b0 b7 – – – – – – b0 0
Accumulator A Accumulator B
Description
Shifts all bits of double accumulator D one bit position to the left. Bit 0 is loaded with a 0. The C status
bit is loaded from the most significant bit of D.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
..... 0
C b15 b0
Description
Shifts all bits of memory location M : M + 1 one bit position to the left. Bit 0 is loaded with a 0. The
C status bit is loaded from the most significant bit of W.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
..... 0
C b15 b0
Description
Shifts all bits of index register X one bit position to the left. Bit 0 is loaded with a 0. The C status bit
is loaded from the most significant bit of X.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
.....
0
C b15 b0
Description
Shifts all bits of index register Y one bit position to the left. Bit 0 is loaded with a 0. The C status bit
is loaded from the most significant bit of Y.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
b7 – – – – – – b0 C
Description
Shifts all bits of memory location M one place to the right. Bit 7 is held constant. Bit 0 is loaded into
the C status bit. This operation effectively divides a two’s complement value by two without changing
its sign. The carry bit can be used to round the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
b7 – – – – – – b0 C
Description
Shifts all bits of accumulator A one place to the right. Bit 7 is held constant. Bit 0 is loaded into the C
status bit. This operation effectively divides a two’s complement value by two without changing its
sign. The carry bit can be used to round the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
b7 – – – – – – b0 C
Description
Shifts all bits of accumulator B one place to the right. Bit 7 is held constant. Bit 0 is loaded into the C
status bit. This operation effectively divides a two’s complement value by two without changing its
sign. The carry bit can be used to round the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
.....
b15 b0 C
Description
Shifts all bits of memory location M : M + 1 one place to the right. Bit 15 is held constant. Bit 0 is
loaded into the C status bit. This operation effectively divides a two’s complement value by two
without changing its sign. The carry bit can be used to round the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
.....
b15 b0 C
Description
Shifts all bits of index register X one place to the right. Bit 15 is held constant. Bit 0 is loaded into the
C status bit. This operation effectively divides a two’s complement value by two without changing its
sign. The carry bit can be used to round the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
.....
b15 b0 C
Description
Shifts all bits of index register Y one place to the right. Bit 15 is held constant. Bit 0 is loaded into the
C status bit. This operation effectively divides a two’s complement value by two without changing its
sign. The carry bit can be used to round the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Tests the C status bit and branches if C = 0.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Clears bits in location M. To clear a bit, set the corresponding bit in the mask byte. Bits in M that
correspond to 0s in the mask byte are not changed. Mask bytes can be located at PC + 2, PC + 3, or
PC + 4, depending on addressing mode used.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Tests the C status bit and branches if C = 1.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the Z status bit and branches if Z = 1.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
BGE can be used to branch after comparing or subtracting signed two’s complement values. After
CMPA, CMPB, CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if
the CPU register value is greater than or equal to the value in M. After CBA or SBA, the branch occurs
if the value in B is greater than or equal to the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
CCR Details
S X H I N Z V C
– – – – – – – –
Description
BGT can be used to branch after comparing or subtracting signed two’s complement values. After
CMPA, CMPB, CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if
the CPU register value is greater than the value in M. After CBA or SBA, the branch occurs if the value
in B is greater than the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
BHI can be used to branch after comparing or subtracting unsigned values. After CMPA, CMPB, CPD,
CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if the CPU register value
is greater than the value in M. After CBA or SBA, the branch occurs if the value in B is greater than
the value in A. BHI should not be used for branching after instructions that do not affect the C bit, such
as increment, decrement, load, store, test, clear, or complement.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
BHS can be used to branch after subtracting or comparing unsigned values. After CMPA, CMPB,
CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if the CPU register
value is greater than or equal to the value in M. After CBA or SBA, the branch occurs if the value in
B is greater than or equal to the value in A. BHS should not be used for branching after instructions
that do not affect the C bit, such as increment, decrement, load, store, test, clear, or complement.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Performs bitwise logical AND on the content of accumulator A and the content of memory location M
and modifies the condition codes accordingly. Each bit of the result is the logical AND of the
corresponding bits of the accumulator and the memory location. Neither the content of the accumulator
nor the content of the memory location is affected.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs bitwise logical AND on the content of accumulator B and the content of memory location M
and modifies the condition codes accordingly. Each bit of the result is the logical AND of the
corresponding bits of the accumulator and the memory location. Neither the content of the accumulator
nor the content of the memory location is affected.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs bitwise logical AND on the content of index register X and the content of memory location
M : M + 1 and modifies the condition codes accordingly. Each bit of the result is the logical AND of
the corresponding bits of the index register and the memory location. Neither the content of the index
register nor the content of the memory location is affected.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs bitwise logical AND on the content of index register Y and the content of memory location
M : M + 1 and modifies the condition codes accordingly. Each bit of the result is the logical AND of
the corresponding bits of the index register and the memory location. Neither the content of the index
register nor the content of the memory location is affected.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
BLE can be used to branch after subtracting or comparing signed two’s complement values. After
CMPA, CMPB, CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if
the CPU register value is less than or equal to the value in M. After CBA or SBA, the branch occurs if
the value in B is less than or equal to the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
BLO can be used to branch after subtracting or comparing unsigned values. After CMPA, CMPB,
CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if the CPU register
value is less than the value in M. After CBA or SBA, the branch occurs if the value in B is less than
the value in A. BLO should not be used for branching after instructions that do not affect the C bit,
such as increment, decrement, load, store, test, clear, or complement.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
If BLS is executed immediately after execution of CBA, CMPA, CMPB, CMPD, CPX, CPY, SBA,
SUBA, SUBB, or SUBD, a branch occurs if and only if the unsigned binary number in the accumulator
is less than or equal to the unsigned binary number in memory. Generally not useful after INC/DEC,
LD/ST, and TST/CLR/COM because these instructions do not affect the C status bit.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
BLT can be used to branch after subtracting or comparing signed two’s complement values. After
CMPA, CMPB, CMPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs
if the CPU register value is less than the value in M. After CBA or SBA, the branch occurs if the value
in B is less than the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the N status bit and branches if N = 1.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the Z status bit and branches if Z = 0.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the N status bit and branches if N = 0.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Unconditional branch to an address calculated as shown in the expression. Rel is a relative offset stored
as a two’s complement number in the second byte of the branch instruction.
Execution time is longer when a conditional branch is taken than when it is not, because the instruction
queue must be refilled before execution resumes at the new address. Since the BRA branch condition
is always satisfied, the branch is always taken, and the instruction queue must always be refilled.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Performs a bitwise logical AND of memory location M and the mask supplied with the instruction,
then branches if and only if all bits with a value of 1 in the mask byte correspond to bits with a value
of 0 in the tested byte. Mask operands can be located at PC + 1, PC + 2, or PC + 4, depending on
addressing mode. The branch offset is referenced to the next address after the relative offset (rr) which
is the last byte of the instruction object code.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Never branches. BRN is effectively a 2-byte NOP that requires one cycle to execute. BRN is included
in the instruction set to provide a complement to the BRA instruction. The instruction is useful during
program debug, to negate the effect of another branch instruction without disturbing the offset byte. A
complement for BRA is also useful in compiler implementations.
Execution time is longer when a conditional branch is taken than when it is not, because the instruction
queue must be refilled before execution resumes at the new address. Since the BRN branch condition
is never satisfied, the branch is never taken, and only a single program fetch is needed to update the
instruction queue.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Performs a bitwise logical AND of the inverse of memory location M and the mask supplied with the
instruction, then branches if and only if all bits with a value of 1 in the mask byte correspond to bits
with a value of one in the tested byte. Mask operands can be located at PC + 1, PC + 2, or PC + 4,
depending on addressing mode. The branch offset is referenced to the next address after the relative
offset (rr) which is the last byte of the instruction object code.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Sets bits in memory location M. To set a bit, set the corresponding bit in the mask byte. All other bits
in M are unchanged. The mask byte can be located at PC + 2, PC + 3, or PC + 4, depending upon
addressing mode.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Sets up conditions to return to normal program flow, then transfers control to a subroutine. Uses the
address of the instruction after the BSR as a return address.
Decrements the SP by two, to allow the two bytes of the return address to be stacked.
Stacks the return address (the SP points to the high-order byte of the return address).
Branches to a location determined by the branch offset.
Subroutines are normally terminated with an RTS instruction, which restores the return address from
the stack.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Test bits in memory location M, then set bits in memory location M. To test then set a bit, set the
corresponding bit in the mask byte. All other bits in M are unchanged. BTAS is an atomic instruction
and may be used to implement a semaphore.
NOTE
The CCR bits are affected by the test operation, (M) AND (Mask), and not
the result operation, (M) OR (Mask).
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Tests the V status bit and branches if V = 0.
BVC causes a branch when a previous operation on two’s complement binary values does not cause
an overflow. That is, when BVC follows a two’s complement operation, a branch occurs when the
result of the operation is valid.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the V status bit and branches if V = 1.
BVS causes a branch when a previous operation on two’s complement binary values causes an
overflow. That is, when BVS follows a two’s complement operation, a branch occurs when the result
of the operation is invalid.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Sets up conditions to return to normal program flow, then transfers control to a subroutine in expanded
memory. Uses the address of the instruction following the CALL as a return address. For code
compatibility, CALL also executes correctly in devices that do not have expanded memory capability.
Decrements the SP by two, then stores the return address on the stack. The SP points to the high-order
byte of the return address.
Decrements the SP by one, then stacks the current memory page value from the PPAGE register on the
stack.
Writes a new page value supplied by the instruction to PPAGE and transfers control to the subroutine.
In indexed-indirect modes, the subroutine address and the PPAGE value are fetched from memory in
the order M high byte, M low byte, and new PPAGE value.
Expanded-memory subroutines must be terminated by an RTC instruction, which restores the return
address and PPAGE value from the stack.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Compares the content of accumulator A to the content of accumulator B and sets the condition codes,
which may then be used for arithmetic and logical conditional branches. The contents of the
accumulators are not changed.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Clears the C status bit. This instruction is assembled as ANDCC #$FE. The ANDCC instruction can
be used to clear any combination of bits in the CCR in one operation.
CLC can be used to set up the C bit prior to a shift or rotate instruction involving the C bit.
CCR Details
S X H I N Z V C
– – – – – – – 0
C: 0; cleared
Description
Clears the I mask bit. This instruction is assembled as ANDCC #$EF. The ANDCC instruction can be
used to clear any combination of bits in the CCR in one operation.
When the I bit is cleared, interrupts are enabled. There is a 1-cycle (bus clock) delay in the clearing
mechanism for the I bit so that, if interrupts were previously disabled, the next instruction after a CLI
will always be executed, even if there was an interrupt pending prior to execution of the CLI
instruction.
CCR Details
S X H I N Z V C
– – – 0 – – – – supervisor state
– – – – – – – – user state
Description
All bits in memory location M are cleared to 0.
CCR Details
S X H I N Z V C
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
CLRA Clear A
(CPU12, CPU12X) CLRA
Operation
0A
Description
All bits in accumulator A are cleared to 0.
CCR Details
S X H I N Z V C
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
CLRB Clear B
(CPU12, CPU12X) CLRB
Operation
0B
Description
All bits in accumulator B are cleared to 0.
CCR Details
S X H I N Z V C
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
Description
All bits in memory location M : M + 1 are cleared to 0.
CCR Details
S X H I N Z V C
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
Description
All bits in index register X are cleared to 0.
CCR Details
S X H I N Z V C
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
Description
All bits in index register Y are cleared to 0.
CCR Details
S X H I N Z V C
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
Description
Clears the V status bit. This instruction is assembled as ANDCC #$FD. The ANDCC instruction can
be used to clear any combination of bits in the CCR in one operation.
CCR Details
S X H I N Z V C
– – – – – – 0 –
V: 0; cleared
CMPA Compare A
(CPU12, CPU12X) CMPA
Operation
(A) – (M)
Description
Compares the content of accumulator A to the content of memory location M and sets the condition
codes, which may then be used for arithmetic and logical conditional branching. The contents of A and
location M are not changed.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
CMPB Compare B
(CPU12, CPU12X) CMPB
Operation
(B) – (M)
Description
Compares the content of accumulator B to the content of memory location M and sets the condition
codes, which may then be used for arithmetic and logical conditional branching. The contents of B and
location M are not changed.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Replaces the content of memory location M with its one’s complement. Each bit of M is
complemented. Immediately after a COM operation on unsigned values, only the BEQ, BNE, LBEQ,
and LBNE branches can be expected to perform consistently. After operation on two’s complement
values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 1
COMA Complement A
(CPU12, CPU12X) COMA
Operation
(A) = $FF – (A) A
Description
Replaces the content of accumulator A with its one’s complement. Each bit of A is complemented.
Immediately after a COM operation on unsigned values, only the BEQ, BNE, LBEQ, and LBNE
branches can be expected to perform consistently. After operation on two’s complement values, all
signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 1
COMB Complement B
(CPU12, CPU12X) COMB
Operation
(B) = $FF – (B) B
Description
Replaces the content of accumulator B with its one’s complement. Each bit of B is complemented.
Immediately after a COM operation on unsigned values, only the BEQ, BNE, LBEQ, and LBNE
branches can be expected to perform consistently. After operation on two’s complement values, all
signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 1
Description
Replaces the content of memory location M : M + 1 with its one’s complement. Each bit of M : M + 1
is complemented. Immediately after a COM operation on unsigned values, only the BEQ, BNE,
LBEQ, and LBNE branches can be expected to perform consistently. After operation on two’s
complement values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 1
Description
Replaces the content of index register X with its one’s complement. Each bit of X is complemented.
Immediately after a COM operation on unsigned values, only the BEQ, BNE, LBEQ, and LBNE
branches can be expected to perform consistently. After operation on two’s complement values, all
signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 1
Description
Replaces the content of index register Y with its one’s complement. Each bit of Y is complemented.
Immediately after a COM operation on unsigned values, only the BEQ, BNE, LBEQ, and LBNE
branches can be expected to perform consistently. After operation on two’s complement values, all
signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 1
Description
Compares the content of double accumulator D with a 16-bit value at the address specified and sets the
condition codes accordingly. The compare is accomplished internally by a 16-bit subtract of
(M : M + 1) from D without modifying either D or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Compares the content of accumulator D with a 16-bit value at the address specified and sets the
condition codes accordingly. The compare is accomplished internally by a 16-bit subtract of
((M : M + 1) + C) from D without modifying either D or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Compares the content of stack pointer SP with a 16-bit value at the address specified and sets the
condition codes accordingly. The compare is accomplished internally by a 16-bit subtract of
((M : M + 1) + C) from SP without modifying either SP or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Compares the content of index register X with a 16-bit value at the address specified and sets the
condition codes accordingly. The compare is accomplished internally by a 16-bit subtract of
((M : M + 1) + C) from X without modifying either X or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Compares the content of index register Y with a 16-bit value at the address specified and sets the
condition codes accordingly. The compare is accomplished internally by a 16-bit subtract of
((M : M + 1) + C) from Y without modifying either Y or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Compares the content of the stack pointer SP with a 16-bit value at the address specified, and sets the
condition codes accordingly. The compare is accomplished internally by doing a 16-bit subtract of
(M : M + 1) from SP without modifying either the SP or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Compares the content of index register X with a 16-bit value at the address specified and sets the
condition codes accordingly. The compare is accomplished internally by a 16-bit subtract of
(M : M + 1) from index register X without modifying either index register X or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Compares the content of index register Y to a 16-bit value at the address specified and sets the
condition codes accordingly. The compare is accomplished internally by a 16-bit subtract of
(M : M + 1) from Y without modifying either Y or (M : M + 1).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
CCR Details
S X H I N Z V C
– – – – Δ Δ ? Δ
Description
Subtract one from the specified counter register A, B, D, X, Y, or SP. If the counter register has reached
zero, execute a branch to the specified relative destination. The DBEQ instruction is encoded into three
bytes of machine code including the 9-bit relative offset (–256 to +255 locations from the start of the
next instruction).
IBEQ and TBEQ instructions are similar to DBEQ except that the counter is incremented or tested
rather than being decremented. Bits 7 and 6 of the instruction postbyte are used to determine which
operation is to be performed.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Subtract one from the specified counter register A, B, D, X, Y, or SP. If the counter register has not
been decremented to zero, execute a branch to the specified relative destination. The DBNE instruction
is encoded into three bytes of machine code including a 9-bit relative offset (–256 to +255 locations
from the start of the next instruction).
IBNE and TBNE instructions are similar to DBNE except that the counter is incremented or tested
rather than being decremented. Bits 7 and 6 of the instruction postbyte are used to determine which
operation is to be performed.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Subtract one from the content of memory location M.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the DEC instruction to be used as a loop counter in
multiple-precision computations.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Subtract one from the content of accumulator A.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the DEC instruction to be used as a loop counter in
multiple-precision computations.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Subtract one from the content of accumulator B.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the DEC instruction to be used as a loop counter in
multiple-precision computations.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Subtract one from the content of memory location M : M + 1.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the DEC instruction to be used as a loop counter in
multiple-precision computations.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Subtract one from the content of index register X.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the DEC instruction to be used as a loop counter in
multiple-precision computations.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Subtract one from the content of index register Y.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the DEC instruction to be used as a loop counter in
multiple-precision computations.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Subtract one from the SP. This instruction assembles to LEAS –1,SP. The LEAS instruction does not
affect condition codes as DEX or DEY instructions do.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Subtract one from index register X. LEAX –1,X can produce the same result, but LEAX does not affect
the Z bit. Although the LEAX instruction is more flexible, DEX requires only one byte of object code.
Only the Z bit is set or cleared according to the result of this operation.
CCR Details
S X H I N Z V C
– – – – – Δ – –
Description
Subtract one from index register Y. LEAY –1,Y can produce the same result, but LEAY does not affect
the Z bit. Although the LEAY instruction is more flexible, DEY requires only one byte of object code.
Only the Z bit is set or cleared according to the result of this operation.
CCR Details
S X H I N Z V C
– – – – – Δ – –
Description
Divides a 32-bit unsigned dividend by a 16-bit divisor, producing a 16-bit unsigned quotient and an
unsigned 16-bit remainder. All operands and results are located in CPU registers. If an attempt to
divide by zero is made, C is set and the states of the N, Z, and V bits in the CCR are undefined. In case
of an overflow or a divide by zero, the contents of the registers D and Y do not change.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Divides a signed 32-bit dividend by a 16-bit signed divisor, producing a signed 16-bit quotient and a
signed 16-bit remainder. All operands and results are located in CPU registers. If an attempt to divide
by zero is made, C is set and the states of the N, Z, and V bits in the CCR are undefined. In case of an
overflow or a divide by zero, the contents of the registers D and Y do not change.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
A 16-bit value is multiplied by a 16-bit value to produce a 32-bit intermediate result. This 32-bit
intermediate result is then added to the content of a 32-bit accumulator in memory. EMACS is a signed
integer operation. All operands and results are located in memory. When the EMACS instruction is
executed, the first source operand is fetched from an address pointed to by X, and the second source
operand is fetched from an address pointed to by index register Y. Before the instruction is executed,
the X and Y index registers must contain values that point to the most significant bytes of the source
operands. The most significant byte of the 32-bit result is specified by an extended address supplied
with the instruction.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Operation
MAX ((D), (M : M + 1)) D
Description
Subtracts an unsigned 16-bit value in memory from an unsigned 16-bit value in double accumulator D
to determine which is larger, and leaves the larger of the two values in D. The Z status bit is set when
the result of the subtraction is zero (the values are equal), and the C status bit is set when the subtraction
requires a borrow (the value in memory is larger than the value in the accumulator). When C = 1, the
value in D has been replaced by the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand. Auto increment/decrement variations of
indexed addressing facilitate finding the largest value in a list of values.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts an unsigned 16-bit value in memory from an unsigned 16-bit value in double accumulator D
to determine which is larger, and leaves the larger of the two values in the memory location. The Z
status bit is set when the result of the subtraction is zero (the values are equal), and the C status bit is
set when the subtraction requires a borrow (the value in memory is larger than the value in the
accumulator). When C = 0, the value in D has replaced the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Operation
MIN ((D), (M : M + 1)) D
Description
Subtracts an unsigned 16-bit value in memory from an unsigned 16-bit value in double accumulator D
to determine which is larger, and leaves the smaller of the two values in D. The Z status bit is set when
the result of the subtraction is zero (the values are equal), and the C status bit is set when the subtraction
requires a borrow (the value in memory is larger than the value in the accumulator). When C = 0, the
value in D has been replaced by the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand. Auto increment/decrement variations of
indexed addressing facilitate finding the smallest value in a list of values.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts an unsigned 16-bit value in memory from an unsigned 16-bit value in double accumulator D
to determine which is larger and leaves the smaller of the two values in the memory location. The Z
status bit is set when the result of the subtraction is zero (the values are equal), and the C status bit is
set when the subtraction requires a borrow (the value in memory is larger than the value in the
accumulator). When C = 1, the value in D has replaced the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
An unsigned 16-bit value is multiplied by an unsigned 16-bit value to produce an unsigned 32-bit
result. The first source operand must be loaded into 16-bit double accumulator D and the second source
operand must be loaded into index register Y before executing the instruction. When the instruction is
executed, the value in D is multiplied by the value in Y. The upper 16-bits of the 32-bit result are stored
in Y and the low-order 16-bits of the result are stored in D.
The C status bit can be used to round the high-order 16 bits of the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ – Δ
Extended Multiply
EMULS 16-Bit by 16-Bit (Signed)
(CPU12, CPU12X)
EMULS
Operation
(D) × (Y) Y : D
Description
A signed 16-bit value is multiplied by a signed 16-bit value to produce a signed 32-bit result. The first
source operand must be loaded into 16-bit double accumulator D, and the second source operand must
be loaded into index register Y before executing the instruction. When the instruction is executed, D
is multiplied by the value Y. The 16 high-order bits of the 32-bit result are stored in Y and the 16
low-order bits of the result are stored in D.
The C status bit can be used to round the high-order 16 bits of the result.
CCR Details
S X H I N Z V C
– – – – Δ Δ – Δ
Description
Performs the logical exclusive OR between the content of accumulator A and the content of memory
location M. The result is placed in A. Each bit of A after the operation is the logical exclusive OR of
the corresponding bits of M and A before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs the logical exclusive OR between the content of accumulator B and the content of memory
location M. The result is placed in A. Each bit of A after the operation is the logical exclusive OR of
the corresponding bits of M and B before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs the logical exclusive OR between the content of index register X and the content of memory
location M : M + 1. The result is placed in X. Each bit of X after the operation is the logical exclusive
OR of the corresponding bits of M : M + 1 and X before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs the logical exclusive OR between the content of index register Y and the content of memory
location M : M + 1. The result is placed in Y. Each bit of Y after the operation is the logical exclusive
OR of the corresponding bits of M : M + 1 and Y before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
ETBL linearly interpolates one of 256 result values that fall between each pair of data entries in a
lookup table stored in memory. Data entries in the table represent the y values of endpoints of
equally-spaced line segments. Table entries and the interpolated result are 16-bit values. The result is
stored in the D accumulator.
Before executing ETBL, an index register points to the table entry corresponding to the x value
(X1 that is closest to, but less than or equal to, the desired lookup point (XL, YL). This defines the left
end of a line segment and the right end is defined by the next data entry in the table. Prior to execution,
accumulator B holds a binary fraction (radix left of MSB) representing the ratio of
(XL–X1) ÷ (X2–X1).
The 16-bit unrounded result is calculated using the following expression:
Where:
(B) = (XL – X1) ÷ (X2 – X1)
Y1 = 16-bit data entry pointed to by <effective address>
Y2 = 16-bit data entry pointed to by <effective address> + 2
The intermediate value [(B) × (Y2 – Y1)] produces a 24-bit result with the radix point between bits 7
and 8. Any indexed addressing mode, except indirect modes or 9-bit and 16-bit offset modes, can be
used to identify the first data point (X1,Y1). The second data point is the next table entry.
CCR Details
S X H I N Z V C
– – – – Δ Δ – Δ1
Description
Exchanges the contents of registers specified in the instruction as shown below. Note that the order in
which exchanges between 8-bit and 16-bit registers are specified affects the high byte of the 16-bit
registers differently. Exchanges of D with A or B are ambiguous. Cases involving TMP2 and TMP3
are reserved, so some assemblers may not permit their use, but it is possible to generate these cases by
using DC.B or DC.W assembler directives.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
– – – – – – – – – – – – – –
OR
– – – – Δ Δ Δ Δ Δ Δ Δ Δ supervisor state
– – – – – – − − Δ − Δ Δ Δ Δ user state
None affected, unless the CCR (or CCRL, CCRH, CCRW) is the destination register. Condition codes
take on the value of the corresponding source bits, except that the X mask bit cannot change from 0 to
1. Software can leave the X bit set, leave it cleared, or change it from 1 to 0, but it can be set only in
response to any reset or by recognition of an XIRQ interrupt.
LS A B CCR TMPx D X Y SP
A ⇔ CCRL B ⇔ CCRL CCRL ⇔ CCRL TMP3L CCRL B CCRL XL CCRL YL CCRL SPL CCRL
$FF:CCRL TMP3 $FF:CCRL D $FF:CCRL X $FF:CCRL Y $FF:CCRL SP
2 CCR
EXG A, CCR EXG B,CCR EXG CCR,CCR EXG, TMP3,CCR EXG D,CCR EXG X,CCR EXG Y,CCR EXG SP,CCR
EXG A,CCRL EXG B,CCRL EXG CCRL,CCRL EXG TMP3,CCRL EXG D,CCRL EXG X,CCRL EXG Y,CCRL EXG SP,CCRL
$00:A TMP2 $00:B TMP2 $00:CCRL TMP2 TMP3 ⇔ TMP2 D ⇔ TMP2 X ⇔ TMP2 Y ⇔ TMP2 SP ⇔ TMP2
3 TMP2 TMP2L A TMP2L B TMP2L CCR EXG TMP3,TMP2 EXG D,TMP2 EXG X,TMP2 EXG Y,TMP2 EXG SP,TMP2
EXG A,TMP2 EXG B,TMP2 EXG CCR,TMP2
B⇔A
A⇔A B⇔A CCRH ⇔ A TMP3H ⇔ A XH ⇔ A YH ⇔ A SPH ⇔ A
8 A EXG D,A
EXG A,A EXG B,A EXG CCRH,A EXG TMP3H,A EXG XH,A EXG YH,A EXG SPH,A
A ⇔ CCRH B ⇔ CCRL CCRH:L ⇔ CCRH:L TMP3 ⇔ CCRH:L D ⇔ CCRH:L X ⇔ CCRH:L Y ⇔ CCRH:L SP ⇔ CCRH:L
A CCR
EXG A,CCRH EXG B,CCRL EXG CCRW,CCRW EXG TMP3,CCRW EXG D,CCRW EXG X,CCRW EXG Y,CCRW EXG, SP,CCRW
A ⇔ TMP2H B ⇔ TMP2L CCRH:L⇔ TMP2 TMP3 ⇔ TMP2 D ⇔ TMP1 X ⇔ TMP2 Y ⇔ TMP2 SP ⇔ TMP2
B TMPx
EXG A,TMP2H EXG B,TMP2L EXG CCRW,TMP2 EXG TMP3,TMP2 EXG D,TMP1 EXG X,TMP2 EXG Y,TMP2 EXG SP,TMP2
Note: Encodings in the shaded area (LS = [8 , F]) are only available on the CPU12X.
Description
Divides an unsigned 16-bit numerator in double accumulator D by an unsigned 16-bit denominator in
index register X, producing an unsigned 16-bit quotient in X and an unsigned 16-bit remainder in D.
If both the numerator and the denominator are assumed to have radix points in the same positions, the
radix point of the quotient is to the left of bit 15. The numerator must be less than the denominator. In
the case of overflow (denominator is less than or equal to the numerator) or division by zero, the
quotient is set to $FFFF, and the remainder is indeterminate.
FDIV is equivalent to multiplying the numerator by 216 and then performing 32 by 16-bit integer
division. The result is interpreted as a binary-weighted fraction, which resulted from the division of a
16-bit integer by a larger 16-bit integer. A result of $0001 corresponds to 0.000015, and $FFFF
corresponds to 0.9998. The remainder of an IDIV instruction can be resolved into a binary-weighted
fraction by an FDIV instruction. The remainder of an FDIV instruction can be resolved into the next
16 bits of binary-weighted fraction by another FDIV instruction.
CCR Details
S X H I N Z V C
– – – – – Δ Δ Δ
Description
Loads the content of global memory location M into accumulator A. The condition codes are set
according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the content of global memory location M into accumulator B. The condition codes are set
according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the content of global memory location M : M + 1 into double accumulator D. The condition
codes are set according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the content of global memory location M : M + 1 into stack pointer SP. The condition codes are
set according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the content of global memory location M : M + 1 into index register X. The condition codes are
set according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the content of global memory location M : M + 1 into index register Y. The condition codes are
set according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of accumulator A into global memory location M. The condition codes are set
according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of accumulator B into global memory location M. The condition codes are set
according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of double accumulator D into global memory location M : M + 1. The condition
codes are set according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of stack pointer SP into global memory location M : M+ 1. The condition codes are
set according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of index register X into global memory location M : M + 1. The condition codes are
set according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of index register Y into global memory location M. The condition codes are set
according to the data.
A global memory reference appends the contents of the GPAGE register to the most significant byte
of the effective address to form a 23-bit address.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Add one to the specified counter register A, B, D, X, Y, or SP. If the counter register has reached zero,
branch to the specified relative destination. The IBEQ instruction is encoded into three bytes of
machine code including a 9-bit relative offset (–256 to +255 locations from the start of the next
instruction).
DBEQ and TBEQ instructions are similar to IBEQ except that the counter is decremented or tested
rather than being incremented. Bits 7 and 6 of the instruction postbyte are used to determine which
operation is to be performed.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Add one to the specified counter register A, B, D, X, Y, or SP. If the counter register has not been
incremented to zero, branch to the specified relative destination. The IBNE instruction is encoded into
three bytes of machine code including a 9-bit relative offset (–256 to +255 locations from the start of
the next instruction).
DBNE and TBNE instructions are similar to IBNE except that the counter is decremented or tested
rather than being incremented. Bits 7 and 6 of the instruction postbyte are used to determine which
operation is to be performed.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Divides an unsigned 16-bit dividend in double accumulator D by an unsigned 16-bit divisor in index
register X, producing an unsigned 16-bit quotient in X, and an unsigned 16-bit remainder in D. If both
the divisor and the dividend are assumed to have radix points in the same positions, the radix point of
the quotient is to the right of bit 0. In the case of division by zero, C is set, the quotient is set to $FFFF,
and the remainder is indeterminate.
CCR Details
S X H I N Z V C
– – – – – Δ 0 Δ
Description
Performs signed integer division of a signed 16-bit numerator in double accumulator D by a signed
16-bit denominator in index register X, producing a signed 16-bit quotient in X, and a signed 16-bit
remainder in D. If division by zero is attempted, the values in D and X are not changed, C is set, and
the values of the N, Z, and V status bits are undefined.
Other than division by zero, which is not legal and causes the C status bit to be set, the only overflow
case is:
$8000 –32,768
---------------- = ------------------- = +32,768
$FFFF –1
But the highest positive value that can be represented in a 16-bit two’s complement number is 32,767
($7FFF).
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Add one to the content of memory location M.
The N, Z and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the INC instruction to be used as a loop counter in
multiple-precision computations.
When operating on unsigned values, only BEQ, BNE, LBEQ, and LBNE branches can be expected to
perform consistently. When operating on two’s complement values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Add one to the content of accumulator A.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the INC instruction to be used as a loop counter in
multiple-precision computations.
When operating on unsigned values, only BEQ, BNE, LBEQ, and LBNE branches can be expected to
perform consistently. When operating on two’s complement values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Add one to the content of accumulator B.
The N, Z, and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the INC instruction to be used as a loop counter in
multiple-precision computations.
When operating on unsigned values, only BEQ, BNE, LBEQ, and LBNE branches can be expected to
perform consistently. When operating on two’s complement values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Add one to the content of memory location M : M + 1.
The N, Z and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the INC instruction to be used as a loop counter in
multiple-precision computations.
When operating on unsigned values, only BEQ, BNE, LBEQ, and LBNE branches can be expected to
perform consistently. When operating on two’s complement values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Add one to the content of index register X.
The N, Z and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the INC instruction to be used as a loop counter in
multiple-precision computations.
When operating on unsigned values, only BEQ, BNE, LBEQ, and LBNE branches can be expected to
perform consistently. When operating on two’s complement values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Add one to the content of index register Y.
The N, Z and V status bits are set or cleared according to the results of the operation. The C status bit
is not affected by the operation, thus allowing the INC instruction to be used as a loop counter in
multiple-precision computations.
When operating on unsigned values, only BEQ, BNE, LBEQ, and LBNE branches can be expected to
perform consistently. When operating on two’s complement values, all signed branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ –
Description
Add one to the stack pointer SP. This instruction is assembled to LEAS 1,SP. The LEAS instruction
does not affect condition codes as an INX or INY instruction would.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Add one to index register X. LEAX 1,X can produce the same result but LEAX does not affect the Z
status bit. Although the LEAX instruction is more flexible, INX requires only one byte of object code.
INX operation affects only the Z status bit.
CCR Details
S X H I N Z V C
– – – – – Δ – –
Description
Add one to index register Y. LEAY 1,Y can produce the same result but LEAY does not affect the Z
status bit. Although the LEAY instruction is more flexible, INY requires only one byte of object code.
INY operation affects only the Z status bit.
CCR Details
S X H I N Z V C
– – – – – Δ – –
Description
Jumps to the instruction stored at the effective address. The effective address is obtained according to
the rules for extended or indexed addressing.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Sets up conditions to return to normal program flow, then transfers control to a subroutine. Uses the
address of the instruction following the JSR as a return address.
Decrements the SP by two to allow the two bytes of the return address to be stacked.
Stacks the return address. The SP points to the high order byte of the return address.
Calculates an effective address according to the rules for extended, direct, or indexed addressing.
Jumps to the location determined by the effective address.
Subroutines are normally terminated with an RTS instruction, which restores the return address from
the stack.
For SP relative auto pre/post decrement/increment indexed addressing modes, the effective address of
the jump is calculated firsts, then SP adjustments associated with the stacking operation.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the C status bit and branches if C = 0.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the C status bit and branches if C = 1.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the Z status bit and branches if Z = 1.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBGE can be used to branch after subtracting or comparing signed two’s complement values. After
CMPA, CMPB, CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if
the CPU register value is greater than or equal to the value in M. After CBA or SBA, the branch occurs
if the value in B is greater than or equal to the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBGT can be used to branch after subtracting or comparing signed two’s complement values. After
CMPA, CMPB, CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if
the CPU register value is greater than or equal to the value in M. After CBA or SBA, the branch occurs
if the value in B is greater than or equal to the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBHI can be used to branch after subtracting or comparing unsigned values. After CMPA, CMPB,
CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if the CPU register
value is greater than the value in M. After CBA or SBA, the branch occurs if the value in B is greater
than the value in A. LBHI should not be used for branching after instructions that do not affect the C
bit, such as increment, decrement, load, store, test, clear, or complement.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBHS can be used to branch after subtracting or comparing unsigned values. After CMPA, CMPB,
CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if the CPU register
value is greater than or equal to the value in M. After CBA or SBA, the branch occurs if the value in
B is greater than or equal to the value in A. LBHS should not be used for branching after instructions
that do not affect the C bit, such as increment, decrement, load, store, test, clear, or complement.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBLE can be used to branch after subtracting or comparing signed two’s complement values. After
CMPA, CMPB, CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if
the CPU register value is less than or equal to the value in M. After CBA or SBA, the branch occurs if
the value in B is less than or equal to the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBLO can be used to branch after subtracting or comparing unsigned values. After CMPA, CMPB,
CPD, CPS, CPX, CPY, SUBA, SUBB, or SUBD, the branch occurs if the CPU register value is less
than the value in M. After CBA or SBA, the branch occurs if the value in B is less than the value in A.
LBLO should not be used for branching after instructions that do not affect the C bit, such as increment,
decrement, load, store, test, clear, or complement.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBLS can be used to branch after subtracting or comparing unsigned values. After CMPA, CMPB,
CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if the CPU register
value is less than or equal to the value in M. After CBA or SBA, the branch occurs if the value in B is
less than or equal to the value in A. LBLS should not be used for branching after instructions that do
not affect the C bit, such as increment, decrement, load, store, test, clear, or complement.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
LBLT can be used to branch after subtracting or comparing signed two’s complement values. After
CMPA, CMPB, CPD, CPS, CPX, CPY, SBCA, SBCB, SUBA, SUBB, or SUBD, the branch occurs if
the CPU register value is less than the value in M. After CBA or SBA, the branch occurs if the value
in B is less than the value in A.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the N status bit and branches if N = 1.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the Z status bit and branches if Z = 0.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the N status bit and branches if N = 0.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Unconditional branch to an address calculated as shown in the expression. Rel is a relative offset stored
as a two’s complement number in the second and third bytes of machine code corresponding to the long
branch instruction.
Execution time is longer when a conditional branch is taken than when it is not, because the instruction
queue must be refilled before execution resumes at the new address. Since the LBRA branch condition
is always satisfied, the branch is always taken, and the instruction queue must always be refilled, so
execution time is always the larger value.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Never branches. LBRN is effectively a 4-byte NOP that requires three cycles to execute. LBRN is
included in the instruction set to provide a complement to the LBRA instruction. The instruction is
useful during program debug, to negate the effect of another branch instruction without disturbing the
offset byte. A complement for LBRA is also useful in compiler implementations.
Execution time is longer when a conditional branch is taken than when it is not, because the instruction
queue must be refilled before execution resumes at the new address. Since the LBRN branch condition
is never satisfied, the branch is never taken, and the queue does not need to be refilled, so execution
time is always the smaller value.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the V status bit and branches if V = 0.
LBVC causes a branch when a previous operation on two’s complement binary values does not cause
an overflow. That is, when LBVC follows a two’s complement operation, a branch occurs when the
result of the operation is valid.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Tests the V status bit and branches if V = 1.
LBVS causes a branch when a previous operation on two’s complement binary values causes an
overflow. That is, when LBVS follows a two’s complement operation, a branch occurs when the result
of the operation is invalid.
See Section 3.9, “Relative Addressing Mode”” for details of branch execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Loads the content of memory location M into accumulator A. The condition codes are set according to
the data.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the content of memory location M into accumulator B. The condition codes are set according to
the data.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the contents of memory locations M and M+1 into double accumulator D. The condition codes
are set according to the data. The information from M is loaded into accumulator A, and the
information from M+1 is loaded into accumulator B.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the most significant byte of the SP with the content of memory location M : M + 1, and loads
the least significant byte of the SP with the content of the next byte of memory at M : M + 1.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the most significant byte of index register X with the content of memory location M, and loads
the least significant byte of X with the content of the next byte of memory at M + 1.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the most significant byte of index register Y with the content of memory location M, and loads
the least significant byte of Y with the content of the next memory location at M + 1.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Loads the stack pointer with an effective address specified by the program. The effective address can
be any indexed addressing mode operand address except an indirect address. Indexed addressing mode
operand addresses are formed by adding an optional constant supplied by the program or an
accumulator value to the current value in X, Y, SP, or PC. See Section 3.10, “Indexed Addressing
Modes”” for more details.
LEAS does not alter condition code bits. This allows stack modification without disturbing CCR bits
changed by recent arithmetic operations.
Operation is a bit more complex when LEAS is used with auto-increment or auto-decrement operand
specifications and the SP is the referenced index register. The index register is loaded with what would
have gone out to the address bus in the case of a load index instruction. In the case of a pre-increment
or pre-decrement, the modification is made before the index register is loaded. In the case of a
post-increment or post-decrement, modification would have taken effect after the address went out on
the address bus, so post-modification does not affect the content of the index register.
In the unusual case where LEAS involves two different index registers and post-increment or
post-decrement, both index registers are modified as demonstrated by the following example. Consider
the instruction LEAS 4,Y+. First S is loaded with the value of Y, then Y is incremented by 4.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Loads index register X with an effective address specified by the program. The effective address can
be any indexed addressing mode operand address except an indirect address. Indexed addressing mode
operand addresses are formed by adding an optional constant supplied by the program or an
accumulator value to the current value in X, Y, SP, or PC. See Section 3.10, “Indexed Addressing
Modes”” for more details.
Operation is a bit more complex when LEAX is used with auto-increment or auto-decrement operand
specifications and index register X is the referenced index register. The index register is loaded with
what would have gone out to the address bus in the case of a load indexed instruction. In the case of a
pre-increment or pre-decrement, the modification is made before the index register is loaded. In the
case of a post-increment or post-decrement, modification would have taken effect after the address
went out on the address bus, so post-modification does not affect the content of the index register.
In the unusual case where LEAX involves two different index registers and post-increment and
post-decrement, both index registers are modified as demonstrated by the following example. Consider
the instruction LEAX 4,Y+. First X is loaded with the value of Y, then Y is incremented by 4.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Loads index register Y with an effective address specified by the program. The effective address can
be any indexed addressing mode operand address except an indirect address. Indexed addressing mode
operand addresses are formed by adding an optional constant supplied by the program or an
accumulator value to the current value in X, Y, SP, or PC. See Section 3.10, “Indexed Addressing
Modes”” for more details.
Operation is a bit more complex when LEAY is used with auto-increment or auto-decrement operand
specifications and index register Y is the referenced index register. The index register is loaded with
what would have gone out to the address bus in the case of a load indexed instruction. In the case of a
pre-increment or pre-decrement, the modification is made before the index register is loaded. In the
case of a post-increment or post-decrement, modification would have taken effect after the address
went out on the address bus, so post-modification does not affect the content of the index register.
In the unusual case where LEAY involves two different index registers and post-increment and
post-decrement, both index registers are modified as demonstrated by the following example. Consider
the instruction LEAY 4,X+. First Y is loaded with the value of X, then X is incremented by 4.
CCR Details
S X H I N Z V C
– – – – – – – –
C b7 – – – – – – b0 0
Description
Shifts all bits of the memory location M one place to the left. Bit 0 is loaded with 0. The C status bit is
loaded from the most significant bit of M.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 – – – – – – b0 0
Description
Shifts all bits of accumulator A one place to the left. Bit 0 is loaded with 0. The C status bit is loaded
from the most significant bit of A.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 – – – – – – b0 0
Description
Shifts all bits of accumulator B one place to the left. Bit 0 is loaded with 0. The C status bit is loaded
from the most significant bit of B.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 – – – – – – b0 b7 – – – – – – b0 0
Accumulator A Accumulator B
Description
Shifts all bits of double accumulator D one place to the left. Bit 0 is loaded with 0. The C status bit is
loaded from the most significant bit of accumulator A.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
..... 0
C b15 b0
Description
Shifts all bits of memory location M : M + 1 one bit position to the left. Bit 0 is loaded with a 0. The
C status bit is loaded from the most significant bit of W.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
..... 0
C b15 b0
Description
Shifts all bits of index register X one bit position to the left. Bit 0 is loaded with a 0. The C status bit
is loaded from the most significant bit of X.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
..... 0
C b15 b0
Description
Shifts all bits of index register Y one bit position to the left. Bit 0 is loaded with a 0. The C status bit
is loaded from the most significant bit of Y.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
0 b7 – – – – – – b0 C
Description
Shifts all bits of memory location M one place to the right. Bit 7 is loaded with 0. The C status bit is
loaded from the least significant bit of M.
CCR Details
S X H I N Z V C
– – – – 0 Δ Δ Δ
N: 0; cleared
Z: Set if result is $00; cleared otherwise
V: N ⊕ C = [N • C] + [N • C] (for N and C after the shift)
Set if (N is set and C is cleared) or (N is cleared and C is set); cleared otherwise (for values of
N and C after the shift)
C: M0
Set if the LSB of M was set before the shift; cleared otherwise
0 b7 – – – – – – b0 C
Description
Shifts all bits of accumulator A one place to the right. Bit 7 is loaded with 0. The C status bit is loaded
from the least significant bit of A.
CCR Details
S X H I N Z V C
– – – – 0 Δ Δ Δ
C
N: 0; cleared
Z: Set if result is $00; cleared otherwise
V: N ⊕ C = [N • C] + [N • C] (for N and C after the shift)
Set if (N is set and C is cleared) or (N is cleared and C is set); cleared otherwise (for values of
N and C after the shift)
C: A0
Set if the LSB of A was set before the shift; cleared otherwise
0 b7 – – – – – – b0 C
Description
Shifts all bits of accumulator B one place to the right. Bit 7 is loaded with 0. The C status bit is loaded
from the least significant bit of B.
CCR Details
S X H I N Z V C
– – – – 0 Δ Δ Δ
N: 0; cleared
Z: Set if result is $00; cleared otherwise
V: N ⊕ C = [N • C] + [N • C] (for N and C after the shift)
Set if (N is set and C is cleared) or (N is cleared and C is set); cleared otherwise (for values of
N and C after the shift)
C: B0
Set if the LSB of B was set before the shift; cleared otherwise
0 b7 – – – – – – b0 b7 – – – – – – b0 C
Accumulator A Accumulator B
Description
Shifts all bits of double accumulator D one place to the right. D15 (MSB of A) is loaded with 0. The
C status bit is loaded from D0 (LSB of B).
CCR Details
S X H I N Z V C
– – – – 0 Δ Δ Δ
N: 0; cleared
Z: Set if result is $0000; cleared otherwise
V: D0
Set if, after the shift operation, C is set; cleared otherwise
C: D0
Set if the LSB of D was set before the shift; cleared otherwise
0 ....
b15 b0 C
Description
Shifts all bits of memory location M : M + 1 one place to the right. Bit 15 is loaded with 0. The C status
bit is loaded from the least significant bit of M : M + 1.
CCR Details
S X H I N Z V C
– – – – 0 Δ Δ Δ
N: 0; cleared
Z: Set if result is $0000; cleared otherwise
V: N ⊕ C = [N • C] + [N • C] (for N and C after the shift)
Set if (N is set and C is cleared) or (N is cleared and C is set); cleared
otherwise (for values of N and C after the shift)
C: M0
Set if the LSB of M : M + 1 was set before the shift; cleared otherwise
0 ....
b15 b0 C
Description
Shifts all bits of index register X one place to the right. Bit 15 is loaded with 0. The C status bit is
loaded from the least significant bit of X.
CCR Details
S X H I N Z V C
– – – – 0 Δ Δ Δ
N: 0; cleared
Z: Set if result is $0000; cleared otherwise
V: N ⊕ C = [N • C] + [N • C] (for N and C after the shift)
Set if (N is set and C is cleared) or (N is cleared and C is set); cleared
otherwise (for values of N and C after the shift)
C: X0
Set if the LSB of X was set before the shift; cleared otherwise
0 ....
b15 b0 C
Description
Shifts all bits of index register Y one place to the right. Bit 15 is loaded with 0. The C status bit is
loaded from the least significant bit of Y.
CCR Details
S X H I N Z V C
– – – – 0 Δ Δ Δ
N: 0; cleared
Z: Set if result is $0000; cleared otherwise
V: N ⊕ C = [N • C] + [N • C] (for N and C after the shift)
Set if (N is set and C is cleared) or (N is cleared and C is set); cleared otherwise (for values of
N and C after the shift)
C: Y0
Set if the LSB of Y was set before the shift; cleared otherwise
Description
Subtracts an unsigned 8-bit value in memory from an unsigned 8-bit value in accumulator A to
determine which is larger and leaves the larger of the two values in A. The Z status bit is set when the
result of the subtraction is zero (the values are equal), and the C status bit is set when the subtraction
requires a borrow (the value in memory is larger than the value in the accumulator). When C = 1, the
value in A has been replaced by the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand. Auto increment/decrement variations of
indexed addressing facilitate finding the largest value in a list of values.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts an unsigned 8-bit value in memory from an unsigned 8-bit value in accumulator A to
determine which is larger and leaves the larger of the two values in the memory location. The Z status
bit is set when the result of the subtraction is zero (the values are equal), and the C status bit is set when
the subtraction requires a borrow (the value in memory is larger than the value in the accumulator).
When C = 0, the value in accumulator A has replaced the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Before executing MEM, initialize A, X, and Y. Load A with the current crisp value of a system input
variable. Load Y with the fuzzy input RAM location where the grade of membership is to be stored.
Load X with the first address of a 4-byte data structure that describes a trapezoidal membership
function. The data structure consists of:
• Point_1 — The x-axis starting point for the leading side (at MX)
• Point_2 — The x-axis position of the rightmost point (at MX+1)
• Slope_1 — The slope of the leading side (at MX+2)
• Slope_2 — The slope of the trailing side (at MX+3); the right side slopes up and to the left from
Point_2
A Slope_1 or Slope_2 value of $00 is a special case in which the membership function either starts
with a grade of $FF at input = Point_1, or ends with a grade of $FF at input = Point_2 (infinite slope).
During execution, the value of A remains unchanged. X is incremented by four and Y is incremented
by one.
CCR Details
S X H I N Z V C
– – ? – ? ? ? ?
Description
Subtracts an unsigned 8-bit value in memory from an unsigned 8-bit value in accumulator A to
determine which is larger, and leaves the smaller of the two values in accumulator A. The Z status bit
is set when the result of the subtraction is zero (the values are equal), and the C status bit is set when
the subtraction requires a borrow (the value in memory is larger than the value in the accumulator).
When C = 0, the value in accumulator A has been replaced by the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand. Auto increment/decrement variations of
indexed addressing facilitate finding the smallest value in a list of values.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts an unsigned 8-bit value in memory from an unsigned 8-bit value in accumulator A to
determine which is larger and leaves the smaller of the two values in the memory location. The Z status
bit is set when the result of the subtraction is zero (the values are equal), and the C status bit is set when
the subtraction requires a borrow (the value in memory is larger than the value in the accumulator).
When C = 1, the value in accumulator A has replaced the value in memory.
The unsigned value in memory is accessed by means of indexed addressing modes, which allow a great
deal of flexibility in specifying the address of the operand.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Moves the immediate value # to memory location M.
Move byte instructions specify the source first and destination second in the object code for an
immediate value source and an extended addressing mode destination. Move byte instructions using
immediate values for the source and indexed addressing modes for the destination have the destination
index code (xb) specified before the source value for CPU12 and HC12 compatibility.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 8-bit memory location to another 8-bit memory location. The content of the
source memory location is not changed.
Move byte instructions specify the source first and destination second in the object code for an
extended addressing mode source and an extended addressing mode destination. Move byte
instructions using extended addressing for the source and indexed addressing modes for the destination
have the destination index code (xb) specified before the source value for CPU12 and HC12
compatibility.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 8-bit memory location to another 8-bit memory location. The content of the
source memory location is not changed.
Move byte instructions specify the source first and destination second in the object code for all indexed
addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVB instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 8-bit memory location to another 8-bit memory location. The content of the
source memory location is not changed.
Move byte instructions specify the source first and destination second in the object code for all indexed
addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVB instruction.
CCR Details
\
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 8-bit memory location to another 8-bit memory location. The content of the
source memory location is not changed.
Move byte instructions specify the source first and destination second in the object code for all indexed
addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVB instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 8-bit memory location to another 8-bit memory location. The content of the
source memory location is not changed. Move byte instructions specify the source first and destination
second in the object code for all indexed addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVB instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 8-bit memory location to another 8-bit memory location. The content of the
source memory location is not changed.
Move byte instructions specify the source first and destination second in the object code for all indexed
addressing mode sources.For auto pre/post decrement/increment indexed addressing modes, the
effective address of the source is calculated fist and the source index register is updated appropriately,
then the destination effective address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVB instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 16-bit location in memory to another 16-bit location in memory. The content
of the source memory location is not changed.
Move word instructions specify the source first and destination second in the object code for an
immediate value source and an extended addressing mode destination. Move word instructions using
immediate values for the source and indexed addressing modes for the destination have the destination
index code (xb) specified before the source value for CPU12V0 and HC12 compatibility.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 16-bit location in memory to another 16-bit location in memory. The content
of the source memory location is not changed.
Move word instructions specify the source first and destination second in the object code for an
extended addressing mode source and an extended addressing mode destination. Move word
instructions using extended addressing for the source and indexed addressing modes for the destination
have the destination index code (xb) specified before the source value for CPU12V0 and HC12
compatibility.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 16-bit location in memory to another 16-bit location in memory. The content
of the source memory location is not changed.
Move word instructions specify the source first and destination second in the object code for all
indexed addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVW instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 16-bit location in memory to another 16-bit location in memory. The content
of the source memory location is not changed. Move word instructions specify the source first and
destination second in the object code for all indexed addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVW instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 16-bit location in memory to another 16-bit location in memory. The content
of the source memory location is not changed. Move word instructions specify the source first and
destination second in the object code for all indexed addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVW instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 16-bit location in memory to another 16-bit location in memory. The content
of the source memory location is not changed. Move word instructions specify the source first and
destination second in the object code for all indexed addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVW instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Moves the content of one 16-bit location in memory to another 16-bit location in memory. The content
of the source memory location is not changed. Move word instructions specify the source first and
destination second in the object code for all indexed addressing mode sources.
For auto pre/post decrement/increment indexed addressing modes, the effective address of the source
is calculated fist and the source index register is updated appropriately, then the destination effective
address is calculated.
A PC offset must be applied to the source address when using PC relative index addressing for the
source operand and any of the three destination index addressing modes listed below:
IDX1: +1
IDX2: +2
[IDX2]: +2
These offsets compensate for the variable instruction length and are needed to identify the location of
the instruction immediately following the MOVW instruction.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Multiplies the 8-bit unsigned binary value in accumulator A by the 8-bit unsigned binary value in
accumulator B and places the 16-bit unsigned result in double accumulator D. The carry flag allows
rounding the most significant byte of the result through the sequence MUL, ADCA #0.
CCR Details
S X H I N Z V C
– – – – – – – Δ
C: R7
Set if bit 7 of the result (B bit 7) is set; cleared otherwise
Description
Replaces the content of memory location M with its two’s complement.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Replaces the content of accumulator A with its two’s complement.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Replaces the content of accumulator B with its two’s complement.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Replaces the content of memory location M : M + 1 with its two’s complement.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Replaces the content of index register X with its two’s complement.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Replaces the content of index register Y with its two’s complement.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
This single-byte instruction increments the PC and does nothing else. No other CPU12 registers are
affected. NOP is typically used to produce a time delay, although some software disciplines discourage
CPU12 frequency-based time delays. During debug, NOP instructions are sometimes used to
temporarily replace other machine code instructions, thus disabling the replaced instruction(s).
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Performs bitwise logical inclusive OR between the content of accumulator A and the content of
memory location M and places the result in A. Each bit of A after the operation is the logical inclusive
OR of the corresponding bits of M and of A before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs bitwise logical inclusive OR between the content of accumulator B and the content of
memory location M. The result is placed in B. Each bit of B after the operation is the logical inclusive
OR of the corresponding bits of M and of B before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs bitwise logical inclusive OR between the content of memory location M and the content of
the CCR and places the result in the CCR. Each bit of the CCR after the operation is the logical OR of
the corresponding bits of M and of CCR before the operation. To set one or more bits, set the
corresponding bit of the mask equal to 1. Bits corresponding to 0s in the mask are not changed by the
ORCC operation.
CCR Details
S X H I N Z V C
– supervisor state
− – − user state
Condition code bits are set if the corresponding bit was 1 before the operation or if the corresponding
bit in the instruction-provided mask is 1. The X interrupt mask cannot be set by any software
instruction.
Description
Performs bitwise logical inclusive OR between the content of index register X and the content of
memory location M : M + 1 and places the result in X. Each bit of X after the operation is the logical
inclusive OR of the corresponding bits of M : M + 1 and of X before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Performs bitwise logical inclusive OR between the content of index register Y and the content of
memory location M : M + 1 and places the result in Y. Each bit of Y after the operation is the logical
inclusive OR of the corresponding bits of M : M + 1 and of Y before the operation.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stacks the content of accumulator A. The stack pointer is decremented by one. The content of A is then
stored at the address the SP points to.
Push instructions are commonly used to save the contents of one or more CPU registers at the start of
a subroutine. Complementary pull instructions can be used to restore the saved CPU registers just
before returning from the subroutine.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Stacks the content of accumulator B. The stack pointer is decremented by one. The content of B is then
stored at the address the SP points to.
Push instructions are commonly used to save the contents of one or more CPU registers at the start of
a subroutine. Complementary pull instructions can be used to restore the saved CPU registers just
before returning from the subroutine.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Stacks the content of the condition codes register. The stack pointer is decremented by one. The content
of the CCR is then stored at the address to which the SP points.
Push instructions are commonly used to save the contents of one or more CPU registers at the start of
a subroutine. Complementary pull instructions can be used to restore the saved CPU registers just
before returning from the subroutine.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Stacks the content of the condition codes register. The stack pointer is decremented by two. The
content of the CCR is then stored at the address to which the SP points.
Push instructions are commonly used to save the contents of one or more CPU registers at the start of
a subroutine. Complementary pull instructions can be used to restore the saved CPU registers just
before returning from the subroutine.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
– 0 0 0 0 – – – – – – – – –
Description
Stacks the content of double accumulator D. The stack pointer is decremented by two, then the contents
of accumulators A and B are stored at the location to which the SP points.
After PSHD executes, the SP points to the stacked value of accumulator A. This stacking order is the
opposite of the order in which A and B are stacked when an interrupt is recognized. The interrupt
stacking order is backward-compatible with the M6800, which had no 16-bit accumulator.
Push instructions are commonly used to save the contents of one or more CPU registers at the start of
a subroutine. Complementary pull instructions can be used to restore the saved CPU registers just
before returning from the subroutine.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Stacks the content of index register X. The stack pointer is decremented by two. The content of X is
then stored at the address to which the SP points. After PSHX executes, the SP points to the stacked
value of the high-order half of X.
Push instructions are commonly used to save the contents of one or more CPU registers at the start of
a subroutine. Complementary pull instructions can be used to restore the saved CPU registers just
before returning from the subroutine.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Stacks the content of index register Y. The stack pointer is decremented by two. The content of Y is
then stored at the address to which the SP points. After PSHY executes, the SP points to the stacked
value of the high-order half of Y.
Push instructions are commonly used to save the contents of one or more CPU registers at the start of
a subroutine. Complementary pull instructions can be used to restore the saved CPU registers just
before returning from the subroutine.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Accumulator A is loaded from the address indicated by the stack pointer. The SP is then incremented
by one.
Pull instructions are commonly used at the end of a subroutine, to restore the contents of CPU registers
that were pushed onto the stack before subroutine execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Accumulator B is loaded from the address indicated by the stack pointer. The SP is then incremented
by one.
Pull instructions are commonly used at the end of a subroutine, to restore the contents of CPU registers
that were pushed onto the stack before subroutine execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
The condition code register is loaded from the address indicated by the stack pointer. The SP is then
incremented by one.
Pull instructions are commonly used at the end of a subroutine to restore the contents of CPU registers
that were pushed onto the stack before subroutine execution.
CCR Details
S X H I N Z V C
Δ Δ Δ Δ Δ Δ Δ supervisor state
− − Δ − Δ Δ Δ Δ user state
Condition codes take on the value pulled from the stack, except that the X mask bit cannot change from
0 to 1. Software can leave the X bit set, leave it cleared, or change it from 1 to 0, but it can be set only
by a reset or by recognition of an XIRQ interrupt.
Description
The condition code register is loaded from the address indicated by the stack pointer. The SP is then
incremented by two.
Pull instructions are commonly used at the end of a subroutine to restore the contents of CPU registers
that were pushed onto the stack before subroutine execution.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
0 0 0 0 Δ Δ Δ Δ Δ Δ Δ Δ supervisor state
− 0 0 0 0 − − − Δ − Δ Δ Δ Δ user state
Condition codes take on the value pulled from the stack, except that the X mask bit cannot change from
0 to 1. Software can leave the X bit set, leave it cleared, or change it from 1 to 0, but it can be set only
by a reset or by recognition of an XIRQ interrupt.
Description
Double accumulator D is loaded from the address indicated by the stack pointer. The SP is then
incremented by two.
The order in which A and B are pulled from the stack is the opposite of the order in which A and B are
pulled when an RTI instruction is executed. The interrupt stacking order for A and B is backward-
compatible with the M6800, which had no 16-bit accumulator.
Pull instructions are commonly used at the end of a subroutine to restore the contents of CPU registers
that were pushed onto the stack before subroutine execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Index register X is loaded from the address indicated by the stack pointer. The SP is then incremented
by two.
Pull instructions are commonly used at the end of a subroutine to restore the contents of CPU registers
that were pushed onto the stack before subroutine execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Index register Y is loaded from the address indicated by the stack pointer. The SP is then incremented
by two.
Pull instructions are commonly used at the end of a subroutine to restore the contents of CPU registers
that were pushed onto the stack before subroutine execution.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Performs an unweighted evaluation of a list of rules, using fuzzy input values to produce fuzzy outputs.
REV can be interrupted, so it does not adversely affect interrupt latency.
The REV instruction uses an 8-bit offset from a base address stored in index register Y to determine
the address of each fuzzy input and fuzzy output. For REV to execute correctly, each rule in the
knowledge base must consist of a table of 8-bit antecedent offsets followed by a table of 8-bit
consequent offsets. The value $FE marks boundaries between antecedents and consequents and
between successive rules. The value $FF marks the end of the rule list. REV can evaluate any number
of rules with any number of inputs and outputs.
Beginning with the address pointed to by the first rule antecedent, REV evaluates each successive
fuzzy input value until it encounters an $FE separator. Operation is similar to that of a MINA
instruction. The smallest input value is the truth value of the rule. Then, beginning with the address
pointed to by the first rule consequent, the truth value is compared to each successive fuzzy output
value until another $FE separator is encountered; if the truth value is greater than the current output
value, it is written to the output. Operation is similar to that of a MAXM instruction. Rules are
processed until an $FF terminator is encountered.
Before executing REV, perform these set up operations.
• X must point to the first 8-bit element in the rule list.
• Y must point to the base address for fuzzy inputs and fuzzy outputs.
• A must contain the value $FF, and the CCR V bit must = 0.
(LDAA #$FF places the correct value in A and clears V.)
• Clear fuzzy outputs to 0s.
Index register X points to the element in the rule list that is being evaluated. X is automatically updated
so that execution can resume correctly if the instruction is interrupted. When execution is complete, X
points to the next address after the $FF separator at the end of the rule list.
Index register Y points to the base address for the fuzzy inputs and fuzzy outputs. The value in Y does
not change during execution.
CCR Details
S X H I N Z V C
– – ? – ? ? Δ ?
Description
REVW performs either weighted or unweighted evaluation of a list of rules, using fuzzy inputs to
produce fuzzy outputs. REVW can be interrupted, so it does not adversely affect interrupt latency.
For REVW to execute correctly, each rule in the knowledge base must consist of a table of 16-bit
antecedent pointers followed by a table of 16-bit consequent pointers. The value $FFFE marks
boundaries between antecedents and consequents, and between successive rules. The value $FFFF
marks the end of the rule list. REVW can evaluate any number of rules with any number of inputs and
outputs.
Setting the C status bit enables weighted evaluation. To use weighted evaluation, a table of 8-bit
weighting factors, one per rule, must be stored in memory. Index register Y points to the weighting
factors.
Beginning with the address pointed to by the first rule antecedent, REVW evaluates each successive
fuzzy input value until it encounters an $FFFE separator. Operation is similar to that of a MINA
instruction. The smallest input value is the truth value of the rule. Next, if weighted evaluation is
enabled, a computation is performed, and the truth value is modified. Then, beginning with the address
pointed to by the first rule consequent, the truth value is compared to each successive fuzzy output
value until another $FFFE separator is encountered; if the truth value is greater than the current output
value, it is written to the output. Operation is similar to that of a MAXM instruction. Rules are
processed until an $FFFF terminator is encountered.
Perform these set up operations before execution:
• X must point to the first 16-bit element in the rule list.
• A must contain the value $FF, and the CCR V bit must = 0 (LDAA #$FF places the correct
value in A and clears V).
• Clear fuzzy outputs to 0s.
• Set or clear the CCR C bit. When weighted evaluation is enabled, Y must point to the first item
in a table of 8-bit weighting factors.
Index register X points to the element in the rule list that is being evaluated. X is automatically updated
so that execution can resume correctly if the instruction is interrupted. When execution is complete, X
points to the address after the $FFFF separator at the end of the rule list.
CCR Details
S X H I N Z V C
– – ? – ? ? Δ !
C b7 b0
Description
Shifts all bits of memory location M one place to the left. Bit 0 is loaded from the C status bit. The C
bit is loaded from the most significant bit of M. Rotate operations include the carry bit to allow
extension of shift and rotate operations to multiple bytes. For example, to shift a 24-bit value one bit
to the left, the sequence ASL LOW, ROL MID, ROL HIGH could be used where LOW, MID and
HIGH refer to the low-order, middle and high-order bytes of the 24-bit value, respectively.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 b0
Description
Shifts all bits of accumulator A one place to the left. Bit 0 is loaded from the C status bit. The C bit is
loaded from the most significant bit of A. Rotate operations include the carry bit to allow extension of
shift and rotate operations to multiple bytes. For example, to shift a 24-bit value one bit to the left, the
sequence ASL LOW, ROL MID, and ROL HIGH could be used where LOW, MID, and HIGH refer
to the low-order, middle, and high-order bytes of the 24-bit value, respectively.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
C b7 b0
Description
Shifts all bits of accumulator B one place to the left. Bit 0 is loaded from the C status bit. The C bit is
loaded from the most significant bit of B. Rotate operations include the carry bit to allow extension of
shift and rotate operations to multiple bytes. For example, to shift a 24-bit value one bit to the left, the
sequence ASL LOW, ROL MID, and ROL HIGH could be used where LOW, MID, and HIGH refer
to the low-order, middle and high-order bytes of the 24-bit value, respectively.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
....
C b15 b0
Description
Shifts all bits of memory location M : M + 1 one place to the left. Bit 0 is loaded from the C status bit.
The C bit is loaded from the most significant bit of M : M + 1. Rotate operations include the carry bit
to allow extension of shift and rotate operations to multiple words.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
....
C b15 b0
Description
Shifts all bits of index register X one place to the left. Bit 0 is loaded from the C status bit. The C bit
is loaded from the most significant bit of X. Rotate operations include the carry bit to allow extension
of shift and rotate operations to multiple words.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
....
C b15 b0
Description
Shifts all bits of index register Y one place to the left. Bit 0 is loaded from the C status bit. The C bit
is loaded from the most significant bit of Y. Rotate operations include the carry bit to allow extension
of shift and rotate operations to multiple words.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
b7 b0 C
Description
Shifts all bits of memory location M one place to the right. Bit 7 is loaded from the C status bit. The C
bit is loaded from the least significant bit of M. Rotate operations include the carry bit to allow
extension of shift and rotate operations to multiple bytes. For example, to shift a 24-bit value one bit
to the right, the sequence LSR HIGH, ROR MID, and ROR LOW could be used where LOW, MID,
and HIGH refer to the low-order, middle, and high-order bytes of the 24-bit value, respectively.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
b7 b0 C
Description
Shifts all bits of accumulator A one place to the right. Bit 7 is loaded from the C status bit. The C bit
is loaded from the least significant bit of A. Rotate operations include the carry bit to allow extension
of shift and rotate operations to multiple bytes. For example, to shift a 24-bit value one bit to the right,
the sequence LSR HIGH, ROR MID, and ROR LOW could be used where LOW, MID, and HIGH
refer to the low-order, middle, and high-order bytes of the 24-bit value, respectively.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
b7 b0 C
Description
Shifts all bits of accumulator B one place to the right. Bit 7 is loaded from the C status bit. The C bit
is loaded from the least significant bit of B. Rotate operations include the carry bit to allow extension
of shift and rotate operations to multiple bytes. For example, to shift a 24-bit value one bit to the right,
the sequence LSR HIGH, ROR MID, and ROR LOW could be used where LOW, MID, and HIGH
refer to the low-order, middle, and high-order bytes of the 24-bit value, respectively.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
....
b15 b0 C
Description
Shifts all bits of memory location M : M + 1 one place to the right. Bit 15 is loaded from the C status
bit. The C bit is loaded from the least significant bit of M : M + 1. Rotate operations include the carry
bit to allow extension of shift and rotate operations to multiple words.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
....
b15 b0 C
Description
Shifts all bits of index register X one place to the right. Bit 15 is loaded from the C status bit. The C
bit is loaded from the least significant bit of X. Rotate operations include the carry bit to allow
extension of shift and rotate operations to multiple words.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
....
b15 b0 C
Description
Shifts all bits of index register Y one place to the right. Bit 15 is loaded from the C status bit. The C
bit is loaded from the least significant bit of Y. Rotate operations include the carry bit to allow
extension of shift and rotate operations to multiple words.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Terminates subroutines in expanded memory invoked by the CALL instruction. Returns execution
flow from the subroutine to the calling program. The program overlay page (PPAGE) register and the
return address are restored from the stack; program execution continues at the restored address. For
code compatibility purposes, CALL and RTC also execute correctly in devices that do not have
expanded memory capability.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Restores system context after interrupt service processing is completed. The condition codes,
accumulators B and A, index register X, the PC, and index register Y are restored to a state pulled from
the stack. The X mask bit may be cleared as a result of an RTI instruction, but cannot be set if it was
cleared prior to execution of the RTI instruction.
If another interrupt is pending when RTI has finished restoring registers from the stack, the SP is
adjusted to preserve stack content, and the new vector is fetched. This operation is functionally
identical to the same operation in the M68HC11, where registers actually are re-stacked, but is faster.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
0 0 0 0 Δ Δ Δ Δ Δ Δ Δ Δ supervisor state
− 0 0 0 0 − − − Δ − Δ Δ Δ Δ user state
Condition codes take on the value pulled from the stack, except that the X mask bit cannot change from
0 to 1. Software can leave the X bit set, leave it cleared, or change it from 1 to 0, but it can be set only
by a reset or by recognition of an XIRQ interrupt.
Description
Restores context at the end of a subroutine. Loads the program counter with a 16-bit value pulled from
the stack and increments the stack pointer by two. Program execution continues at the address restored
from the stack.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Subtracts the content of accumulator B from the content of accumulator A and places the result in A.
The content of B is not affected. For subtraction instructions, the C status bit represents a borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M and the value of the C status bit from the content of
accumulator A. The result is placed in A. For subtraction instructions, the C status bit represents a
borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M and the value of the C status bit from the content of
accumulator B. The result is placed in B. For subtraction instructions, the C status bit represents a
borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M : M + 1 and the value of the C status bit from the content
of accumulator D. The result is placed in D. For subtraction instructions, the C status bit represents a
borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M : M + 1 and the value of the C status bit from the content
of index register X. The result is placed in X. For subtraction instructions, the C status bit represents a
borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M : M + 1 and the value of the C status bit from the content
of index register Y. The result is placed in Y. For subtraction instructions, the C status bit represents a
borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Sets the C status bit. This instruction is assembled as ORCC #$01. The ORCC instruction can be used
to set any combination of bits in the CCR in one operation.
SEC can be used to set up the C bit prior to a shift or rotate instruction involving the C bit.
CCR Details
S X H I N Z V C
– – – – – – – 1
C: 1; set
Description
Sets the I mask bit. This instruction is assembled as ORCC #$10. The ORCC instruction can be used
to set any combination of bits in the CCR in one operation. When the I bit is set, all maskable interrupts
are inhibited, and the CPU will recognize only non-maskable interrupt sources or an SWI.
CCR Details
S X H I N Z V C
– – – 1 – – – – supervisor state
– – – – – – – – user state
I: 1; set
Description
Sets the V status bit. This instruction is assembled as ORCC #$02. The ORCC instruction can be used
to set any combination of bits in the CCR in one operation.
CCR Details
S X H I N Z V C
– – – – – – 1 –
V: 1; set
Description
For the case r1,r3 this instruction is an alternate mnemonic for the TFR r1,r3 instruction, where r1 is
an 8-bit register and r3 is a 16-bit register. The case r2,r3, where both r2 and r3 are 16-bit registers, is
new on CPU12XV0. For both cases the result in r3 is the 16-bit sign extended representation of the
original two’s complement number in r1 or r2. The content of r1 or r2 is unchanged in all cases except
that of SEX A,D (D is A : B).
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Stores the content of accumulator A in memory location M. The content of A is unchanged.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of accumulator B in memory location M. The content of B is unchanged.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of double accumulator D in memory location M : M + 1. The content of D is
unchanged.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
When the S control bit is set, STOP is disabled and operates like a 2-cycle NOP instruction. When the
S bit is cleared, STOP stacks CPU12 context, stops all system clocks, and puts the device in standby
mode.
Standby operation minimizes system power consumption. The contents of registers and the states of
I/O pins remain unchanged.
Asserting the RESET, XIRQ, or IRQ signals ends standby mode. Stacking on entry to STOP allows
the CPU12 to recover quickly when an interrupt is used, provided a stable clock is applied to the
device. If the system uses a clock reference crystal that also stops during low-power mode, crystal
startup delay lengthens recovery time.
If XIRQ is asserted while the X mask bit = 0 (XIRQ interrupts enabled), execution resumes with a
vector fetch for the XIRQ interrupt. While the X mask bit = 1 (XIRQ interrupts disabled), a 2-cycle
recovery sequence is used to adjust the instruction queue and the stack pointer, and execution continues
with the next instruction after STOP.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Stores the content of the stack pointer in memory. The most significant byte of the SP is stored at the
specified address, and the least significant byte of the SP is stored at the next higher byte address (the
specified address plus one).
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of index register X in memory. The most significant byte of X is stored at the
specified address, and the least significant byte of X is stored at the next higher byte address (the
specified address plus one).
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Stores the content of index register Y in memory. The most significant byte of Y is stored at the
specified address, and the least significant byte of Y is stored at the next higher byte address (the
specified address plus one).
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Subtracts the content of memory location M from the content of accumulator A, and places the result
in A. For subtraction instructions, the C status bit represents a borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M from the content of accumulator B and places the result
in B. For subtraction instructions, the C status bit represents a borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M : M + 1 from the content of double accumulator D and
places the result in D. For subtraction instructions, the C status bit represents a borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M : M + 1 from the content of index register X and places
the result in X. For subtraction instructions, the C status bit represents a borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Subtracts the content of memory location M : M + 1 from the content of index register Y and places
the result in Y. For subtraction instructions, the C status bit represents a borrow.
CCR Details
S X H I N Z V C
– – – – Δ Δ Δ Δ
Description
Causes an interrupt without an external interrupt service request. Uses the address of the next
instruction after SWI as a return address. Stacks the return address, index registers Y and X,
accumulators B and A, and the CCR, decrementing the SP before each item is stacked. The I mask bit
is then set, the user state bit (U) is cleared, the PC is loaded with the SWI vector, and instruction
execution resumes at that location. SWI is not affected by the I mask bit. Refer to Chapter 7,
“Exception Processing” for more information.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
0 – – – – – – – – 1 – – – –
I: 1; set
U: 0; cleared
1
The CPU12 and CPU12X also use the SWI processing sequence for hardware interrupts and unimplemented opcode traps.
A variation of the sequence (VfPPP) is used for resets.
Description
Causes an interrupt without an external interrupt service request. Uses the address of the next
instruction after SYS as a return address. Stacks the return address, index registers Y and X,
accumulators B and A, and the CCR, decrementing the SP before each item is stacked. The I mask bit
is then set, the user state bit (U) is cleared, the PC is loaded with the SYS vector, and instruction
execution resumes at that location. SYS is not affected by the I mask bit. Refer to Chapter 7,
“Exception Processing” for more information.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
0 – – – – – – – – 1 – – – –
I: 1; set
U: 0; cleared
Description
Moves the content of accumulator A to accumulator B. The former content of B is lost; the content of
A is not affected. Unlike the general transfer instruction TFR A,B which does not affect condition
codes, the TAB instruction affects the N, Z, and V status bits for compatibility with M68HC11.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Transfers the logic states of bits [7:0] of accumulator A to the corresponding bit positions of the CCR.
The content of A remains unchanged. The X mask bit can be cleared as a result of a TAP, but cannot
be set if it was cleared prior to execution of the TAP. If the I bit is cleared, there is a 1-cycle delay before
the system allows interrupt requests. This prevents interrupts from occurring between instructions in
the sequences CLI, WAI and CLI, STOP.
This instruction is accomplished with the TFR A,CCR instruction. For compatibility with the
M68HC11, the mnemonic TAP is translated by the assembler.
CCR Details
S X H I N Z V C
Δ Δ Δ Δ Δ Δ Δ supervisor state
− − Δ − Δ Δ Δ Δ user state
Condition codes take on the value of the corresponding bit of accumulator A, except that the X mask
bit cannot change from 0 to 1. Software can leave the X bit set, leave it cleared, or change it from 1 to
0, but it can only be set by a reset or by recognition of an XIRQ interrupt.
Description
Moves the content of accumulator B to accumulator A. The former content of A is lost; the content of
B is not affected. Unlike the general transfer instruction TFR B,A, which does not affect condition
codes, the TBA instruction affects N, Z, and V for compatibility with M68HC11.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 –
Description
Tests the specified counter register A, B, D, X, Y, or SP. If the counter register is zero, branches to the
specified relative destination. TBEQ is encoded into three bytes of machine code including a 9-bit
relative offset (–256 to +255 locations from the start of the next instruction).
DBEQ and IBEQ instructions are similar to TBEQ, except that the counter is decremented or
incremented rather than simply being tested. Bits 7 and 6 of the instruction postbyte are used to
determine which operation is to be performed.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Linearly interpolates one of 256 result values that fall between each pair of data entries in a lookup
table stored in memory. Data entries in the table represent the Y values of endpoints of equally spaced
line segments. Table entries and the interpolated result are 8-bit values. The result is stored in
accumulator A. Before executing TBL, an index register points to the table entry corresponding to the
X value (X1) that is closest to, but less than or equal to, the desired lookup point (XL, YL). This defines
the left end of a line segment and the right end is defined by the next data entry in the table. Prior to
execution, accumulator B holds a binary fraction (radix point to left of MSB), representing the ratio
(XL–X1) ÷ (X2–X1).
The 8-bit unrounded result is calculated using the following expression:
A = Y1 + [(B) × (Y2 – Y1)]
Where :
(B) = (XL – X1) ÷ (X2 – X1)
Y1 = 8-bit data entry pointed to by <effective address>
Y2 = 8-bit data entry pointed to by <effective address> + 1
The intermediate value [(B) × (Y2 – Y1)] produces a 16-bit result with the radix point between bits 7
and 8. Any indexed addressing mode referenced to X, Y, SP, or PC, except indirect modes or 9-bit and
16-bit offset modes, can be used to identify the first data point (X1,Y1). The second data point is the
next table entry.
CCR Details
S X H I N Z V C
– – – – Δ Δ – Δ
l
Description
Tests the specified counter register A, B, D, X, Y, or SP. If the counter register is not zero, branches to
the specified relative destination. TBNE is encoded into three bytes of machine code including a 9-bit
relative offset (–256 to +255 locations from the start of the next instruction).
DBNE and IBNE instructions are similar to TBNE, except that the counter is decremented or
incremented rather than simply being tested. Bits 7 and 6 of the instruction postbyte are used to
determine which operation is to be performed.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Transfers the content of a source register to a destination register specified in the instruction. The order
in which transfers between 8-bit and 16-bit registers are specified affects the high byte of the 16-bit
registers differently. Cases involving TMP2 and TMP3 are reserved for NXP use, so some assemblers
may not permit their use. It is possible to generate these cases by using DC.B or DC.W assembler
directives.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
– – – – – – – – – – – – – –
OR
– – – – Δ Δ Δ Δ Δ Δ Δ Δ supervisor state
– – – – – – − − Δ − Δ Δ Δ Δ user state
None affected, unless the CCR (or CCRL, CCRH, CCRW) is the destination register. Condition codes
take on the value of the corresponding source bits, except that the X mask bit cannot change from 0 to
1. Software can leave the X bit set, leave it cleared, or change it from 1 to 0, but it can be set only by
a reset or by recognition of an XIRQ interrupt.
LS A B CCR TMPx D X Y SP
A CCR B CCR CCRL CCRL TMP3L CCR B CCR XL CCR YL CCR SPL CCR
2 CCR TFR A,CCR TFR B,CCR TFR CCR,CCR TFR TMP3,CCR TFR D,CCR TFR X,CCR TFR Y,CCR TFR SP,CCR
TFR A,CCRL TFR B,CCRL TFR CCRL,CCRL TFR TMP3L,CCRL TFR D,CCRL TFR XL,CCRL TFR YL,CCRL TFR SPL,CCRL
A CCRH B CCRL CCRW CCRW TMP3 CCRH:L D CCRH:L X CCRH:L Y CCRH:L SP CCRH:L
A CCR
TFR A,CCRH TFR B,CCRL TFR CCRW,CCRW TFR TMP3,CCRW TFR D,CCRW TFR X,CCRW TFR Y,CCRW TFR SP,CCRW
A TMP2H B TMP2L CCRH:L TMP2 TMP3 TMP2 D TMP1 X TMP2 Y TMP2 SP TMP2
B TMPx
TFR A,TMP2H TFR B,TMP2L TFR CCRW,TMP2 TFR TMP3,TMP2 TFR D,TMP1 TFR X,TMP2 TFR Y,TMP2 TFR SP,TMP2
Note: Encodings in the shaded area (LS = 8–F) are only available on CPU12X.
Description
Transfers the content of the condition code register to corresponding bit positions of accumulator A.
The CCR remains unchanged.
This mnemonic is implemented by the TFR CCR,A instruction. For compatibility with the M68HC11,
the mnemonic TPA is translated into the TFR CCR,A instruction by the assembler.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Traps unimplemented opcodes. There are opcodes in all 256 positions in the page 1 opcode map, but
only 54 of the 256 positions on page 2 of the opcode map are used. If the CPU attempts to execute one
of the unimplemented opcodes on page 2, an opcode trap interrupt occurs. Unimplemented opcode
traps are essentially interrupts that share the $FFF8:$FFF9 interrupt vector.
TRAP uses the next address after the unimplemented opcode as a return address. It stacks the return
address, index registers Y and X, accumulators B and A, and the CCR, automatically decrementing the
SP before each item is stacked. The I mask bit is then set, the user state bit (U) is cleared, the PC is
loaded with the trap vector, and instruction execution resumes at that location. This instruction is not
maskable by the I bit. Refer to Chapter 7, “Exception Processing” for more information.
CCR Details
U 0 0 0 0 IPL S X H I N Z V C
0 – – – – – – – – 1 – – – –
I: 1; set
U: 0; cleared
Description
Subtracts $00 from the content of memory location M and sets the condition codes accordingly.
The subtraction is accomplished internally without modifying M.
The TST instruction provides limited information when testing unsigned values. Since no unsigned
value is less than zero, BLO and BLS have no utility following TST. While BHI can be used after TST,
it performs the same function as BNE, which is preferred. After testing signed values, all signed
branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 0
Description
Subtracts $00 from the content of accumulator A and sets the condition codes accordingly.
The subtraction is accomplished internally without modifying A.
The TSTA instruction provides limited information when testing unsigned values. Since no unsigned
value is less than zero, BLO and BLS have no utility following TSTA. While BHI can be used after
TST, it performs the same function as BNE, which is preferred. After testing signed values, all signed
branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 0
Description
Subtracts $00 from the content of accumulator B and sets the condition codes accordingly.
The subtraction is accomplished internally without modifying B.
The TSTB instruction provides limited information when testing unsigned values. Since no unsigned
value is less than zero, BLO and BLS have no utility following TSTB. While BHI can be used after
TST, it performs the same function as BNE, which is preferred. After testing signed values, all signed
branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 0
Description
Subtracts $0000 from the content of memory location M : M + 1 and sets the condition codes
accordingly.
The subtraction is accomplished internally without modifying M : M + 1.
The TST instruction provides limited information when testing unsigned values. Since no unsigned
value is less than zero, BLO and BLS have no utility following TST. While BHI can be used after TST,
it performs the same function as BNE, which is preferred. After testing signed values, all signed
branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 0
Description
Subtracts $0000 from the content of index register X and sets the condition codes accordingly.
The subtraction is accomplished internally without modifying X.
The TST instruction provides limited information when testing unsigned values. Since no unsigned
value is less than zero, BLO and BLS have no utility following TST. While BHI can be used after TST,
it performs the same function as BNE, which is preferred. After testing signed values, all signed
branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 0
Description
Subtracts $0000 from the content of index register Y and sets the condition codes accordingly.
The subtraction is accomplished internally without modifying Y.
The TST instruction provides limited information when testing unsigned values. Since no unsigned
value is less than zero, BLO and BLS have no utility following TST. While BHI can be used after TST,
it performs the same function as BNE, which is preferred. After testing signed values, all signed
branches are available.
CCR Details
S X H I N Z V C
– – – – Δ Δ 0 0
Description
This is an alternate mnemonic to transfer the stack pointer value to index register X. The content of the
SP remains unchanged. After a TSX instruction, X points at the last value that was stored on the stack.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
This is an alternate mnemonic to transfer the stack pointer value to index register Y. The content of the
SP remains unchanged. After a TSY instruction, Y points at the last value that was stored on the stack.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
This is an alternate mnemonic to transfer index register X value to the stack pointer. The content of X
is unchanged.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
This is an alternate mnemonic to transfer index register Y value to the stack pointer. The content of Y
is unchanged.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Puts the CPU into a wait state. Uses the address of the instruction following WAI as a return address.
Stacks the return address, index registers Y and X, accumulators B and A, and the CCR, decrementing
the SP before each item is stacked.
The CPU then enters a wait state for an integer number of bus clock cycles. During the wait state, CPU
clocks are stopped, but other MCU clocks can continue to run. The CPU leaves the wait state when it
senses an interrupt that has not been masked.
If XIRQ is asserted while the X mask bit = 0 (XIRQ interrupts enabled), execution resumes with a
vector fetch for the XIRQ interrupt. While the X mask bit = 1 (XIRQ interrupts disabled), a 2-cycle
recovery sequence is used to adjust the instruction queue and the stack pointer, and execution continues
with the next instruction after WAI.
CCR Details
S X H I N Z V C
– – – – – – – –
Access Detail
Source Address Object
Form Mode Code CPU12XV0
CPU12 CPU12XV2
CPU12XV1
WAI (before interrupt) INH 3E OSSSSsf OSSSSSf
WAI (when interrupt comes) fVfPPP fVfPPP
(continue) ff ff
(CPU in user state) NA NA O
Description
Performs weighted average calculations on values stored in memory. Uses indexed (X) addressing
mode to reference one source operand list, and indexed (Y) addressing mode to reference a second
source operand list. Accumulator B is used as a counter to control the number of elements to be
included in the weighted average.
For each pair of data points, a 24-bit sum of products (SOP) and a 16-bit sum of weights (SOW) is
accumulated in temporary registers. When B reaches zero (no more data pairs), the SOP is placed in
Y : D. The SOW is placed in X. To arrive at the final weighted average, divide the content of Y : D by
X by executing an EDIV after the WAV.
This instruction can be interrupted. If an interrupt occurs during WAV execution, the intermediate
results (six bytes) are stacked in the order SOW[15:0], SOP[15:0], $00:SOP[23:16] before the interrupt is
processed. The wavr pseudo-instruction is used to resume execution after an interrupt. The mechanism
is re-entrant. New WAV instructions can be started and interrupted while a previous WAV instruction
is interrupted.
This instruction is often used in fuzzy logic rule evaluation. Refer to Section Chapter 9, “Fuzzy Logic
Support” for more information.
CCR Details
S X H I N Z V C
– – ? – ? 1 ? ?
Z: 1; set
H, N, V and C may be altered by this instruction
Description
Exchanges the content of double accumulator D and the content of index register X. For compatibility
with the M68HC11, the XGDX instruction is translated into an EXG D,X instruction by the assembler.
CCR Details
S X H I N Z V C
– – – – – – – –
Description
Exchanges the content of double accumulator D and the content of index register Y. For compatibility
with the M68HC11, the XGDY instruction is translated into an EXG D,Y instruction by the assembler.
CCR Details
S X H I N Z V C
– – – – – – – –
• All remaining interrupt service requests can be masked with the I bit (I=1) and are subject to
priority filtering using the IPL bits (on CPU12X).
7.4 Resets
CPU12 Family devices perform resets with a combination of hardware and software. Integration module
circuitry determines the type of reset that has occurred, performs basic system configuration, then passes
control to the CPU. The CPU fetches a vector determined by the type of reset that has occurred, jumps to
the address pointed to by the vector, and begins to execute code at that address. For more information on
possible causes of a reset and the associated reset vectors please refer to the MCU reference manual of the
device.
7.5 Interrupts
Each CPU12 Family device can recognize a number of interrupt sources. Each source is associated with a
vector in the vector table. The unimplemented opcode trap, the SYS instruction, the SWI instruction and
the access violation interrupts are non-maskable, and have a fixed priority. The XIRQ signal is X
bit-maskable. The remaining interrupt sources can be masked by the I bit. The I bit maskable interrupt
sources have default priorities that follow the address order of the interrupt vectors. The higher the vector
address, the higher the priority of the interrupt. On the CPU12 a device integration module incorporates
logic that can give any one maskable source priority over other maskable sources. On the CPU12X the
priority of each I bit maskable interrupt can be configured to one out of 7 possible priority levels,
controlled by the IPL bits. Please refer to the interrupt module chapter in the MCU reference manual for
details.
begins to service an interrupt, the instruction queue is refilled, a return address is calculated, and then the
return address and the contents registers are stacked as shown in Table 7-1 for CPU12 and Table 7-2 for
CPU12X.
Table 7-1. CPU12 Stacking Order on Entry to Interrupts
After the CCR is stacked, the I bit (and the X bit, if an XIRQ interrupt service request caused the interrupt)
is set to prevent other interrupts from disrupting the interrupt service routine. On CPU12XV2 the U bit is
cleared to make sure the interrupt service routine is executed in supervisor state. Execution continues at
the address pointed to by the vector for the highest-priority interrupt that was pending at the beginning of
the interrupt sequence. At the end of the interrupt service routine, an RTI instruction restores context from
the stacked registers, and normal program execution resumes.
On the CPU12XV2, supervisor state is forced before the vector fetch cycle to ensure the entire exception
processing sequence takes place in supervisor state. This is independent from the actual clearing of the U
bit which during an interrupt sequence does not happen until the CCRW register was stacked.
During the vector fetch cycle, the CPU issues a signal that tells the interrupt module to drive the vector
address of the highest priority, pending exception onto the system address bus (the CPU12 does not
provide this address).
After the vector fetch, the CPU selects one of the three alternate execution paths, depending upon the cause
of the exception.
Start
Yes
Opcode Trap?
No
1.0 - V Fetch Vector
T.1 - f Internal Calculations
Force supervisor state and fetch
address of exception handler
Yes
Reset?
No
No
Interrupt?
Yes
2.0 - f No Bus Access 2.1 - S Push Return Address 2.2 - S Push Return Address
Set S, X, and I Address of inst that would have Address of inst after SWI, SYS or
Clear U and IPL[2:0] executed if no interrupt unimplemented opcode
3.0 - P Fetch Program Word 3.1 - P Fetch Program Word 3.2 - P Fetch Program Word
Start to fill instruction queue Start to fill instruction queue Start to fill instruction queue
End
End
Cycle 0 Cycle 1
E Clock
Mnemonic Meaning
0:0 — No movement
0:1 — Unused?
1:0 ALD Advance queue and load from bus
1:1
0:0 — No start
0:1 INT Start interrupt sequence
1:0 SEV Start even instruction
1:1 SOD Start odd instruction
Execution (EX)
Start Even Instruction (SEV)
Pipe Stage 3
Pipe Stage 2
Data Movement (DM)
Pipe Stage 1
Pipe Status DM-1 EX-1 DM0 EX0 DM1 EX1 DM2 EX2
Note: IQSTAT contains data movement of the pipe in time T-2 (ALD) and/or the
corresponding execution information in T-1 (INT, SEV, or SOD)
8.3.3 Null
The (00 for CPU12) (0000 for CPU12X) data movement state indicates that there was no data movement
in the instruction queue; the (00 for CPU12) (0000 for CPU12X)) execution start state indicates
continuation of an instruction or interrupt sequence (no new instruction or interrupt start).
Mnemonic Meaning
E Clock
TAGLO
LSTRB/TAGLO LSTRB Valid Valid
TAGHI
BKGD/TAGHI Valid
Table 8-3 shows the functions of the two independent tagging pins. The presence of logic level 0 on either
pin at the fall of ECLK tags (marks) the associated byte of program information as it is read into the
instruction queue. Tagging is allowed in all modes. Tagging is disabled when BDM becomes active.
In CPU12 derivatives that have hardware breakpoint capability, the breakpoint control logic and BDM
control logic use the same internal signals for instruction tagging. The CPU12 does not differentiate
between the two kinds of tags.
The tag follows program information as it advances through the queue. When a tagged instruction reaches
the head of the queue, the CPU12 enters active background debug mode rather than executing the
instruction.
RESET
E Clock
Emulation Normal
Special Test OR Expanded
Figure 8-5. Tag Input Timing (CPU12X)
Table 8-4 shows the functions of the two independent tagging pins. The presence of logic level 0 on either
pin at the rise of ECLK tags (marks) the associated byte of program information as it is read into the
instruction queue. Tagging is allowed only in emulation modes. Tagging is disabled when BDM becomes
active.
Table 8-4. Tag Pin Function (CPU12X)
On the CPU12X internal breakpoints can also be generated by the DBG module. Breakpoints generated
by the TAGLO or TAGHI have a higher priority than the internally generated breakpoints.
The tag follows program information as it advances through the queue. When a tagged instruction reaches
the head of the queue, a tag hit occurs generating a hardware beakpoint to BDM or SWI.
NOTE
The four Fuzzy instructions (MEM, REV, REVW, WAV/WAVR) are
removed on CPU12V1, CPU12XV1 and CPU12XV2.
9.1 Introduction
The instruction set of the CPU12 Family is the first instruction set to specifically address the needs of fuzzy
logic. This section describes the use of fuzzy logic in control systems, discusses the CPU12 Family fuzzy
logic instructions, and provides examples of fuzzy logic programs.
The CPU12 Family includes four instructions that perform specific fuzzy logic tasks. In addition, several
other instructions are especially useful in fuzzy logic programs. The overall C-friendliness of the
instruction set also aids development of efficient fuzzy logic programs.
This section explains the basic fuzzy logic algorithm for which the four fuzzy logic instructions are
intended. Each of the fuzzy logic instructions are then explained in detail. Finally, other custom fuzzy logic
algorithms are discussed, with emphasis on use of other CPU instructions.
The four fuzzy logic instructions are:
• MEM (determine grade of membership), which evaluates trapezoidal membership functions
• REV (fuzzy logic rule evaluation) and REVW (fuzzy logic rule evaluation weighted), which
perform unweighted or weighted MIN-MAX rule evaluation
• WAV (weighted average), which performs weighted average defuzzification on singleton output
membership functions.
Other instructions that are useful for custom fuzzy logic programs include:
• MINA (place smaller of two unsigned 8-bit values in accumulator A)
• EMIND (place smaller of two unsigned 16-bit values in accumulator D)
• MAXM (place larger of two unsigned 8-bit values in memory)
• EMAXM (place larger of two unsigned 16-bit values in memory)
• TBL (table lookup and interpolate)
• ETBL (extended table lookup and interpolate)
• EMACS (extended multiply and accumulate signed 16-bit by 16-bit to 32-bit)
For higher resolution fuzzy programs, the fast extended precision math instructions in the CPU12 Family
instruction set are also beneficial. Flexible indexed addressing modes help simplify access to fuzzy logic
data structures stored as lists or tabular data structures in memory.
The actual logic additions required to implement fuzzy logic support in the CPU12 Family are quite small,
so there is no appreciable increase in cost for the typical user. A fuzzy inference kernel for the CPU12
Family requires one-fifth as much code space and executes almost 50 times faster than a comparable kernel
implemented on a typical midrange microcontroller.
System
Knowledge Inputs
Base Fuzzy
Inference
Input Kernel
Membership Fuzzifiction
Functions
… Fuzzy Inputs
(In RAM)
… Fuzzy Outputs
(In RAM)
Output
Membership Defuzzification
Functions
System
Outputs
Figure 9-1. Block Diagram of a Fuzzy Logic System
One execution pass through the fuzzy inference kernel generates system output signals in response to
current input conditions. The kernel is executed as often as needed to maintain control. If the kernel is
executed more often than needed, processor bandwidth and power are wasted; delaying too long between
passes can cause the system to get too far out of control. Choosing a periodic rate for a fuzzy control system
is the same as it would be for a conventional control system.
Membership Functions
for Temperature Fuzzy Inputs
$FF
Hot
$C0
$80
$40 Temperature is Hot $00
$00
0°F 32°F 64°F 96°F 128°F
$FF
Warm
$C0
$80
$40 Temperature is Warm $40
$00
0°F 32°F 64°F 96°F 128°F
$FF
Cold
$C0
$80
$40 Temperature is Cold $C0
$00
0°F 32°F 64°F 96°F 128°F
Current
Temperature
is 64°F
Figure 9-2. Fuzzification Using Membership Functions
When the fuzzification step begins, the current value of the system input is in an accumulator of the CPU,
one index register points to the first membership function definition in the knowledge base, and a second
index register points to the first fuzzy input in RAM. As each fuzzy input is calculated by executing a
MEM instruction, the result is stored to the fuzzy input and both pointers are updated automatically to
point to the locations associated with the next fuzzy input. The MEM instruction takes care of everything
except counting the number of labels per system input and loading the current value of any subsequent
system inputs.
The end result of the fuzzification step is a table of fuzzy inputs representing current system conditions.
The CPU12 Family offers two variations of rule evaluation instructions. The REV instruction provides for
unweighted rules (all rules are considered to be equally important). The REVW instruction is similar but
allows each rule to have a separate weighting factor which is stored in a separate parallel data structure in
the knowledge base. In addition to the weights, the two rule evaluation instructions also differ in the way
rules are encoded into the knowledge base.
An understanding of the structure and syntax of rules is needed to understand how a microcontroller
performs the rule evaluation task. An example of a typical rule is:
If temperature is warm and pressure is high, then heat is (should be) off.
At first glance, it seems that encoding this rule in a compact form understandable to the microcontroller
would be difficult, but it is actually simple to reduce the rule to a small list of memory pointers. The
antecedent portion of the rule is a statement of input conditions and the consequent portion of the rule is a
statement of output actions.
The antecedent portion of a rule is made up of one or more (in this case two) antecedents connected by a
fuzzy and operator. Each antecedent expression consists of the name of a system input, followed by is,
followed by a label name. The label must be defined by a membership function in the knowledge base.
Each antecedent expression corresponds to one of the fuzzy inputs in RAM. Since and is the only operator
allowed to connect antecedent expressions, there is no need to include these in the encoded rule. The
antecedents can be encoded as a simple list of pointers to (or addresses of) the fuzzy inputs to which they
refer.
The consequent portion of a rule is made up of one or more (in this case one) consequents. Each
consequent expression consists of the name of a system output, followed by is, followed by a label name.
Each consequent expression corresponds to a specific fuzzy output in RAM. Consequents for a rule can
be encoded as a simple list of pointers to (or addresses of) the fuzzy outputs to which they refer.
The complete rules are stored in the knowledge base as a list of pointers or addresses of fuzzy inputs and
fuzzy outputs. For the rule evaluation logic to work, there must be some means of knowing which pointers
refer to fuzzy inputs and which refer to fuzzy outputs. There also must be a way to know when the last rule
in the system has been reached.
• One method of organization is to have a fixed number of rules with a specific number of
antecedents and consequents.
• A second method, employed in NXP Freeware M68HC11 kernels, is to mark the end of the rule
list with a reserved value, and use a bit in the pointers to distinguish antecedents from consequents.
• A third method of organization, used in the CPU12 Family, is to mark the end of the rule list with
a reserved value, and separate antecedents and consequents with another reserved value. This
permits any number of rules, and allows each rule to have any number of antecedents and
consequents, subject to the limits imposed by availability of system memory.
Each rule is evaluated sequentially, but the rules as a group are treated as if they were all evaluated
simultaneously. Two mathematical operations take place during rule evaluation. The fuzzy and operator
corresponds to the mathematical minimum operation and the fuzzy or operation corresponds to the
mathematical maximum operation. The fuzzy and is used to connect antecedents within a rule. The fuzzy
or is implied between successive rules. Before evaluating any rules, all fuzzy outputs are set to zero
(meaning not true at all). As each rule is evaluated, the smallest (minimum) antecedent is taken to be the
overall truth of the rule. This rule truth value is applied to each consequent of the rule (by storing this value
to the corresponding fuzzy output) unless the fuzzy output is already larger (maximum). If two rules affect
the same fuzzy output, the rule that is most true governs the value in the fuzzy output because the rules are
connected by an implied fuzzy or.
In the case of rule weighting, the truth value for a rule is determined as usual by finding the smallest rule
antecedent. Before applying this truth value to the consequents for the rule, the value is multiplied by a
fraction from zero (rule disabled) to one (rule fully enabled). The resulting modified truth value is then
applied to the fuzzy outputs.
The end result of the rule evaluation step is a table of suggested or “raw” fuzzy outputs in RAM. These
values were obtained by plugging current conditions (fuzzy input values) into the system rules in the
knowledge base. The raw results cannot be supplied directly to the system outputs because they may be
ambiguous. For instance, one raw output can indicate that the system output should be medium with a
degree of truth of 50 percent while, at the same time, another indicates that the system output should be
low with a degree of truth of 25 percent. The defuzzification step resolves these ambiguities.
Si Fi
System Output = i-----------------------
=1
n
Fi
i=1
Where n is the number of labels of a system output, Si are the singleton positions from the knowledge base,
and Fi are fuzzy outputs from RAM. For a common fuzzy logic program on the CPU12 Family, n is eight
or less (though this instruction can handle any value to 255) and Si and Fi are 8-bit values. The final divide
is performed with a separate EDIV instruction placed immediately after the WAV instruction.
Before executing WAV, an accumulator must be loaded with the number of iterations (n), one index register
must be pointed at the list of singleton positions in the knowledge base, and a second index register must
be pointed at the list of fuzzy outputs in RAM. If the system has more than one system output, the WAV
instruction is executed once for each system output.
Lines 1 to 3 set up pointers and load the system input value into the A accumulator.
Line 4 sets the loop count for the loop in lines 5 and 6.
Lines 5 and 6 make up the fuzzification loop for seven labels of one system input. The MEM instruction
finds the y-value on a trapezoidal membership function for the current input value, for one label of the
current input, and then stores the result to the corresponding fuzzy input. Pointers in X and Y are
automatically updated by four and one so they point at the next membership function and fuzzy input
respectively.
Line 7 loads the current value of the next system input. Pointers in X and Y already point to the right places
as a result of the automatic update function of the MEM instruction in line 5.
Line 8 reloads a loop count.
Lines 9 and 10 form a loop to fuzzify the seven labels of the second system input. When the program drops
to line 11, the Y index register is pointing at the next location after the last fuzzy input, which is the first
fuzzy output in this system.
Graphical Representation
$FF
$E0
$C0
Degree $A0
of $80
Truth Slope_2
$60
$40 Point_1 Slope_1
Point_2
$20
$00
$00 $10 $20 $30 $40 $50 $60 $70 $80 $90 $A0 $B0 $C0 $D0 $E0 $F0 $FF
Input Range
Memory Representation
ADDR $40 X-Position of Point_1
ADDR+1 $D0 X-Position of Point_2
ADDR+2 $08 Slope_1 ($FF/(X-POS of saturation – Point_1))
ADDR+3 $04 Slope_2 ($FF/(Point_2 – X-POS of saturation))
Figure 9-4. Defining a Normal Membership Function
An internal CPU algorithm calculates the y-value where the current input intersects a membership
function. This algorithm assumes the membership function obeys some common-sense rules. If the
membership function definition is improper, the results may be unusual. See Section 9.4.2, “Abnormal
Membership Function Definitions”” for a discussion of these cases.
These rules apply to normal membership functions.
• $00 ≤ Point_1 < $FF
• $00 < Point_2 ≤ $FF
• Point_1 < Point_2
• The sloping sides of the trapezoid meet at or above $FF.
Each system input such as temperature has several labels such as cold, cool, normal, warm, and hot. Each
label of each system input must have a membership function to describe its meaning in an unambiguous
numerical way. Typically, there are three to seven labels per system input, but there is no practical
restriction on this number as far as the fuzzification step is concerned.
membership functions. Although these abnormal shapes do not correspond to any working systems,
understanding how these cases are treated in the CPU12 Family can be helpful for debugging.
A close examination of the MEM instruction algorithm will show how such membership functions are
evaluated. Figure 9-5 is a complete flow diagram for the execution of a MEM instruction. Each rectangular
box represents one CPU bus cycle. The number in the upper left corner corresponds to the cycle number
and the letter corresponds to the cycle type (refer to <st-blue>Chapter 6 Instruction Glossary for details).
The upper portion of the box includes information about bus activity during this cycle (if any). The lower
portion of the box, which is separated by a dashed line, includes information about internal CPU processes.
It is common for several internal functions to take place during a single CPU cycle (for example, in cycle
2, two 8-bit subtractions take place and a flag is set based on the results).
Start
4-O If misaligned, then read program word to fill instruction queue else no bus access.
4a — If (((Slope_2 = 0) or (Grade_2 > $FF)) and (flag_d12n = 0)) then Grade = $FF
else Grade = Grade_2
4b — If (((Slope_1 = 0) or (Grade_1 > $FF)) and (flag_d12n = 0)) then Grade = Grade
else Grade = Grade_1
End
Memory Definition: $60, $80, $04, $04; Point_1, Point_2, Slope_1, Slope_2
P1 P2 P1 P2
Figure 9-6. Abnormal Membership Function Case 1
If Point_1 was to the right of Point_2, flag_d12n would force the result to be $00 for all input values. In
fact, flag_d12n always limits the region of interest to the space greater than or equal to Point_1 and less
than or equal to Point_2.
Memory Definition: $60, $C0, $04, $04; Point_1, Point_2, Slope_1, Slope_2
P1 P2 P1 Left Side P2
Crosses $FF
Figure 9-7. Abnormal Membership Function Case 2
Memory Definition: $60, $80, $00, $04; Point_1, Point_2, Slope_1, Slope_2
P1 P2 P1 P2
Figure 9-8. Abnormal Membership Function Case 3
If the current truth value is larger, it is written over the previous value in the fuzzy output. After all rules
have been evaluated, the fuzzy output contains the truth value for the most-true rule that referenced that
fuzzy output.
After REV finishes, A will hold the truth value for the last rule in the rule list. The V condition code bit
should be one because the last element before the $FF end marker should have been a rule consequent. If
V is zero after executing REV, it indicates the rule list was structured incorrectly.
START
Yes
Interrupt pending?
No
6.0 - x No bus access 6.1 - x Update Fy with value read in cyc 4.0
Update Fy with value read in cyc 4.0 If Rx ¼ $FE or $FF, and ACCA > Fy
then Write byte @ Rx,Y
If Rx ¼ $FE then A = min(A, Fy)
else no bus access
else A = A (no change to A)
No
Rx = $FF (end of rules)?
Yes
7.0 - O Read program word if $3A misaligned
END
In cycle 1.0, the CPU does an optional program word access to replace the $18 prebyte of the REV
instruction. Notice that cycle 7.0 is also an O type cycle. One or the other of these will be a program word
fetch, while the other will be a free cycle where the CPU does not access the bus. Although the $18 page
prebyte is a required part of the REV instruction, it is treated by the CPU as a somewhat separate single
cycle instruction.
Rule evaluation begins at cycle 2.0 with a byte read of the first element in the rule list. Usually this would
be the first antecedent of the first rule, but the REV instruction can be interrupted, so this could be a read
of any byte in the rule list. The X index register is incremented so it points to the next element in the rule
list. Cycle 3.0 is needed to satisfy the required delay between a read and when data is valid to the CPU.
Some internal CPU housekeeping activity takes place during this cycle, but there is no bus activity. By
cycle 4.0, the rule element that was read in cycle 2.0 is available to the CPU.
Cycle 4.0 is the first cycle of the main three cycle rule evaluation loop. Depending upon whether rule
antecedents or consequents are being processed, the loop will consist of cycles 4.0, 5.0, 6.0, or the
sequence 4.0, 5.0, 6.1. This loop is executed once for every byte in the rule list, including the $FE
separators and the $FF end-of-rules marker.
At each cycle 4.0, a fuzzy input or fuzzy output is read, except during the loop passes associated with the
$FE and $FF marker bytes, where no bus access takes place during cycle 4.0. The read access uses the Y
index register as the base address and the previously read rule byte (Rx) as an unsigned offset from Y. The
fuzzy input or output value read here will be used during the next cycle 6.0 or 6.1. Besides being used as
the offset from Y for this read, the previously read Rx is checked to see if it is a separator character ($FE).
If Rx was $FE and the V bit was one, this indicates a switch from processing consequents of one rule to
starting to process antecedents of the next rule. At this transition, the A accumulator is initialized to $FF
to prepare for the min operation to find the smallest fuzzy input. Also, if Rx is $FE, the V bit is toggled to
indicate the change from antecedents to consequents, or consequents to antecedents.
During cycle 5.0, a new rule byte is read unless this is the last loop pass, and Rx is $FF (marking the end
of the rule list). This new rule byte will not be used until cycle 4.0 of the next pass through the loop.
Between cycle 5.0 and 6.x, the V-bit is used to decide which of two paths to take. If V is zero, antecedents
are being processed and the CPU progresses to cycle 6.0. If V is one, consequents are being processed and
the CPU goes to cycle 6.1.
During cycle 6.0, the current value in the A accumulator is compared to the fuzzy input that was read in
the previous cycle 4.0, and the lower value is placed in the A accumulator (min operation). If Rx is $FE,
this is the transition between rule antecedents and rule consequents, and this min operation is skipped
(although the cycle is still used). No bus access takes place during cycle 6.0 but cycle 6.x is considered an
x type cycle because it could be a byte write (cycle 6.1) or a free cycle (cycle 6.0 or 6.1 with Rx = $FE or
$FF).
If an interrupt arrives while the REV instruction is executing, REV can break between cycles 4.0 and 5.0
in an orderly fashion so that the rule evaluation operation can resume after the interrupt has been serviced.
Cycles 5.2 and 6.2 are needed to adjust the PC and X index register so the REV operation can recover after
the interrupt. PC is adjusted backward in cycle 5.2 so it points to the currently running REV instruction.
After the interrupt, rule evaluation will resume, but the values that were stored on the stack for index
registers, accumulator A, and CCR will cause the operation to pick up where it left off. In cycle 6.2, the X
index register is adjusted backward by one because the last rule byte needs to be re-fetched when the REV
instruction resumes.
After cycle 6.2, the REV instruction is finished, and execution would continue to the normal interrupt
processing flow.
method of weighting rules allows an 8-bit weighting factor to represent a value between zero and one
inclusive.
The 8-bit A accumulator is used to hold intermediate calculation results during execution of the REVW
instruction. During antecedent processing, A starts out at $FF and is replaced by any smaller fuzzy input
that is referenced by a rule antecedent. If rule weights are enabled by the C condition code bit equal one,
the rule truth value is multiplied by the rule weight just before consequent processing starts. During
consequent processing, A holds the truth value (possibly weighted) for the rule. This truth value is stored
to any fuzzy output that is referenced by a rule consequent, unless that fuzzy output is already larger
(MAX).
Before starting to execute REVW, A must be set to $FF (the largest 8-bit value) because rule evaluation
always starts with processing of the antecedents of the first rule. For subsequent rules in the list, A is
automatically set to $FF when the instruction detects the $FFFE marker word between the last consequent
of the previous rule, and the first antecedent of a new rule.
Both the C and V condition code bits must be set up prior to starting a REVW instruction. Once the REVW
instruction starts, the C bit remains constant and the value in the V bit is automatically maintained as
$FFFE separator words are detected.
The final requirement to clear all fuzzy outputs to $00 is part of the MAX algorithm. Each time a rule
consequent references a fuzzy output, that fuzzy output is compared to the truth value (weighted) for the
current rule. If the current truth value is larger, it is written over the previous value in the fuzzy output.
After all rules have been evaluated, the fuzzy output contains the truth value for the most-true rule that
referenced that fuzzy output.
After REVW finishes, A will hold the truth value (weighted) for the last rule in the rule list. The V
condition code bit should be one because the last element before the $FFFF end marker should have been
a rule consequent. If V is zero after executing REVW, it indicates the rule list was structured incorrectly.
START
No Yes
Interrupt pending?
END
At cycle 4.0, if Rx is $FFFE and V was one, a change from consequents to antecedents of a new rule is
taking place, so accumulator A must be reinitialized to $FF. During processing of rule antecedents, A is
updated with the smaller of A, or the current fuzzy input (cycle 6.0). Cycle 5.0 is usually used to read the
next rule word and update the pointer in X. This read is skipped if the current Rx is $FFFF (end of rules
mark). If this is a weight multiply pass, the read is delayed until cycle 7.2. During processing of
consequents, cycle 6.1 is used to optionally update a fuzzy output if the value in accumulator A is larger.
After all rules have been processed, cycle 7.0 is used to update the PC to point at the next instruction. If
weights were enabled, Y is updated to point at the location that immediately follows the last rule weight.
Si Fi
System Output = i-----------------------
=1
n
Fi
i=1
Where n is the number of labels of a system output, Si are the singleton positions from the knowledge base,
and Fi are fuzzy outputs from RAM. Si and Fi are 8-bit values. The 8-bit B accumulator holds the iteration
count n. Internal temporary registers hold intermediate sums, 24 bits for the numerator and 16 bits for the
denominator. This makes this instruction suitable for n values up to 255 although eight is a more typical
value. The final long division is performed with a separate EDIV instruction immediately after the WAV
instruction. The WAV instruction returns the numerator and denominator sums in the correct registers for
the EDIV. (EDIV performs the unsigned division Y = Y : D / X; remainder in D.)
Execution time for this instruction depends on the number of iterations (labels for the system output). WAV
is interruptible so that worst case interrupt latency is not affected by the execution time for the complete
weighted average operation. WAV includes initialization for the 24-bit and 16-bit partial sums so the first
entry into WAV looks different than a resume from interrupt operation. The CPU handles this difficulty
with a pseudo-instruction (wavr), which is specifically intended to resume an interrupted weighted average
calculation. Refer to Section 9.6.3, “Cycle-by-Cycle Details for WAV and wavr”” for more detail.
and accumulate this result into TMP1 : TMP2. Even though the sum-of-products will not exceed 24 bits,
the sum is maintained in the 32-bit combined TMP1 : TMP2 register because it is easier to use existing
16-bit operations than it would be to create a new smaller operation to handle the high order bits of this
sum.
Since the weighted average operation could be quite long, it is made to be interruptible. The usual longest
latency path is from very early in cycle 6.0, through cycle 9.0, to the top of the loop to cycle 3.0, through
cycle 5.0 to the interrupt check.
If the WAV instruction is interrupted, the internal temporary registers TMP3, TMP2, and TMP1 need to be
stored on the stack so the operation can be resumed. Since the WAV instruction included initialization in
cycle 2.0, the recovery path after an interrupt needs to be different. The wavr pseudo-instruction has the
same opcode as WAV, but it is on the first page of the opcode map so there is no page prebyte ($18) like
there is for WAV. When WAV is interrupted, the PC is adjusted to point at the second byte of the WAV
object code, so that it will be interpreted as the wavr pseudo-instruction on return from the interrupt, rather
than the WAV instruction. During the recovery sequence, the PC is readjusted in case another interrupt
comes before the weighted average operation finishes.
The resume sequence includes recovery of the temporary registers from the stack (1.1 through 3.1), and
reads to get the operands for the current iteration. The normal WAV flow is then rejoined at cycle 6.0.
Upon normal completion of the instruction (cycle 10.0), the PC is adjusted so it points to the next
instruction. The results are transferred from the TMP registers into CPU registers in such a way that the
EDIV instruction can be used to divide the sum-of-products by the sum-of-weights. TMP1 : TMP2 is
transferred into Y : D and TMP3 is transferred into X.
wavr
WAV
1.0 - O Read program word if $18 misaligned 1.1 - U Read word @ 0,SP (unstack TMP1)
SP = SP + 2
2.0 - f No bus access
TMP1 = TMP2 = TMP3 = $0000 2.1 - U Read word @ 0,SP (unstack TMP2)
SP = SP + 2
3.0 - f No bus access
B = B – 1 decrement iteration counter 3.1 - U Read word @ 0,SP (unstack TMP3)
SP = SP + 2
4.0 - f Read byte @ 0,Y (fuzzy output Fi) 4.1 - r Read byte @ –1,Y (fuzzy output Fi)
Y = Y + 1 point at next fuzzy output
5.0 - r Read byte @ 0,X (singleton Si) 5.1 - r Read byte @ –1,X (singleton Si)
X = X + 1 point at next singleton
Yes
Interrupt pending?
No
END
MIN-MAX rule evaluation and other methods have been discussed in fuzzy logic literature. The weighted
average of singletons is not the only defuzzification technique. The CPU12 Family has several instructions
and addressing modes that can be helpful when developing custom fuzzy logic systems.
The notation A,X causes the TBL instruction to use the Ath line segment in the table. The low-order half
of D (B) is used by TBL to calculate the exact data value from this line segment. This type of table uses
only 257 entries to approximate a table with 16 bits of resolution. This type of table has the disadvantage
of equal width line segments, which means just as many points are needed to describe a flat portion of the
desired function as are needed for the most active portions.
Another type of table stores x:y coordinate pairs for the endpoints of each linear segment. This type of table
may reduce the table storage space compared to the previous fixed-width segments because flat areas of
the functions can be specified with a single pair of endpoints. This type of table is a little harder to use with
the CPU12 Family TBL and ETBL instructions because the table instructions expect y-values for segment
endpoints to be in consecutive memory locations.
Consider a table made up of an arbitrary number of x:y coordinate pairs, where all values are eight bits.
The table is entered with the x-coordinate of the desired point to lookup in the A accumulator. When the
table is exited, the corresponding y-value is in the A accumulator. Figure 9-12 shows one way to work with
this type of table.
BEGIN LDY #TABLE_START-2
;setup initial table pointer
FIND_LOOP CMPA 2,+Y ;find first Xn > XL
;(auto pre-inc Y by 2)
BLS FIND_LOOP ;loop if XL .le. Xn
* on fall thru, XB@-2,Y YB@-1,Y XE@0,Y and YE@1,Y
TFR D,X ;save XL in high half of X
CLRA ;zero upper half of D
LDAB 0,Y ;D = 0:XE
SUBB -2,Y ;D = 0:(XE-XB)
EXG D,X ;X = (XE-XB).. D = XL:junk
SUBA -2,Y ;A = (XL-XB)
EXG A,D ;D = 0:(XL-XB), uses trick of EXG
FDIV ;X reg = (XL-XB)/(XE-XB)
EXG D,X ;move fractional result to A:B
EXG A,B ;byte swap - need result in B
TSTA ;check for rounding
BPL NO_ROUND
INCB ;round B up by 1
NO_ROUND LDAA 1,Y ;YE
PSHA ;put on stack for TBL later
LDAA -1,Y ;YB
PSHA ;now YB@0,SP and YE@1,SP
TBL 2,SP+ ;interpolate and deallocate
;stack temps
Figure 9-12. Endpoint Table Handling
The basic idea is to find the segment of interest, temporarily build a 1-segment table of the correct format
on the stack, then use TBL with stack relative indexed addressing to interpolate. The most difficult part of
the routine is calculating the proportional distance from the beginning of the segment to the lookup point
versus the width of the segment ((XL–XB)/(XE–XB)). With this type of table, this calculation must be
done at run time. In the previous type of table, this proportional term is an inherent part (the lowest order
bits) of the data input to the table.
Some fuzzy theorists have suggested membership functions should be shaped like normal distribution
curves or other mathematical functions. This may be correct, but the processing requirements to solve for
an intercept on such a function would be unacceptable for most microcontroller-based fuzzy systems. Such
a function could be encoded into a table of one of the previously described types.
For many common systems, the thing that is most important about membership function shape is that there
is a gradual transition from non-membership to membership as the system input value approaches the
central range of the membership function.
Examine the human problem of stopping a car at an intersection. Rules such as “If intersection is close and
speed is fast, apply brakes” might be used. The meaning (reflected in membership function shape and
position) of the labels “close” and “fast” will be different for a teenager than they are for a grandmother,
but both can accomplish the goal of stopping. It makes intuitive sense that the exact shape of a membership
function is much less important than the fact that it has gradual boundaries.
automates the central operations needed to process rule antecedents. The E stands for extended, so this
instruction compares 16-bit operands. The D at the end of the mnemonic stands for the D accumulator,
which is both the first operand for the comparison and the destination of the result. The 2,X+ is an indexed
addressing specification that says X points to the second operand for the comparison and it will be
post-incremented by 2 to point at the next rule antecedent.
When processing rule consequents, the operand in the accumulator must remain constant (in case there is
more than one consequent in the rule), and the result of the comparison must replace the referenced fuzzy
output in RAM. To do this, use the instruction
EMAXM 2,X+ ;process one rule consequent
The M at the end of the mnemonic indicates that the result will replace the referenced memory operand.
Again, indexed addressing is used. These two instructions would form the working part of a 16-bit
resolution fuzzy inference routine.
There are many other methods of performing inference, but none of these are as widely used as the
min-max method. Since the CPU12 Family is a general-purpose microcontroller family, the programmer
has complete freedom to program any algorithm desired. A custom programmed algorithm would typically
take more code space and execution time than a routine that used the built-in REV or REVW instructions.
The primary part of the WAV instruction is a multiply and accumulate operation to get the numerator for
the weighted average calculation. When working with operands as large as 16 bits, the EMACS instruction
could at least be used to automate the multiply and accumulate function. The CPU12 Family has extended
math capabilities, including the EMACS instruction which uses 16-bit input operands and accumulates the
sum to a 32-bit memory location and 32-bit by 16-bit divide instructions.
One benefit of the WAV instruction is that both a sum of products and a sum of weights are maintained,
while the fuzzy output operand is only accessed from memory once. Since memory access time is such a
significant part of execution time, this provides a speed advantage compared to conventional instructions.
The weighted average of singletons is the most commonly used technique in microcontrollers because it
is computationally less difficult than most other methods. The simplest method is called max
defuzzification, which simply uses the largest fuzzy output as the system result. However, this approach
does not take into account any other fuzzy outputs, even when they are almost as true as the chosen max
output. Max defuzzification is not a good general choice because it only works for a subset of fuzzy logic
applications.
The CPU12 Family is well suited for more computationally challenging algorithms than weighted average.
A 32-bit by 16-bit divide instruction takes 11 or 12 25-MHz cycles for unsigned or signed variations. A
16-bit by 16-bit multiply with a 32-bit result takes only three 25-MHz cycles. The EMACS instruction uses
16-bit operands and accumulates the result in a 32-bit memory location, taking only 12 25-MHz cycles per
iteration, including accessing all operands from memory and storing the result to memory.
15 X 0 Index Register X
15 Y 0 Index Register Y
15 SP 0 Stack Pointer
15 PC 0 Program Counter
CCRH CCRL
U 0 0 0 0 IPL[2:0] S X H I N Z V C Condition Code Register
Carry
These Four Overflow
Bits Always
Read 0 Zero
User Interrupt
State Priority Negative
Level
Mask (Disable) IRQ Interrupts
Half-Carry
(Used in BCD arithematic)
CPU12X only Mask (Disable) XIRQ Interrupts
RESET or XIRQ Set X,
CPU12XV2 only Instructions May Clear X
But Cannot Set X
Stop Disable (Ignore Stop Opcodes)
Reset Default is 1
YLO YLO
YHI YHI
XLO XLO
XHI XHI
A A
B B
SP After CCRL
CCRL
Interrupt SP After
Interrupt CCRH
Lower Addresses Lower Addresses
STACK UPON ENTRY TO SERVICE ROUTINE STACK UPON ENTRY TO SERVICE ROUTINE
IF SP WAS ODD BEFORE INTERRUPT IF SP WAS ODD BEFORE INTERRUPT
SP +8 RTNLO SP +9 SP +9 RTNLO SP +10
SP +6 YLO RTNHI SP +7 SP +7 YLO RTNHI SP +8
SP +4 XLO YHI SP +5 SP +5 XLO YHI SP +6
SP +2 A XHI SP +3 SP +3 A XHI SP +4
SP CCR B SP +1 SP +1 CCRL B SP +2
SP –2 SP –1 SP –1 CCRH SP
STACK UPON ENTRY TO SERVICE ROUTINE STACK UPON ENTRY TO SERVICE ROUTINE
IF SP WAS EVEN BEFORE INTERRUPT IF SP WAS EVEN BEFORE INTERRUPT
SP +9 SP +10 SP +10 SP +11
SP +7 RTNHI RTNLO SP +8 SP +8 RTNHI RTNLO SP +9
SP +5 YHI YLO SP +6 SP +6 YHI YLO SP +7
SP +4 XHI XLO SP +4 SP +4 XHI XLO SP +5
SP +1 B A SP +2 SP +2 B A SP +3
SP –1 CCR SP SP CCRH CCRL SP +1
Operators
—
Addition
+
– —
Subtraction
• —
Logical AND
| —
Logical OR (inclusive)
⊕ —
Logical exclusive OR
× —
Multiplication
÷ —
Division
M —
Negation. One’s complement (invert each bit of M)
: —
Concatenate
Example: A : B means the 16-bit value formed by concatenating 8-bit
accumulator A with 8-bit accumulator B.
A is in the high-order position.
— Transfer
Example: (A) M means the content of accumulator A is transferred to
memory location M.
⇔ — Exchange
Example: D ⇔ X means exchange the contents of D with those of X.
Machine Coding
dd — 8-bit direct address $0000 to $00FF. (High byte assumed to be $00).
ee — High-order byte of a 16-bit constant offset for indexed addressing.
eb — Exchange/Transfer post-byte. See Table A-5.
ff — Low-order eight bits of a 9-bit signed constant offset for indexed addressing,
or low-order byte of a 16-bit constant offset for indexed addressing.
hh — High-order byte of a 16-bit extended address.
ii — 8-bit immediate data value.
jj — High-order byte of a 16-bit immediate data value.
kk — Low-order byte of a 16-bit immediate data value.
lb — Loop primitive (DBNE) post-byte. See Table A-6.
ll — Low-order byte of a 16-bit extended address.
mm — 8-bit immediate mask value for bit manipulation instructions.
Set bits indicate bits to be affected.
pg — Program page (bank) number used in CALL instruction.
qq — High-order byte of a 16-bit relative offset for long branches.
tn — Trap number $30–$39 or $40–$FF.
rr — Signed relative offset $80 (–128) to $7F (+127).
Offset relative to the byte following the relative offset byte, or low-order byte
of a 16-bit relative offset for long branches.
xb — Indexed addressing post-byte. See Table A-3 and Table A-4.
Access Detail
Each code letter except (,), and comma equals one CPU cycle. Uppercase = 16-bit operation and
lowercase = 8-bit operation. For complex sequences refer to Chapter 5, “Instruction Set Overview”.
f — Free cycle, CPU doesn’t use bus
g — Read PPAGE internally
I — Read indirect pointer (indexed indirect)
i — Read indirect PPAGE value (CALL indirect only)
n — Write PPAGE internally
NA — Not available
O — Optional program word fetch (P) if instruction is misaligned and has an odd
number of bytes of object code — otherwise, appears as a free cycle (f); Page
2 prebyte treated as a separate 1-byte instruction
P — Program word fetch (always an aligned-word read)
r — 8-bit data read
R — 16-bit data read
16 by 16 Bit 32 Bit
Multiply and Accumulate (signed)
* The cycle timing of CPU12V1 has been improved by removing two free cycles compared to CPU12V0 : ORROfRRfWWP
EMAXD oprx0_xysp MAX((D), (M:M+1)) D IDX 18 1A xb ORPf –––– Δ Δ Δ Δ
EMAXD oprx9,xysp MAX of 2 Unsigned 16-Bit Values IDX1 18 1A xb ff ORPO
EMAXD oprx16,xysp IDX2 18 1A xb ee ff OfRPP
EMAXD [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1A xb OfIfRPf
EMAXD [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1A xb ee ff OfIPRPf
EMAXM oprx0_xysp MAX((D), (M:M+1)) M:M+1 IDX 18 1E xb ORPW –––– Δ Δ Δ Δ
EMAXM oprx9,xysp MAX of 2 Unsigned 16-Bit Values IDX1 18 1E xb ff ORPWO
EMAXM oprx16,xysp IDX2 18 1E xb ee ff OfRPWP
EMAXM [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1E xb OfIfRPW
EMAXM [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1E xb ee ff OfIPRPW
EMIND oprx0_xysp MIN((D), (M:M+1)) D IDX 18 1B xb ORPf –––– Δ Δ Δ Δ
EMIND oprx9,xysp MIN of 2 Unsigned 16-Bit Values IDX1 18 1B xb ff ORPO
EMIND oprx16,xysp IDX2 18 1B xb ee ff OfRPP
EMIND [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1B xb OfIfRPf
EMIND [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1B xb ee ff OfIPRPf
EMINM oprx0_xysp MIN((D), (M:M+1)) M:M+1 IDX 18 1F xb ORPW –––– Δ Δ Δ Δ
EMINM oprx9,xysp MIN of 2 Unsigned 16-Bit Values IDX1 18 1F xb ff ORPWO
EMINM oprx16,xysp IDX2 18 1F xb ee ff OfRPWP
EMINM [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1F xb OfIfRPW
EMINM [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1F xb ee ff OfIPRPW
EMUL (D) × (Y) Y:D INH 13 O ff0 –––– ΔΔ–Δ
16 by 16 Bit Multiply (unsigned)
EMULS (D) × (Y) Y:D INH 18 13 OfO OffO –––– ΔΔ–D
16 by 16 Bit Multiply (signed)
EORA #opr8i (A) ⊕ (M) A IMM 88 ii P –––– ΔΔ0–
EORA opr8a Exclusive-OR A with Memory DIR 98 dd rPf
EORA opr16a EXT B8 hh ll rPO
EORA oprx0_xysp IDX A8 xb rPf
EORA oprx9,xysp IDX1 A8 xb ff rPO
EORA oprx16,xysp IDX2 A8 xb ee ff frPP
EORA [D,xysp] [D,IDX] A8 xb fIfrPf
EORA [oprx16,xysp] [IDX2] A8 xb ee ff fIPrPf
EORB #opr8i (B) ⊕ (M) B IMM C8 ii P –––– ΔΔ0–
EORB opr8a Exclusive-OR B with Memory DIR D8 dd rPf
EORB opr16a EXT F8 hh ll rPO
EORB oprx0_xysp IDX E8 xb rPf
EORB oprx9,xysp IDX1 E8 xb ff rPO
EORB oprx16,xysp IDX2 E8 xb ee ff frPP
EORB [D,xysp] [D,IDX] E8 xb fIfrPf
EORB [oprx16,xysp] [IDX2] E8 xb ee ff fIPrPf
r1 and r2 may be
A, B, CCR, D, X, Y, or SP
FDIV (D) ÷ (X) X; Remainder fi D INH 18 11 OffffffffffO –––– –ΔΔΔ
16 by 16 Bit Fractional Divide
GLDAA opr8a G(M) A DIR 18 96 dd OrPf NA –––– ΔΔ0–
GLDAA opr16a Load Accumulator A from Global Memory EXT 18 B6 hh ll OrPO NA
GLDAA oprx0_xysp IDX 18 A6 xb OrPf NA
GLDAA oprx9,xysp IDX1 18 A6 xb ff OrPO NA
GLDAA oprx16,xysp IDX2 18 A6 xb ee ff OfrPP NA
GLDAA [D,xysp] [D,IDX] 18 A6 xb OfIfrPf NA
GLDAA [oprx16,xysp] [IDX2] 18 A6 xb ee ff OfIPrPf NA
GLDAB opr8a G(M) B DIR 18 D6 dd OrPf NA –––– ΔΔ0–
GLDAB opr16a Load Accumulator B from Global Memory EXT 18 F6 hh ll OrPO NA
GLDAB oprx0_xysp IDX 18 E6 xb OrPf NA
GLDAB oprx9,xysp IDX1 18 E6 xb ff OrPO NA
GLDAB oprx16,xysp IDX2 18 E6 xb ee ff OfrPP NA
GLDAB [D,xysp] [D,IDX] 18 E6 xb OfIfrPf NA
GLDAB [oprx16,xysp] [IDX2] 18 E6 xb ee ff OfIPrPf NA
GLDD opr8a G(M:M+1) A:B DIR 18 DC dd ORPf NA –––– ΔΔ0–
GLDD opr16a Load Double Accumulator D (A:B) from EXT 18 FC hh ll ORPO NA
GLDD oprx0_xysp Global Memory IDX 18 EC xb ORPf NA
GLDD oprx9,xysp IDX1 18 EC xb ff ORPO NA
GLDD oprx16,xysp IDX2 18 EC xb ee ff OfRPP NA
GLDD [D,xysp] [D,IDX] 18 EC xb OfIfRPf NA
GLDD [oprx16,xysp] [IDX2] 18 EC xb ee ff OfIPRPf NA
GLDS opr8a G(M:M+1) SP DIR 18 DF dd ORPf NA –––– ΔΔ0–
GLDS opr16a Load Stack Pointer from Global Memory EXT 18 FF hh ll ORPO NA
GLDS oprx0_xysp IDX 18 EF xb ORPf NA
GLDS oprx9,xysp IDX1 18 EF xb ff ORPO NA
GLDS oprx16,xysp IDX2 18 EF xb ee ff OfRPP NA
GLDS [D,xysp] [D,IDX] 18 EF xb OfIfRPf NA
GLDS [oprx16,xysp] [IDX2] 18 EF xb ee ff OfIPRPf NA
GLDX opr8a G(M:M+1) X DIR 18 DE dd ORPf NA –––– ΔΔ0–
GLDX opr16a Load Index Register X from Global Memory EXT 18 FE hh ll ORPO NA
GLDX oprx0_xysp IDX 18 EE xb ORPf NA
GLDX oprx9,xysp IDX1 18 EE xb ff ORPO NA
GLDX oprx16,xysp IDX2 18 EE xb ee ff OfRPP NA
GLDX [D,xysp] [D,IDX] 18 EE xb OfIfRPf NA
GLDX [oprx16,xysp] [IDX2] 18 EE xb ee ff OfIPRPf NA
Si Fi fi Y:D and Fi fi X
(add if interrupt)
SSS + UUUrr,
i=1 i=1
Calculate Sum of Products and Sum of Weights for
Weighted Average Calculation
NXP Semiconductors
INY MUL BHI PULA INCA INCB INC INC SBCA SBCA SBCA SBCA SBCB SBCB SBCB SBCB
IH 1 IH 1 RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3
03 1 13 §1 23 3/1 33 3 43 1 53 1 63 3-6 73 4 83 2 93 3 A3 3-6 B3 3 C3 2 D3 3 E3 3-6 F3 3
DEY EMUL BLS PULB DECA DECB DEC DEC SUBD SUBD SUBD SUBD ADDD ADDD ADDD ADDD
IH 1 IH 1 RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IM 3 DI 2 ID 2-4 EX 3 IM 3 DI 2 ID 2-4 EX 3
04 3 14 1 24 3/1 34 2 44 1 54 1 64 3-6 74 4 84 1 94 3 A4 3-6 B4 3 C4 1 D4 3 E4 3-6 F4 3
*
loop ORCC BCC PSHX LSRA LSRB LSR LSR ANDA ANDA ANDA ANDA ANDB ANDB ANDB ANDB
RL 3 IM 2 RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3
05 3-6 15 4-7 25 3/1 35 2 45 1 55 1 65 3-6 75 4 85 1 95 3 A5 3-6 B5 3 C5 1 D5 3 E5 3-6 F5 3
JMP JSR BCS PSHY ROLA ROLB ROL ROL BITA BITA BITA BITA BITB BITB BITB BITB
ID 2-4 ID 2-4 RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3
06 3 16 4 26 3/1 36 2 46 1 56 1 66 3-6 76 4 86 1 96 3 A6 3-6 B6 3 C6 1 D6 3 E6 3-6 F6 3
JMP JSR BNE PSHA RORA RORB ROR ROR LDAA LDAA LDAA LDAA LDAB LDAB LDAB LDAB
EX 3 EX 3 RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3
07 4 17 4 27 3/1 37 2 47 1 57 1 67 3-6 77 4 87 1 97 1 A7 1 B7 1 C7 1 D7 1 E7 3-6 F7 3
BSR JSR BEQ PSHB ASRA ASRB ASR ASR CLRA TSTA NOP TFR/EXG CLRB TSTB TST TST
RL 2 DI 2 RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IH 1 IH 1 IH 1 IH 2 IH 1 IH 1 ID 2-4 EX 3
08 1 18 - 28 3/1 38 3 48 1 58 1 68 3-6 78 4 88 1 98 3 A8 3-6 B8 3 C8 1 D8 3 E8 3-6 F8 3
INX Page 2 BVC PULC ASLA ASLB ASL ASL EORA EORA EORA EORA EORB EORB EORB EORB
IH 1 - - RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3
09 1 19 2 29 3/1 39 2 49 1 59 1 69 2-4 79 3 89 1 99 3 A9 3-6 B9 3 C9 1 D9 3 E9 3-6 F9 3
DEX LEAY BVS PSHC LSRD ASLD CLR CLR ADCA ADCA ADCA ADCA ADCB ADCB ADCB ADCB
IH 1 ID 2-4 RL 2 IH 1 IH 1 IH 1 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3
0A 7 1A 2 2A 3/1 3A 3 4A 7 5A 2 6A 2-4 7A 3 8A 1 9A 3 AA 3-6 BA 3 CA 1 DA 3 EA 3-6 FA 3
RTC LEAX BPL PULD CALL STAA STAA STAA ORAA ORAA ORAA ORAA ORAB ORAB ORAB ORAB
IH 1 ID 2-4 RL 2 IH 1 EX 4 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3 IM 2 DI 2 ID 2-4 EX 3
0B †8 1B 2 2B 3/1 3B 2 4B 7-10 5B 2 6B 2-4 7B 3 8B 1 9B 3 AB 3-6 BB 3 CB 1 DB 3 EB 3-6 FB 3
RTI LEAS BMI PSHD CALL STAB STAB STAB ADDA ADDA ADDA ADDA ADDB ADDB ADDB ADDB
453
Notation Used in Instruction Set Summary
454
Table A-2. Opcode Map (Sheet 2 of 3) — CPU12 Page 2 Opcodes
00 4 10 12 20 4 30 10 40 10 50 10 60 10 70 10 80 10 90 10 A0 10 B0 10 C0 10 D0 10 E0 10 F0 10
MOVW IDIV LBRA TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IM-ID 5 IH 2 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
01 5 11 12 21 3 31 10 41 10 51 10 61 10 71 10 81 10 91 10 A1 10 B1 10 C1 10 D1 10 E1 10 F1 10
MOVW FDIV LBRN TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
EX-ID 5 IH 2 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
02 5 12 13 22 4/3 32 10 42 10 52 10 62 10 72 10 82 10 92 10 A2 10 B2 10 C2 10 D2 10 E2 10 F2 10
MOVW EMACS LBHI TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
ID-ID 4 SP 4 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
03 5 13 3 23 4/3 33 10 43 10 53 10 63 10 73 10 83 10 93 10 A3 10 B3 10 C3 10 D3 10 E3 10 F3 10
MOVW EMULS LBLS TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IM-EX 6 IH 2 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
04 6 14 12 24 4/3 34 10 44 10 54 10 64 10 74 10 84 10 94 10 A4 10 B4 10 C4 10 D4 10 E4 10 F4 10
MOVW EDIVS LBCC TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
EX-EX 6 IH 2 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
05 5 15 12 25 4/3 35 10 45 10 55 10 65 10 75 10 85 10 95 10 A5 10 B5 10 C5 10 D5 10 E5 10 F5 10
MOVW IDIVS LBCS TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
ID-EX 5 IH 2 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
06 2 16 2 26 4/3 36 10 46 10 56 10 66 10 76 10 86 10 96 10 A6 10 B6 10 C6 10 D6 10 E6 10 F6 10
ABA SBA LBNE TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IH 2 IH 2 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
07 3 17 2 27 4/3 37 10 47 10 57 10 67 10 77 10 87 10 97 10 A7 10 B7 10 C7 10 D7 10 E7 10 F7 10
DAA CBA LBEQ TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IH 2 IH 2 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
08 5 18 4-7 28 4/3 38 10 48 10 58 10 68 10 78 10 88 10 98 10 A8 10 B8 10 C8 10 D8 10 E8 10 F8 10
MOVB MAXA LBVC TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IM-ID 4 ID 3-5 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
09 5 19 4-7 29 4/3 39 10 49 10 59 10 69 10 79 10 89 10 99 10 A9 10 B9 10 C9 10 D9 10 E9 10 F9 10
MOVB MINA LBVS TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
EX-ID 5 ID 3-5 RL 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
0A 5 1A 4-7 2A 4/3 3A †3n 4A 10 5A 10 6A 10 7A 10 8A 10 9A 10 AA 10 BA 10 CA 10 DA 10 EA 10 FA 10
MOVB EMAXD LBPL REV TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
ID-ID 4 ID 3-5 RL 4 SP 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
0B 4 1B 4-7 2B 4/3 3B †5n/3n 4B 10 5B 10 6B 10 7B 10 8B 10 9B 10 AB 10 BB 10 CB 10 DB 10 EB 10 FB 10
* The opcode $04 (on sheet 1 of 3) corresponds to one of the loop primitive instructions DBEQ, DBNE, IBEQ, IBNE, TBEQ, or TBNE.
† Refer to instruction summary for more information.
Page 2 When the CPU12 encounters a page 2 opcode ($18 on page 1 of the opcode map), it treats the next byte of object code as a page 2 instruction opcode.
NXP Semiconductors
Table A-2. Opcode Map (Sheet 3 of 3) — CPU12X Page 2 Opcodes
00 4-6 10 12 20 4 30 10 40 2 50 2 60 4-7 70 5 80 3 90 4 A0 4-7 B0 4 C0 3 D0 4 E0 4-7 F0 4
MOVW IDIV LBRA TRAP NEGX NEGY NEGW NEGW SUBX SUBX SUBX SUBX SUBY SUBY SUBY SUBY
IM-ID 5 IH 2 RL 4 IH 2 IH 2 IH 2 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
01 5-7 11 12 21 3 31 10 41 2 51 2 61 4-7 71 5 81 10 91 10 A1 10 B1 10 C1 10 D1 10 E1 10 F1 10
MOVW FDIV LBRN TRAP COMX COMY COMW COMW TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
EX-ID 5 IH 2 RL 4 IH 2 IH 2 IH 2 ID 3-5 EX 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
NXP Semiconductors
02 5-10 12 9 22 4/3 32 10 42 2 52 2 62 4-7 72 5 82 3 92 4 A2 4-7 B2 4 C2 3 D2 4 E2 4-7 F2 4
MOVW EMACS LBHI TRAP INCX INCY INCW INCW SBEX SBEX SBEX SBEX SBEY SBEY SBEY SBEY
ID-ID 4 SP 4 RL 4 IH 2 IH 2 IH 2 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
03 5 13 3 23 4/3 33 10 43 2 53 2 63 4-7 73 5 83 3 93 4 A3 4-7 B3 4 C3 3 D3 4 E3 4-7 F3 4
MOVW EMULS LBLS TRAP DECX DECY DECW DECW SBED SBED SBED SBED ADED ADED ADED ADED
IM-EX 6 IH 2 RL 4 IH 2 IH 2 IH 2 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
04 6 14 12 24 4/3 34 10 44 2 54 2 64 4-7 74 5 84 3 94 4 A4 4-7 B4 3 C4 3 D4 4 E4 4-7 F4 3
MOVW EDIVS LBCC TRAP LSRX LSRY LSRW LSRW ANDX ANDX ANDX ANDX ANDY ANDY ANDY ANDY
EX-EX 6 IH 2 RL 4 IH 2 IH 2 IH 2 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
05 5-8 15 12 25 4/3 35 5 45 2 55 2 65 4-7 75 5 85 3 95 4 A5 4-7 B5 3 C5 3 D5 4 E5 4-7 F5 3
MOVW IDIVS LBCS BTAS ROLX ROLY ROLW ROLW BITX BITX BITX BITX BITY BITY BITY BITY
ID-EX 5 IH 2 RL 4 DI 4 IH 2 IH 2 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
06 2 16 2 26 4/3 36 6 46 2 56 2 66 4-7 76 5 86 10 96 4 A6 4-7 B6 4 C6 10 D6 4 E6 4-7 F6 4
ABA SBA LBNE BTAS RORX RORY RORW RORW TRAP GLDAA GLDAA GLDAA TRAP GLDAB GLDAB GLDAB
IH 2 IH 2 RL 4 EX 5 IH 2 IH 2 ID 3-5 EX 4 IH 2 DI 3 ID 3-5 EX 4 IH 2 DI 3 ID 3-5 EX 4
07 3 17 2 27 4/3 37 5-7 47 2 57 2 67 4-7 77 5 87 2 97 2 A7 10 B7 10 C7 2 D7 2 E7 4-7 F7 4
DAA CBA LBEQ BTAS ASRX ASRY ASRW ASRW CLRX TSTX SYSTRAP TRAP CLRY TSTY TSTW TSTW
IH 2 IH 2 RL 4 ID 4-6 IH 2 IH 2 ID 3-5 EX 4 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 ID 3-5 EX 4
08 4-6 18 4-7 28 4/3 38 4 48 2 58 2 68 4-7 78 5 88 3 98 4 A8 4-7 B8 3 C8 3 D8 4 E8 4-7 F8 3
MOVB MAXA LBVC PULCW ASLX ASLY ASLW ASLW EORX EORX EORX EORX EORY EORY EORY EORY
IM-ID 4 ID 3-5 RL 4 IH 2 IH 2 IH 2 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
09 5-7 19 4-7 29 4/3 39 3 49 10 59 10 69 4-7 79 5 89 3 99 4 A9 4-7 B9 4 C9 3 D9 4 E9 4-7 F9 4
MOVB MINA LBVS PSHCW TRAP TRAP CLRW CLRW ADEX ADEX ADEX ADEX ADEY ADEY ADEY ADEY
EX-ID 5 ID 3-5 RL 4 IH 2 IH 2 IH 2 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
0A 5-10 1A 4-7 2A 4/3 3A †3n 4A 10 5A 3 6A 3-5 7A 4 8A 3 9A 4 AA 4-7 BA 3 CA 3 DA 4 EA 4-7 FA 3
MOVB EMAXD LBPL REV TRAP GSTAA GSTAA GSTAA ORX ORX ORX ORX ORY ORY ORY ORY
ID-ID 4 ID 3-5 RL 4 SP 2 IH 2 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4 IM 4 DI 3 ID 3-5 EX 4
0B 4 1B 4-7 2B 4/3 3B †5n/3n 4B 10 5B 3 6B 3-5 7B 4 8B 3 9B 4 AB 4-7 BB 4 CB 3 DB 4 EB 4-7 FB 4
455
Notation Used in Instruction Set Summary
Table A-3. Indexed Addressing Mode Postbyte Encoding (xb)
456
00 10 20 30 40 50 60 70 80 90 A0 B0 C0 D0 E0 F0
0,X –16,X 1,+X 1,X+ 0,Y –16,Y 1,+Y 1,Y+ 0,SP –16,SP 1,+SP 1,SP+ 0,PC –16,PC n,X n,SP
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const 9b const 9b const
01 11 21 31 41 51 61 71 81 91 A1 B1 C1 D1 E1 F1
1,X –15,X 2,+X 2,X+ 1,Y –15,Y 2,+Y 2,Y+ 1,SP –15,SP 2,+SP 2,SP+ 1,PC –15,PC –n,X –n,SP
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const 9b const 9b const
02 12 22 32 42 52 62 72 82 92 A2 B2 C2 D2 E2 F2
2,X –14,X 3,+X 3,X+ 2,Y –14,Y 3,+Y 3,Y+ 2,SP –14,SP 3,+SP 3,SP+ 2,PC –14,PC n,X n,SP
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const 16b const 16b const
03 13 23 33 43 53 63 73 83 93 A3 B3 C3 D3 E3 F3
3,X –13,X 4,+X 4,X+ 3,Y –13,Y 4,+Y 4,Y+ 3,SP –13,SP 4,+SP 4,SP+ 3,PC –13,PC [n,X] [n,SP]
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const 16b indr 16b indr
04 14 24 34 44 54 64 74 84 94 A4 B4 C4 D4 E4 F4
4,X –12,X 5,+X 5,X+ 4,Y –12,Y 5,+Y 5,Y+ 4,SP –12,SP 5,+SP 5,SP+ 4,PC –12,PC A,X A,SP
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const A offset A offset
05 15 25 35 45 55 65 75 85 95 A5 B5 C5 D5 E5 F5
5,X –11,X 6,+X 6,X+ 5,Y –11,Y 6,+Y 6,Y+ 5,SP –11,SP 6,+SP 6,SP+ 5,PC –11,PC B,X B,SP
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const B offset B offset
06 16 26 36 46 56 66 76 86 96 A6 B6 C6 D6 E6 F6
6,X –10,X 7,+X 7,X+ 6,Y –10,Y 7,+Y 7,Y+ 6,SP –10,SP 7,+SP 7,SP+ 6,PC –10,PC D,X D,SP
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const D offset D offset
07 17 27 37 47 57 67 77 87 97 A7 B7 C7 D7 E7 F7
7,X –9,X 8,+X 8,X+ 7,Y –9,Y 8,+Y 8,Y+ 7,SP –9,SP 8,+SP 8,SP+ 7,PC –9,PC [D,X] [D,SP]
5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const pre-inc post-inc 5b const 5b const D indirect D indirect
08 18 28 38 48 58 68 78 88 98 A8 B8 C8 D8 E8 F8
8,X –8,X 8,–X 8,X– 8,Y –8,Y 8,–Y 8,Y– 8,SP –8,SP 8,–SP 8,SP– 8,PC –8,PC n,Y n,PC
5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const 9b const 9b const
09 19 29 39 49 59 69 79 89 99 A9 B9 C9 D9 E9 F9
9,X –7,X 7,–X 7,X– 9,Y –7,Y 7,–Y 7,Y– 9,SP –7,SP 7,–SP 7,SP– 9,PC –7,PC –n,Y –n,PC
5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const 9b const 9b const
0A 1A 2A 3A 4A 5A 6A 7A 8A 9A AA BA CA DA EA FA
10,X –6,X 6,–X 6,X– 10,Y –6,Y 6,–Y 6,Y– 10,SP –6,SP 6,–SP 6,SP– 10,PC –6,PC n,Y n,PC
5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const 16b const 16b const
0B 1B 2B 3B 4B 5B 6B 7B 8B 9B AB BB CB DB EB FB
11,X –5,X 5,–X 5,X– 11,Y –5,Y 5,–Y 5,Y– 11,SP –5,SP 5,–SP 5,SP– 11,PC –5,PC [n,Y] [n,PC]
5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const pre-dec post-dec 5b const 5b const 16b indr 16b indr
0C 1C 2C 3C 4C 5C 6C 7C 8C 9C AC BC CC DC EC FC
12,X –4,X 4,–X 4,X– 12,Y –4,Y 4,–Y 4,Y– 12,SP –4,SP 4,–SP 4,SP– 12,PC –4,PC A,Y A,PC
NXP Semiconductors
Instruction Reference
Postbyte Operand
Comments
Code (xb) Syntax
rr0nnnnn ,r 5-bit constant offset
n,r n = –16 to +15
–n,r rr can specify X, Y, SP, or PC
111rr0zs n,r Constant offset (9- or 16-bit signed)
–n,r z- 0 = 9-bit with sign in LSB of postbyte (s)
1 = 16-bit
if z = s = 1, 16-bit offset indexed-indirect (see below)
rr can specify X, Y, SP, or PC
rr1pnnnn n,–r Auto predecrement, preincrement, postdecrement, or postincrement;
n,+r p = pre-(0) or post-(1), n = –8 to –1, +1 to +8
n,r– rr can specify X, Y, or SP (PC not a valid choice)
n,r+
111rr1aa A,r Accumulator offset (unsigned 8-bit or 16-bit)
B,r aa -00 = A
D,r 01 = B
10 = D (16-bit)
11 = see accumulator D offset indexed-indirect
rr can specify X, Y, SP, or PC
111rr011 [n,r] 16-bit offset indexed-indirect
rr can specify X, Y, SP, or PC
111rr111 [D,r] Accumulator D offset indexed-indirect
rr can specify X, Y, SP, or PC
TRANSFERS
MS
0 1 2 3 4 5 6 7
LS A B CCR TMPx D X Y SP
AA BA CCRL A TMP3L A BA XL A YL A SPL A
0 A TFR A,A TFR B,A TFR CCR,A TFR TMP3,A TFR D,A TFR X, A TFR Y,A TFR SP,A
TFR CCRL,A TFR TMP3L,A TFR XL,A TFR YL,A TFR SPL,A
A CCR B CCR CCRL CCRL TMP3L CCR B CCR XL CCR YL CCR SPL CCR
2 CCR TFR A,CCR TFR B,CCR TFR CCR,CCR TFR TMP3,CCR TFR D,CCR TFR X,CCR TFR Y,CCR TFR SP,CCR
TFR A,CCRL TFR B,CCRL TFR CCRL,CCRL TFR TMP3L,CCRL TFR D,CCRL TFR XL,CCRL TFR YL,CCRL TFR SPL,CCRL
TMP sex:A TMP2 sex:B TMP2 sex:CCRL TMP2 TMP3 TMP2 D TMP2 X TMP2 Y TMP2 SP TMP2
3 SEX A,TMP2 SEX B,TMP2 SEX CCR,TMP2 TFR TMP3,TMP2 TFR D,TMP2 TFR X,TMP2 TFR Y,TMP2 TFR SP,TMP2
2 SEX CCRL,TMP2
A CCRH B CCRL CCRW CCRW TMP3 CCRH:L D CCRH:L X CCRH:L Y CCRH:L SP CCRH:L
A CCR TFR A,CCRH TFR B,CCRL TFR CCRW,CCRW TFR TMP3,CCRW TFR D,CCRW TFR X,CCRW TFR Y,CCRW TFR SP,CCRW
TMP A TMP2H B TMP2L CCRH:L TMP2 TMP3 TMP2 D TMP1 X TMP2 Y TMP2 SP TMP2
B TFR A,TMP2H TFR B,TMP2L TFR CCRW,TMP2 TFR TMP3,TMP2 TFR D,TMP1 TFR X,TMP2 TFR Y,TMP2 TFR SP,TMP2
x
sex:A D sex:B D CCRH:L D TMP1 D DD XD YD SP D
C D SEX A,D SEX B,D TFR CCRW,D TFR TMP1,D TFR D,D TFR X,D TFR Y,D TFR SP,D
Note: Encodings in the shaded area (LS = 8–F) are only available on the CPU12X.
EXCHANGES
MS 8 9 A B C D E F
LS A B CCR TMPx D X Y SP
A⇔A B⇔A CCRL⇔ A TMP3L A B⇔A XL A YL A SPL A
0 A EXG CCR,A $00:A TMP3 EXG D,A $00:A X $00:A Y $00:A SP
EXG A,A EXG B,A EXG CCRL,A EXG A, TMP3 EXG X,A EXG Y,A EXG SP,A
A ⇔ CCRL B ⇔ CCRL CCRL ⇔ CCRL TMP3L CCRL B CCRL XL CCRL YL CCRL SPL CCRL
$FF:CCRL TMP3 $FF:CCRL D $FF:CCRL X $FF:CCRL Y $FF:CCRL SP
2 CCR EXG A, CCR EXG B,CCR EXG CCR,CCR EXG, TMP3,CCR EXG D,CCR EXG X,CCR EXG Y,CCR EXG SP,CCR
EXG A,CCRL EXG B,CCRL EXG CCRL,CCRL EXG TMP3,CCRL EXG D,CCRL EXG X,CCRL EXG Y,CCRL EXG SP,CCRL
TMP $00:A TMP2 $00:B TMP2 $00:CCRL TMP2 TMP3 ⇔ TMP2 D ⇔ TMP2 X ⇔ TMP2 Y ⇔ TMP2 SP ⇔ TMP2
3 TMP2L A TMP2L B TMP2L CCR EXG TMP3,TMP2 EXG D,TMP2 EXG X,TMP2 EXG Y,TMP2 EXG SP,TMP2
2 EXG A,TMP2 EXG B,TMP2 EXG CCR,TMP2
A ⇔ CCRH B ⇔ CCRL CCRH:L ⇔ CCRH:L TMP3 ⇔ CCRH:L D ⇔ CCRH:L X ⇔ CCRH:L Y ⇔ CCRH:L SP ⇔ CCRH:L
A CCR EXG A,CCRH EXG B,CCRL EXG CCRW,CCRW EXG TMP3,CCRW EXG D,CCRW EXG X,CCRW EXG Y,CCRW EXG, SP,CCRW
TMP A ⇔ TMP2H B ⇔ TMP2L CCRH:L⇔ TMP2 TMP3 ⇔ TMP2 D ⇔ TMP1 X ⇔ TMP2 Y ⇔ TMP2 SP ⇔ TMP2
B EXG A,TMP2H EXG B,TMP2L EXG CCRW,TMP2 EXG TMP3,TMP2 EXG D,TMP1 EXG X,TMP2 EXG Y,TMP2 EXG SP,TMP2
x
$00:A D $00:B D CCRH:L ⇔ D TMP1 ⇔ D D⇔D X⇔D Y⇔D SP ⇔ D
C D EXG A,D EXG B,D EXG CCRW,D EXG TMP1,D EXG D,D EXG X,D EXG Y,D EXG SP,D
Note: Encodings in the shaded area (LS = 8–F) are only available on the CPU12X.
03 13 23 33 43 53 63 73 83 93 A3 B3
— — — — — — — — — — — —
04 D 14 D 24 D 34 D 44 D 54 D 64 D 74 D 84 D 94 D A4 D B4 D
DBEQ DBEQ DBNE DBNE TBEQ TBEQ TBNE TBNE IBEQ IBEQ IBNE IBNE
(+) (–) (+) (–) (+) (–) (+) (–) (+) (–) (+) (–)
05 X 15 X 25 X 35 X 45 X 55 X 65 X 75 X 85 X 95 X A5 X B5 X
DBEQ DBEQ DBNE DBNE TBEQ TBEQ TBNE TBNE IBEQ IBEQ IBNE IBNE
(+) (–) (+) (–) (+) (–) (+) (–) (+) (–) (+) (–)
06 Y 16 Y 26 Y 36 Y 46 Y 56 Y 66 Y 76 Y 86 Y 96 Y A6 Y B6 Y
DBEQ DBEQ DBNE DBNE TBEQ TBEQ TBNE TBNE IBEQ IBEQ IBNE IBNE
(+) (–) (+) (–) (+) (–) (+) (–) (+) (–) (+) (–)
07 SP 17 SP 27 SP 37 SP 47 SP 57 SP 67 SP 77 SP 87 SP 97 SP A7 SP B7 SP
DBEQ DBEQ DBNE DBNE TBEQ TBEQ TBNE TBNE IBEQ IBEQ IBNE IBNE
(+) (–) (+) (–) (+) (–) (+) (–) (+) (–) (+) (–)
15 12 11 8 7 4 3 0
4th Hex Digit 3rd Hex Digit 2nd Hex Digit 1st Hex Digit
CPU12V0 CPU12V1
Instruction Acess Detail Acess Detail
Class 1 improves the data manipulation capabilities of the CPU12X by allowing direct operation on larger
data sizes. On the CPU12, most arithmetic and logical operations, such as addition, can only take place by
using the A, B or D accumulators. The CPU12X extends this capability to the X and Y registers and adds
new instructions for the D register. All arithmetic and logical functions using the A or B accumulator will
now have a 16-bit counterpart using the X and Y register. New instructions of this type are: ADE (add with
carry), ADD (add without carry), SBE (subtract with carry), DEC (decrement) and INC (increment), SUB
(subtract without carry), AND (logical AND), BIT (logical bit test), OR (logical OR), EOR (logical
EXCLUSIVE OR), NEG (two’s complement), COM (one’s complement), CLR (clear register), TST (test
register), LSL (logical shift left), ROL (rotate left), ASR (arithmetic shift right), LSR (logical shift right),
and ROR (rotate right). The same addressing modes as for their counterparts with the A, B accumulator
are available.
To improve the 32-bit capability of the D-Accumulator, ADED (add with carry) and SBED (subtract with
carry) are added. In addition, the CPU12X provides a set of compare instructions carrying forward the
carry and also the zero flag (CPED, CPEX, CPEY, CPES). This improves the capability to perform 32-bit
compares.
While the existing architecture allows 8-bit read-modify-write instructions, the CPU12X extends this
capability to 16-bit words and provides NEGW (two’s complement), COMW (one’s complement), DECW
(decrement 16-bit), INCW (increment 16-bit), RORW (rotate right), LSRW (logical shift right), ARSW
(arithmetic shift right), ROLW (rotate left), LSLW (logical shift left), CLRW (clear memory) and TSTW
(test memory). Addressing modes are the same as for their 8-bit counterparts. In general, these new 16-bit
operations allow significantly faster manipulation of data compared to the CPU12.
Class 2 provides access to a new mode available on the S12X Memory Management Controller (Refer to
S12XMMC BlockGuide). This allows access to any 64K byte page in global memory based on a new
MCU register in the core block (GPAGE). The new instructions include all the available addressing modes
and concatenate the GPAGE register with the 16-bit address data. Global instructions are available for the
following instructions: LDAA (load accumulator A), LDAB (load accumulator B), LDD (load
accumulator D), LDX (load X register), LDY (load Y register), LDS (load stack pointer), STAA (store
accumulator A), STAB (store accumulator B), STD (store accumulator D), STX (store X register), STY
(store Y register), and STS (store stack pointer).
The GPAGE register is seven bits wide, so that global memory runs from $00_0000 to $7F_FFFF, and each
location is accessible with a single instruction from anywhere in a program (once the GPAGE register is
configured for that 64K byte page).
NOTE
Users developing code on the CPU12 for later use on the CPU12X should
carefully note areas of opportunity/requirement to use this feature and
modify their code, and their compiler and linker settings, once using the
CPU12X.
Class 3 allows more efficient use of semaphores, which are important for real time operating systems
(RTOS) and for sharing resources between the CPU and the XGATE. The new instruction is BTAS (bit test
and set). Since this is a single instruction, it cannot be interrupted; therefore, it is useful when requesting
access to resources.
Resources are usually locked via a status bit in RAM when the bit is set the resource is in use. On the
CPU12, users must take care that two tasks cannot both appear to have allocated the resource. This can
occur if one task interrupts another immediately after a bit test instruction. Therefore, tasks typically
disable interrupts while checking and allocating resources. The BTAS instruction removes this need, as it
tests and sets the resource bit in a single instruction step. BTAS follows the same syntax and allows the
same addressing modes as the BSET instruction, except that the test is based on the original data and not
on the data written back. A typical use for a BTAS instruction is shown below :
BTAS $1020, #$20
BNE ResourceNotAvailable
<ResourceLocked>
Class 4 is designed to improve the opportunity for compilers to use the memory-to-memory move
instructions by allowing the use of all relevant CPU12X addressing modes, and not only those fitting in a
single postbyte xb.
CPU12 CPU12X
Instruction Acess Detail Access Detail
EMUL ffO O
EMULS OffO OfO
EMACS ORROfffRRfWWP ORRORRWWP
ETBL ORRffffffP ORRffffP
RTI uUUUUPPP UUUUUPPP
STOP OOSSSSsf OOSSSSSf
SWI VSPSSPSsP VSPSSPSSP
WAI OSSSSsf OSSSSSf
LEA oprx0_xysp Pf P
MOVB (EXT,IDX) (EXT,IDX,IDX1,IDX2, [D,IDX], [IDX2])
MOVW (EXT,IDX) (EXT,IDX,IDX1,IDX2, [D,IDX], [IDX2])
D.5 Performance
Performance of the CPU12XV2 is identical to the CPU12XV0.
E.5 Performance
Performance of the CPU12XV1 is identical to the CPU12XV0.
The (de)allocation can even be combined with a register push or pull as in this example:
LDX 8,S+ ;Load return value and deallocate
X is loaded with the 16-bit integer value at the top of the stack, and the stack pointer is adjusted up by eight
to deallocate space for eight bytes worth of temporary storage. Post-increment indexed addressing is
used in this example, but all four combinations of pre/post increment/decrement are available (offsets from
–8 to +8 inclusive, from X, Y, or SP). This form of indexing can often be used to get an index (or stack
pointer) adjustment for free during an indexed operation (the instruction requires no more code space or
cycles than a zero-offset indexed instruction).
The concept of a frame pointer is supported in the CPU12 Family through a combination of improved
indexed addressing, universal transfer/exchange, and the LEA instruction. These instructions work
together to achieve more efficient handling of frame pointers. It is important to consider the complete
instruction set as a complex system with subtle interrelationships rather than simply examining individual
instructions when trying to improve an instruction set. Adding or removing a single instruction can have
unexpected consequences.
byte relative offset that allows branching to a destination within about ±128 locations from the branch.
Long branches use a 16-bit relative offset that allows conditional branching to any location in the 64KB
map.
F.11 Pointers
The CPU12 Family supports pointers by allowing direct arithmetic operations on the 16-bit index registers
(LEAS, LEAX, and LEAY instructions) and by allowing indexed indirect addressing modes.
completely orthogonal instruction set would allow any instruction to operate in any addressing mode,
would have identical code sizes and execution times for similar operations on different registers, and
would include both signed and unsigned versions of all mathematical instructions. Greater regularity of
the instruction set makes it possible to implement compilers more efficiently, because operation is more
consistent, and fewer special cases must be handled.
A
ABA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Abbreviations for system resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
ABX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
ABY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Access details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80–83, 431
Accumulator offset indexed addressing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Accumulator offset indexed indirect addressing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Accumulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 37
B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 37
D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 37
ADCA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
ADCB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
ADCD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
ADCX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
ADCY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
ADDA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
ADDB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
ADDD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Addition instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
ADDR mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Extended . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Indexed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26, 37
Inherent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
ADDX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
ADDY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
ANDA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
ANDB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
ANDCC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
ANDX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
ANDY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Arithmetic shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109, 112, 113, 114
ASL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
ASLA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
ASLB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
B
Background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74, 120
Base index register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38–42
BCC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
BCD instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56, 171
BCLR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
BCS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
BEQ instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
BGE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
BGND instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74, 120
BGT instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
BHI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
BHS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Binary-coded decimal instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56, 171
Bit manipulation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60, 116, 139, 141, 473
Mask operand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43, 116, 136, 138, 139, 141
Multiple addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Bit test instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60, 67, 124, 125, 126, 127, 136, 138
BITA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
BITB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
BITBY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Bit-condition branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67, 136, 138
BITX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
BLE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
BLO instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
BLS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
BLT instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
BMI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
BNE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Boolean logic instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 98, 99, 100, 101
Complement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157, 158, 159, 160, 161, 162
Exclusive OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192, 193, 194, 195, 205
C
C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
C status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 60, 115, 117
CALL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44–??, 47, 68, 144, 476
Case statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
CBA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
CCR (see Condition codes register)
Changes in execution flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46–49
CLC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Clear instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Clear memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148, 151, 152, 153
Cleared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
CLI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
CLR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
CLRA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
D
DAA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
DATA mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 473
E
EDIV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
EDIVS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Effective address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33, 37, 72, 251, 252, 253, 473–475
EMACS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64, 185
EMAXD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
EMAXM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187, 399
EMIND instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188, 399
EMINM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
EMUL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
EMULS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Enabling maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 147
EORA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
EORB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193, 205
EORX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
EORY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
ETBL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64, 196, 399
Even bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46, 383
Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Non-maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Processing flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383, 384–??
Software interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69, 356, 357, 387
Unimplemented opcode trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383, 384, 387
F
f-cycle (free cycle) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80, 431
FDIV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59, 199
Fractional division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59, 199
Frame pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474, 475
Free cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80, 431
Fuzzy logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399–426
Antecedents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403, 425
Consequents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403, 425
Custom programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
Defuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 404, 419–??
Fuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 401, 422
Inference kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400, 405
Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 270, 314–??, 379, 399, 406–??
Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416, 420–421
Knowledge base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400, 403, 425
Membership functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 270, 400, 401, 406–410, 423–424
Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 425
Rule evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 314–??, 402, 410–419, 425
Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400, 403, 425
Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Tabular membership functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65, 423
Weighted average . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 379, 399, 404, 419–??
G
g-cycle (read PPAGE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80, 431
General purpose accumulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
H
H status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29, 171
Highest priority interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
High-level language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473–477
Addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473, 474, 476
Condition codes register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Expanded memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Loop primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473, 474
I
I mask bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 99, 147, 340, 384
IBEQ instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212, 460
IBNE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213, 460
I-cycle (16-bit read indirect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80, 431
i-cycle (8-bit read indirect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80, 431
IDIV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
IDIVS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215, 475
Immediate addressing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
INC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
INCA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
INCB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Increment instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
INCW instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
INCX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
INCY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Index calculation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Index manipulation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Index registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 70, 72, 474
PC (as an index register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27, 38, 80
SP (as an index register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27, 38, 80
X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26, 38, 80
J
JMP instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49, 225
JSR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47, 226
K
Knowledge base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
L
Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
LBCC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
LBCS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
LBEQ instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
LBGE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
LBGT instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
LBHI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
LBHS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
LBLE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
LBLO instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
LBLS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
LBLT instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
LBMI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
LBNE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
LBPL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
LBRA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
LBRN instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
LBVC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
LBVS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
LDAA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
LDAB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
LDD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
LDS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
LDX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
LDY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
LEAS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251, 474, 476
Least significant byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Least significant word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
LEAX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252, 476
LEAY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253, 476
Legal label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Literal expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Load instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Logic level one . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Logic level zero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Loop primitive instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49, 68, 460, 475
Offset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Postbyte encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Low-power stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73, 74, 346
LSL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60, 254
M
Maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 385
MAXA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Maximum instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
16-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186, 187
8-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268, 269
MAXM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269, 399
MEM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 270, 399, 406–410
Membership functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400, 406–410
Memory and addressing symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
MINA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271, 399
Minimum instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
16-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188, 189
8-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271, 272
MINM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Misaligned instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Most significant byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Most significant word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
MOVB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273, 274, 275, 276, 277, 278, 279
Move instructions . . . . . . . . . . . . 54, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286
Destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Multiple addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
PC relative addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Reference index register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
MOVW instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280, 281, 282, 283, 284, 285, 286
MUL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Multiple addressing modes
Bit manipulation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Move instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Multiplication instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
16-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190, 191
8-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Multiply and accumulate instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64, 185, 379, 426
O
Object code notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
O-cycle (optional program word fetch) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48, 81, 431
Odd bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Offset
Branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36–37
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37–40
Opcode map ??– . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453, 453–454, ??–455
Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 430
Optional cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48, 81, 431
ORAA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
ORAB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
ORCC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Orthogonality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
ORX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
ORY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
P
Page 2 prebyte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48, 81, 453, 454, 455
P-cycle (program word fetch) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 431
Q
Queue reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
HCS12 queue reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
HCS12 timing detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392, 393
R
R-cycle (16-bit data read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 431
r-cycle (8-bit data read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 431
Read 16-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 431
S
S control bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
SBA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
SBCA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
SBCB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
SBCD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
SBCX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
SBCY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
S-cycle (16-bit stack write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 432
s-cycle (8-bit stack write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 432
SEC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
SEI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Setting memory bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139, 141
SEV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
SEX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53, 342
Shift instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
T
TAB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Table interpolation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64, 196, 362
U
U-cycle (16-bit stack read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
u-cycle (8-bit stack read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Unary branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65–67
Unimplemented opcode trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69, 367, 383, 384, 454
Unsigned branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65–67
Unsigned multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Unstack 16-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Unstack 8-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Unweighted rule evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314–315, 402, 410–414, 425
V
V status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 73
V-cycle (vector fetch) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Vector fetch cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Vectors, exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383, 387
W
WAI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73, 378
Wait instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73, 378
WAV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62, 379, 399, 404, 419–421
HCS12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
wavr pseudo-instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420–421
HCS12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
W-cycle (16-bit data write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
w-cycle (8-bit data write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Weighted average . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Weighted rule evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316–??, 402, 410–412, 415–419, 425
Word moves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55, 280, 281, 282, 283, 284, 285, 286
Write 16-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Write 8-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
Write PPAGE cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81, 431
X
X mask bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29, 197, 309, 310, 331, 346, 359, 364
x-cycle (8-bit conditional write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82, 432
XGDX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
Z
Z status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30, 118, 133
Zero-page addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
NXP, the NXP logo, NXP SECURE CONNECTIONS FOR A SMARTER WORLD, COOLFLUX,
EMBRACE, GREENCHIP, HITAG, I2C BUS, ICODE, JCOP, LIFE VIBES, MIFARE, MIFARE
CLASSIC, MIFARE DESFire, MIFARE PLUS, MIFARE FLEX, MANTIS, MIFARE ULTRALIGHT,
MIFARE4MOBILE, MIGLO, NTAG, ROADLINK, SMARTLX, SMARTMX, STARPLUG, TOPFET,
TRENCHMOS, UCODE, Freescale, the Freescale logo, AltiVec, C-5, CodeTEST, CodeWarrior,
ColdFire, ColdFire+, C-Ware, the Energy Efficient Solutions logo, Kinetis, Layerscape, MagniV,
mobileGT, PEG, PowerQUICC, Processor Expert, QorIQ, QorIQ Qonverge, Ready Play,
SafeAssure, the SafeAssure logo, StarCore, Symphony, VortiQa, Vybrid, Airfast, BeeKit, BeeStack,
CoreNet, Flexis, MXC, Platform in a Package, QUICC Engine, SMARTMOS, Tower, TurboLink, and
UMEMS are trademarks of NXP B.V. All other product or service names are the property of their
respective owners. ARM, AMBA, ARM Powered, Artisan, Cortex, Jazelle, Keil, SecurCore, Thumb,
TrustZone, and μVision are registered trademarks of ARM Limited (or its subsidiaries) in the EU
and/or elsewhere. ARM7, ARM9, ARM11, big.LITTLE, CoreLink, CoreSight, DesignStart, Mali,
mbed, NEON, POP, Sensinode, Socrates, ULINK and Versatile are trademarks of ARM Limited (or
its subsidiaries) in the EU and/or elsewhere. All rights reserved. Oracle and Java are registered
trademarks of Oracle and/or its affiliates. The Power Architecture and Power.org word marks and
the Power and Power.org logos and related marks are trademarks and service marks licensed by
Power.org.
© 2016 NXP B.V.