S12CPUV2
S12CPUV2
Reference Manual
HCS12
Microcontrollers
S12CPUV2
Rev. 4.0
03/2006
freescale.com
S12CPUV2
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://www.freescale.com
The following revision history table summarizes changes contained in this document.
Revision History
Revision
Date Summary of Changes
Number
3.0 April, 2002 Incorporated information covering HCS12 Family of 16-bit MCUs throughout the book.
4.0 March, 2006 Reformatted to Freescale publication standards.
Corrected mistake in ANDCC/TAP descriptions (Instruction Glossary).
Corrected mistake in MEM description (Instruction Glossary).
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
© Freescale Semiconductor, Inc., 2005. All rights reserved.
Freescale Semiconductor 3
S12CPUV2 Reference Manual, Rev. 4.0
4 Freescale Semiconductor
Reference Manual — S12CPUV2
List of Sections
Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Section 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Section 2. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Freescale Semiconductor 5
S12CPUV2 Reference Manual, Rev. 4.0
6 Freescale Semiconductor
Reference Manual — S12CPUV2
Table of Contents
Section 1. Introduction
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
1.3 Symbols and Notation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
1.3.1 Abbreviations for System Resources . . . . . . . . . . . . . . . . . . . . . . . . . .16
1.3.2 Memory and Addressing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
1.3.3 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
1.3.4 Definitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
Section 2. Overview
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
2.2 Programming Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
2.2.1 Accumulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
2.2.2 Index Registers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
2.2.3 Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
2.2.4 Program Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
2.2.5 Condition Code Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
2.2.5.1 S Control Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
2.2.5.2 X Mask Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
2.2.5.3 H Status Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
2.2.5.4 I Mask Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
2.2.5.5 N Status Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
2.2.5.6 Z Status Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
2.2.5.7 V Status Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
2.2.5.8 C Status Bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
2.3 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
2.4 Memory Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
2.5 Instruction Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
Freescale Semiconductor 7
Section 3. Addressing Modes
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
3.2 Mode Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
3.3 Effective Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
3.4 Inherent Addressing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
3.5 Immediate Addressing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
3.6 Direct Addressing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
3.7 Extended Addressing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
3.8 Relative Addressing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
3.9 Indexed Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
3.9.1 5-Bit Constant Offset Indexed Addressing . . . . . . . . . . . . . . . . . . . . . .37
3.9.2 9-Bit Constant Offset Indexed Addressing . . . . . . . . . . . . . . . . . . . . . .37
3.9.3 16-Bit Constant Offset Indexed Addressing . . . . . . . . . . . . . . . . . . . . .38
3.9.4 16-Bit Constant Indirect Indexed Addressing . . . . . . . . . . . . . . . . . . . .38
3.9.5 Auto Pre/Post Decrement/Increment Indexed Addressing . . . . . . . . . .39
3.9.6 Accumulator Offset Indexed Addressing . . . . . . . . . . . . . . . . . . . . . . .40
3.9.7 Accumulator D Indirect Indexed Addressing . . . . . . . . . . . . . . . . . . . .41
3.10 Instructions Using Multiple Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
3.10.1 Move Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
3.10.2 Bit Manipulation Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
3.11 Addressing More than 64 Kbytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
8 Freescale Semiconductor
4.4.3.1 Short Branches. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
4.4.3.2 Long Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
4.4.3.3 Bit Condition Branches. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
4.4.3.4 Loop Primitives. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
4.4.4 Jumps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Freescale Semiconductor 9
5.22 Interrupt Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
5.23 Index Manipulation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
5.24 Stacking Instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
5.25 Pointer and Index Calculation Instructions . . . . . . . . . . . . . . . . . . . . . . . .83
5.26 Condition Code Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
5.27 Stop and Wait Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
5.28 Background Mode and Null Operations . . . . . . . . . . . . . . . . . . . . . . . . . .86
10 Freescale Semiconductor
7.8 Exception Processing Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .318
7.8.1 Vector Fetch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .318
7.8.2 Reset Exception Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320
7.8.3 Interrupt and Unimplemented Opcode Trap Exception Processing . .320
Freescale Semiconductor 11
9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337
9.2 Fuzzy Logic Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .338
9.2.1 Fuzzification (MEM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .340
9.2.2 Rule Evaluation (REV and REVW). . . . . . . . . . . . . . . . . . . . . . . . . . .342
9.2.3 Defuzzification (WAV). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .344
9.3 Example Inference Kernel. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345
9.4 MEM Instruction Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
9.4.1 Membership Function Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
9.4.2 Abnormal Membership Function Definitions. . . . . . . . . . . . . . . . . . . .349
9.4.2.1 Abnormal Membership Function Case 1 . . . . . . . . . . . . . . . . . . . .351
9.4.2.2 Abnormal Membership Function Case 2 . . . . . . . . . . . . . . . . . . . .352
9.4.2.3 Abnormal Membership Function Case 3 . . . . . . . . . . . . . . . . . . . .352
9.5 REV and REVW Instruction Details . . . . . . . . . . . . . . . . . . . . . . . . . . . .353
9.5.1 Unweighted Rule Evaluation (REV) . . . . . . . . . . . . . . . . . . . . . . . . . .353
9.5.1.1 Set Up Prior to Executing REV. . . . . . . . . . . . . . . . . . . . . . . . . . . .353
9.5.1.2 Interrupt Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .355
9.5.1.3 Cycle-by-Cycle Details for REV . . . . . . . . . . . . . . . . . . . . . . . . . . .355
9.5.2 Weighted Rule Evaluation (REVW) . . . . . . . . . . . . . . . . . . . . . . . . . .359
9.5.2.1 Set Up Prior to Executing REVW . . . . . . . . . . . . . . . . . . . . . . . . . .359
9.5.2.2 Interrupt Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .361
9.5.2.3 Cycle-by-Cycle Details for REVW . . . . . . . . . . . . . . . . . . . . . . . . .361
9.6 WAV Instruction Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .364
9.6.1 Set Up Prior to Executing WAV . . . . . . . . . . . . . . . . . . . . . . . . . . . . .364
9.6.2 WAV Interrupt Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .365
9.6.3 Cycle-by-Cycle Details for WAV and wavr . . . . . . . . . . . . . . . . . . . . .365
9.7 Custom Fuzzy Logic Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . .369
9.7.1 Fuzzification Variations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369
9.7.2 Rule Evaluation Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .372
9.7.3 Defuzzification Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373
12 Freescale Semiconductor
A.6 Decimal to Hexadecimal Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . .402
Freescale Semiconductor 13
C.3 Parameters and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426
C.3.1 Register Pushes and Pulls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426
C.3.2 Allocating and Deallocating Stack Space . . . . . . . . . . . . . . . . . . . . . .427
C.3.3 Frame Pointer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427
C.4 Increment and Decrement Operators . . . . . . . . . . . . . . . . . . . . . . . . . . .428
C.5 Higher Math Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .428
C.6 Conditional If Constructs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .429
C.7 Case and Switch Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .429
C.8 Pointers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .429
C.9 Function Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .430
C.10 Instruction Set Orthogonality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .431
14 Freescale Semiconductor
Reference Manual — S12CPUV2
Section 1. Introduction
1.1 Introduction
This manual describes the features and operation of the core (central
processing unit, or CPU, and development support functions) used in all
HCS12 microcontrollers. For reference, information is provided for the
M68HC12.
1.2 Features
The CPU12 is a high-speed, 16-bit processing unit that has a programming
model identical to that of the industry standard M68HC11 central processor
unit (CPU). 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.
• 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 CPU 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)
Freescale Semiconductor 15
1.3 Symbols and Notation
The symbols and notation shown here are used throughout the manual.
More specialized notation that applies only to the instruction glossary or
instruction set summary are described at the beginning of those sections.
A — Accumulator A
B — Accumulator B
D — Double accumulator D (A : B)
X — Index register X
Y — Index register Y
SP — Stack pointer
PC — Program counter
CCR — Condition code register
S — STOP instruction control bit
X — Non-maskable interrupt control bit
H — Half-carry status bit
I — Maskable interrupt control bit
N — Negative status bit
Z — Zero status bit
V — Two’s complement overflow status bit
C — Carry/Borrow status bit
16 Freescale Semiconductor
1.3.2 Memory and Addressing
Freescale Semiconductor 17
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 concatenat-
ing 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.
18 Freescale Semiconductor
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.
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.
Freescale Semiconductor 19
S12CPUV2 Reference Manual, Rev. 4.0
20 Freescale Semiconductor
Reference Manual — S12CPUV2
Section 2. Overview
2.1 Introduction
This section describes the CPU12 programming model, register set, the
data types used, and basic memory organization.
15 IX 0 INDEX REGISTER X
15 IY 0 INDEX REGISTER Y
15 SP 0 STACK POINTER
15 PC 0 PROGRAM COUNTER
Freescale Semiconductor 21
2.2.1 Accumulators
16-bit index registers X and Y are used for indexed addressing. In the
indexed addressing modes, the contents of an index register are added to
5-bit, 9-bit, or 16-bit constants or to the content of an accumulator to form
the effective address of the instruction operand. The second index register
is especially useful for moves and in cases where operands from two
separate tables are used in a calculation.
The CPU12 supports an automatic program stack. The stack is used to save
system context during subroutine calls and interrupts and can also be used
for temporary data storage. The stack can be located anywhere in the
standard 64-Kbyte address space and can grow to any size up to the total
amount of memory available in the system.
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.
22 Freescale Semiconductor
loads the program counter with the previously stacked return address and
execution continues at that address.
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)
The program counter (PC) is a 16-bit register that holds the address of the
next instruction to be executed. It is automatically incremented each time an
instruction is fetched.
The condition code register (CCR), named for its five status indicators,
contains:
• Five status indicators
• Two interrupt masking bits
• STOP instruction control bit
Freescale Semiconductor 23
The status bits reflect the results of CPU operation as it executes
instructions. The five flags are:
• Half carry (H)
• Negative (N)
• Zero (Z)
• Overflow (V)
• Carry/borrow (C)
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.
24 Freescale Semiconductor
2.2.5.2 X Mask Bit
The XIRQ input is an updated version of the NMI input found on earlier
generations of MCUs. Non-maskable interrupts are typically used to deal
with major system failures, such as loss of power. However, enabling
non-maskable interrupts before a system is fully powered and initialized can
lead to spurious interrupts. The X bit provides a mechanism for enabling
non-maskable interrupts after a system is stable.
By default, the X bit is set to 1 during reset. As long as the X bit remains set,
interrupt service requests made via the XIRQ pin are not recognized. An
instruction must clear the X bit to enable non-maskable interrupt service
requests made via the XIRQ pin. Once the X bit has been cleared to 0,
software cannot reset it to 1 by writing to the CCR. The X bit is not affected
by maskable interrupts.
When an XIRQ interrupt occurs after non-maskable interrupts are enabled,
both the X bit and the I bit are set automatically to prevent other interrupts
from being recognized during the interrupt service routine. The mask bits
are set after the registers are stacked, but before the interrupt vector is
fetched.
Normally, a return-from-interrupt (RTI) instruction at the end of the interrupt
service routine restores register values that were present before the
interrupt occurred. Since the CCR is stacked before the X bit is set, the RTI
normally clears the X bit, and thus re-enables non-maskable interrupts.
While it is possible to manipulate the stacked value of X so that X is set after
an RTI, there is no software method to reset X (and disable XIRQ) once X
has been cleared.
The I bit enables and disables maskable interrupt sources. By default, the I
bit is set to 1 during reset. An instruction must clear the I bit to enable
maskable interrupts. While the I bit is set, maskable interrupts can become
Freescale Semiconductor 25
pending and are remembered, but operation continues uninterrupted until
the I bit is cleared.
The N bit shows the state of the MSB of the result. N is most commonly used
in two’s complement arithmetic, where the MSB of a negative number is 1
and the MSB of a positive number is 0, but it has other uses. For instance,
if the MSB of a register or memory location is used as a status flag, the user
can test status by loading an accumulator.
The Z bit is set when all the bits of the result are 0s. Compare instructions
perform an internal implied subtraction, and the condition codes, including
Z, reflect the results of that subtraction. The increment index register X
(INX), decrement index register X (DEX), increment index register Y (INY),
and decrement index register Y (DEY) instructions affect the Z bit and no
other condition flags. These operations can only determine = (equal) and ≠
(not equal).
The C bit is set when a carry occurs during addition or a borrow occurs
during subtraction. The C bit also acts as an error flag for multiply and divide
26 Freescale Semiconductor
operations. Shift and rotate instructions operate through the C bit to facilitate
multiple-word shifts.
Five-bit and 9-bit signed integers are used only as offsets for indexed
addressing modes.
Eight-bit values can be stored at any odd or even byte address in available
memory.
Freescale Semiconductor 27
Sixteen-bit values are stored in memory as two consecutive bytes; the high
byte occupies the lowest address, but need not be aligned to an even
boundary.
28 Freescale Semiconductor
Reference Manual — S12CPUV2
3.1 Introduction
Addressing modes determine how the central processor unit (CPU)
accesses memory locations to be operated upon. This section discusses
the various modes and how they are used.
The CPU12 uses all M68HC11 modes as well as new forms of indexed
addressing. Differences between M68HC11 and M68HC12 indexed modes
are described in 3.9 Indexed Addressing Modes. Instructions that use
more than one mode are discussed in 3.10 Instructions Using Multiple
Modes.
Freescale Semiconductor 29
Table 3-1. M68HC12 Addressing Mode Summary
Addressing Mode Source Format Abbreviation Description
INST
Inherent (no externally INH Operands (if any) are in CPU registers
supplied operands)
INST #opr8i
Operand is included in instruction stream
Immediate or IMM
8- or 16-bit size implied by context
INST #opr16i
Operand is the lower 8 bits of an address
Direct INST opr8a DIR
in the range $0000–$00FF
Extended INST opr16a EXT Operand is a 16-bit address
INST rel8
An 8-bit or 16-bit relative offset from the current pc
Relative or REL
is supplied in the instruction
INST rel16
Indexed 5-bit signed constant offset
INST oprx5,xysp IDX
(5-bit offset) from X, Y, SP, or PC
Indexed
INST oprx3,–xys IDX Auto pre-decrement x, y, or sp by 1 ~ 8
(pre-decrement)
Indexed
INST oprx3,+xys IDX Auto pre-increment x, y, or sp by 1 ~ 8
(pre-increment)
Indexed
INST oprx3,xys– IDX Auto post-decrement x, y, or sp by 1 ~ 8
(post-decrement)
Indexed
INST oprx3,xys+ IDX Auto post-increment x, y, or sp by 1 ~ 8
(post-increment)
Indexed Indexed with 8-bit (A or B) or 16-bit (D)
INST abd,xysp IDX
(accumulator offset) accumulator offset from X, Y, SP, or PC
Indexed 9-bit signed constant offset from X, Y, SP, or PC
INST oprx9,xysp IDX1
(9-bit offset) (lower 8 bits of offset in one extension byte)
Indexed 16-bit constant offset from X, Y, SP, or PC
INST oprx16,xysp IDX2
(16-bit offset) (16-bit offset in two extension bytes)
Pointer to operand is found at...
Indexed-Indirect
INST [oprx16,xysp] [IDX2] 16-bit constant offset from X, Y, SP, or PC
(16-bit offset)
(16-bit offset in two extension bytes)
Indexed-Indirect Pointer to operand is found at...
INST [D,xysp] [D,IDX]
(D accumulator offset) X, Y, SP, or PC plus the value in D
30 Freescale Semiconductor
3.4 Inherent Addressing Mode
Instructions that use this addressing mode either have no operands or all
operands are in internal CPU registers. In either case, the CPU does not
need to access any memory locations to complete the instruction.
Examples:
NOP ;this instruction has no operands
INX ;operand is a CPU register
Examples:
LDAA #$55
LDX #$1234
LDY #$67
Example:
BRSET FOO,#$03,THERE
Freescale Semiconductor 31
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.
Example:
LDAA $55
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.
32 Freescale Semiconductor
3.7 Extended Addressing Mode
In this addressing mode, the full 16-bit address of the memory location to be
operated on is provided in the instruction. This addressing mode can be
used to access any location in the 64-Kbyte memory map.
Example:
LDAA $F03B
Short branch instructions consist of an 8-bit opcode and a signed 8-bit offset
contained in the byte that follows the opcode. Long branch instructions
consist of an 8-bit prebyte, an 8-bit opcode, and a signed 16-bit offset
contained in the two bytes that follow the opcode.
Each conditional branch instruction tests certain status bits in the condition
code register. If the bits are in a specified state, the offset is added to the
address of the next memory location after the offset to form an effective
address, and execution continues at that address. If the bits are not in the
specified state, execution continues with the instruction immediately
following the branch instruction.
Freescale Semiconductor 33
8-bit, 9-bit, and 16-bit offsets are signed two’s complement numbers to
support branching upward and downward in memory. The numeric range of
short branch offset values is $80 (–128) to $7F (127). Loop primitive
instructions support a 9-bit offset which allows a range of $100 (–256) to
$0FF (255). The numeric range of long branch offset values is $8000
(–32,768) to $7FFF (32,767). If the offset is 0, the CPU executes the
instruction immediately following the branch instruction, regardless of the
test involved.
Since the offset is at the end of a branch instruction, using a negative offset
value can cause the program counter (PC) to point to the opcode and initiate
a loop. For instance, a branch always (BRA) instruction consists of two
bytes, so using an offset of $FE sets up an infinite loop; the same is true of
a long branch always (LBRA) instruction with an offset of $FFFC.
The indexed addressing scheme uses a postbyte plus zero, one, or two
extension bytes after the instruction opcode. The postbyte and extensions
do the following tasks:
1. Specify which index register is used
2. Determine whether a value in an accumulator is used as an offset
3. Enable automatic pre- or post-increment or pre- or post-decrement
4. Specify size of increment or decrement
5. Specify use of 5-, 9-, or 16-bit signed offsets
34 Freescale Semiconductor
This approach eliminates the differences between X and Y register use
while dramatically enhancing the indexed addressing capabilities.
All indexed addressing modes use a 16-bit CPU register and additional
information to create an effective address. In most cases the effective
address specifies the memory location affected by the operation. In some
variations of indexed addressing, the effective address specifies the
location of a value that points to the memory location affected by the
operation.
Freescale Semiconductor 35
Table 3-2. Summary of Indexed Operations
Source
Postbyte Comments
Code
Code (xb) rr; 00 = X, 01 = Y, 10 = SP, 11 = PC
Syntax
,r
5-bit constant offset n = –16 to +15
rr0nnnnn n,r
r can specify X, Y, SP, or PC
–n,r
36 Freescale Semiconductor
3.9.1 5-Bit Constant Offset Indexed Addressing
This indexed addressing mode uses a 5-bit signed offset which is included
in the instruction postbyte. This short offset is added to the base index
register (X, Y, SP, or PC) to form the effective address of the memory
location that will be affected by the instruction. This gives a range of –16
through +15 from the value in the base index register. Although other
indexed addressing modes allow 9- or 16-bit offsets, those modes 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).
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.
Freescale Semiconductor 37
This variation of the indexed addressing mode in the CPU12 is similar to the
M68HC11 indexed addressing mode, but is functionally enhanced. The
M68HC11 CPU provides for unsigned 8-bit constant offset indexing from X
or Y, and use of Y requires an extra instruction byte and thus, an extra
execution cycle. The 9-bit signed offset used in the CPU12 covers the same
range of positive offsets as the M68HC11, and adds negative offset
capability. The CPU12 can use X, Y, SP, or PC as the base index register.
38 Freescale Semiconductor
3.9.5 Auto Pre/Post Decrement/Increment Indexed Addressing
This indexed addressing mode provides four ways to automatically change
the value in a base index register as a part of instruction execution. The
index register can be incremented or decremented by an integer value
either before or after indexing takes place. The base index register may be
X, Y, or SP. (Auto-modify modes would not make sense on PC.)
Pre-decrement and pre-increment versions of the addressing mode adjust
the value of the index register before accessing the memory location
affected by the instruction — the index register retains the changed value
after the instruction executes. Post-decrement and post-increment versions
of the addressing mode use the initial value in the index register to access
the memory location affected by the instruction, then change the value of the
index register.
The CPU12 allows the index register to be incremented or decremented by
any integer value in the ranges –8 through –1 or 1 through 8. The value
need not be related to the size of the operand for the current instruction.
These instructions can be used to incorporate an index adjustment into an
existing instruction rather than using an additional instruction and increasing
execution time. This addressing mode is also used to perform operations on
a series of data structures in memory.
Examples:
STAA 1,–SP ;equivalent to PSHA
STX 2,–SP ;equivalent to PSHX
LDX 2,SP+ ;equivalent to PULX
LDAA 1,SP+ ;equivalent to PULA
For a “last-used” type of stack like the CPU12 stack, these four examples
are equivalent to common push and pull instructions.
For a “next-available” stack like the M68HC11 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. However,
in the M68HC11, 16-bit operations like push register X onto stack (PSHX)
and pull register X from stack (PULX) require multiple instructions to
decrement the SP by one, then store X, then decrement SP by one again.
Freescale Semiconductor 39
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).
Example:
LDAA B,X
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 in the CPU12.
40 Freescale Semiconductor
3.9.7 Accumulator D Indirect Indexed Addressing
This indexed addressing mode adds the value in the D accumulator to the
value in the base index register to form the address of a memory location
that contains a pointer to the memory location affected by the instruction.
The instruction operand does not point to the address of the memory
location to be acted upon, but rather to the location of a pointer to the
address to be acted upon. The square brackets distinguish this addressing
mode from D accumulator offset indexing.
Examples:
JMP [D,PC]
GO1 DC.W PLACE1
GO2 DC.W PLACE2
GO3 DC.W PLACE3
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 CPU 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.
Freescale Semiconductor 41
Move instructions do not support indirect modes, 9-bit, or 16-bit offset
modes requiring extra extension bytes. There are special considerations
when using PC-relative addressing with move instructions. The original
M68HC12 implemented the instruction queue slightly differently than the
newer HCS12. In the older M68HC12 implementation, the CPU did not
maintain a pointer to the start of the instruction after the current instruction
(what the user thinks of as the PC value during execution). This caused an
offset for PC-relative 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 original M68HC12, move instructions pose three special
problems:
• Some moves use an indexed source and an indexed destination.
• 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.
• All moves do not have the indexed postbyte as the last byte of object
code.
These cases are 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.
Table 3-3 shows PC offsets from the location immediately following the
current instruction by addressing mode.
42 Freescale Semiconductor
Example:
1000 18 09 C2 20 00 MOVB $2000 2,PC
$18 is the page pre-byte, 09 is the MOVB opcode for ext-idx, C2 is the
indexed postbyte for 2,PC (without correction).
NOTE: Instead of assembling the 2,PC as C2, the correction has been applied to
make it C0. Check whether an assembler makes the correction before using
PC-relative moves.
On the newer HCS12, the instruction queue was implemented such that an
internal pointer, to the start of the next instruction, is always available. On
the HCS12, PC-relative move instructions work as expected without any
offset adjustment. Although this is different from the original M68HC12, it is
unlikely to be a problem because PC-relative indexing is rarely, if ever, used
with move instructions.
The clear bits in memory (BCLR) and set bits in memory (BSET) instructions
use an 8-bit mask to determine which bits in a memory byte are to be
changed. The mask must be supplied with the instruction as an immediate
mode value. The memory location to be modified can be specified by means
of direct, extended, or indexed addressing modes.
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.
Freescale Semiconductor 43
3.11 Addressing More than 64 Kbytes
Some M68HC12 devices incorporate hardware that supports addressing a
larger memory space than the standard 64 Kbytes. The expanded memory
system uses fast on-chip logic to implement a transparent bank-switching
scheme.
MCUs with expanded memory treat the 16 Kbytes of memory space from
$8000 to $BFFF as a program memory window. Expanded-memory
architecture includes an 8-bit program page register (PPAGE), which allows
up to 256 16-Kbyte program memory pages to be switched into and out of
the program memory window. This provides for up to 4 Megabytes of paged
program memory.
44 Freescale Semiconductor
provided by an immediate operand in the instruction. For indexed indirect
variations of CALL, a pointer specifies memory locations where the new
page value and the address of the called subroutine are stored. Use of
indirect addressing for both the page value and the address within the page
frees the program from keeping track of explicit values for either address.
The RTC instruction restores the saved program page value and the return
address from the stack. This causes execution to resume at the next
instruction after the original CALL instruction.
Freescale Semiconductor 45
S12CPUV2 Reference Manual, Rev. 4.0
46 Freescale Semiconductor
Reference Manual — S12CPUV2
4.1 Introduction
The CPU12 uses an instruction queue to increase execution speed.
This section describes queue operation during normal program execution
and changes in execution flow. These concepts augment the descriptions of
instructions and cycle-by-cycle instruction execution in subsequent
sections, but it is important to note that queue operation is automatic, and
generally transparent to the user.
Each instruction refills the queue by fetching the same number of bytes that
the instruction uses. Program information is fetched in aligned 16-bit words.
Each program fetch (P) indicates that two bytes need to be replaced in the
instruction queue. Each optional fetch (O) indicates that only one byte needs
to be replaced. For example, an instruction composed of five bytes does two
program fetches and one optional fetch. If the first byte of the five-byte
instruction was even-aligned, the optional fetch is converted into a free
Freescale Semiconductor 47
cycle. If the first byte was odd-aligned, the optional fetch is executed as a
program fetch.
There are two 16-bit queue stages and one 16-bit buffer. Program
information is fetched in aligned 16-bit words. Unless buffering is required,
program information is first queued into stage 1, then advanced to stage 2
for execution.
At least two words of program information are available to the CPU when
execution begins. The first byte of object code is in either the even or odd
half of the word in stage 2, and at least two more bytes of object code are in
the queue.
The buffer is used when a program word arrives before the queue can
advance. This occurs during execution of single-byte and odd-aligned
instructions. For instance, the queue cannot advance after an aligned,
single-byte instruction is executed, because the first byte of the next
instruction is also in stage 2. In these cases, information is latched into the
buffer until the queue can advance.
There are three 16-bit stages in the instruction queue. Instructions enter the
queue at stage 1 and shift out of stage 3 as the CPU executes instructions
and fetches new ones into stage 1. Each byte in the queue is selectable. An
opcode prediction algorithm determines the location of the next opcode in
the instruction queue.
48 Freescale Semiconductor
4.3.1 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.3.2 Latch Data from Bus (Applies Only to the M68HC12 Queue Implementation)
The content of queue is advanced by one stage, and stage 1 is loaded with
a word of program information from the data bus. The information was
requested two bus cycles earlier but has only become available this cycle,
due to access delay.
4.3.4 Advance and Load from Buffer (Applies Only to M68HC12 Queue Implementation)
Freescale Semiconductor 49
subroutine calls, branches, and jumps are considered to be elements of
program structure.
During design, great care is taken to assure that the mechanism that
increases instruction throughput during normal program execution does not
cause bottlenecks during changes of program flow, but internal queue
operation is largely transparent to the user. The following information is
provided to enhance subsequent descriptions of instruction execution.
4.4.1 Exceptions
Exceptions are events that require processing outside the normal flow of
instruction execution. CPU12 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.
4.4.2 Subroutines
The CPU12 can branch to (BSR), jump to (JSR), or call (CALL) subroutines.
BSR and JSR are used to access subroutines in the normal 64-Kbyte
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.
50 Freescale Semiconductor
Subroutines in the normal 64-Kbyte 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 and RTC execute correctly in the normal 64-Kbyte 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.4.3 Branches
Freescale Semiconductor 51
4.4.3.1 Short Branches
The “not-taken” case for short branches is simple. Since the instruction
consists of a single word containing both an opcode and an 8-bit offset, the
queue advances, another program word is fetched, and execution continues
with the next instruction.
The “taken” case for short branches requires that the queue be refilled so
that execution can continue at a new address. First, the effective address of
the destination is calculated using the relative offset in the instruction. Then,
the address is loaded into the program counter, and the CPU performs three
program word fetches at the new address to refill the instruction queue.
The “not-taken” case for all long branches requires three cycles, while the
“taken” case requires four cycles. This is due to differences in the amount of
program information needed to fill the queue.
Long branch instructions begin with a $18 prebyte which indicates that the
opcode is on page 2 of the opcode map. The CPU12 treats the prebyte as
a special one-byte instruction. If the prebyte is not aligned, the first cycle is
used to perform a program word access; if the prebyte is aligned, the first
cycle is used to perform a free cycle. The first cycle for the prebyte is
executed whether or not the branch is taken.
The first cycle of the branch instruction is an optional cycle. Optional cycles
make the effects of byte-sized and misaligned instructions consistent with
those of aligned word-length instructions. Program information is always
fetched as aligned 16-bit words. When an instruction has an odd number of
bytes, and the first byte is not aligned with an even byte boundary, the
optional cycle makes an additional program word access that maintains
queue order. In all other cases, the optional cycle is a free cycle.
In the “not-taken” case, the queue must advance so that execution can
continue with the next instruction. Two cycles are used to refill the queue.
Alignment determines how the second of these cycles is used.
In the “taken” case, the effective address of the branch is calculated using
the 16-bit relative offset contained in the second word of the instruction. This
address is loaded into the program counter, then the CPU performs three
program word fetches at the new address.
52 Freescale Semiconductor
4.4.3.3 Bit Condition Branches
4.4.4 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.
Freescale Semiconductor 53
S12CPUV2 Reference Manual, Rev. 4.0
54 Freescale Semiconductor
Reference Manual — S12CPUV2
5.1 Introduction
This section contains general information about the central processor unit
(CPU12) instruction set. It is organized into instruction categories grouped
by function.
In the M68HC12 and HCS12 architecture, all memory and input/output (I/O)
are mapped in a common 64-Kbyte address space (memory-mapped I/O).
This allows the same set of instructions to be used to access memory, I/O,
and control registers. General-purpose load, store, transfer, exchange, and
move instructions facilitate movement of data to and from memory and
peripherals.
The CPU12 has a full set of 8-bit and 16-bit mathematical instructions.
There are instructions for signed and unsigned arithmetic, division, and
multiplication with 8-bit, 16-bit, and some larger operands.
Freescale Semiconductor 55
accumulate operations, table interpolation, and specialized fuzzy logic
operations that involve mathematical calculations.
56 Freescale Semiconductor
Table 5-1. Load and Store Instructions (Continued)
Store Instructions
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
The sign extend 8-bit operand (SEX) instruction is a special case of the
universal transfer instruction that is used to sign extend 8-bit two’s
complement numbers so that they can be used in 16-bit operations. The
8-bit number is copied from accumulator A, accumulator B, or the condition
code register to accumulator D, the X index register, the Y index register, or
the stack pointer. All the bits in the upper byte of the 16-bit result are given
the value of the most-significant bit (MSB) of the 8-bit number.
Freescale Semiconductor 57
Table 5-2 is a summary of transfer and exchange instructions.
58 Freescale Semiconductor
5.6 Addition and Subtraction Instructions
Signed and unsigned 8- and 16-bit addition can be performed between
registers or between registers and memory. Special instructions support
index calculation. Instructions that add the carry bit in the condition code
register (CCR) facilitate multiple precision computation.
Load effective address (LEAS, LEAX, and LEAY) instructions could also be
considered as specialized addition and subtraction instructions. See 5.25
Pointer and Index Calculation Instructions for more information.
Freescale Semiconductor 59
5.7 Binary-Coded Decimal Instructions
To add binary-coded decimal (BCD) operands, use addition instructions that
set the half-carry bit in the CCR, then adjust the result with the decimal
adjust A (DAA) instruction. Table 5-5 is a summary of instructions that can
be used to perform BCD operations.
Table 5-5. BCD Instructions
Mnemonic Function Operation
ABA Add B to A (A) + (B) ⇒ A
ADCA Add with carry to A (A) + (M) + C ⇒ A
1. These instructions are not normally used for BCD operations because, although they affect H
correctly, they do not leave the result in the correct accumulator (A) to be used with the DAA
instruction. Thus additional steps would be needed to adjust the result to correct BCD form.
60 Freescale Semiconductor
5.8 Decrement and Increment Instructions
The decrement and increment instructions are optimized 8- and 16-bit
addition and subtraction operations. They are generally used to implement
counters. Because they do not affect the carry bit in the CCR, they are
particularly well suited for loop counters in multiple-precision computation
routines. Refer to 5.20 Loop Primitive Instructions for information
concerning automatic counter branches. Table 5-6 is a summary of
decrement and increment instructions.
Table 5-6. Decrement and Increment Instructions
Mnemonic Function Operation
Decrement Instructions
DEC Decrement memory (M) – $01 ⇒ M
DECA Decrement A (A) – $01 ⇒ A
DECB Decrement B (B) – $01 ⇒ B
DES Decrement SP (SP) – $0001 ⇒ SP
DEX Decrement X (X) – $0001 ⇒ X
DEY Decrement Y (Y) – $0001 ⇒ Y
Increment Instructions
INC Increment memory (M) + $01 ⇒ M
INCA Increment A (A) + $01 ⇒ A
INCB Increment B (B) + $01 ⇒ B
INS Increment SP (SP) + $0001 ⇒ SP
INX Increment X (X) + $0001 ⇒ X
INY Increment Y (Y) + $0001 ⇒ Y
Freescale Semiconductor 61
5.9 Compare and Test Instructions
Compare and test instructions perform subtraction between a pair of
registers or between a register and memory. The result is not stored, but
condition codes are set by the operation. These instructions are generally
used to establish conditions for branch instructions. In this architecture,
most instructions update condition code bits automatically, so it is often
unnecessary to include separate test or compare instructions. Table 5-7 is
a summary of compare and test instructions.
62 Freescale Semiconductor
5.10 Boolean Logic Instructions
The Boolean logic instructions perform a logic operation between an 8-bit
accumulator or the CCR and a memory value. AND, OR, and exclusive OR
functions are supported. Table 5-8 summarizes logic instructions.
Table 5-8. Boolean Logic Instructions
Mnemonic Function Operation
ANDA AND A with memory (A) • (M) ⇒ A
ANDB AND B with memory (B) • (M) ⇒ B
ANDCC AND CCR with memory (clear CCR bits) (CCR) • (M) ⇒ CCR
EORA Exclusive OR A with memory (A) ⊕ (M) ⇒ A
EORB Exclusive OR B with memory (B) ⊕ (M) ⇒ B
ORAA OR A with memory (A) + (M) ⇒ A
ORAB OR B with memory (B) + (M) ⇒ B
ORCC OR CCR with memory (set CCR bits) (CCR) + (M) ⇒ CCR
Freescale Semiconductor 63
5.12 Multiplication and Division Instructions
There are instructions for signed and unsigned 8- and 16-bit multiplication.
Eight-bit multiplication operations have a 16-bit product. Sixteen-bit
multiplication operations have 32-bit products.
64 Freescale Semiconductor
5.13 Bit Test and Manipulation Instructions
The bit test and manipulation operations use a mask value to test or change
the value of individual bits in an accumulator or in memory. Bit test A (BITA)
and bit test B (BITB) provide a convenient means of testing bits without
altering the value of either operand. Table 5-11 is a summary of bit test and
manipulation instructions.
Freescale Semiconductor 65
5.14 Shift and Rotate Instructions
There are shifts and rotates for all accumulators and for memory bytes. All
pass the shifted-out bit through the C status bit to facilitate multiple-byte
operations. Because logical and arithmetic left shifts are identical, there are
no separate logical left shift operations. Logic shift left (LSL) mnemonics are
assembled as arithmetic shift left memory (ASL) operations. Table 5-12
shows shift and rotate instructions.
Arithmetic Shifts
ASL Arithmetic shift left memory
ASLA Arithmetic shift left A 0
C b7 b0
ASLB Arithmetic shift left B
66 Freescale Semiconductor
5.15 Fuzzy Logic Instructions
The CPU12 instruction set includes instructions that support efficient
processing of fuzzy logic operations. The descriptions of fuzzy logic
instructions given here are functional overviews. Table 5-13 summarizes
the fuzzy logic instructions. Refer to Section 9. Fuzzy Logic Support for
detailed discussion.
Freescale Semiconductor 67
5.15.3 Fuzzy Logic Weighted Average Instruction
68 Freescale Semiconductor
Table 5-13. Fuzzy Logic Instructions (Continued)
Mnemonic Function Operation
Find smallest rule input (MIN)
Store to rule outputs unless fuzzy output is larger
(MAX)
Freescale Semiconductor 69
5.16 Maximum and Minimum Instructions
The maximum (MAX) and minimum (MIN) instructions are used to make
comparisons between an accumulator and a memory location. These
instructions can be used for linear programming operations, such as
simplex-method optimization, or for fuzzification.
70 Freescale Semiconductor
5.17 Multiply and Accumulate Instruction
The multiply and accumulate (EMACS) instruction multiplies two 16-bit
operands stored in memory and accumulates the 32-bit result in a third
memory location. EMACS can be used to implement simple digital filters
and defuzzification routines that use 16-bit operands. The WAV instruction
incorporates an 8- to 16-bit multiply and accumulate operation that obtains
a numerator for the weighted average calculation. The EMACS instruction
can automate this portion of the averaging operation when 16-bit operands
are used. Table 5-15 shows the EMACS instruction.
Freescale Semiconductor 71
5.18 Table Interpolation Instructions
The table interpolation instructions (TBL and ETBL) interpolate values from
tables stored in memory. Any function that can be represented as a series
of linear equations can be represented by a table of appropriate 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.
72 Freescale Semiconductor
5.19 Branch Instructions
Branch instructions cause a sequence to change when specific conditions
exist. The CPU12 uses three kinds of branch instructions. These are short
branches, long branches, and bit condition branches.
Branch instructions can also be classified by the type of condition that must
be satisfied in order for a branch to be taken. Some instructions belong to
more than one classification. For example:
Freescale Semiconductor 73
5.19.1 Short Branch 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.
74 Freescale Semiconductor
5.19.2 Long Branch Instructions
The numeric range of long branch offset values is $8000 (–32,768) to $7FFF
(32,767) from the address of the next memory location after the offset value.
This permits branching from any location in the standard 64-Kbyte address
map to any other location in the 64-Kbyte map.
Freescale Semiconductor 75
5.19.3 Bit Condition Branch Instructions
The bit condition branches are taken when bits in a memory byte are in a
specific state. A mask operand is used to test the location. If all bits in that
location that correspond to ones in the mask are set (BRSET) or cleared
(BRCLR), the branch is taken.
The numeric range of 8-bit offset values is $80 (–128) to $7F (127)
from the address of the next memory location after the offset value.
76 Freescale Semiconductor
5.20 Loop Primitive Instructions
The loop primitives can also be thought of as counter branches. The
instructions test a counter value in a register or accumulator (A, B, D, X, Y,
or SP) for zero or non-zero value as a branch condition. There are
predecrement, preincrement, and test-only versions of these instructions.
The numeric range of 9-bit offset values is $100 (–256) to $0FF (255)
from the address of the next memory location after the offset value.
Freescale Semiconductor 77
5.21 Jump and Subroutine Instructions
Jump (JMP) instructions cause immediate changes in sequence. The JMP
instruction loads the PC with an address in the 64-Kbyte memory map, and
program execution continues at that address. The address can be provided
as an absolute 16-bit address or determined by various forms of indexed
addressing.
78 Freescale Semiconductor
Table 5-21. Jump and Subroutine Instructions
Mnemonic Function Operation
SP – 2 ⇒ SP
BSR Branch to subroutine RTNH : RTNL ⇒ M(SP) : M(SP+1)
Subroutine address ⇒ PC
SP – 2 ⇒ SP
RTNH:RTNL⇒ M(SP) : M(SP+1)
Call subroutine SP – 1 ⇒ SP
CALL
in expanded memory (PPAGE) ⇒ M(SP)
Page ⇒ PPAGE
Subroutine address ⇒ PC
JMP Jump Address ⇒ PC
SP – 2 ⇒ SP
JSR Jump to subroutine RTNH : RTNL⇒ M(SP) : M(SP+1)
Subroutine address ⇒ PC
M(SP) ⇒ PPAGE
SP + 1 ⇒ SP
RTC Return from call
M(SP) : M(SP+1) ⇒ PCH : PCL
SP + 2 ⇒ SP
M(SP) : M(SP+1) ⇒ PCH : PCL
RTS Return from subroutine
SP + 2 ⇒ SP
Freescale Semiconductor 79
are used. If the CPU attempts to execute one of the unimplemented
opcodes on page 2, an opcode trap interrupt occurs. Traps are essentially
interrupts that share the $FFF8:$FFF9 interrupt vector.
80 Freescale Semiconductor
5.23 Index Manipulation Instructions
The index manipulation instructions perform 8- and 16-bit operations on the
three index registers and accumulators, other registers, or memory, as
shown in Table 5-23.
Freescale Semiconductor 81
5.24 Stacking Instructions
The two types of stacking instructions, are shown in Table 5-24. Stack
pointer instructions use specialized forms of mathematical and data transfer
instructions to perform stack pointer manipulation. Stack operation
instructions save information on and retrieve information from the system
stack.
82 Freescale Semiconductor
5.25 Pointer and Index Calculation Instructions
The load effective address instructions allow 5-, 8-, or 16-bit constants or the
contents of 8-bit accumulators A and B or 16-bit accumulator D to be added
to the contents of the X and Y index registers, or to the SP.
Freescale Semiconductor 83
5.26 Condition Code Instructions
Condition code instructions are special forms of mathematical and data
transfer instructions that can be used to change the condition code register.
Table 5-26 shows instructions that can be used to manipulate the CCR.
84 Freescale Semiconductor
5.27 Stop and Wait Instructions
As shown in Table 5-27, two instructions put the CPU12 in an inactive state
that reduces power consumption.
The stop instruction (STOP) stacks a return address and the contents of
CPU registers and accumulators, then halts all system clocks.
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.
Freescale Semiconductor 85
5.28 Background Mode and Null Operations
Background debug mode (BDM) is a special CPU12 operating mode that is
used for system development and debugging. Executing enter background
debug mode (BGND) when BDM is enabled puts the CPU12 in this mode.
For complete information, refer to Section 8. Instruction Queue.
Null operations are often used to replace other instructions during software
debugging. Replacing conditional branch instructions with branch never
(BRN), for instance, permits testing a decision-making routine by disabling
the conditional branch without disturbing the offset value.
Table 5-28 shows the BGND and null operation (NOP) instructions.
86 Freescale Semiconductor
Reference Manual — S12CPUV2
6.1 Introduction
This section is a comprehensive reference to the CPU12 instruction set.
Freescale Semiconductor 87
6.2 Glossary Information
The glossary contains an entry for each assembler mnemonic, in alphabetic
order. Figure 6-1 is a representation of a glossary page.
Operation: (M : M+1) ⇒ X
SYMBOLIC DESCRIPTION
OF OPERATION Description: Loads the most significa
memory at the addres
content of the next b
DETAILED DESCRIPTION
OF OPERATION S X H
CCR Details: — — —
88 Freescale Semiconductor
6.3 Condition Code Changes
The following special characters are used to describe the effects of
instruction execution on the status bits in the condition code register.
– — Status bit not affected by operation
0 — Status bit cleared by operation
1 — Status bit set by operation
∆ — Status bit affected by operation
⇓ — Status bit may be cleared or remain set, but is not set
by operation.
⇑ — Status bit may be set or remain cleared, but is not
cleared by operation.
? — Status bit may be changed by operation, but the final
state is not defined.
! — Status bit used for a special purpose
Freescale Semiconductor 89
6.4 Object Code Notation
The digits 0 to 9 and the uppercase letters A to F are used to express
hexadecimal values. Pairs of lowercase letters represent the 8-bit values as
described here.
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
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
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 overlay 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
90 Freescale Semiconductor
6.5 Source Forms
The glossary pages provide only essential information about assembler
source forms. Assemblers generally support a number of assembler
directives, allow definition of program labels, and have special conventions
for comments. For complete information about writing source files for a
particular assembler, refer to the documentation provided by the assembler
vendor.
Assemblers are typically flexible about the use of spaces and tabs. Often,
any number of spaces or tabs can be used where a single space is shown
on the glossary pages. Spaces and tabs are also normally allowed before
and after commas. When program labels are used, there must also be at
least one tab or space before all instruction mnemonics. This required
space is not apparent in the source forms.
Freescale Semiconductor 91
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 Freescale
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 64-Kbyte
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
64-Kbyte address space.
92 Freescale Semiconductor
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 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 CPU12 recognizes up to an 8-bit page value for
memory expansion but not all MCUs that include the
CPU12 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.
Freescale Semiconductor 93
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 64-Kbyte 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.
A single letter code in the column represents a single CPU cycle. Uppercase
letters indicate 16-bit access cycles. There are cycle codes for each
addressing mode variation of each instruction. Simply count code letters to
determine the execution time of an instruction in a best-case system. An
94 Freescale Semiconductor
example of a best-case system is a single-chip 16-bit system with no 16-bit
off-boundary data accesses to any locations other than on-chip RAM.
The following paragraphs explain the cycle code letters used and note
conditions that can cause each type of cycle to be stretched.
Freescale Semiconductor 95
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.
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.
96 Freescale Semiconductor
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.
Freescale Semiconductor 97
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.
98 Freescale Semiconductor
Special Notation for Branch Taken/Not Taken Cases
6.7 Glossary
This subsection contains an entry for each assembler mnemonic, in
alphabetic order.
Freescale Semiconductor 99
ABA Add Accumulator B to Accumulator A ABA
Operation: (A) + (B) ⇒ A
S X H I N Z V C
CCR Details:
– – ∆ – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – ∆ – ∆ ∆ ∆ ∆
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
S X H I N Z V C
CCR Details:
– – ∆ – ∆ ∆ ∆ ∆
H: X3 • M3 + M3 • R3 + R3 • X3
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: X7 • M7 • R7 + X7 • M7 • R7
Set if two’s complement overflow resulted from the operation;
cleared otherwise
C: X7 • M7 + M7 • R7 + R7 • X7
Set if there was a carry from the MSB of the result; 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.
S X H I N Z V C
CCR Details:
– – ∆ – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – ∆ – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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).
S X H I N Z V C
CCR Details:
⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓ ⇓
Condition code bits are cleared if the corresponding bit was 0 before the
operation or if the corresponding bit in the mask is 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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
C b7 – – – – – – b0 0
Description: Shifts all bits of accumulator A one bit position to the left. Bit 0 is loaded with
a 0. TheC status bit is loaded from the most significant bit of A.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
For all other types of BDM entry, the CPU performs the same sequence of
operations as for a BGND instruction, but the value stored in TMP2 already
points to the instruction that would have executed next had BDM not
become active. If active BDM is triggered just as a BGND instruction is
about to execute, the BDM firmware does increment TMP2, but the change
does not affect resumption of normal execution.
While BDM is active, the CPU executes debugging commands received via
a special single-wire serial interface. BDM is terminated by the execution of
specific debugging commands. Upon exit from BDM, the background/boot
ROM and registers are disabled, the instruction queue is refilled starting
with the return address pointed to by TMP2, and normal processing
resumes.
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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 3.8 Relative Addressing Mode for details of branch execution.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
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 3.8 Relative Addressing Mode for details of branch execution.
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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).
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
CLC can be used to set up the C bit prior to a shift or rotate instruction
involving the C bit.
S X H I N Z V C
CCR Details:
– – – – – – – 0
C: 0; cleared
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.
S X H I N Z V C
CCR Details:
– – – 0 – – – –
I: 0; cleared
S X H I N Z V C
CCR Details:
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
S X H I N Z V C
CCR Details:
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
S X H I N Z V C
CCR Details:
– – – – 0 1 0 0
N: 0; cleared
Z: 1; set
V: 0; cleared
C: 0; cleared
S X H I N Z V C
CCR Details:
– – – – – – 0 –
V: 0; cleared
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 1
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 1
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
Description: Compares the content of the 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 the SP without
modifying either the SP or (M : M + 1).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
1 2 3 4 5 6
Initial Value Initial Value Correction Corrected
C Bit Value of A[7:4] H Bit Value of A[3:0] Factor C Bit Value
0 0–9 0 0–9 00 0
0 0–8 0 A–F 06 0
0 0–9 1 0–3 06 0
0 A–F 0 0–9 60 1
0 9–F 0 A–F 66 1
0 A–F 1 0–3 66 1
1 0–2 0 0–9 60 1
1 0–2 0 A–F 66 1
1 0–3 1 0–3 66 1
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ? ∆
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – ∆ – –
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.
S X H I N Z V C
CCR Details:
– – – – – ∆ – –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
The C status bit can be used to round the high-order 16 bits of the result.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ – ∆
The C status bit can be used to round the high-order 16 bits of the result.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ – ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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:
D = Y1 + [(B) × (Y2 – Y1)]
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ – ∆(1)
S X H I N Z V C S X H I N Z V C
CCR Details: Or:
– – – – – – – – ∆ ⇓ ∆ ∆ ∆ ∆ ∆ ∆
None affected, unless the CCR 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.
S X H I N Z V C
CCR Details:
– – – – – ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – ∆ 0 ∆
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).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ –
Description: Add one to the SP. This instruction is assembled to LEAS 1,SP. The LEAS
instruction does not affect condition codes as an INX or INY instruction
would.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – ∆ – –
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.
S X H I N Z V C
CCR Details:
– – – – – ∆ – –
Description: Jumps to the instruction stored at the effective address. The effective
address is obtained according to the rules for extended or indexed
addressing.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
Simple branch
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – – – – –
Description: Loads the content of memory location M into accumulator A. The condition
codes are set according to the data.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
Description: Loads the content of memory location M into accumulator B. The condition
codes are set according to the data.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
Description: Loads the most significant byte of the SP with the content of memory
location M, and loads the least significant byte of the SP with the content of
the next byte of memory at M+1.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
S X H I N Z V C
CCR Details:
– – – – – – – –
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 3.9 Indexed Addressing Modes for more details.
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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 3.9 Indexed Addressing Modes for more details.
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – 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.
S X H I N Z V C
CCR Details:
– – – – 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: 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.
S X H I N Z V C
CCR Details:
– – – – 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).
S X H I N Z V C
CCR Details:
– – – – 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
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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
S X H I N Z V C
CCR Details:
– – ? – ? ? ? ?
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
Description: Moves the content of one memory location to another memory location. The
content of the source memory location is not changed.
Move instructions use separate addressing modes to access the source and
destination of a move. The following combinations of addressing modes are
supported: IMM–EXT, IMM–IDX, EXT–EXT, EXT–IDX, IDX–EXT, and
IDX–IDX. IDX operands allow indexed addressing mode specifications that
fit in a single postbyte including 5-bit constant, accumulator offsets, and
auto increment/decrement modes. Nine-bit and 16-bit constant offsets
would require additional extension bytes and are not allowed. Indexed
indirect modes (for example [D,r]) are also not allowed.
S X H I N Z V C
CCR Details:
– – – – – – – –
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 instructions use separate addressing modes to access the source and
destination of a move. The following combinations of addressing modes are
supported: IMM–EXT, IMM–IDX, EXT–EXT, EXT–IDX, IDX–EXT, and
IDX–IDX. IDX operands allow indexed addressing mode specifications that
fit in a single postbyte including 5-bit constant, accumulator offsets, and
auto increment/decrement modes. Nine-bit and 16-bit constant offsets
would require additional extension bytes and are not allowed. Indexed
indirect modes (for example [D,r]) are also not allowed.
S X H I N Z V C
CCR Details:
– – – – – – – –
MUL Multiply
8-Bit by 8-Bit (Unsigned) MUL
Operation: (A) × (B) ⇒ A : B
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.
S X H I N Z V C
CCR Details:
– – – – – – – ∆
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 (the
value $80 is left unchanged).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
Description: Replaces the content of accumulator A with its two’s complement (the value
$80 is left unchanged).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
Description: Replaces the content of accumulator B with its two’s complement (the value
$80 is left unchanged).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
Description: This single-byte instruction increments the PC and does nothing else. No
other CPU registers are affected. NOP is typically used to produce a time
delay, although some software disciplines discourage CPU
frequency-based time delays. During debug, NOP instructions are
sometimes used to temporarily replace other machine code instructions,
thus disabling the replaced instruction(s).
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
S X H I N Z V C
CCR Details:
⇑ – ⇑ ⇑ ⇑ ⇑ ⇑ ⇑
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.
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
Description: Accumulator A is loaded from the address indicated by the stack pointer.
The SP is then incremented by one.
S X H I N Z V C
CCR Details:
– – – – – – – –
Description: Accumulator B is loaded from the address indicated by the stack pointer.
The SP is then incremented by one.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
∆ ⇓ ∆ ∆ ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
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.
S X H I N Z V C
CCR Details:
– – ? – ? ? ∆ ?
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.
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.
The V status bit signals whether antecedents (0) or consequents (1) are
being processed. V must be initialized to 0 for processing to begin with the
antecedents of the first rule. Once execution begins, the value of V is
automatically changed as $FFFE separators are encountered. At the end of
execution, V should equal 1, because the last element before the $FF end
marker should be a rule consequent. If V is equal to 0 at the end of
execution, the rule list is incorrect.
Fuzzy outputs must be cleared to $00 before processing begins in order for
the MAX algorithm used during consequent processing to work correctly.
Residual output values would cause incorrect comparison.
C b7 – – – – – – b0 C
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
C b7 – – – – – – b0 C
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
C b7 – – – – – – b0 C
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
∆ ⇓ ∆ ∆ ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – – – – 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.
S X H I N Z V C
CCR Details:
– – – 1 – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – 1 –
V: 1; set
Description: This instruction is an alternate mnemonic for the TFR r1,r2 instruction,
where r1 is an 8-bit register and r2 is a 16-bit register. The result in r2 is the
16-bit sign extended representation of the original two’s complement
number in r1. The content of r1 is unchanged in all cases except that of SEX
A,D (D is A : B).
S X H I N Z V C
CCR Details:
– – – – – – – –
0 1 2
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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 CPU context,
stops all system clocks, and puts the device in standby mode.
Asserting the RESET, XIRQ, or IRQ signals ends standby mode. Stacking
on entry to STOP allows the CPU 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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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).
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ ∆ ∆
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 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
Section 7. Exception Processing for more information.
S X H I N Z V C
CCR Details:
– – – 1 – – – –
I: 1; set
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
∆ ⇓ ∆ ∆ ∆ ∆ ∆ ∆
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ – ∆(1)
1. C-bit was undefined in original M68HC12.
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
S X H I N Z V C S X H I N Z V C
CCR Details: Or:
– – – – – – – – ∆ ⇓ ∆ ∆ ∆ ∆ ∆ ∆
None affected, unless the CCR 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.
0 1 2 3 4 5 6 7
0 A⇒A B⇒A CCR ⇒ A TMP3L ⇒ A B⇒A XL ⇒ A YL ⇒ A SPL ⇒ A
2 A ⇒ CCR B ⇒ CCR CCR ⇒ CCR TMP3L ⇒ CCR B ⇒ CCR XL ⇒ CCR YL ⇒ CCR SPL ⇒ CCR
3 sex:A ⇒ TMP2 sex:B ⇒ TMP2 sex:CCR ⇒ TMP2 TMP3 ⇒ TMP2 D ⇒ TMP2 X ⇒ TMP2 Y ⇒ TMP2 SP ⇒ TMP2
sex:A ⇒ D sex:B ⇒ D sex:CCR ⇒ D
4 TMP3 ⇒ D D⇒D X⇒D Y⇒D SP ⇒ D
SEX A,D SEX B,D SEX CCR,D
sex:A ⇒ X sex:B ⇒ X sex:CCR ⇒ X
5 TMP3 ⇒ X D⇒X X⇒X Y⇒X SP ⇒ X
SEX A,X SEX B,X SEX CCR,X
sex:A ⇒ Y sex:B ⇒ Y sex:CCR ⇒ Y
6 TMP3 ⇒ Y D⇒Y X⇒Y Y⇒Y SP ⇒ Y
SEX A,Y SEX B,Y SEX CCR,Y
sex:A ⇒ SP sex:B ⇒ SP sex:CCR ⇒ SP
7 TMP3 ⇒ SP D ⇒ SP X ⇒ SP Y ⇒ SP SP ⇒ SP
SEX A,SP SEX B,SP SEX CCR,SP
Description: Transfers the content of the condition code register to corresponding bit
positions of accumulator A. The CCR remains unchanged.
S X H I N Z V C
CCR Details:
– – – – – – – –
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 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 Section 7. Exception Processing for more
information.
S X H I N Z V C
CCR Details:
– – – 1 – – – –
I: 1; set
Description: Subtracts $00 from the content of memory location M and sets the condition
codes accordingly.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 0
Description: Subtracts $00 from the content of accumulator A and sets the condition
codes accordingly.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 0 0
Description: Subtracts $00 from the content of accumulator B and sets the condition
codes accordingly.
S X H I N Z V C
CCR Details:
– – – – ∆ ∆ 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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
Description: This is an alternate mnemonic to transfer index register X value to the stack
pointer. The content of X is unchanged.
S X H I N Z V C
CCR Details:
– – – – – – – –
Description: This is an alternate mnemonic to transfer index register Y value to the stack
pointer. The content of Y is unchanged.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
Upon leaving the wait state, the CPU sets the appropriate interrupt mask
bit(s), fetches the vector corresponding to the interrupt sensed, and
instruction execution continues at the location the vector points to.
S X H I N Z V C
CCR Details:
– – – – – – – –
Although the WAI instruction itself does not alter the condition codes, the
interrupt that causes the CPU to resume processing also causes the I mask
bit (and the X mask bit, if the interrupt was XIRQ) to be set as the interrupt
vector is fetched.
S X H I N Z V C
CCR Details:
– – ? – ? 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.
S X H I N Z V C
CCR Details:
– – – – – – – –
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.
S X H I N Z V C
CCR Details:
– – – – – – – –
7.1 Introduction
Exceptions are events that require processing outside the normal flow of
instruction execution. This section describes exceptions and the way each
is handled.
Each exception has an associated 16-bit vector, which points to the memory
location where the routine that handles the exception is located. As shown
in Table 7-1, vectors are stored in the upper bytes of the standard 64-Kbyte
address map.
The six highest vector addresses are used for resets and unmaskable
interrupt sources. The remaining vectors are used for maskable interrupts.
All vectors must be programmed to point to the address of the appropriate
service routine.
The CPU12 can handle up to 128 exception vectors, but the number actually
used varies from device to device, and some vectors are reserved for
Freescale use. Refer to Device User Guide for more information.
Exceptions can be classified by the effect of the X and I interrupt mask bits
on recognition of a pending request.
• Resets, the unimplemented opcode trap, and the SWI instruction are
not affected by the X and I mask bits.
• Interrupt service requests from the XIRQ pin are inhibited when X =
1, but are not affected by the I bit.
• All other interrupts are inhibited when I = 1.
The unimplemented page 2 opcode trap (TRAP) and the SWI are special
cases. In one sense, these two exceptions have very low priority, because
any enabled interrupt source that is pending prior to the time exception
processing begins will take precedence. However, once the CPU begins
processing a TRAP or SWI, neither can be interrupted. Also, since these are
mutually exclusive instructions, they have no relative priority.
All remaining interrupts are subject to masking via the I bit in the CCR. Most
HCS12 microcontroller units (MCU) have an external IRQ pin, which is
assigned the highest I-bit interrupt priority and an internal periodic real-time
interrupt generator, which has the next highest priority. The other maskable
sources have default priorities that follow the address order of the interrupt
vectors — the higher the address, the higher the priority of the interrupt.
Other maskable interrupts are associated with on-chip peripherals such as
timers or serial ports. On the HCS12, logic in the device integration module
can give one I-masked source priority over other I-masked sources. Refer
to the documentation for the specific HCS12 derivative for more information.
7.4 Resets
M68HC12 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
CPU12. 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.
During reset, both the I bit and the X bit in the CCR are set. This disables
maskable interrupts and interrupt service requests made by asserting the
XIRQ signal. After minimum system initialization, software can clear the X
bit using an instruction such as ANDCC #$BF. Software cannot set the X bit
from 0 to 1 once it has been cleared, and interrupt requests made via the
XIRQ pin become non-maskable. When a non-maskable interrupt is
recognized, both the X and I bits are set after context is saved. The X bit is
not affected by maskable interrupts. Execution of an return-from-interrupt
(RTI) instruction at the end of the interrupt service routine normally restores
the X and I bits to the pre-interrupt request state.
Once enabled, an interrupt request can be recognized at any time after the
I mask bit is cleared. When an interrupt service request is recognized, the
CPU responds at the completion of the instruction being executed. Interrupt
latency varies according to the number of cycles required to complete the
current instruction. Because the fuzzy logic rule evaluation (REV), fuzzy
logic rule evaluation weighted (REVW), and weighted average (WAV)
instructions can take many cycles to complete, they are designed so that
they can be interrupted. Instruction execution resumes when interrupt
execution is complete. When the CPU begins to service an interrupt, the
instruction queue is refilled, a return address is calculated, and then the
return address and the contents of the CPU registers are stacked as shown
in Table 7-2.
SP + 5 YH : YL
SP + 3 XH : XL
SP + 1 B:A
SP CCR
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. 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.
The I bit serves as the IRQ interrupt enable flag. When an IRQ interrupt is
recognized, the I bit is set to inhibit interrupts during the interrupt service
routine. Before other maskable interrupt requests can be recognized, the I
bit must be cleared. This is generally done by an RTI instruction at the end
of the service routine.
The CPU12 uses the next address after an unimplemented page 2 opcode
as a return address. This differs from the M68HC11 illegal opcode interrupt,
which uses the address of an illegal opcode as the return address. In the
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 CPU 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.
YES
OPCODE TRAP?
NO
T.1 - f INTERNAL CALCULATIONS
1.0 - V FETCH VECTOR
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 OR
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
If reset caused the exception, processing continues to cycle 2.0. This cycle
sets the S, X, and I bits in the CCR. Cycles 3.0 through 5.0 are program
word fetches that refill the instruction queue. Fetches start at the address
pointed to by the reset vector. When the fetches are completed, exception
processing ends, and the CPU starts executing the instruction at the head
of the instruction queue.
8.1 Introduction
This section describes development and debug support features related to
the central processor unit (CPU12). Topics include:
• Single-wire background debug interface
• Hardware breakpoint system
• Instruction queue operation and reconstruction
• Instruction tagging
1 = Valid Data
TRACE — Trace Flag
Indicates when tracing is enabled. Firmware in the BDM ROM sets
TRACE in response to a TRACE1 command and TRACE is cleared upon
completion of the TRACE1 command. Do not attempt to write TRACE
directly with WRITE_BD_BYTE commands.
0 = Tracing not enabled
1 = TRACE1 command in progress
CYCLE 0 CYCLE 1
E CLOCK
E CLOCK
The 0:0 data movement state indicates that there was no data movement in
the instruction queue; the 0:0 execution start state indicates continuation of
an instruction or interrupt sequence (no new instruction or interrupt start).
This code is not used in the HCS12. In the M68HC12, fetched program
information has arrived, but the queue is not ready to advance. The
information is latched into a buffer. Later, when the queue does advance,
stage 1 is refilled from the buffer or from the data bus if the buffer is empty.
In some instruction sequences, there can be several latch cycles before the
queue advances. In these cases, the buffer is filled on the first latch event
and additional latch requests are ignored.
8.3.5 ALD — Advance and Load from Data Bus (Code 1:0)
The instruction queue is advanced by one word and stage one is refilled with
a word of program information from the data bus. The CPU requested the
information two bus cycles earlier but, due to access delays, the information
was not available until the E cycle referred to by the ALD code.
This code is not used in the HCS12. In the M68HC12, the 2-stage instruction
queue is advanced by one word and stage one is refilled with a word of
program information from the buffer. The information was latched from the
data bus at the falling edge of a previous E cycle because the instruction
queue was not ready to advance when it arrived.
The E cycle associated with this code is the first cycle of an interrupt
sequence. Normally, this cycle is a read of the interrupt vector. However, in
systems that have interrupt vectors in external memory and an 8-bit data
bus, this cycle reads the upper byte of the 16-bit interrupt vector.
The E cycle associated with this code is the first cycle of the instruction in
the even (high order) half of the word at the head of the instruction queue.
The queue treats the $18 prebyte for instructions on page 2 of the opcode
map as a special 1-byte, 1-cycle instruction, except that interrupts are not
recognized at the boundary between the prebyte and the rest of the
instruction.
The E cycle associated with this code is the first cycle of the instruction in
the odd (low order) half of the word at the head of the instruction queue. The
queue treats the $18 prebyte for instructions on page 2 of the opcode map
as a special 1-byte, 1-cycle instruction, except that interrupts are not
recognized at the boundary between the prebyte and the rest of the
instruction.
An example:
Systems with an 8-bit data bus and a program stored in external memory
require two cycles for each program word fetch. MCU bus-control logic
freezes the CPU clocks long enough to do two 8-bit accesses rather than
Some MCUs have address lines to support memory expansion beyond the
standard 64-Kbyte address space. When memory expansion is used,
expanded addresses must also be captured and maintained.
These registers contain address and data for the first stage of the
reconstructed instruction queue.
These registers contain address and data for the middle stage of the
reconstructed instruction queue.
These registers contain address and data for the final stage of the
reconstructed instruction queue. When the IPIPE[1:0] signals indicate the
execution status, the address and opcode can be found in these registers.
Typically, the first few cycles of raw capture data are not useful because it
takes several cycles before an instruction propagates to the head of the
queue. During these first raw cycles, the only meaningful information
available is data movement signals. Information on the external address
and data buses during this setup time is still captured and propagated
through the reconstructed queue, but the information reflects the actions of
instructions that were fetched before data collection started.
Figure 8-3 shows the reset sequence and illustrates the relationship
between instruction cycle codes (VfPPP) and pipe status signals. One cycle
of the data bus is shown to indicate the relationship between the ALD data
movement code and the data value it refers to. The SEV execution start
code indicates that the reset vector pointed to an even address in this
example.
INSTRUCTION P P FIRST
V f P
CYCLE CODES USER
INSTRUCTION
E CLOCK DM DM DM EX
DATA BUS
IPIPE[1:0] 00 00 00 00 00 10 00 10 00 10 10
ALD ALD ALD SEV
Implementation details depend upon the type of device and the mode of
operation. For instance, the data bus can be eight bits or 16 bits wide, and
non-multiplexed or multiplexed. In all cases, the externally reconstructed
queue must use 16-bit words. Demultiplexing and assembly of 8-bit data
into 16-bit words is done before program information enters the real queue,
so it must also be done for the external reconstruction.
An example:
Systems with an 8-bit data bus and a program stored in external memory
require two cycles for each program word fetch. MCU bus control logic
freezes the CPU clocks long enough to do two 8-bit accesses rather than
a single 16-bit access, so the CPU sees only 16-bit words of program
information. To recover the 16-bit program words externally, latch the
data bus state at the falling edge of E when ADDR0 = 0, and gate the
outputs of the latch onto DATA[15:8] when a LAT or ALD cycle occurs.
Since the 8-bit data bus is connected to DATA[7:0], the 16-bit word on the
data lines corresponds to the ALD or LAT status indication at the E rise
after the second 8-bit fetch, which is always to an odd address. IPIPE1
and IPIPE0 status signals indicate 0:0 at the beginning (E fall) and middle
(E rise) of the first 8-bit fetch.
These registers contain the address and data from the previous external
bus cycle. Depending on how records are read and processed from the raw
capture information, it may be possible to simply read this information from
the raw capture data file when needed.
These registers buffer address and data for information that was fetched
before the queue was ready to advance.
These registers contain address and data for the first stage of the
reconstructed instruction queue.
These registers contain address and data for the final stage of the
reconstructed instruction queue. When the IPIPE1 and IPIPE0 signals
indicate that an instruction is starting to execute, the address and opcode
can be found in these registers.
This subsection describes in detail how to use IPIPE1 and IPIPE0 signals
and queue reconstruction registers to reconstruct the queue. An “is_full” flag
is used to indicate when the fetch_add and fetch_dat buffer registers
contain information. The use of the flag is explained more fully in
subsequent paragraphs.
Typically, the first few cycles of raw capture data are not useful because it
takes several cycles before an instruction propagates to the head of the
queue. During these first raw cycles, the only meaningful information
available are data movement signals. Information on the external address
and data buses during this setup time reflects the actions of instructions that
were fetched before data collection started.
Before starting to reconstruct the queue, clear the is_full flag to indicate that
there is no meaningful information in the fetch_add and fetch_dat buffers.
Further movement of information in the instruction queue is based on the
decoded status on the IPIPE1 and IPIPE0 signals at the rising edges of E.
On a latch cycle (LAT), check the is_full flag. If and only if is_full = 0, transfer
the address and data from the previous bus cycle (in_add and in_dat) into
the fetch_add and fetch_dat registers, respectively. Then, set the is_full
flag. The usual reason for a latch request instead of an advance request is
that the previous instruction ended with a single aligned byte of program
information in the last stage of the instruction queue. Since the odd half of
this word still holds the opcode for the next instruction, the queue cannot
advance on this cycle. However, the cycle to fetch the next word of program
information has already started and the data is on its way.
Figure 8-4 shows the reset sequence and illustrates the relationship
between instruction cycle codes (VfPPP) and pipe status signals. One cycle
of the data bus is shown to indicate the relationship between the ALD data
movement code and the data value it refers to. The SEV execution start
code indicates that the reset vector pointed to an even address in this
example.
INSTRUCTION P P
V f P
CYCLE CODES FIRST USER
INSTRUCTION
E CLOCK
DM DM EX DM
DATA BUS
IPIPE[1:0] 00 00 00 00 00 00 10 00 10 10 10
ALD ALD SEV ALD
Executing the BDM TAGGO command configures two MCU pins for
tagging. The TAGLO signal shares a pin with the LSTRB signal, and the
TAGHI signal shares the BKGD pin. Tagging information is latched on the
falling edge of ECLK, as shown in Figure 8-5.
E CLOCK
TAGLO
LSTRB/TAGLO LSTRB VALID VALID
TAGHI
BKGD/TAGHI VALID
Table 8-2 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.
9.1 Introduction
The instruction set of the central processor unit (CPU12) 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
fuzzy logic instructions, and provides examples of fuzzy logic programs.
The CPU12 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 CPU12 instructions.
SYSTEM
KNOWLEDGE INPUTS
BASE
FUZZY
INFERENCE
KERNEL
INPUT
MEMBERSHIP FUZZIFICATION
FUNCTIONS
… FUZZY INPUTS
(IN RAM)
FUZZY OUTPUTS
… (IN RAM)
OUTPUT
MEMBERSHIP DEFUZZIFICATION
FUNCTIONS
SYSTEM
OUTPUTS
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.
During the fuzzification step, the current system input values are compared
against stored input membership functions to determine the degree to which
each label of each system input is true. This is accomplished by finding the
y-value for the current input value on a trapezoidal membership function for
each label of each system input. The MEM instruction in the CPU12
performs this calculation for one label of one system input. To perform the
complete fuzzification task for a system, several MEM instructions must be
executed, usually in a program loop structure.
Figure 9-2 shows a system of three input membership functions, one for
each label of the system input. The x-axis of all three membership functions
represents the range of possible values of the system input. The vertical line
through all three membership functions represents a specific system input
value. The y-axis represents degree of truth and varies from completely
false ($00 or 0 percent) to completely true ($FF or 100 percent). The y-value
where the vertical line intersects each of the membership functions, is the
degree to which the current input value matches the associated label for this
system input. For example, the expression “temperature is warm” is 25
MEMBERSHIP FUNCTIONS
FOR TEMPERATURE FUZZY INPUTS
$FF
HOT
$C0
$80
$40 TEMPERATURE IS HOT $00
$00
$FF
WARM
$C0
$80
$40 TEMPERATURE IS WARM $40
$00
$FF
COLD
$C0
$80
$40 TEMPERATURE IS COLD $C0
$00
CURRENT
TEMPERATURE
IS 64°F
When the fuzzification step begins, the current value of the system input is
in an accumulator of the CPU12, 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 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.
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
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 Freescale 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, 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 final step in the fuzzy logic program combines the raw fuzzy outputs into
a composite system output. Unlike the trapezoidal shapes used for inputs,
the CPU12 typically uses singletons for output membership functions. As
with the inputs, the x-axis represents the range of possible values for a
system output. Singleton membership functions consist of the x-axis
position for a label of the system output. Fuzzy outputs correspond to the
y-axis height of the corresponding output membership function.
The WAV instruction calculates the numerator and denominator sums for
weighted average of the fuzzy outputs according to the formula:
n
∑ Si Fi
i=1
System Output = -----------------------
n
∑ Fi
i=1
*
01 [2] FUZZIFY LDX #INPUT_MFS ;Point at MF definitions
02 [2] LDY #FUZ_INS ;Point at fuzzy input table
03 [3] LDAA CURRENT_INS ;Get first input value
04 [1] LDAB #7 ;7 labels per input
05 [5] GRAD_LOOP MEM ;Evaluate one MF
06 [3] DBNE B,GRAD_LOOP ;For 7 labels of 1 input
07 [3] LDAA CURRENT_INS+1 ;Get second input value
08 [1] LDAB #7 ;7 labels per input
09 [5] GRAD_LOOP1 MEM ;Evaluate one MF
10 [3] DBNE B,GRAD_LOOP1 ;For 7 labels of 1 input
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
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.
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.
Lines 12 and 13 form a loop to clear all fuzzy outputs before rule evaluation
starts.
Line 14 initializes the X index register to point at the first element in the rule
list for the REV instruction.
Line 15 initializes the Y index register to point at the fuzzy inputs and outputs
in the system. The rule list (for REV) consists of 8-bit offsets from this base
address to particular fuzzy inputs or fuzzy outputs. The special value $FE is
interpreted by REV as a marker between rule antecedents and
consequents.
Lines 18 through 20 set up pointers and an iteration count for the WAV
instruction.
$FF
$E0
$C0
$A0
DEGREE
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))
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 9.4.2 Abnormal
Membership Function Definitions for a discussion of these cases.
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.
Although a good fuzzy development tool will not allow the user to specify an
improper membership function, it is possible to have program errors or
memory errors which result in erroneous abnormal membership functions.
Although these abnormal shapes do not correspond to any working
systems, understanding how the CPU12 treats these cases 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 Section 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).
The flag_d12n is zero as long as the input value (in accumulator A) is within
the trapezoid. Everywhere outside the trapezoid, one or the other delta term
will be negative, and the flag will equal one. Slope_2 equals zero indicates
the right side of the trapezoid has infinite slope, so the resulting grade
should be $FF everywhere in the trapezoid, including at point_2, as far as
this side is concerned. The term grade_2 greater than $FF means the value
is far enough into the trapezoid that the right sloping side of the trapezoid
has crossed above the $FF cutoff level and the resulting grade should be
$FF as far as the right sloping side is concerned. 4a decides if the value is
left of the right sloping side (Grade = $FF), or on the sloping portion of the
right side of the trapezoid (Grade = Grade_2). 4b could still override this
tentative value in grade.
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
In 4b, slope_1 is zero if the left side of the trapezoid has infinite slope
(vertical). If so, the result (grade) should be $FF at and to the right of point_1
everywhere within the trapezoid as far as the left side is concerned. The
grade_1 greater than $FF term corresponds to the input being to the right of
where the left sloping side passes the $FF cutoff level. If either of these
conditions is true, the result (grade) is left at the value it got from 4a. The
“else” condition in 4b corresponds to the input falling on the sloping portion
of the left side of the trapezoid (or possibly outside the trapezoid), so the
result is grade equal grade_1. If the input was outside the trapezoid,
flag_d12n would be one and grade_1 and grade_2 would have been forced
to $00 in cycle 3. The else condition of 4b would set the result to $00.
MEMORY DEFINITION: $60, $80, $04, $04; point_1, point_2, slope_1, slope_2
P1 P2 P1 P2
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
MEMORY DEFINITION: $60, $80, $00, $04; point_1, point_2, slope_1, slope_2
P1 P2 P1 P2
The X index register is set to the address of the first element in the rule list
(in the knowledge base). The REV instruction automatically updates this
pointer so that the instruction can resume correctly if it is interrupted. After
the REV instruction finishes, X will point at the next address past the $FF
separator character that marks the end of the rule list.
Before starting to execute REV, 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 $FE marker
character between the last consequent of the previous rule and the first
antecedent of a new rule.
The instruction LDAA #$FF clears the V bit at the same time it initializes A
to $FF. This satisfies the REV setup requirement to clear the V bit as well
as the requirement to initialize A to $FF. Once the REV instruction starts, the
value in the V bit is automatically maintained as $FE separator characters
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 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 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.
The REV instruction includes a 3-cycle processing loop for each byte in the
rule list (including antecedents, consequents, and special separator
characters). Within this loop, a check is performed to see if any qualified
interrupt request is pending. If an interrupt is detected, the current CPU
registers are stacked and the interrupt is honored. When the interrupt
service routine finishes, an RTI instruction causes the CPU to recover its
previous context from the stack, and the REV instruction is resumed as if it
had not been interrupted.
The central element of the REV instruction is a 3-cycle loop that is executed
once for each byte in the rule list. There is a small amount of housekeeping
activity to get this loop started as REV begins and a small sequence to end
the instruction. If an interrupt comes, there is a special small sequence to
save CPU status on the stack before honoring the requested interrupt.
When a value is read from memory, it cannot be used by the CPU until the
second cycle after the read takes place. This is due to access and
propagation delays.
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 CPU12 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 CPU12 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
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.
The X index register is set to the address of the first element in the rule list
(in the knowledge base). The REVW instruction automatically updates this
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.
The REVW instruction includes a 3-cycle processing loop for each word in
the rule list (this loop expands to five cycles between antecedents and
consequents to allow time for the multiplication with the rule weight). Within
this loop, a check is performed to see if any qualified interrupt request is
pending. If an interrupt is detected, the current CPU registers are stacked
and the interrupt is honored. When the interrupt service routine finishes, an
RTI instruction causes the CPU to recover its previous context from the
stack, and the REVW instruction is resumed as if it had not been interrupted.
Figure 9-10 is a detailed flow diagram for the REVW instruction. Each
rectangular box represents one CPU clock cycle. Decision blocks and
connecting arrows are considered to take no time at all. The letters in the
small rectangles in the upper left corner of each bold box correspond to the
execution cycle codes (refer to Section 6. Instruction Glossary for
details). Lower case letters indicate a cycle where 8-bit or no data is
transferred. Upper case letters indicate cycles where 16-bit data could be
transferred.
NO YES
INTERRUPT PENDING?
END
The operations performed in cycle 4.0 depend on the value of the word read
from the rule list. $FFFE is a special token that indicates a transition from
antecedents to consequents or from consequents to antecedents of a new
rule. The V bit can be used to decide which transition is taking place, and V
is toggled each time the $FFFE token is detected. If V was zero, a change
from antecedents to consequents is taking place, and it is time to apply
weighting (provided it is enabled by the C bit equal one). The address in
TMP2 (derived from Y) is used to read the weight byte from memory. In this
case, there is no bus access in cycle 5.0, but the index into the rule list is
updated to point to the next rule element.
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.
The WAV instruction includes a 7-cycle processing loop for each label of the
system output (8 cycles in M68HC12). Within this loop, the CPU checks
whether a qualified interrupt request is pending. If an interrupt is detected,
the current values of the internal temporary registers for the 24-bit and 16-bit
sums are stacked, the CPU registers are stacked, and the interrupt is
serviced.
A special processing sequence is executed when an interrupt is detected
during a weighted average calculation. This exit sequence adjusts the PC
so that it points to the second byte of the WAV object code ($3C), before the
PC is stacked. Upon return from the interrupt, the $3C value is interpreted
as a wavr pseudo-instruction. The wavr pseudo-instruction causes the CPU
to execute a special WAV resumption sequence. The wavr recovery
sequence adjusts the PC so that it looks like it did during execution of the
original WAV instruction, then jumps back into the WAV processing loop. If
another interrupt occurs before the weighted average calculation finishes,
the PC is adjusted again as it was for the first interrupt. WAV can be
interrupted any number of times, and additional WAV instructions can be
executed while a WAV instruction is interrupted.
The WAV instruction is unusual in that the logic flow has two separate entry
points. The first entry point is the normal start of a WAV instruction. The
second entry point is used to resume the weighted average operation after
a WAV instruction has been interrupted. This recovery operation is called
the wavr pseudo-instruction.
Figure 9-12 is a flow diagram of the WAV instruction in the HCS12,
including the wavr pseudo-instruction. Figure 9-12 is a flow diagram of the
WAV instruction in the M68HC12, including the wavr pseudo-instruction.
Each rectangular box in these figures represents one CPU clock cycle.
Decision blocks and connecting arrows are considered to take no time at all.
The letters in the small rectangles in the upper left corner of the boxes
correspond to execution cycle codes (refer to Section 6. Instruction
Glossary for details). Lower case letters indicate a cycle where 8-bit or no
data is transferred. Upper case letters indicate cycles where 16-bit data
could be transferred.
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
Figure 9-11. WAV and wavr Instruction Flow Diagram (for HCS12)
5.0 - r READ BYTE @ 0,Y (FUZZY OUTPUT Fi) 5.1 - r READ BYTE @ –1,Y (FUZZY OUTPUT Fi)
Y = Y + 1 point at next fuzzy output
6.1 - r READ BYTE @ –1,X (SINGLETON Si)
6.0 - r READ BYTE @ 0,X (SINGLETON Si)
X = X + 1 POINT AT NEXT SINGLETON
YES
INTERRUPT PENDING?
NO
NO
B = 0?
YES
END
Figure 9-12. WAV and wavr Instruction Flow Diagram (for M68HC12)
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.
The TBL instruction uses 8-bit table entries (y-values) and returns an 8-bit
result. The ETBL instruction uses 16-bit table entries (y-values) and returns
a 16-bit result. A flexible indexed addressing mode is used to identify the
effective address of the data point at the beginning of the line segment, and
the data value for the end point of the line segment is the next consecutive
memory location (byte for TBL and word for ETBL). In both cases, the B
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 TBL and ETBL instructions because
the table instructions expect y-values for segment endpoints to be in
consecutive memory locations.
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.
The REV and REVW instructions expect fuzzy input and fuzzy output values
to be 8-bit values. In a custom fuzzy inference program, higher resolution
may be desirable (although this is not a common requirement). The CPU12
includes variations of minimum and maximum operations that work with the
fuzzy MIN-MAX inference algorithm. The problem with the fuzzy inference
algorithm is that the min and max operations need to store their results
differently, so the min and max instructions must work differently or more
than one variation of these instructions is needed.
The CPU12 has MIN and MAX instructions for 8- or 16-bit operands, where
one operand is in an accumulator and the other is a referenced memory
location. There are separate variations that replace the accumulator or the
memory location with the result. While processing rule antecedents in a
fuzzy inference program, a reference value must be compared to each of
the referenced fuzzy inputs, and the smallest input must end up in an
accumulator. The instruction
EMIND 2,X+ ;process one rule antecedent
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.
There are many other methods of performing inference, but none of these
are as widely used as the min-max method. Since the CPU12 is a
general-purpose microcontroller, 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.
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.
A.1 Introduction
This appendix provides quick references for the instruction set, opcode
map, and encoding.
15 X 0 INDEX REGISTER X
15 Y 0 INDEX REGISTER Y
15 SP 0 STACK POINTER
15 PC 0 PROGRAM COUNTER
CARRY
OVERFLOW
ZERO
NEGATIVE
MASK (DISABLE) IRQ INTERRUPTS
HALF-CARRY
(USED IN BCD ARITHMETIC)
YLO
YHI
XLO
XHI
A
B
SP AFTER
INTERRUPT CCR
LOWER ADDRESSES
STACK UPON ENTRY TO SERVICE ROUTINE STACK UPON ENTRY TO SERVICE ROUTINE
IF SP WAS ODD BEFORE INTERRUPT IF SP WAS EVEN BEFORE INTERRUPT
SP +8 RTNLO SP +9 SP +9 SP +10
SP +6 YLO RTNHI SP +7 SP +7 RTNHI RTNLO SP +8
SP +4 XLO YHI SP +5 SP +5 YHI YLO SP +6
SP +2 A XHI SP +3 SP +4 XHI XLO SP +4
SP CCR B SP +1 SP +1 B A SP +2
SP –2 SP –1 SP –1 CCR SP
Operators
+ — Addition
– — Subtraction
• — Logical AND
+ — Logical OR (inclusive)
Continued on next page
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 on page 399.
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 on page 400.
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.
Access Detail
Each code letter except (,), and comma equals one CPU cycle. Uppercase = 16-bit
operation and lowercase = 8-bit operation. For complex sequences see the CPU12
Reference Manual (CPU12RM/AD) for more detailed information.
16 by 16 Bit ⇒ 32 Bit
Multiply and Accumulate (signed)
EMAXD oprx0_xysp MAX((D), (M:M+1)) ⇒ D IDX 18 1A xb ORPf ORfP –––– ∆∆∆∆
EMAXD oprx9,xysp MAX of 2 Unsigned 16-Bit Values IDX1 18 1A xb ff ORPO ORPO
EMAXD oprx16,xysp IDX2 18 1A xb ee ff OfRPP OfRPP
EMAXD [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1A xb OfIfRPf OfIfRfP
EMAXD [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1A xb ee ff OfIPRPf OfIPRfP
EMAXM oprx0_xysp MAX((D), (M:M+1)) ⇒ M:M+1 IDX 18 1E xb ORPW ORPW –––– ∆∆∆∆
EMAXM oprx9,xysp MAX of 2 Unsigned 16-Bit Values IDX1 18 1E xb ff ORPWO ORPWO
EMAXM oprx16,xysp IDX2 18 1E xb ee ff OfRPWP OfRPWP
EMAXM [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1E xb OfIfRPW OfIfRPW
EMAXM [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1E xb ee ff OfIPRPW OfIPRPW
EMIND oprx0_xysp MIN((D), (M:M+1)) ⇒ D IDX 18 1B xb ORPf ORfP –––– ∆∆∆∆
EMIND oprx9,xysp MIN of 2 Unsigned 16-Bit Values IDX1 18 1B xb ff ORPO ORPO
EMIND oprx16,xysp IDX2 18 1B xb ee ff OfRPP OfRPP
EMIND [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1B xb OfIfRPf OfIfRfP
EMIND [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1B xb ee ff OfIPRPf OfIPRfP
EMINM oprx0_xysp MIN((D), (M:M+1)) ⇒ M:M+1 IDX 18 1F xb ORPW ORPW –––– ∆∆∆∆
EMINM oprx9,xysp MIN of 2 Unsigned 16-Bit Values IDX1 18 1F xb ff ORPWO ORPWO
EMINM oprx16,xysp IDX2 18 1F xb ee ff OfRPWP OfRPWP
EMINM [D,xysp] N, Z, V and C status bits reflect result of [D,IDX] 18 1F xb OfIfRPW OfIfRPW
EMINM [oprx16,xysp] internal compare ((D) – (M:M+1)) [IDX2] 18 1F xb ee ff OfIPRPW OfIPRPW
EMUL (D) × (Y) ⇒ Y:D INH 13 ffO ffO –––– ∆∆–∆
16 by 16 Bit Multiply (unsigned)
EMULS (D) × (Y) ⇒ Y:D INH 18 13 OfO OfO –––– ∆∆–∆
16 by 16 Bit Multiply (signed) (if followed by page 2 instruction)
OffO OfO
EORA #opr8i (A) ⊕ (M) ⇒ A IMM 88 ii P P –––– ∆∆0–
EORA opr8a Exclusive-OR A with Memory DIR 98 dd rPf rfP
EORA opr16a EXT B8 hh ll rPO rOP
EORA oprx0_xysp IDX A8 xb rPf rfP
EORA oprx9,xysp IDX1 A8 xb ff rPO rPO
EORA oprx16,xysp IDX2 A8 xb ee ff frPP frPP
EORA [D,xysp] [D,IDX] A8 xb fIfrPf fIfrfP
EORA [oprx16,xysp] [IDX2] A8 xb ee ff fIPrPf fIPrfP
Notes:
1. Due to internal CPU requirements, the program word fetch is performed twice to the same address during this instruction.
2. opr16a is an extended address specification. Both X and Y point to source operands.
EORB #opr8i (B) ⊕ (M) ⇒ B IMM C8 ii P P –––– ∆∆0–
EORB opr8a Exclusive-OR B with Memory DIR D8 dd rPf rfP
EORB opr16a EXT F8 hh ll rPO rOP
EORB oprx0_xysp IDX E8 xb rPf rfP
EORB oprx9,xysp IDX1 E8 xb ff rPO rPO
EORB oprx16,xysp IDX2 E8 xb ee ff frPP frPP
EORB [D,xysp] [D,IDX] E8 xb fIfrPf fIfrfP
EORB [oprx16,xysp] [IDX2] E8 xb ee ff fIPrPf fIPrfP
r1 and r2 may be
A, B, CCR, D, X, Y, or SP
FDIV (D) ÷ (X) ⇒ X; Remainder ⇒ D INH 18 11 OffffffffffO OffffffffffO –––– –∆∆∆
16 by 16 Bit Fractional Divide
IBEQ abdxys, rel9 (cntr) + 1⇒ cntr REL 04 lb rr PPP (branch) PPP –––– ––––
If (cntr) = 0, then Branch (9-bit) PPO (no
else Continue to next instruction branch)
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 4 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
MOVB EMIND LBMI REVW TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IM-EX 5 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
0C 6 1C 4-7 2C 4/3 3C ‡†7B 4C 10 5C 10 6C 10 7C 10 8C 10 9C 10 AC 10 BC 10 CC 10 DC 10 EC 10 FC 10
MOVB MAXM LBGE WAV TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
EX-EX 6 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
0D 5 1D D4-7 2D 4/3 3D ‡6 4D 10 5D 10 6D 10 7D 10 8D 10 9D 10 AD 10 BD 10 CD 10 DD 10 ED 10 FD 10
MOVB MINM LBLT TBL TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
ID-EX 5 ID 3-5 RL 4 ID 3 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
0E 2 1E 4-7 2E 4/3 3E ‡8 4E 10 5E 10 6E 10 7E 10 8E 10 9E 10 AE 10 BE 10 CE 10 DE 10 EE 10 FE 10
Freescale Semiconductor
TAB EMAXM LBGT STOP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IH 2 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
0F 2 1F 4-7 2F 4/3 3F 10 4F 10 5F 10 6F 10 7F 10 8F 10 9F 10 AF 10 BF 10 CF 10 DF 10 EF 10 FF 10
TBA EMINM LBLE ETBL TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP TRAP
IH 2 ID 3-5 RL 4 ID 3 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2 IH 2
* The opcode $04 (on sheet 1 of 2) corresponds to one of the loop primitive instructions DBEQ, DBNE, IBEQ, IBNE, TBEQ, or TBNE.
† Refer to instruction summary for more information.
‡ Refer to instruction summary for different HC12 cycle count.
Page 2: When the CPU 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.
Freescale Semiconductor
Table A-3. Indexed Addressing Mode Postbyte Encoding (xb)
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
S12CPUV2 Reference Manual, Rev. 4.0
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
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 A offset A offset
0D 1D 2D 3D 4D 5D 6D 7D 8D 9D AD BD CD DD ED FD
13,X –3,X 3,–X 3,X– 13,Y –3,Y 3,–Y 3,Y– 13,SP –3,SP 3,–SP 3,SP– 13,PC –3,PC B,Y B,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 B offset B offset
0E 1E 2E 3E 4E 5E 6E 7E 8E 9E AE BE CE DE EE FE
14,X –2,X 2,–X 2,X– 14,Y –2,Y 2,–Y 2,Y– 14,SP –2,SP 2,–SP 2,SP– 14,PC –2,PC D,Y D,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 D offset D offset
0F 1F 2F 3F 4F 5F 6F 7F 8F 9F AF BF CF DF EF FF
15,X –1,X 1,–X 1,X– 15,Y –1,Y 1,–Y 1,Y– 15,SP –1,SP 1,–SP 1,SP– 15,PC –1,PC [D,Y] [D,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 D indirect D indirect
2 A ⇒ CCR B ⇒ CCR CCR ⇒ CCR TMP3L ⇒ CCR B ⇒ CCR XL ⇒ CCR YL ⇒ CCR SPL ⇒ CCR
3 sex:A ⇒ TMP2 sex:B ⇒ TMP2 sex:CCR ⇒ TMP2 TMP3 ⇒ TMP2 D ⇒ TMP2 X ⇒ TMP2 Y ⇒ TMP2 SP ⇒ TMP2
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
(+) (–) (+) (–) (+) (–) (+) (–) (+) (–) (+) (–)
B.1 Introduction
This appendix discusses similarities and differences between the CPU12
and the M68HC11 CPU. In general, the CPU12 is a proper superset of the
M68HC11. Significant changes have been made to improve the efficiency
and capabilities of the CPU12 without eliminating compatibility and
familiarity for the large community of M68HC11 programmers.
The CPU12 supports all M68HC11 addressing modes and includes several
new variations of indexed addressing mode. CPU12 instructions affect
condition code bits in the same way as M68HC11 instructions.
CPU12 object code is similar to but not identical to M68HC11 object code.
Some primary objectives, such as the elimination of the penalty for using Y,
could not be achieved without object code differences. While the object
code has been changed, the majority of the opcodes are identical to those
of the M6800, which was developed more than 20 years earlier.
All of the translations produce the same amount of or slightly more object
code than the original M68HC11 instructions. However, there are offsetting
savings in other instructions. Y-indexed instructions in particular assemble
into one byte less object code than the same M68HC11 instruction.
The CPU12 has a 2-page opcode map, rather than the 4-page M68HC11
map. This is largely due to redesign of the indexed addressing modes. Most
of pages 2, 3, and 4 of the M68HC11 opcode map are required because
Y-indexed instructions use different opcodes than X-indexed instructions.
Approximately two-thirds of the M68HC11 page 1 opcodes are unchanged
in CPU12, and some M68HC11 opcodes have been moved to page 1 of the
CPU12 opcode map. Object code for each of the moved instructions is one
byte smaller than object code for the equivalent M68HC11 instruction.
Table B-2 shows instructions that assemble to one byte less object code on
the CPU12.
The relative size of code for M68HC11 vs. code for CPU12 has also been
tested by rewriting several smaller programs from scratch. In these cases,
the CPU12 code is typically about 30 percent smaller. These savings are
mostly due to improved indexed addressing.
The CPU12 is a 16-bit processor with 16-bit data paths. Typical HCS12 and
M68HC12 devices have internal and external 16-bit data paths, but some
derivatives incorporate operating modes that allow for an 8-bit data bus, so
that a system can be built with low-cost 8-bit program memory. HCS12 and
M68HC12 MCUs include an on-chip integration module that manages the
external bus interface. When the CPU makes a 16-bit access to a resource
that is served by an 8-bit bus, the integration module performs two 8-bit
accesses, freezes the CPU clocks for part of the sequence, and assembles
the data into a 16-bit word. As far as the CPU is concerned, there is no
difference between this access and a 16-bit access to an internal resource
via the 16-bit data bus. This is similar to the way an M68HC11 can stretch
clock cycles to accommodate slow peripherals.
The CPU12 has a 2-word instruction queue and a 16-bit holding buffer,
which sometimes acts as a third word for queueing program information. All
program information is fetched from memory as aligned 16-bit words, even
though there is no requirement for instructions to begin or end on even word
boundaries. There is no penalty for misaligned instructions. If a program
begins on an odd boundary (if the reset vector is an odd address), program
information is fetched to fill the instruction queue, beginning with the aligned
word at the next address below the misaligned reset vector. The instruction
queue logic starts execution with the opcode in the low-order half of this
word.
The CPU is not aware of instruction alignment. The queue logic includes a
multiplexer that sorts out the information in the queue to present the opcode
and the next two bytes of information as CPU inputs. The multiplexer
determines whether the opcode is in the even or odd half of the word at the
head of the queue. Alignment status is also available to the ALU for address
calculations. The execution sequence for all instructions is independent of
the alignment of the instruction.
The only situation where alignment can affect the number of cycles an
instruction takes occurs in devices that have a narrow (8-bit) external data
bus and is related to optional program fetch cycles (O type cycles). O cycles
are always performed, but serve different purposes determined by
instruction size and alignment.
Each instruction includes one program fetch cycle for every two bytes of
object code. Instructions with an odd number of bytes can use an O cycle to
fetch an extra word of object code. If the queue is aligned at the start of an
instruction with an odd byte count, the last byte of object code shares a
queue word with the opcode of the next instruction. Since this word holds
part of the next instruction, the queue cannot advance after the odd byte
executes because the first byte of the next instruction would be lost. In this
case, the O cycle appears as a free cycle since the queue is not ready to
accept the next word of program information. If this same instruction had
Both the M68HC11 and the CPU12 stack nine bytes for interrupts. Since this
is an odd number of bytes, there is no practical way to ensure that the stack
will stay aligned. To ensure that instructions take a fixed number of cycles
regardless of stack alignment, the internal RAM in M68HC12 MCUs is
designed to allow single cycle 16-bit accesses to misaligned addresses. As
long as the stack is located in this special RAM, stacking and unstacking
operations take the same amount of execution time, regardless of stack
alignment. If the stack is located in an external 16-bit RAM, a PSHX
instruction can take two or three cycles depending on the alignment of the
stack. This extra access time is transparent to the CPU because the
integration module freezes the CPU clocks while it performs the extra 8-bit
bus cycle required for a misaligned stack operation.
The CPU12 has a “last-used” stack rather than a “next-available” stack like
the M68HC11 CPU. That is, the stack pointer points to the last 16-bit stack
address used, rather than to the address of the next available stack location.
This generally has very little effect, because it is very unusual to access
stacked information using absolute addressing. The change allows a 16-bit
word of data to be removed from the stack without changing the value of the
SP twice.
The change completely eliminates pages three and four of the M68HC11
opcode map and eliminates almost all instructions from page two of the
opcode map. For offsets of 0 to +15 from the X index register, the object
code is the same size as it was for the M68HC11. For offsets of 0 to +15
from the Y index register, the object code is one byte smaller than it was for
the M68HC11.
Table A-3 and Table A-4 summarize CPU12 indexed addressing mode
capabilities. Table A-6 shows how the postbyte is encoded.
The 5-bit constant offset variation covers the most frequent indexing
requirements by including the offset in the postbyte. This reduces a load
accumulator indexed instruction to two bytes of object code, and matches
the object code size of the smallest M68HC11 indexed instructions, which
can only use X as the index register. The CPU12 can use X, Y, SP, or PC
as the index reference with no additional object code size cost.
The signed 9-bit constant offset indexing mode covers the same positive
range as the M68HC11 8-bit unsigned offset. The size was increased to
nine bits with the sign bit (ninth bit) included in the postbyte, and the
remaining 8 bits of the offset in a single extension byte.
The 16-bit constant offset indexing mode allows indexed access to the
entire normal 64-Kbyte address space. Since the address consists of 16
bits, the 16-bit offset can be regarded as a signed (–32,768 to +32,767) or
unsigned (0 to 65,535) value. In 16-bit constant offset mode, the offset is
supplied in two extension bytes after the opcode and postbyte.
18 A6 00 LDAA 0,Y
18 08 INY A6 71 LDAA 2,Y+
18 08 INY
The M68HC11 object code requires seven bytes, while the CPU12 requires
only two bytes to accomplish the same functions. Three bytes of M68HC11
code were due to the page prebyte for each Y-related instruction ($18).
CPU12 post-increment indexing capability allowed the two INY instructions
to be absorbed into the LDAA indexed instruction. The replacement code is
not identical to the original 3-instruction sequence because the Z condition
code bit is affected by the M68HC11 INY instructions, while the Z bit in the
CPU12 would be determined by the value loaded into A.
The CPU12 object code is only one byte smaller, but the LDX # instruction
is outside the loop. It is not necessary to reload the base address in the
index register on each pass through the loop because the LDAA B,X
instruction does not alter the index register. This reduces the loop execution
time from 15 cycles to six cycles. This reduction, combined with the 25-MHz
bus speed of the HCS12 (M68HC12) Family, can have significant effects.
The CPU12 allows some forms of indexed indirect addressing where the
instruction points to a location in memory where the address of the operand
is stored. This is an extra level of indirection compared to ordinary indexed
addressing. The two forms of indexed indirect addressing are 16-bit
constant offset indexed indirect and D accumulator indexed indirect. The
reference index register can be X, Y, SP, or PC as in other CPU12 indexed
addressing modes. PC-relative indirect addressing is one of the more
common uses of indexed indirect addressing. The indirect variations of
indexed addressing help in the implementation of pointers. D accumulator
indexed indirect addressing can be used to implement a runtime computed
GOTO function. Indirect addressing is also useful in high-level language
compilers. For instance, PC-relative indirect indexing can be used to
efficiently implement some C case statements.
No M68HC11 instruction takes less than two cycles, but the CPU12 has
more than 50 opcodes that take only one cycle. Some of the reduction
comes from the instruction queue, which ensures that several program
bytes are available at the start of each instruction. Other cycle reductions
occur because the CPU12 can fetch 16 bits of information at a time, rather
than eight bits at a time.
The CPU12 has some of the fastest math ever designed into a Freescale
general-purpose MCU. Much of the speed is due to a 20-bit ALU that can
perform two smaller operations simultaneously. The ALU can also perform
two operations in a single bus cycle in certain cases.
Table B-3 compares the speed of CPU12 and M68HC11 math instructions.
The CPU12 requires fewer cycles to perform an operation, and the cycle
time is considerably faster than that of the M68HC11.
Other CPU12 code space reductions are more subtle. Memory-to- memory
moves are one example. The CPU12 move instruction requires almost as
many bytes as an equivalent sequence of M68HC11 instructions, but the
move operations themselves do not require the use of an accumulator. This
means that the accumulator often need not be saved and restored, which
saves instructions.
The M68HC11 has only eight transfer instructions and two exchange
instructions. The CPU12 has a universal transfer/exchange instruction that
can be used to transfer or exchange data between any two CPU registers.
The operation is obvious when the two registers are the same size, but
some of the other combinations provide very useful results. For example
when an 8-bit register is transferred to a 16-bit register, a sign-extend
operation is performed. Other combinations can be used to perform a
zero-extend operation.
The CPU12 instruction set includes a new family of six loop primitive
instructions. These instructions decrement, increment, or test a loop count
in a CPU register and then branch based on a zero or non-zero test result.
The CPU registers that can be used for the loop count are A, B, D, X, Y, or
All of the branch instructions from the M68HC11 are also available with
16-bit offsets which allows them to reach any location in the 64-Kbyte
address space.
Control programs often need to restrict data values within upper and lower
limits. The CPU12 facilitates this function with 8- and 16-bit versions of MIN
and MAX instructions. Each of these instructions has a version that stores
the result in either the accumulator or in memory.
For example, in a fuzzy logic inference program, rule evaluation consists of
a series of MIN and MAX operations. The min operation is used to
determine the smallest rule input (the running result is held in an
accumulator), and the max operation is used to store the largest rule truth
value (in an accumulator) or the previous fuzzy output value (in a RAM
location) to the fuzzy output in RAM. The following code demonstrates how
MIN and MAX instructions can be used to evaluate a rule with four inputs
and two outputs.
LDY #OUT1 ;Point at first output
LDX #IN1 ;Point at first input value
LDAA #$FF ;start with largest 8-bit number in A
MINA 1,X+ ;A=MIN(A,IN1)
MINA 1,X+ ;A=MIN(A,IN2)
MINA 1,X+ ;A=MIN(A,IN3)
MINA 1,X+ ;A=MIN(A,IN4) so A holds smallest input
MAXM 1,Y+ ;OUT1=MAX(A,OUT1) and A is unchanged
MAXM 1,Y+ ;OUT1=MAX(A,OUT2) A still has min input
The “,PCR” notation is also new for the CPU12. This notation indicates the
programmer wants an appropriate offset from the PC reference to the
memory location (HILIMIT or LOWLIMIT in this example), and then to
assemble this instruction into a PC-relative indexed MIN or MAX instruction.
The CPU12 includes four instructions (MEM, REV, REVW, and WAV)
specifically designed to support fuzzy logic programs. These instructions
have a very small impact on the size of the CPU and even less impact on
the cost of a complete MCU. At the same time, these instructions
dramatically reduce the object code size and execution time for a fuzzy logic
inference program. A kernel written for the M68HC11 required about 250
bytes and executed in about 750 milliseconds. The CPU12 kernel uses
about 50 bytes and executes in about 16 microseconds (in a 25-MHz
HCS12).
The CPU12 instruction set includes two instructions (TBL and ETBL) for
lookup and interpolation of compressed tables. Consecutive table values
are assumed to be the x coordinates of the endpoints of a line segment. The
TBL instruction uses 8-bit table entries (y-values) and returns an 8-bit result.
The ETBL instruction uses 16-bit table entries (y-values) and returns a
16-bit result.
The M68HC11 CPU allows only direct or indexed addressing. This typically
causes the programmer to dedicate an index register to point at some
memory area such as the on-chip registers. The CPU12 allows all bit
manipulation instructions to work with direct, extended, or indexed
addressing modes.
The CPU12 includes instructions to push and pull the D accumulator and the
CCR. It is interesting to note that the order in which 8-bit accumulators A and
B are stacked for interrupts is the opposite of what would be expected for
the upper and lower bytes of the 16-bit D accumulator. The order used
originated in the M6800, an 8-bit microprocessor developed long before
anyone thought 16-bit single-chip devices would be made. The interrupt
stacking order for accumulators A and B is retained for code compatibility.
B.8.10 Compare SP
The indexed indirect versions of the CALL instruction access the address of
the called routine and the destination page value indirectly. For other
addressing mode variations of the CALL instruction, the destination page
value is provided as immediate data in the instruction object code. CALL
and RTC execute correctly in the normal 64-Kbyte address space, thus
providing for portable code.
C.1 Introduction
Many programmers are turning to high-level languages such as C as an
alternative to coding in native assembly languages. High-level language
(HLL) programming can improve productivity and produce code that is more
easily maintained than assembly language programs. The most serious
drawback to the use of HLL in MCUs has been the relatively large size of
programs written in HLL. Larger program ROM size requirements translate
into increased system costs.
The M68HC11 has push and pull instructions for A, B, X, and Y, but requires
separate 8-bit pushes and pulls of accumulators A and B to stack or unstack
the 16-bit D accumulator (the concatenated combination of A:B). The PSHD
and PULD instructions allow directly stacking the D accumulator in the
expected 16-bit order.
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).
First, parameters (typically values in CPU registers) are pushed onto the
system stack prior to using a JSR or CALL to get to the function subroutine.
At the beginning of the called subroutine, the frame pointer of the calling
program is pushed onto the stack. Typically, an index register, such as X, is
used as the frame pointer, so a PSHX instruction would save the frame
pointer from the calling program.
Notice that parameters are at positive offsets from the frame pointer while
locals are at negative offsets. In the M68HC11, the indexed addressing
mode uses only positive offsets, so the frame pointer always points to the
lowest address of any parameter or local. After the function subroutine
finishes, calculations are required to restore the stack pointer to the
The CPU12 includes a set of six basic loop control instructions which
decrement, increment, or test a loop count register, and then branch if it is
either equal to zero or not equal to zero. The loop count register can be A,
B, D, X, Y, or SP. A or B could be used if the loop count fits in an 8-bit char
variable; the other choices are all 16-bit registers. The relative offset for the
loop branch is a 9-bit signed value, so these instructions can be used with
loops as long as 256 bytes.
The most apparent case is the IDIVS instruction, which divides two 16-bit
signed numbers to produce a 16-bit result. While the same function can be
accomplished with the EDIVS instruction (a 32 by 16 divide), doing so is
C.8 Pointers
The CPU12 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.
The CPU12 has dedicated signal lines that allow the CPU to access the
bank page register without having to use an address in the normal 64-Kbyte
address space. This eliminates the need for the program to know where the
page register is physically located.
The RTC instruction is similar to the RTS instruction, except that RTC uses
the byte of information that was saved on the stack by the corresponding
CALL instruction to restore the bank page register to its old value. Although
a CALL/RTC pair can be used to access any function subroutine regardless
of the location of the called routine (on the current bank page or a different
page), it is most efficient to access some subroutines with JSR/RTS
instructions when the called subroutine is on the current page or in an area
of memory that is always visible in the 64-Kbyte map regardless of the bank
page selection.
Push and pull instructions can be used to stack some or all the CPU
registers during a function call. The CPU12 can push and pull any of the
CPU registers A, B, CCR, D, X, Y, or SP.
Index
A
ABA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Abbreviations for system resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
ABX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
ABY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Access details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94–99, 379
Accumulator offset indexed addressing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Accumulator offset indexed indirect addressing mode . . . . . . . . . . . . . . . . . . . . . . 40
Accumulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21, 35
B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21, 35
D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21, 35
ADCA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
ADCB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
ADDA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
ADDB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
ADDD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Addition instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
ADDR mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Extended . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Indexed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 34
Inherent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
ANDA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
ANDB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
ANDCC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Arithmetic shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
ASL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
ASLA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
ASLB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
ASLD instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
B
Background debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86, 123
Base index register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37–41
BCC instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
BCD instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60, 161
BCLR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
BCS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
BEQ instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
BGE instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
BGND instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86, 123
BGT instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
BHI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
BHS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Binary-coded decimal instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60, 161
Bit manipulation instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . .65, 119, 140, 423, 425
Mask operand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43, 119, 137, 139, 140
Multiple addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Bit test instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65, 76, 127, 128, 137, 139
BITA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
BITB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Bit-condition branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76, 137, 139
BLE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
BLO instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
BLS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
BLT instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
BMI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
BNE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Boolean logic instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108, 109, 110
Complement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154, 155, 156
Exclusive OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179, 180
Inclusive OR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243, 244, 245
Negate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239, 240, 241
BPL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
BRA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Branch instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33, 51–53, 73, 429
Bit-condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53, 76, 137, 139
C
C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
C status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26, 66, 118, 120
CALL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44–??, 50, 78, 144, 424, 430
Case statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
CBA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
CCR (see Condition codes register)
Changes in execution flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49–53
CLC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Clear instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Clear memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Cleared . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
CLI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Clock monitor reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
CLR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
CLRA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
CLRB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
CLV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
D
DAA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
DATA mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27, 425
DBEQ instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162, 400
DBNE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163, 400
DEC instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
DECA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
DECB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
E
EDIV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
EDIVS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Effective address . . . . . . . . . . . . . . . . . . . . . . . 29, 35, 83, 220, 221, 222, 417, 426–428
EMACS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71, 172
EMAXD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
EMAXM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174, 338
EMIND instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175, 338
EMINM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
EMUL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
EMULS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Enabling maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 147
EORA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
EORB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
ETBL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72, 181, 338
Even bytes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50, 311
Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315, 317
Non-maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Processing flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311, 313–314
Software interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79, 289, 318
Unimplemented opcode trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311, 313, 317
Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311, 318
Exchange instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57, 182, 417, 420
Postbyte encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Execution cycles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Execution time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
EXG instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Expanded memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44, 50, 424, 430
F
Fast math. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
f-cycle (free cycle) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 379
FDIV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64, 183
Fractional division . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64, 183
Frame pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427, 428
Free cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 379
Fuzzy logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337–374
Antecedents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342, 372
Consequents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342, 372
Custom programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
Defuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68, 344, 364–367
Fuzzification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67, 340, 369
Inference kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339, 345
Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
Instructions . . . . . . . . . . . . . . . . . . . . 67, 68, 233, 258–262, 307, 337, 347–367, 422
Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361, 365–368
Knowledge base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340, 342, 372
Membership functions . . . . . . . . . . . . . . . . . . 67, 233, 338, 340, 347–352, 369–371
Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68, 372
Rule evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67, 258–262, 342, 353–363, 372
Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340, 342, 372
Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Tabular membership functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72, 369
Weighted average . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68, 307, 337, 344, 364–367
H
H status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 161
Highest priority interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
High-level language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425–431
Addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425, 427, 429
Condition codes register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Expanded memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Loop primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426, 427
I
I mask bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25, 110, 147, 276, 313
IBEQ instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184, 400
IBNE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185, 400
I-cycle (16-bit read indirect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 379
i-cycle (8-bit read indirect) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 379
IDIV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
IDIVS instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187, 428
Immediate addressing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
INC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
INCA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
INCB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Increment instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Index calculation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83, 417
Index manipulation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Index registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21, 81, 83, 427
PC (as an index register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23, 36, 37, 94
SP (as an index register) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22, 36, 37, 94
X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 36, 94
Y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 36, 94
Indexed addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . 22, 34–43, 397, 410–414
16-bit constant indirect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
16-bit constant offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5-bit constant offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
9-bit constant offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Accumulator direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
J
JMP instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53, 194
JSR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50, 195
K
Knowledge base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
L
Label. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
LBCC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
LBCS instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
LBEQ instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
LBGE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
LBGT instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
LBHI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
LBHS instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
LBLE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
LBLO instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
LBLS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
LBLT instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
LBMI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
LBNE instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
LBPL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
LBRA instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
LBRN instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
LBVC instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
LBVS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
LDAA instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
LDAB instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
LDD instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
LDS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
LDX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
LDY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
LEAS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220, 427, 429
Least significant byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Least significant word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
LEAX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221, 429
LEAY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222, 429
Legal label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Literal expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Load instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Logic level one . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Logic level zero. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Loop primitive instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53, 77, 400, 420, 428
Offset values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
M
M68HC11 compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29, 403–424
M68HC11 instruction mnemonics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
Maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 315
MAXA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Maximum instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70, 421
16-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173, 174
8-bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231, 232
MAXM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232, 338
MEM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67, 233, 337, 347–352
Membership functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340, 347–352
Memory and addressing symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
MINA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234, 338
Minimum instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70, 421
16-bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175, 176
8-bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234, 235
MINM instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Misaligned instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Mnemonic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Most significant byte . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Most significant word . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
MOVB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Move instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58, 236, 237, 417, 420
Destination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Multiple addressing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
PC relative addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Reference index register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
MOVW instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
MUL instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
Multiple addressing modes
Bit manipulation instructions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Move instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
N
N status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
n-cycle (write PPAGE). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96, 379
NEG instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
NEGA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Negate instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Negated . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Negative integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
NEGB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Non-maskable interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 313, 315
NOP instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86, 242
Notation
Branch taken/not taken . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99, 379
Changes in CCR bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Cycle-by-cycle operation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Memory and addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Object code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 377
Source forms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
System resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Null operation instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86, 242
Numeric range of branch offsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34, 74–77
O
Object code notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
O-cycle (optional program word fetch) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52, 96, 379
Odd bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Offset
Branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33–34
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34–38
Opcode map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395–396
Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 377
Optional cycles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52, 96, 379
ORAA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
ORAB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
ORCC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Orthogonality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Q
Queue reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
HCS12 queue reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
HCS12 reconstruction algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
R
R-cycle (16-bit data read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 379
r-cycle (8-bit data read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 379
Read 16-bit data cycle. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 379
Read 8-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 379
Read indirect pointer cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 379
Read indirect PPAGE value cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 379
Read PPAGE cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95, 379
Register designators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Relative addressing mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Relative offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Resets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311, 313
Clock monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
COP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
External . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Power-on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Return from call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Return from interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
Return from subroutine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
REV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . 67, 258–259, 337, 342, 353–358, 372
REVW instruction . . . . . . . . . . . . . . . . . . . . . . . . . 67, 260–262, 337, 342, 359–363, 372
ROL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
ROLA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264
ROLB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
ROR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
RORA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
RORB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Rotate instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
RTC instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44, 50, 78, 269, 424, 430
RTI instruction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26, 80, 270, 317
RTS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51, 271
S
S control bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24, 282
SBA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
SBCA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
SBCB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274
S-cycle (16-bit stack write) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 379
T
TAB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
Table interpolation instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72, 181, 294, 422
Tabular membership functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369–371
TAP instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
TBA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
TBEQ instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293, 400
TBL instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72, 294, 338, 369–370
TBNE instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295, 400
T-cycle (16-bit conditional read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 379
t-cycle (8-bit conditional read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 379
Termination of interrupt service routines . . . . . . . . . . . . . . . . . . . . . . . . . . 80, 270, 317
Termination of subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269, 271
Test instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
TFR instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
TPA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Transfer instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57, 417, 420
Postbyte encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
TRAP instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79, 298, 317, 396
TST instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
TSTA instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
TSTB instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
TSX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
TSY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Twos-complement form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
TXS instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
Types of instructions
Addition and Subtraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Background and null . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Binary-coded decimal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Bit test and manipulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Boolean logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Branch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Clear, complement, and negate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Compare and test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Condition code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Decrement and increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
U
U-cycle (16-bit stack read) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 379
u-cycle (8-bit stack read). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 379
Unary branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73–75
Unimplemented opcode trap . . . . . . . . . . . . . . . . . . . . . . . . . . . .79, 298, 311, 313, 396
Unsigned branches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73–75
Unsigned multiplication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Unstack 16-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 379
Unstack 8-bit data cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97, 379
Unweighted rule evaluation . . . . . . . . . . . . . . . . . . . . . . . 258–259, 342, 353–358, 372
V
V status bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26, 84
V-cycle (vector fetch) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 379
Vector fetch cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 379
Vectors, exception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311, 318
W
WAI instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85, 306
Wait instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85, 306
Watchdog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
WAV instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68, 307, 337, 344, 364–368
X
X mask bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25, 182, 254, 270, 282, 291, 296, 306
x-cycle (8-bit conditional write). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98, 379
XGDX instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
XGDY instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Z
Z status bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26, 121, 134
Zero-page addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
E-mail:
support@freescale.com
<size-12>S12CPUV2
Rev. 4.0, 03/2006