Motorola CPU12 Refrence Manual

Type
Refrence Manual

This manual is also suitable for

Order this document by
CPU12RM/AD
Rev. 1.0
NON-DISCLOSURE AGREEMENT REQUIRED
CPU12
Reference Manual
HC12
HC12
HC12
NON-DISCLOSURE AGREEMENT REQUIRED
Motorola reserves the right to make changes without further notice to
any products herein to improve reliability, function or design. Motorola
does not assume any liability arising out of the application or use of any
product or circuit described herein; neither does it convey any license
under its patent rights nor the rights of others. Motorola products are not
designed, intended, or authorized for use as components in systems
intendedforsurgicalimplant intothe body,or otherapplications intended
to support or sustain life, or for any other application in which the failure
of the Motorola product could create a situation where personal injury or
death may occur. Should Buyer purchase or use Motorola products for
any such unintended or unauthorized application, Buyer shall indemnify
and hold Motorola and its officers, employees, subsidiaries, affiliates,
and distributors harmless against all claims, costs, damages, and
expenses, and reasonable attorney fees arising out of, directly or
indirectly, any claim of personal injury or death associated with such
unintended orunauthorized use,even if suchclaim alleges thatMotorola
was negligent regarding the design or manufacture of the part.
CPU12 MOTOROLA
REFERENCE MANUAL iii
TABLE OF CONTENTS
Paragraph Page
SECTION 1
INTRODUCTION
1.1 CPU12 Features ..............................................................................................1-1
1.2 Readership.......................................................................................................1-1
1.3 Symbols and Notation......................................................................................1-2
SECTION 2
OVERVIEW
2.1 Programming Model.........................................................................................2-1
2.2 Data Types.......................................................................................................2-5
2.3 Memory Organization.......................................................................................2-5
2.4 Instruction Queue.............................................................................................2-5
SECTION 3
ADDRESSING MODES
3.1 Mode Summary................................................................................................3-1
3.2 Effective Address.............................................................................................3-2
3.3 Inherent Addressing Mode...............................................................................3-2
3.4 Immediate Addressing Mode ...........................................................................3-2
3.5 Direct Addressing Mode...................................................................................3-3
3.6 Extended Addressing Mode.............................................................................3-3
3.7 Relative Addressing Mode...............................................................................3-4
3.8 Indexed Addressing Modes..............................................................................3-5
3.9 Instructions Using Multiple Modes .................................................................3-10
3.10 Addressing More than 64 Kbytes...................................................................3-12
SECTION 4
INSTRUCTION QUEUE
4.1 Queue Description ...........................................................................................4-1
4.2 Data Movement in the Queue..........................................................................4-2
4.3 Changes in Execution Flow..............................................................................4-2
SECTION 5
INSTRUCTION SET OVERVIEW
5.1 Instruction Set Description...............................................................................5-1
5.2 Load and Store Instructions.............................................................................5-1
5.3 Transfer and Exchange Instructions ................................................................5-2
5.4 Move Instructions.............................................................................................5-3
5.5 Addition and Subtraction Instructions...............................................................5-3
5.6 Binary Coded Decimal Instructions..................................................................5-4
5.7 Decrement and Increment Instructions............................................................5-4
5.8 Compare and Test Instructions........................................................................5-5
5.9 Boolean Logic Instructions...............................................................................5-6
5.10 Clear, Complement, and Negate Instructions..................................................5-6
MOTOROLA CPU12
iv REFERENCE MANUAL
Paragraph Page
TABLE OF CONTENTS
5.11 Multiplication and Division Instructions ............................................................5-7
5.12 Bit Test and Manipulation Instructions.............................................................5-7
5.13 Shift and Rotate Instructions............................................................................5-8
5.14 Fuzzy Logic Instructions...................................................................................5-9
5.15 Maximum and Minimum Instructions..............................................................5-11
5.16 Multiply and Accumulate Instruction...............................................................5-11
5.17 Table Interpolation Instructions......................................................................5-12
5.18 Branch Instructions ........................................................................................5-13
5.19 Loop Primitive Instructions.............................................................................5-16
5.20 Jump and Subroutine Instructions..................................................................5-17
5.21 Interrupt Instructions ......................................................................................5-18
5.22 Index Manipulation Instructions......................................................................5-19
5.23 Stacking Instructions......................................................................................5-20
5.24 Pointer and Index Calculation Instructions.....................................................5-20
5.25 Condition Code Instructions...........................................................................5-21
5.26 STOP and WAIT Instructions.........................................................................5-21
5.27 Background Mode and Null Operations.........................................................5-22
SECTION 6
INSTRUCTION GLOSSARY
6.1 Glossary Information........................................................................................6-1
6.2 Condition Code Changes.................................................................................6-2
6.3 Object Code Notation.......................................................................................6-2
6.4 Source Forms...................................................................................................6-3
6.5 Cycle-by-Cycle Execution................................................................................6-5
6.6 Glossary...........................................................................................................6-8
SECTION 7
EXCEPTION PROCESSING
7.1 Types of Exceptions.........................................................................................7-1
7.2 Exception Priority.............................................................................................7-2
7.3 Resets..............................................................................................................7-2
7.4 Interrupts..........................................................................................................7-3
7.5 Unimplemented Opcode Trap..........................................................................7-5
7.6 Software Interrupt Instruction...........................................................................7-6
7.7 Exception Processing Flow..............................................................................7-6
SECTION 8
DEVELOPMENT AND DEBUG SUPPORT
8.1 External Reconstruction of the Queue.............................................................8-1
8.2 Instruction Queue Status Signals.....................................................................8-1
8.3 Implementing Queue Reconstruction...............................................................8-3
8.4 Background Debug Mode ................................................................................8-6
8.5 Instruction Tagging.........................................................................................8-13
CPU12 MOTOROLA
REFERENCE MANUAL v
Paragraph Page
TABLE OF CONTENTS
8.6 Breakpoints....................................................................................................8-14
SECTION 9
FUZZY LOGIC SUPPORT
9.1 Introduction ......................................................................................................9-1
9.2 Fuzzy Logic Basics ..........................................................................................9-1
9.3 Example Inference Kernel................................................................................9-7
9.4 MEM Instruction Details...................................................................................9-9
9.5 REV, REVW Instruction Details .....................................................................9-13
9.6 WAV Instruction Details .................................................................................9-22
9.7 Custom Fuzzy Logic Programming................................................................9-26
SECTION 10
MEMORY EXPANSION
10.1 Expansion System Description ......................................................................10-1
10.2 CALL and Return from Call Instructions.........................................................10-3
10.3 Address Lines for Expansion Memory ...........................................................10-4
10.4 Overlay Window Controls...............................................................................10-4
10.5 Using Chip-Select Circuits .............................................................................10-5
10.6 System Notes.................................................................................................10-7
APPENDIX A
INSTRUCTION REFERENCE
A.1 Instruction Set Summary..................................................................................A-1
A.2 Opcode Map.....................................................................................................A-1
A.3 Indexed Addressing Postbyte Encoding ..........................................................A-1
A.4 Transfer and Exchange Postbyte Encoding.....................................................A-1
A.5 Loop Primitive Postbyte Encoding ...................................................................A-1
APPENDIX B
M68HC11 TO M68HC12 UPGRADE PATH
B.1 CPU12 Design Goals.......................................................................................B-1
B.2 Source Code Compatibility...............................................................................B-1
B.3 Programmer’s Model and Stacking..................................................................B-3
B.4 True 16-Bit Architecture...................................................................................B-3
B.5 Improved Indexing............................................................................................B-6
B.6 Improved Performance.....................................................................................B-9
B.7 Additional Functions.......................................................................................B-11
APPENDIX C
HIGH-LEVEL LANGUAGE SUPPORT
C.1 Data Types...................................................................................................... C-1
C.2 Parameters and Variables............................................................................... C-1
C.3 Increment and Decrement Operators.............................................................. C-3
MOTOROLA CPU12
vi REFERENCE MANUAL
Paragraph Page
TABLE OF CONTENTS
C.4 Higher Math Functions.................................................................................... C-3
C.5 Conditional If Constructs................................................................................. C-4
C.6 Case and Switch Statements.......................................................................... C-4
C.7 Pointers........................................................................................................... C-4
C.8 Function Calls ................................................................................................. C-4
C.9 Instruction Set Orthogonality........................................................................... C-5
APPENDIX D
ASSEMBLY LISTING
INDEX
SUMMARY OF CHANGES
CPU12 MOTOROLA
REFERENCE MANUAL vii
LIST OF ILLUSTRATIONS
Figure Page
2-1 Programming Model.........................................................................................2-1
6-1 Example Glossary Page...................................................................................6-1
7-2 Exception Processing Flow Diagram ...............................................................7-7
8-1 Queue Status Signal Timing ............................................................................8-2
8-2 BDM Host to Target Serial Bit Timing..............................................................8-8
8-3 BDM Target to Host Serial Bit Timing (Logic 1)...............................................8-8
8-4 BDM Target to Host Serial Bit Timing (Logic 0)...............................................8-9
8-5 Tag Input Timing............................................................................................8-13
9-1 Block Diagram of a Fuzzy Logic System..........................................................9-3
9-2 Fuzzification Using Membership Functions......................................................9-4
9-3 Fuzzy Inference Engine ...................................................................................9-8
9-4 Defining a Normal Membership Function.......................................................9-10
9-5 MEM Instruction Flow Diagram......................................................................9-11
9-6 Abnormal Membership Function Case 1........................................................9-12
9-7 Abnormal Membership Function Case 2........................................................9-13
9-8 Abnormal Membership Function Case 3........................................................9-13
9-9 REV Instruction Flow Diagram.......................................................................9-16
9-10 REVW Instruction Flow Diagram....................................................................9-21
9-11 WAV and wavr Instruction Flow Diagram.......................................................9-25
9-12 Endpoint Table Handling................................................................................9-28
MOTOROLA CPU12
viii REFERENCE MANUAL
CPU12 MOTOROLA
REFERENCE MANUAL ix
LIST OF TABLES
Table Page
3-1 M68HC12 Addressing Mode Summary............................................................3-1
3-2 Summary of Indexed Operations .....................................................................3-6
3-3 PC Offsets for Move Instructions ...................................................................3-11
5-1 Load and Store Instructions.............................................................................5-2
5-2 Transfer and Exchange Instructions ................................................................5-3
5-3 Move Instructions.............................................................................................5-3
5-4 Addition and Subtraction Instructions...............................................................5-4
5-5 BCD Instructions..............................................................................................5-4
5-6 Decrement and Increment Instructions............................................................5-5
5-7 Compare and Test Instructions........................................................................5-5
5-8 Boolean Logic Instructions...............................................................................5-6
5-9 Clear, Complement, and Negate Instructions..................................................5-6
5-10 Multiplication and Division Instructions ............................................................5-7
5-11 Bit Test and Manipulation Instructions.............................................................5-7
5-12 Shift and Rotate Instructions............................................................................5-8
5-13 Fuzzy Logic Instructions.................................................................................5-10
5-14 Minimum and Maximum Instructions..............................................................5-11
5-15 Multiply and Accumulate Instructions.............................................................5-12
5-16 Table Interpolation Instructions......................................................................5-12
5-17 Short Branch Instructions...............................................................................5-14
5-18 Long Branch Instructions ...............................................................................5-15
5-19 Bit Condition Branch Instructions...................................................................5-16
5-20 Loop Primitive Instructions.............................................................................5-16
5-21 Jump and Subroutine Instructions..................................................................5-17
5-22 Interrupt Instructions ......................................................................................5-18
5-23 Index Manipulation Instructions......................................................................5-19
5-24 Stacking Instructions......................................................................................5-20
5-25 Pointer and Index Calculation Instructions.....................................................5-21
5-26 Condition Codes Instructions.........................................................................5-21
5-27 STOP and WAIT Instructions.........................................................................5-22
5-28 Background Mode and Null Operation Instructions........................................5-22
7-1 CPU12 Exception Vector Map .........................................................................7-1
7-2 Stacking Order on Entry to Interrupts...............................................................7-5
8-1 IPIPE[1:0] Decoding.........................................................................................8-2
8-2 BDM Commands Implemented in Hardware..................................................8-10
8-3 BDM Firmware Commands............................................................................8-11
8-4 BDM Register Mapping..................................................................................8-11
8-5 Tag Pin Function............................................................................................8-13
10-1 Mapping Precedence.....................................................................................10-2
A-1 Instruction Set Summary..................................................................................A-2
A-2 CPU12 Opcode Map......................................................................................A-20
A-3 Indexed Addressing Mode Summary.............................................................A-22
A-4 Indexed Addressing Mode Postbyte Encoding (xb).......................................A-23
MOTOROLA CPU12
x REFERENCE MANUAL
LIST OF TABLES
A-5 Transfer and Exchange Postbyte Encoding...................................................A-24
A-6 Loop Primitive Postbyte Encoding (lb)...........................................................A-25
B-1 Translated M68HC11 Mnemonics....................................................................B-2
B-2 Instructions with Smaller Object Code.............................................................B-3
B-3 Comparison of Math Instruction Speeds........................................................B-10
B-4 New M68HC12 Instructions ...........................................................................B-11
CPU12 INTRODUCTION MOTOROLA
REFERENCE MANUAL 1-1
SECTION 1
INTRODUCTION
This manual describes the features and operation of the CPU12 processing unit used
in all M68HC12 microcontrollers.
1.1 CPU12 Features
The CPU12 is a high-speed, 16-bit processing unit that has a programming model
identical to that of the industry standard M68HC11 CPU. The CPU12 instruction set is
a proper superset of the M68HC11 instruction set, and M68HC11 source code is ac-
cepted by CPU12 assemblers with no changes.
The CPU12 has full 16-bit data paths and can perform arithmetic operations up to 20
bits wide for high-speed math execution.
Unlike many other 16-bit CPUs, the CPU12 allows 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.
In addition to the addressing modes found in other Motorola MCUs, the CPU12 offers
an extensive set of indexed addressing capabilities including:
Using the stack pointer as an index register in all indexed operations
Using the program counter as an index register in all but auto inc/dec mode
Accumulator offsets allowed using A, B, or D accumulators
Automatic pre- or post-increment or pre- or post-decrement (by
8 to +8)
5-bit, 9-bit, or 16-bit signed constant offsets
16-bit offset indexed-indirect and accumulator D offset indexed-indirect ad-
dressing
1.2 Readership
This manual iswritten for professionals andstudents in electronic design and software
development. The primary goal is to provide information necessary to implement con-
trol systems using M68HC12 devices. Basic knowledge of electronics, microproces-
sors, and assembly language programming is required to use the manual effectively.
Because the CPU12 has a great deal of commonality with the M68HC11 CPU, prior
knowledge of M68HC11 devices is helpful, but is not essential. The CPU12 also in-
cludes features that are new and unique. In these cases, there is supplementary ma-
terial in the text to explain the new technology.
MOTOROLA INTRODUCTION CPU12
1-2 REFERENCE MANUAL
1.3 Symbols and Notation
The followingsymbols and notationare used throughoutthe manual. More specialized
usages thatapply onlyto theinstruction glossary are described atthe beginningof that
section.
1.3.1 Abbreviations for System Resources
1.3.2 Memory and Addressing
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
M 8-bit memory location pointed to by the effective address of the in-
struction
M : M+1 16-bit memory location. Consists of the location pointed to by the
effective address concatenated with the next higher memory loca-
tion. The most significant byte is at location M.
M~M+3
M
(Y)
~M
(Y+3)
32-bit memory location. Consists of the effective address of the
instruction concatenated with the next three higher memory
locations. The most significant byte is at location M or M
(Y)
.
M
(X)
Memory locations pointed to by index register X
M
(SP)
Memory locations pointed to by the stack pointer
M
(Y+3)
Memory locations pointed to by index register Y plus 3,
respectively.
PPAGE Program overlay page (bank) number for extended memory
(>64K).
Page Program overlay page
X
H
High-order byte
X
L
Low-order byte
( ) Content of register or memory location
$ Hexadecimal value
% Binary value
CPU12 INTRODUCTION MOTOROLA
REFERENCE MANUAL 1-3
1.3.3 Operators
1.3.4 Conventions
Logic level one is the voltage that corresponds to the True (1) state.
Logic level zero is the voltage that corresponds to the False (0) state.
Set refers specifically to establishing logic level one on a bit or bits.
Cleared refers specifically to establishing logic level zero on a bit or bits.
Asserted means that a signal is in active logic state. An active low signal changes
from logic level one to logic levelzero when asserted, andan active high signal chang-
es from logic level zero to logic level one.
Negated means that an asserted signal changes logic state. An active low signal
changes from logic level zero to logic level one when negated, and an active high sig-
nal changes from logic level one to logic level zero.
ADDR is the mnemonic for address bus.
DATA is the mnemonic for data bus.
LSB means least significant bit or bits; MSB, most significant bit or bits.
LSW means least significant word or words; MSW, most significant word or words.
A specific mnemonic within a range is referred to by mnemonic and number. A7 is
bit 7 of accumulator A. A range of mnemonics is referred to by mnemonic and the
numbers that define the range. DATA[15:8] form the high byte of the data bus.
+
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:Bmeans: “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.”
MOTOROLA INTRODUCTION CPU12
1-4 REFERENCE MANUAL
CPU12 OVERVIEW MOTOROLA
REFERENCE MANUAL 2-1
SECTION 2
OVERVIEW
This section describes the CPU12 programming model, register set, the data types
used, and basic memory organization.
2.1 Programming Model
The CPU12 programming model, shown in Figure 2-1, is the same as that of the
M68HC11 CPU. The CPU has two 8-bit general-purpose accumulators (A and B) that
can be concatenatedinto asingle 16-bitaccumulator (D)for certain instructions.It also
has twoindex registers (Xand Y), a16-bit stack pointer(SP), a 16-bitprogram counter
(PC), and an 8-bit condition code register (CCR).
Figure 2-1 Programming Model
2.1.1 Accumulators
General-purpose 8-bit accumulators A and B are used to hold operands and results of
operations. Some instructions treat the combination of these two 8-bit accumulators
(A : B) as a 16-bit double accumulator (D).
7
15
15
15
15
15
D
IX
IY
SP
PC
AB
NSXHI ZVC
0
0
0
0
0
0
70
CONDITION CODE REGISTER
8-BIT ACCUMULATORS A AND B
16-BIT DOUBLE ACCUMULATOR D
INDEX REGISTER X
INDEX REGISTER Y
STACK POINTER
PROGRAM COUNTER
OR
HC12 PROG MODEL
MOTOROLA OVERVIEW CPU12
2-2 REFERENCE MANUAL
Most operations can use accumulator A or B interchangeably. However, there are a
few exceptions. Add, subtract, and compare instructions involving both A and B (ABA,
SBA, and CBA) only operate in one direction, so itis important to makecertain the cor-
rect operand is in the correct accumulator. The decimal adjust accumulator A (DAA)
instruction is used after binary-coded decimal (BCD) arithmetic operations. There is
no equivalent instruction to adjust accumulator B.
2.1.2 Index Registers
16-bit index registers X and Y are used for indexed addressing. In the indexed ad-
dressing 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 in-
struction operand. The second index register is especially useful for moves and in
cases where operands from two separate tables are used in a calculation.
2.1.3 Stack Pointer
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 sys-
tem.
The stack pointer holds the 16-bit address of the last stack location used. Normally,
the SP is initialized by one of the first instructions in an application program. The stack
grows downward from the address pointed to by the SP. Each time a byte is pushed
onto the stack, the stack pointer is automatically decremented, and each time a byte
is pulled from the stack, the stack pointer is automatically incremented.
When a subroutineis called, the addressof the instruction followingthe calling instruc-
tion is automatically calculated and pushed onto the stack. Normally, a return from
subroutine (RTS) or a return from call (RTC) instruction is executed at the end of a
subroutine. The return instruction loads the program counter with the previously
stacked return address and execution continues at that address.
When an interrupt occurs, the current instruction finishes execution (REV, REVW, and
WAV instructions can be interrupted, and resume execution once the interrupt has
been serviced), the address of the next instruction is calculated and pushed onto the
stack, all the CPU registers are pushed onto the stack, the program counter is loaded
with the address pointed to by the interrupt vector, and execution continues at that ad-
dress. The stacked registers are referred to as an interrupt stack frame. The CPU12
stack frame is the same as that of the M68HC11.
2.1.4 Program Counter
Theprogram counter(PC) isa16-bit registerthat holds theaddress ofthe next instruc-
tion to be executed. It is automatically incremented each time an instructionis fetched.
CPU12 OVERVIEW MOTOROLA
REFERENCE MANUAL 2-3
2.1.5 Condition Code Register
This register contains five status indicators, two interrupt masking bits, and a STOP
instruction control bit. It is named for the five status indicators.
The status bits reflectthe results of CPU operation as itexecutes instructions. The five
flags are half carry (H), negative (N), zero (Z), overflow (V), and 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.
In some architectures, only a few instructions affect condition codes, so that multiple
instructions must be executed in order to load and test a variable. Since most CPU12
instructions automatically update condition codes, it is rarely necessary to execute an
extra instruction for this purpose. The challenge in using the CPU12 lies in finding in-
structions that do not alter the condition codes. The most important of these instruc-
tions are pushes, pulls, transfers, and exchanges.
It is always a good idea to refer to an instruction set summary (see APPENDIX A IN-
STRUCTION REFERENCE) to check which condition codes are affected by a partic-
ular instruction.
The following paragraphs describe normal uses of the condition codes. There are oth-
er, more specialized uses. For instance, the C status bit is used to enable weighted
fuzzy logic rule evaluation. Specialized usages are described in the relevant portions
of this manual and in SECTION 6 INSTRUCTION GLOSSARY.
2.1.5.1 S Control Bit
Setting the S bit disables the STOP instruction. Execution of a STOP instruction caus-
es the on-chip oscillator to stop. This may be undesirable in some applications. If the
CPU encounters a STOP instruction while the S bit is set, it is treated like a no-oper-
ation (NOP) instruction, and continues to the next instruction.
2.1.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 andinitialized canlead tospurious interrupts.The Xbit providesa mech-
anism for enabling non-maskable interrupts after a system is stable.
By default, theX bitis setto oneduring reset. Aslong asthe Xbit remainsset, 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 zero, software cannot reset it to one 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 automatically set 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.
MOTOROLA OVERVIEW CPU12
2-4 REFERENCE MANUAL
Normally, an 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 be-
fore 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 re-set X (and disable
NMI) once
X has been cleared.
2.1.5.3 H Status Bit
The H bit indicates a carry from accumulator A bit 3 during an addition operation. The
DAA instructionuses thevalue of the H bitto adjusta result inaccumulator Ato correct
BCD format. H is updated only by the ABA, ADD, and ADC instructions.
2.1.5.4 I Mask Bit
The I bit enables and disables maskable interrupt sources. By default, the I bit is set
to one during reset. An instruction must clear the I bit to enable maskable interrupts.
While the I bit is set, maskable interrupts can become pending and are remembered,
but operation continues uninterrupted until the I bit is cleared.
When an interrupt occurs after interrupts are enabled, the I bit is automatically set to
prevent other maskable interrupts during the interrupt service routine. The I bit is set
after the registers are stacked, but before the interrupt vector is fetched.
Normally, an 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 be-
fore the I bit is set, the RTI normally clears the I bit, and thus re-enables interrupts.
Interrupts can be re-enabled by clearing the I bit within the service routine, but imple-
menting a nested interrupt management scheme requires great care, and seldom im-
proves system performance.
2.1.5.5 N Status Bit
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 one and the MSB of
a positive number is zero, 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 ac-
cumulator.
2.1.5.6 Z Status Bit
The Z bit is set when all the bits of the result are zeros. Compare instructions perform
an internal implied subtraction, and the condition codes, including Z, reflect the results
of that subtraction. The INX, DEX, INY, and DEY instructions affect the Z bit and no
other condition flags. These operations can only determine = and .
2.1.5.7 V Status Bit
The V bit is set when two’s complement overflow occurs as a result of an operation.
CPU12 OVERVIEW MOTOROLA
REFERENCE MANUAL 2-5
2.1.5.8 C Status Bit
The C bit is set when a carry occurs during addition or a borrow occurs during subtrac-
tion. The C bit also acts as an error flag for multiply and divide operations. Shift and
rotate instructions operate through the C bit to facilitate multiple-word shifts.
2.2 Data Types
The CPU12 uses the following types of data:
Bits
5-bit signed integers
8-bit signed and unsigned integers
8-bit, 2-digit binary coded decimal numbers
9-bit signed integers
16-bit signed and unsigned integers
16-bit effective addresses
32-bit signed and unsigned integers
Negative integers are represented in two’s complement form.
Five-bit and 9-bit signed integers are used only as offsets for indexed addressing
modes.
Sixteen-bit effective addresses are formed during addressing mode computations.
Thirty-two-bit integer dividends are used by extended division instructions. Extended
multiply and extended multiply-and-accumulate instructions produce 32-bit products.
2.3 Memory Organization
The standard CPU12 address space is 64 Kbytes. Some M68HC12 devices support
a paged memory expansion scheme that increases the standard space by means of
predefined windows in address space. The CPU12 has special instructions that sup-
port use of expanded memory.See SECTION 10 MEMORY EXPANSION for more in-
formation.
Eight-bit values can be stored at any odd or even byte address in available memory.
Sixteen-bit values are stored in memory as two consecutive bytes; the high byte occu-
pies the lowest address, but need not be aligned to an even boundary. Thirty-two-bit
valuesare storedin memory asfour consecutivebytes;the highbyteoccupies thelow-
est address, but need not be aligned to an even boundary.
All I/O and all on-chip peripherals are memory-mapped. No special instruction syntax
is required to access these addresses. On-chip registers and memory are typically
grouped in blocks which can be relocated within the standard 64-Kbyte address
space. Refer to device documentation for specific information.
2.4 Instruction Queue
The CPU12 uses an instruction queue to buffer program information. The mechanism
is called a queue rather than a pipeline because a typical pipelined CPU executes
more than one instruction at the same time, while the CPU12 always finishes execut-
ing an instruction before beginning to execute another. Refer to SECTION 4 IN-
STRUCTION QUEUE for more information.
MOTOROLA OVERVIEW CPU12
2-6 REFERENCE MANUAL
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19
  • Page 20 20
  • Page 21 21
  • Page 22 22
  • Page 23 23
  • Page 24 24
  • Page 25 25
  • Page 26 26
  • Page 27 27
  • Page 28 28
  • Page 29 29
  • Page 30 30
  • Page 31 31
  • Page 32 32
  • Page 33 33
  • Page 34 34
  • Page 35 35
  • Page 36 36
  • Page 37 37
  • Page 38 38
  • Page 39 39
  • Page 40 40
  • Page 41 41
  • Page 42 42
  • Page 43 43
  • Page 44 44
  • Page 45 45
  • Page 46 46
  • Page 47 47
  • Page 48 48
  • Page 49 49
  • Page 50 50
  • Page 51 51
  • Page 52 52
  • Page 53 53
  • Page 54 54
  • Page 55 55
  • Page 56 56
  • Page 57 57
  • Page 58 58
  • Page 59 59
  • Page 60 60
  • Page 61 61
  • Page 62 62
  • Page 63 63
  • Page 64 64
  • Page 65 65
  • Page 66 66
  • Page 67 67
  • Page 68 68
  • Page 69 69
  • Page 70 70
  • Page 71 71
  • Page 72 72
  • Page 73 73
  • Page 74 74
  • Page 75 75
  • Page 76 76
  • Page 77 77
  • Page 78 78
  • Page 79 79
  • Page 80 80
  • Page 81 81
  • Page 82 82
  • Page 83 83
  • Page 84 84
  • Page 85 85
  • Page 86 86
  • Page 87 87
  • Page 88 88
  • Page 89 89
  • Page 90 90
  • Page 91 91
  • Page 92 92
  • Page 93 93
  • Page 94 94
  • Page 95 95
  • Page 96 96
  • Page 97 97
  • Page 98 98
  • Page 99 99
  • Page 100 100
  • Page 101 101
  • Page 102 102
  • Page 103 103
  • Page 104 104
  • Page 105 105
  • Page 106 106
  • Page 107 107
  • Page 108 108
  • Page 109 109
  • Page 110 110
  • Page 111 111
  • Page 112 112
  • Page 113 113
  • Page 114 114
  • Page 115 115
  • Page 116 116
  • Page 117 117
  • Page 118 118
  • Page 119 119
  • Page 120 120
  • Page 121 121
  • Page 122 122
  • Page 123 123
  • Page 124 124
  • Page 125 125
  • Page 126 126
  • Page 127 127
  • Page 128 128
  • Page 129 129
  • Page 130 130
  • Page 131 131
  • Page 132 132
  • Page 133 133
  • Page 134 134
  • Page 135 135
  • Page 136 136
  • Page 137 137
  • Page 138 138
  • Page 139 139
  • Page 140 140
  • Page 141 141
  • Page 142 142
  • Page 143 143
  • Page 144 144
  • Page 145 145
  • Page 146 146
  • Page 147 147
  • Page 148 148
  • Page 149 149
  • Page 150 150
  • Page 151 151
  • Page 152 152
  • Page 153 153
  • Page 154 154
  • Page 155 155
  • Page 156 156
  • Page 157 157
  • Page 158 158
  • Page 159 159
  • Page 160 160
  • Page 161 161
  • Page 162 162
  • Page 163 163
  • Page 164 164
  • Page 165 165
  • Page 166 166
  • Page 167 167
  • Page 168 168
  • Page 169 169
  • Page 170 170
  • Page 171 171
  • Page 172 172
  • Page 173 173
  • Page 174 174
  • Page 175 175
  • Page 176 176
  • Page 177 177
  • Page 178 178
  • Page 179 179
  • Page 180 180
  • Page 181 181
  • Page 182 182
  • Page 183 183
  • Page 184 184
  • Page 185 185
  • Page 186 186
  • Page 187 187
  • Page 188 188
  • Page 189 189
  • Page 190 190
  • Page 191 191
  • Page 192 192
  • Page 193 193
  • Page 194 194
  • Page 195 195
  • Page 196 196
  • Page 197 197
  • Page 198 198
  • Page 199 199
  • Page 200 200
  • Page 201 201
  • Page 202 202
  • Page 203 203
  • Page 204 204
  • Page 205 205
  • Page 206 206
  • Page 207 207
  • Page 208 208
  • Page 209 209
  • Page 210 210
  • Page 211 211
  • Page 212 212
  • Page 213 213
  • Page 214 214
  • Page 215 215
  • Page 216 216
  • Page 217 217
  • Page 218 218
  • Page 219 219
  • Page 220 220
  • Page 221 221
  • Page 222 222
  • Page 223 223
  • Page 224 224
  • Page 225 225
  • Page 226 226
  • Page 227 227
  • Page 228 228
  • Page 229 229
  • Page 230 230
  • Page 231 231
  • Page 232 232
  • Page 233 233
  • Page 234 234
  • Page 235 235
  • Page 236 236
  • Page 237 237
  • Page 238 238
  • Page 239 239
  • Page 240 240
  • Page 241 241
  • Page 242 242
  • Page 243 243
  • Page 244 244
  • Page 245 245
  • Page 246 246
  • Page 247 247
  • Page 248 248
  • Page 249 249
  • Page 250 250
  • Page 251 251
  • Page 252 252
  • Page 253 253
  • Page 254 254
  • Page 255 255
  • Page 256 256
  • Page 257 257
  • Page 258 258
  • Page 259 259
  • Page 260 260
  • Page 261 261
  • Page 262 262
  • Page 263 263
  • Page 264 264
  • Page 265 265
  • Page 266 266
  • Page 267 267
  • Page 268 268
  • Page 269 269
  • Page 270 270
  • Page 271 271
  • Page 272 272
  • Page 273 273
  • Page 274 274
  • Page 275 275
  • Page 276 276
  • Page 277 277
  • Page 278 278
  • Page 279 279
  • Page 280 280
  • Page 281 281
  • Page 282 282
  • Page 283 283
  • Page 284 284
  • Page 285 285
  • Page 286 286
  • Page 287 287
  • Page 288 288
  • Page 289 289
  • Page 290 290
  • Page 291 291
  • Page 292 292
  • Page 293 293
  • Page 294 294
  • Page 295 295
  • Page 296 296
  • Page 297 297
  • Page 298 298
  • Page 299 299
  • Page 300 300
  • Page 301 301
  • Page 302 302
  • Page 303 303
  • Page 304 304
  • Page 305 305
  • Page 306 306
  • Page 307 307
  • Page 308 308
  • Page 309 309
  • Page 310 310
  • Page 311 311
  • Page 312 312
  • Page 313 313
  • Page 314 314
  • Page 315 315
  • Page 316 316
  • Page 317 317
  • Page 318 318
  • Page 319 319
  • Page 320 320
  • Page 321 321
  • Page 322 322
  • Page 323 323
  • Page 324 324
  • Page 325 325
  • Page 326 326
  • Page 327 327
  • Page 328 328
  • Page 329 329
  • Page 330 330
  • Page 331 331
  • Page 332 332
  • Page 333 333
  • Page 334 334
  • Page 335 335
  • Page 336 336
  • Page 337 337
  • Page 338 338
  • Page 339 339
  • Page 340 340
  • Page 341 341
  • Page 342 342
  • Page 343 343
  • Page 344 344
  • Page 345 345
  • Page 346 346
  • Page 347 347
  • Page 348 348
  • Page 349 349
  • Page 350 350
  • Page 351 351
  • Page 352 352
  • Page 353 353
  • Page 354 354
  • Page 355 355
  • Page 356 356
  • Page 357 357
  • Page 358 358
  • Page 359 359
  • Page 360 360
  • Page 361 361
  • Page 362 362
  • Page 363 363
  • Page 364 364
  • Page 365 365
  • Page 366 366
  • Page 367 367
  • Page 368 368
  • Page 369 369
  • Page 370 370
  • Page 371 371
  • Page 372 372
  • Page 373 373
  • Page 374 374
  • Page 375 375
  • Page 376 376
  • Page 377 377
  • Page 378 378
  • Page 379 379
  • Page 380 380
  • Page 381 381
  • Page 382 382
  • Page 383 383
  • Page 384 384
  • Page 385 385
  • Page 386 386
  • Page 387 387
  • Page 388 388
  • Page 389 389
  • Page 390 390
  • Page 391 391
  • Page 392 392
  • Page 393 393
  • Page 394 394
  • Page 395 395
  • Page 396 396
  • Page 397 397
  • Page 398 398
  • Page 399 399
  • Page 400 400
  • Page 401 401
  • Page 402 402
  • Page 403 403
  • Page 404 404
  • Page 405 405
  • Page 406 406
  • Page 407 407
  • Page 408 408
  • Page 409 409
  • Page 410 410
  • Page 411 411
  • Page 412 412
  • Page 413 413
  • Page 414 414
  • Page 415 415
  • Page 416 416
  • Page 417 417
  • Page 418 418
  • Page 419 419
  • Page 420 420
  • Page 421 421
  • Page 422 422
  • Page 423 423
  • Page 424 424
  • Page 425 425
  • Page 426 426
  • Page 427 427
  • Page 428 428
  • Page 429 429
  • Page 430 430
  • Page 431 431
  • Page 432 432
  • Page 433 433
  • Page 434 434
  • Page 435 435
  • Page 436 436
  • Page 437 437
  • Page 438 438
  • Page 439 439
  • Page 440 440

Motorola CPU12 Refrence Manual

Type
Refrence Manual
This manual is also suitable for

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI