Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Rev. 2
HC 8
CPU08
CENTRAL PROCESSOR UNIT
REFERENCE MANUAL
R E Q U I R E D
N O N - D I S C L O S U R E
A G R E E M E N T
CPU08
R E Q U I R E D
A G R E E M E N T
N O N - D I S C L O S U R E
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
intended for surgical implant into the body, or 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 or
unauthorized use, even if such claim alleges that Motorola was negligent regarding the
design or manufacture of the part.
Motorola and the Motorola logo are registered trademarks of Motorola, Inc.
Motorola, Inc. is an Equal Opportunity/Affirmative Action Employer.
List of Sections
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Resets and Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Addressing Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Instruction Set Examples . . . . . . . . . . . . . . . . . . . . . . . 189
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
List of Sections
List of Sections
List of Sections
MOTOROLA
Revision History
Revision History
This table summarizes differences between this revision and the
previous revision of this reference manual.
Previous
Revision
1.0
Current
Revision
2.0
Date
08/96
Changes
Location
Throughout
MOTOROLA
Table of Contents
Overview
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Programming Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Memory Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Arithmetic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
BCD Arithmetic Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
High-Level Language Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Low-Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Architecture
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
CPU08 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
Accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Index Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
Program Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Condition Code Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
CPU08 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
Internal Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Control Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Execution Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Instruction Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Table of Contents
Table of Contents
Resets and Interrupts
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
Elements of Reset and Interrupt Processing . . . . . . . . . . . . . . . . . . .41
Recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
Stacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Masking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
Returning to Calling Program . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Reset Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Initial Conditions Established . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Operating Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Reset Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
External Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
Active Reset from an Internal Source . . . . . . . . . . . . . . . . . . . . . .50
Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Interrupt Sources and Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Interrupts in STOP and WAIT Modes . . . . . . . . . . . . . . . . . . . . . .53
Nesting of Multiple Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Allocating Scratch Space on the Stack . . . . . . . . . . . . . . . . . . . . .53
Addressing Modes
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Inherent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Extended . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Indexed, No Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Indexed, 8-Bit Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Indexed, 16-Bit Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Stack Pointer, 8-Bit Offset 70. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents
MOTOROLA
Table of Contents
Instruction Set
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Nomenclature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Convention Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Instruction Set Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
ADC Add with Carry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
ADD Add without Carry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
AIS Add Immediate Value (Signed) to Stack Pointer . . . . . . . .93
AIX Add Immediate Value (Signed) to Index Register. . . . . . . .94
AND Logical AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
ASL Arithmetic Shift Left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
ASR Arithmetic Shift Right. . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
BCC Branch if Carry Bit Clear . . . . . . . . . . . . . . . . . . . . . . . . . .98
BCLR n Clear Bit n in Memory . . . . . . . . . . . . . . . . . . . . . . . . .99
BCS Branch if Carry Bit Set. . . . . . . . . . . . . . . . . . . . . . . . . . .100
BEQ Branch if Equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
BGE Branch if Greater Than or Equal To . . . . . . . . . . . . . . . .102
BGT Branch if Greater Than . . . . . . . . . . . . . . . . . . . . . . . . . .103
BHCC Branch if Half Carry Bit Clear . . . . . . . . . . . . . . . . . . . .104
BHCS Branch if Half Carry Bit Set. . . . . . . . . . . . . . . . . . . . . .105
BHI Branch if Higher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
BHS Branch if Higher or Same . . . . . . . . . . . . . . . . . . . . . . . .107
BIH Branch if IRQ Pin High . . . . . . . . . . . . . . . . . . . . . . . . . . .108
BIL Branch if IRQ Pin Low. . . . . . . . . . . . . . . . . . . . . . . . . . . .109
Table of Contents
11
Table of Contents
BIT Bit Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
BLE Branch if Less Than or Equal To . . . . . . . . . . . . . . . . . . .111
BLO Branch if Lower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112
BLS Branch if Lower or Same . . . . . . . . . . . . . . . . . . . . . . . . .113
BLT Branch if Less Than . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
BMC Branch if Interrupt Mask Clear . . . . . . . . . . . . . . . . . . . .115
BMI Branch if Minus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
BMS Branch if Interrupt Mask Set . . . . . . . . . . . . . . . . . . . . . .117
BNE Branch if Not Equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118
BPL Branch if Plus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
BRA Branch Always . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120
BRCLR n Branch if Bit n in Memory Clear. . . . . . . . . . . . . . . .121
BRN Branch Never . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
BRSET n Branch if Bit n in Memory Set . . . . . . . . . . . . . . . . .123
BSET n Set Bit n in Memory . . . . . . . . . . . . . . . . . . . . . . . . . .124
BSR Branch to Subroutine . . . . . . . . . . . . . . . . . . . . . . . . . . .125
CBEQ Compare and Branch if Equal . . . . . . . . . . . . . . . . . . .126
CLC Clear Carry Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
CLI Clear Interrupt Mask Bit . . . . . . . . . . . . . . . . . . . . . . . . . .128
CLR Clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129
CMP Compare Accumulator with Memory . . . . . . . . . . . . . . .130
COM Complement (Ones Complement) . . . . . . . . . . . . . . . .131
CPHX Compare Index Register with Memory . . . . . . . . . . . . .132
CPX Compare X (Index Register Low) with Memory . . . . . . .133
DAA Decimal Adjust Accumulator . . . . . . . . . . . . . . . . . . . . . .134
DAA Decimal Adjust Accumulator . . . . . . . . . . . . . . . . . . . . . .135
DBNZ Decrement and Branch if Not Zero . . . . . . . . . . . . . . . .136
DEC Decrement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137
DIV Divide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
EOR Exclusive-OR Memory with Accumulator . . . . . . . . . . . .139
INC Increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140
JMP Jump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
JSR Jump to Subroutine . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
LDA Load Accumulator from Memory . . . . . . . . . . . . . . . . . . .143
LDHX Load Index Register from Memory . . . . . . . . . . . . . . . .144
LDX Load X (Index Register Low) from Memory. . . . . . . . . . .145
LSL Logical Shift Left. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146
LSR Logical Shift Right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
CPU08 Reference Manual Rev. 2.0
12
Table of Contents
MOTOROLA
Table of Contents
Table of Contents
13
Table of Contents
Instruction Set Examples
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .189
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190
New Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190
Code Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191
AIS Add Immediate Value (Signed) to Stack Pointer . . . . . . .192
AIX Add Immediate Value (Signed) to Index Register . . . . . .196
BGE Branch if Greater Than or Equal To . . . . . . . . . . . . . . . .198
BGT Branch if Greater Than . . . . . . . . . . . . . . . . . . . . . . . . . .200
BLE Branch if Less Than or Equal To . . . . . . . . . . . . . . . . . . .202
BLT Branch if Less Than . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204
CBEQ Compare and Branch if Equal . . . . . . . . . . . . . . . . . . .206
CBEQA Compare A with Immediate . . . . . . . . . . . . . . . . . . . .208
CBEQX Compare X with Immediate . . . . . . . . . . . . . . . . . . . .210
CLRH Clear H (Index Register High). . . . . . . . . . . . . . . . . . . .212
CPHX Compare Index Register with Memory . . . . . . . . . . . . .214
DAA Decimal Adjust Accumulator . . . . . . . . . . . . . . . . . . . . . .216
DBNZ Decrement and Branch if Not Zero . . . . . . . . . . . . . . . .218
DIV Divide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220
LDHX Load Index Register with Memory . . . . . . . . . . . . . . .224
MOV Move. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226
NSA Nibble Swap Accumulator . . . . . . . . . . . . . . . . . . . . . . . .228
PSHA Push Accumulator onto Stack. . . . . . . . . . . . . . . . . . . .230
PSHH Push H (Index Register High) onto Stack. . . . . . . . . . .232
PSHX Push X (Index Register Low) onto Stack . . . . . . . . . . .234
PULA Pull Accumulator from Stack . . . . . . . . . . . . . . . . . . . . .236
PULH Pull H (Index Register High) from Stack . . . . . . . . . . . .238
PULX Pull X (Index Register Low) from Stack . . . . . . . . . . . .240
STHX Store Index Register . . . . . . . . . . . . . . . . . . . . . . . . . .242
TAP Transfer Accumulator to Condition Code Register . . . . .244
TPA Transfer Condition Code Register to Accumulator . . . . .246
TSX Transfer Stack Pointer to Index Register . . . . . . . . . . . .248
TXS Transfer Index Register to Stack Pointer. . . . . . . . . . . . .250
Table of Contents
MOTOROLA
Table of Contents
Glossary
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .253
Index
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
Table of Contents
15
Table of Contents
Table of Contents
MOTOROLA
List of Figures
Figure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Title
Page
List of Figures
17
List of Figures
List of Figures
MOTOROLA
List of Tables
Table
Title
Page
10
11
12
13
List of Tables
19
List of Tables
List of Tables
MOTOROLA
Overview
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Programming Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Memory Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Arithmetic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
BCD Arithmetic Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
High-Level Language Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Low-Power Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Introduction
The CPU08 is the central processing unit (CPU) of the Motorola
M68HC08 Family of microcontroller units (MCUs). The fully object code
compatible CPU08 offers M68HC05 users increased performance with
no loss of time or software investment in their HC05-based applications.
The CPU08 also appeals to users of other MCU architectures who need
the CPU08 combination of speed, low power, processing capabilities,
and cost effectiveness.
Overview
21
Overview
Features
CPU08 features include:
16-bit index register (H:X) with high and low byte manipulation
instructions
16 addressing modes
78 new opcodes
Programming Model
The CPU08 programming model consists of an 8-bit accumulator, 16-bit
index register, 16-bit stack pointer, 16-bit program counter, and 8-bit
condition code register. (See Figure 1. CPU08 Programming Model on
page 26.)
Overview
MOTOROLA
Overview
Memory Space
Memory Space
Program memory space and data memory space are contiguous over a
64-Kbyte addressing range. Addition of a page-switching peripheral
allows extension of the addressing range beyond 64 Kbytes.
Addressing Modes
The CPU08 has a total of 16 addressing modes:
Inherent
Immediate
Direct
Extended
Indexed
No offset
No offset, post increment
8-bit offset
8-bit offset, post increment
16-bit offset
Stack pointer
8-bit offset
16-bit offset
Relative
Memory-to-memory (4 modes)
Overview
23
Overview
Arithmetic Instructions
The CPU08 arithmetic functions include the following:
Low-Power Modes
The WAIT and STOP instructions reduce the power consumption of the
CPU08-based MCU. The WAIT instruction stops only the CPU clock and
therefore uses more power than the STOP instruction, which stops both
the CPU clock and the peripheral clocks. In most modules, clocks can
be shut off in wait mode.
Overview
MOTOROLA
Architecture
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
CPU08 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
Accumulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Index Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Stack Pointer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
Program Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Condition Code Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
CPU08 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
Internal Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Control Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Execution Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Instruction Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
Introduction
This section describes the CPU08 registers.
Architecture
25
Architecture
CPU08 Registers
Figure 1 shows the five CPU08 registers. The CPU08 registers are not
part of the memory map.
0
A
15
ACCUMULATOR (A)
15
0
STACK POINTER (SP)
15
0
PROGRAM COUNTER (PC)
7
V
0
1
CONDITION CODE
REGISTER (CCR)
Architecture
MOTOROLA
Architecture
CPU08 Registers
Accumulator
Bit 0
Read:
Write:
Reset:
X = Indeterminate
Index Register
The 16-bit index register shown in Figure 3 allows the user to index or
address a 64-Kbyte memory space. The concatenated 16-bit register is
called H:X. The upper byte of the index register is called H. The lower
byte of the index register is called X. H is cleared by reset. When H = 0
and no instructions that affect H are used, H:X is functionally identical to
the IX register of the M6805 Family.
In the indexed addressing modes, the CPU uses the contents of H:X to
determine the effective address of the operand. H:X can also serve as a
temporary data storage location. (See Indexed, No Offset on page 67;
Indexed, 8-Bit Offset on page 67; and Indexed, 16-Bit Offset on page
68.)
Bit 15 14
13
12
11
10
Bit 0
Read:
Write:
Reset:
X = Indeterminate
Architecture
27
Architecture
Stack Pointer
The stack pointer shown in Figure 4 is a 16-bit register that contains the
address of the next location on the stack. During a reset, the stack pointer
is preset to $00FF to provide compatibility with the M6805 Family.
NOTE:
The RSP instruction sets the least significant byte to $FF and does not
affect the most significant byte.
The address in the stack pointer decrements as data is pushed onto the
stack and increments as data is pulled from the stack. The SP always
points to the next available (empty) byte on the stack.
The CPU08 has stack pointer 8- and 16-bit offset addressing modes that
allow the stack pointer to be used as an index register to access
temporary variables on the stack. The CPU uses the contents in the SP
register to determine the effective address of the operand. (See Stack
Pointer, 8-Bit Offset and Stack Pointer, 16-Bit Offset on page 70.)
Bit 15 14
13
12
11
10
Bit 0
Read:
Write:
Reset:
NOTE:
Although preset to $00FF, the location of the stack is arbitrary and may
be relocated by the user to anywhere that RAM resides within the
memory map. Moving the SP out of page 0 ($0000 to $00FF) will free up
address space, which may be accessed using the efficient direct
addressing mode.
Architecture
MOTOROLA
Architecture
CPU08 Registers
Program Counter
13
12
11
10
Bit 0
Read:
Write:
Reset:
Architecture
29
Architecture
Condition Code
Register
Bit 0
Read:
Write:
Reset:
X = Indeterminate
NOTE:
Architecture
MOTOROLA
Architecture
CPU08 Registers
Architecture
31
Architecture
CONTROL UNIT
CONTROL
SIGNALS
STATUS
SIGNALS
EXECUTION UNIT
INTERNAL
DATA BUS
INTERNAL
ADDRESS BUS
Architecture
MOTOROLA
Architecture
CPU08 Functional Description
Internal Timing
The CPU08 derives its timing from a four-phase clock, each phase
identified as either T1, T2, T3, or T4. A CPU bus cycle consists of one
clock pulse from each phase, as shown in Figure 8. To simplify
subsequent diagrams, the T clocks have been combined into a single
signal called the CPU clock. The start of a CPU cycle is defined as the
leading edge of T1, though the address associated with this cycle does
not drive the address bus until T3. Note that the new address leads the
associated data by one-half of a bus cycle.
For example, the data read associated with a new PC value generated
in T1/T2 of cycle 1 in Figure 8 would not be read into the control unit until
T2 of the next cycle.
T1
T2
T3
T4
CYCLE 1
CPU CLOCK
INTERNAL
ADDRESS BUS
CYCLE 2
T1 T2 T3 T4 T1 T2 T3 T4
ADDR. CYCLE N
INTERNAL
DATA BUS
DATA CYCLE
EXECUTE
CYCLE N
Architecture
33
Architecture
Control Unit
The control unit consists of the sequencer, the control store, and random
control logic. These blocks make up a finite state machine, which
generates all the controls for the execution unit.
The sequencer provides the next state of the machine to the control store
based on the contents of the instruction register (IR) and the current state
of the machine. The control store is strobed (enabled) when the next state
input is stable, producing an output that represents the decoded next state
condition for the execution unit (EU). This result, with the help of some
random logic, is used to generate the control signals that configure the
execution unit. The random logic selects the appropriate signals and adds
timing to the outputs of the control store. The control unit fires once per
bus cycle but runs almost a full cycle ahead of the execution unit to decode
and generate all the controls for the next cycle. The sequential nature of
the machine is shown in Figure 9.
The sequencer also contains and controls the OPCODE LOOKAHEAD
register, which is used to prefetch the next sequential instruction. Timing
of this operation is discussed in Instruction Execution on page 35.
CPU CLOCK
T1
T2
T3
IR/CONTROL UNIT
STATE INPUT
T4
T1
T2
T3
T4
T1
T2
T3
T4
CYCLE N STATE
CONTROL UNIT
STROBE
CYCLE N
STROBE
CONTROL UNIT
OUTPUT TO
EXECUTION UNIT
CYCLE N
EU CONTROL
INTERNAL
ADDRESS BUS
ADDRESS
CYCLE N
INTERNAL
DATA BUS
DATA CYCLE N
FETCH/DECODE
CYCLE N
EXECUTE
CYCLE N
Architecture
MOTOROLA
Architecture
CPU08 Functional Description
Execution Unit
The execution unit (EU) contains all the registers, the ALU, and the bus
interface. Once per bus cycle a new address is computed by passing
selected register values along the internal address buses to the address
buffers. Note that the new address leads the associated data by one half
of a bus cycle. The execution unit also contains some special function
logic for unusual instructions such as DAA, MUL, and DIV.
Instruction
Execution
Architecture
35
Architecture
In the instruction boundaries example (Figure 10) the OPCODE
LOOKAHEAD and LASTBOX are asserted simultaneously during TAX
and INCX execution, but the LDA indexed with 8-bit offset instruction
prefetches the next opcode before the last cycle. Refer to Figure 11.
The boldface instructions in Figure 10 are illustrated in Figure 11.
0100
A6
0102
97
0103
e6
0105
5c
0106
c7
50
ORG
$50
FCB
$12
ORG
$100
LDA
#$50
TAX
$34
02
LDA
2,X
INCX
80 00 STA
$8000
$56
;A = $50
PC=$0103
;A -> X
PC=$0104
;[X+2] -> A
PC=$0106
;X = X+1
PC=$0107
;A -> $8000
PC=$010A
Architecture
MOTOROLA
Architecture
CPU08 Functional Description
OPCODE LOOKAHEAD/DECODE
LDA INSTRUCTION
CPU CLOCK
OPCODE
LOOKAHEAD
REGISTER
T2
T1
T3
T4
T1
TAX
OPCODE
T2
OPCODE LOOKAHEAD
INCX INSTRUCTION
T3
T4
T1
T2
T3
T4
DECODE INCX
INSTRUCTION
T1
LDA OPCODE
T2
T3
T4
INCX OPCODE
LASTBOX
OPCODE LOOKAHEAD
IR/CONTROL
UNIT STATE
INPUT
TAX
STATE 1
LDA STATE 1
CONTROL UNIT
STROBE
CONTROL UNIT
OUTPUT TO
EXECUTION UNIT
LDA CYCLE
1 STROBE
TAX EU CONTROL
LDA OPCODE
PREFETCH
INTERNAL
ADDRESS BUS
LDA STATE 3
LDA STATE 2
LDA CYCLE
2 STROBE
LDA CYCLE 1
EU CONTROL
INCX STATE 1
LDA CYCLE
3 STROBE
LDA CYCLE 2
EU CONTROL
LDA CYCLE 3
EU CONTROL
STA OPCODE
PREFETCH
$0103
$0104
LDA OPCODE
INTERNAL
DATA BUS
$E6
INSTRUCTION
EXECUTION
BOUNDARIES
TAX
$0052
$0105
$0106
INCX OPCODE
$02
$5C
$56
LDA
Architecture
37
Architecture
Architecture
MOTOROLA
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40
Elements of Reset and Interrupt Processing . . . . . . . . . . . . . . . . . . .41
Recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
Stacking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Arbitration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
Masking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45
Returning to Calling Program . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Reset Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Initial Conditions Established . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
CPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Operating Mode Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Reset Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
External Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
Active Reset from an Internal Source . . . . . . . . . . . . . . . . . . . . . .50
Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Interrupt Sources and Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . .52
Interrupts in STOP and WAIT Modes . . . . . . . . . . . . . . . . . . . . . .53
Nesting of Multiple Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Allocating Scratch Space on the Stack . . . . . . . . . . . . . . . . . . . . .53
39
Introduction
The CPU08 in a microcontroller executes instructions sequentially. In
many applications it is necessary to execute sets of instructions in
response to requests from various peripheral devices. These requests
are often asynchronous to the execution of the main program. Resets
and interrupts are both types of CPU08 exceptions. Entry to the
appropriate service routine is called exception processing.
Reset is required to initialize the device into a known state, including
loading the program counter (PC) with the address of the first instruction.
Reset and interrupt operations share the common concept of vector
fetching to force a new starting point for further CPU08 operations.
Interrupts provide a way to suspend normal program execution
temporarily so that the CPU08 can be freed to service these requests.
The CPU08 can process up to 128 separate interrupt sources including
a software interrupt (SWI).
On-chip peripheral systems generate maskable interrupts that are
recognized only if the global interrupt mask bit (I bit) in the condition code
register is clear (reset is non-maskable). Maskable interrupts are
prioritized according to a default arrangement. (See Table 2 and
Interrupt Sources and Priority on page 52.) When interrupt conditions
occur in an on-chip peripheral system, an interrupt status flag is set to
indicate the condition. When the user's program has properly
responded to this interrupt request, the status flag must be cleared.
MOTOROLA
Recognition
41
NOTE:
To maintain compatibility with the M6805 Family, H ( the high byte of the
index register) is not stacked during interrupt processing. If the interrupt
service routine modifies H or uses the indexed addressing mode, it is
the users responsibility to save and restore it prior to returning. See
Figure 12.
IRQINT
PSHH
|
|Interrupt service routine
|
|
PULH
RTI
MOTOROLA
UNSTACKING
ORDER
ACCUMULATOR
STACKING
ORDER
$00FF (DEFAULT ADDRESS
ON RESET)
All reset sources always have equal and highest priority and cannot be
arbitrated. Interrupts are latched, and arbitration is performed in the
system integration module (SIM) at the start of interrupt processing. The
arbitration result is a constant that the CPU08 uses to determine which
vector to fetch. Once an interrupt is latched by the SIM, no other
interrupt may take precedence, regardless of priority, until the latched
interrupt is serviced (or the I bit is cleared). See Figure 14.
43
BUS CYCLE #
BUS CYCLE #
LAST CYCLE OF
CURRENT INSTRUCTION
(A)
COMPLETE NEXT
INSTRUCTION
FETCH (REDUNDANT)
COMPLETE NEXT
INSTRUCTION (B)
FETCH (REDUNDANT)
UNSTACK CCR
UNSTACK A
UNSTACK X
UNSTACK PCH
UNSTACK PCL
FETCH NEXT
INSTRUCTION (B)
STACK PCL
STACK PCH
INTERRUPT PROCESSING
RTI
STACK X
STACK A
STACK CCR
FETCH VECTOR
INTERRUPT HIGH BYTE
INTERRUPT
PENDING?
FETCH VECTOR
INTERRUPT LOW BYTE
FETCH INTERRUPT
SERVICE ROUTINE
FIRST INSTRUCTION
START INTERRUPT
PROCESSING
NO
FIRST CYCLE OF
NEXT INSTRUCTION (B)
EXECUTE INTERRUPT
SERVICE ROUTINE
YES
MOTOROLA
Masking
CLI
LDA
INT1
PSHH
|
|
|
PULH
RTI
#$FF
Background
Routine
45
CLI
LDA
#$FF
INT1 PSHH
|
|
PULH
RTI
INT2
PSHH
|
|
PULH
RTI
Background
Routine
INT1
PSHH
|
|
PULH
RTI
MOTOROLA
Returning to
Calling Program
NOTE:
Since the return I bit state comes from the stacked CCR, the user, by
setting the I bit in the stacked CCR, can block all subsequent interrupts
pending or otherwise, regardless of priority, from within an interrupt
service routine.
LDA
ORA
STA
RTI
#$08
1,SP
1,SP
47
Reset Processing
Reset forces the MCU to assume a set of initial conditions and to begin
executing instructions from a predetermined starting address. For the
M68HC08 Family, reset assertion is asynchronous with instruction
execution, and so the initial conditions can be assumed to take effect
almost immediately after applying an active low level to the reset pin,
regardless of whether the clock has started. Internally, reset is a clocked
process, and so reset negation is synchronous with an internal clock, as
shown in Figure 18, which shows the internal timing for exiting a pin
reset.
CPU CLOCK
T3 T4 T1 T2 T3 T4 T1 T2 T3 T4 T1 T2 T3 T4 T1 T2 T3 T4 T1 T2 T3 T4
INTERNAL
ADDRESS BUS
INDETERMINATE
INTERNAL
DATA BUS
INDETERMINATE
$FFFE
$FFFF
PCH
RESET PIN
RESET PIN SAMPLING
MOTOROLA
Initial Conditions
Established
Once the reset condition is recognized, internal registers and control bits
are forced to an initial state. These initial states are described
throughout this manual. These initial states in turn control on-chip
peripheral systems to force them to known startup states. Most of the
initial conditions are independent of the operating mode. The following
paragraphs summarize the initial conditions of the CPU08 and
input/output (I/O) as they leave reset.
CPU
After reset the CPU08 fetches the reset vector from locations $FFFE and
$FFFF (when in monitor mode, the reset vector is fetched from $FEFE
and $FEFF), loads the vector into the PC, and begins executing
instructions. The stack pointer is loaded with $00FF. The H register is
cleared to provide compatibility for existing M6805 object code. All other
CPU08 registers are indeterminate immediately after reset; however,
the I interrupt mask bit in the condition code register is set to mask any
interrupts, and the STOP and WAIT latches are both cleared.
Operating Mode
Selection
The CPU08 has two modes of operation useful to the user: user mode
and monitor mode. The monitor mode is the same as user mode except
that alternate vectors are used by forcing address bit A8 to 0 instead of
1. The reset vector is therefore fetched from addresses $FEFE and
FEFF instead of FFFE and FFFF. This offset allows the CPU08 to
execute code from the internal monitor firmware instead of the user
code. (Refer to the appropriate technical data manual for specific
information regarding the internal monitor description.)
The mode of operation is latched on the rising edge of the reset pin. The
monitor mode is selected by connecting two port lines to Vss and
applying an over-voltage of approximately 2 x VDD to the IRQ1 pin
concurrent with the rising edge of reset. (See Table 1.) Port allocation
varies from port to port.
Table 1. Mode Selection
IRQ1 Pin
Port x
Port y
Mode
VDD
User
2 x VDD
Monitor
49
The system integration module (SIM) has master reset control and may
include, depending upon device implementation, any of the following
typical reset sources:
COP watchdog
External Reset
A logic zero applied to the RESET pin asserts the internal reset signal,
which halts all processing on the chip. The CPU08 and peripherals are
reset.
All internal reset sources actively pull down the RESET pin to allow the
resetting of external peripherals. The RESET pin will be pulled down for
16 bus clock cycles; the internal reset signal will continue to be asserted
for an additional 16 cycles after that. If the RESET pin is still low at the
the end of the second 16 cycles, then an external reset has occurred. If
the pin is high, the appropriate bit will be set to indicate the source of the
reset.
The active reset feature allows the part to issue a reset to peripherals
and other chips within a system built around an M68HC08
microcontroller.
MOTOROLA
Interrupt Processing
The group of instructions executed in response to an interrupt is called
an interrupt service routine. These routines are much like subroutines
except that they are called through the automatic hardware interrupt
mechanism rather than by a subroutine call instruction, and all CPU08
registers, except the H register, are saved on the stack. (See I
Interrupt Mask on page 30).
An interrupt (provided it is enabled) causes normal program flow to be
suspended as soon as the currently executing instruction finishes. The
interrupt logic then pushes the contents of all CPU08 registers onto the
stack, except the H register, so that the CPU08 contents can be restored
after the interrupt is finished. After stacking the CPU08 registers, the
vector for the highest priority pending interrupt source is loaded into the
program counter and execution continues with the first instruction of the
interrupt service routine.
An interrupt is concluded with a return from interrupt (RTI) instruction,
which causes all CPU08 registers and the return address to be
recovered from the stack, so that the interrupted program can resume as
if there had been no interruption.
Interrupts can be enabled or disabled by the mask bit (I bit) in the
condition code register and by local enable mask bits in the on-chip
peripheral control registers. The interrupt mask bits in the CCR provide
a means of controlling the nesting of interrupts.
In rare cases it may be useful to allow an interrupt routine to be
interrupted. (See Nesting of Multiple Interrupts on page 53.)
However, nesting is discouraged because it greatly complicates a
system and rarely improves system performance.
By default, the interrupt structure inhibits interrupts during the interrupt
entry sequence by setting the interrupt mask bit(s) in the CCR. As the
CCR is recovered from the stack during the return from interrupt, the
condition code bits return to the enabled state so that additional
interrupts can be serviced.
51
Interrupt Sources
and Priority
NOTE:
The CPU08 can have 128 separate vectors including reset and software
interrupt (SWI), which leaves 126 inputs for independent interrupt
sources. (See Table 2.)
Reset
Priority
FFFE
Reset
FFFC
SWI
FFFA
IREQ[0]
FF02
IREQ[124]
127
FF00
IREQ[125]
128
NOTE:
The interrupt source priority for any specific module may not always be
the same in different M68HC08 versions. For details about the priority
assigned to interrupt sources in a specific M68HC08 device, refer to the
SIM section of the technical data manual written for that device.
SWI as an instruction has the highest priority other than reset; once the
SWI opcode is fetched, no other interrupt can be honored until the SWI
vector has been fetched.
MOTOROLA
Interrupts in STOP
and WAIT Modes
In WAIT mode the CPU clocks are disabled, but other module clocks
remain active. A module that is active during WAIT mode can wake up
the CPU08 by an interrupt if the interrupt is enabled. Processing of the
interrupt begins immediately.
In STOP mode, the system clocks do not run. The system control
module inputs are conditioned so that they can be asynchronous. A
particular module can wake the part up from STOP mode with an
interrupt provided that the module has been designed to do so.
Nesting of Multiple
Interrupts
Allocating
Scratch Space
on the Stack
MOTOROLA
53
IRQINT
PSHH
AIS
STA
#-16
3,SP
;Save H register
;Allocate 16 bytes of local storage
;Store a value in the second byte
;of local space
* Note:
*
*
*
*
* Note:
*
*
*
*
*
*
MOTOROLA
Addressing Modes
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Inherent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Immediate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60
Direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Extended . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Indexed, No Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Indexed, 8-Bit Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Indexed, 16-Bit Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Stack Pointer, 8-Bit Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
Stack Pointer, 16-Bit Offset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
Relative . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .73
Memory to Memory Immediate to Direct . . . . . . . . . . . . . . . . . . . .75
Memory to Memory Direct to Direct . . . . . . . . . . . . . . . . . . . . . . .76
Memory to Memory Indexed to Direct with Post Increment . . . . .77
Memory to Memory Direct to Indexed with Post Increment . . . . .78
Indexed with Post Increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
Indexed, 8-Bit Offset with Post Increment . . . . . . . . . . . . . . . . . . .80
Introduction
This section describes the addressing modes of the M68HC08 CPU.
Addressing Modes
55
Addressing Modes
Addressing Modes
The CPU uses 16 addressing modes for flexibility in accessing data.
These addressing modes define how the CPU finds the data required to
execute an instruction. The 16 addressing modes are as follows:
Inherent
Immediate
Direct
Extended
Indexed, no offset
Relative
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Inherent
Machine
Code
Label
Operation
Operand
A657
AB45
72
EX_1
LDA
ADD
DAA
#$57
#$45
;A =
;A =
;A =
;bit
A614
8C
AE03
52
EX_2
LDA
CLRH
LDX
DIV
#20
;LS dividend in A
;Clear MS dividend
;Divisor in X
;(H:A)/XA=06,H=02
A630
87
EX_3
LDA
PSHA
#3
#$30
Comments
$57
$9C
$02 w/carry
set $102
;A = $30
;Push $30 on stack and
;decrement stack
;pointer by 1
Addressing Modes
57
Addressing Modes
Table 3. Inherent Addressing Instructions
Instruction
Mnemonic
ASLA, ASLX
ASRA, ASRX
CLC
CLI
Clear
CLRA, CLRX
CLRH
COMA, COMX
DAA
DBNZA
DBNZX
Decrement
DECA, DECX
DIV
Increment
INCA, INCX
LSLA, LSLX
LSRA, LSRX
Multiply
MUL
Negate
NEGA, NEGX
NSA
No Operation
NOP
PSHA
PSHH
PSHX
PULA
PULH
PULX
ROLA, ROLX
RORA, RORX
RSP
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Mnemonic
RTI
RTS
SEC
SEI
STOP
Software Interrupt
SWI
TAP
TAX
TPA
TSTA, TSTX
TSX
TXA
TXS
WAIT
Addressing Modes
59
Addressing Modes
Immediate
Machine
Code
5F
8C
AF01
65FFFF
26F9
20F5
Label
START
TAG
Operation
Operand
CLRX
CLRH
AIX
CPHX
#1
#$FFFF
BNE
BRA
TAG
START
Comments
;X = 0
;H = 0
;(H:X) = (H:X) + 1
;Compare (H:X) to
;$FFFF
;Loop until equal
;Start over
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Mnemonic
ADC
ADD
AIS
AIX
AND
BIT
CBEQA
CBEQX
CMP
CPHX
CPX
EOR
LDA
LDHX
LDX
ORA
SBC
SUB
Addressing Modes
61
Addressing Modes
Direct
Most direct instructions can access any of the first 256 memory
addresses with only two bytes. The first byte is the opcode, and the
second is the low byte of the operand address. The high-order byte of
the effective address is assumed to be $00 and is not included as an
instruction byte (saving program memory space and execution time).
The use of direct addressing mode is therefore limited to operands in the
$0000$00FF area of memory (called the direct page or page 0).
Direct addressing instructions take one less byte of program memory
space than the equivalent instructions using extended addressing. By
eliminating the additional memory access, the execution time is reduced
by one cycle. In the course of a long program, this savings can be
substantial. Most microcontroller units place some if not all RAM in the
$0000$00FF area; this allows the designer to assign these locations to
frequently referenced data variables, thus saving execution time.
BRSET and BRCLR are three-byte instructions that use direct
addressing to access the operand and relative addressing to specify a
branch destination.
CPHX, STHX, and LDHX are two-byte instructions that fetch a 16-bit
operand. The most significant byte comes from the direct address; the
least significant byte comes from the direct address + 1.
Table 5 lists the instructions that use direct addressing.
The following example code contains two direct addressing mode
instructions: STHX (store H:X in memory) and CPHX (compare H:X
with memory). The first STHX instruction initializes RAM storage
location TEMP to zero, and the second STHX instruction loads TEMP
with $5555. The CPHX instruction compares the value in H:X with the
value of RAM:(RAM + 1). In this example RAM:(RAM + 1) = TEMP =
$50:$51 = $5555.
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Machine
Code
Label
RAM
ROM
TEMP
5F
8C
3550
455555
3550
7550
26FC
START
BAD_PART
20F1
Operation
Operand
EQU
EQU
ORG
RMB
ORG
CLRX
CLRH
STHX
LDHX
STHX
CPHX
BNE
$50
$6E00
$RAM
2
$ROM
BRA
START
TEMP
#$5555
TEMP
RAM
BAD_PART
Comments
;RAM equate
;ROM equate
;Beginning of RAM
;Reserve 2 bytes
;Beginning of ROM
;X = 0
;H = 0
;H:X=0 > temp
;Load H:X with $5555
;Temp=$5555
;RAM=temp
;RAM=temp will be
;same unless something
;is very wrong!
;Do it again
Mnemonic
ADC
ADD
AND
ASL*
ASR
BCLR
BIT
BRCLR
BRSET
BSET
CBEQ
Clear Memory
CLR
CMP
Complement Memory
COM
CPHX
Addressing Modes
63
Addressing Modes
Table 5. Direct Addressing Instructions (Continued)
Instruction
Compare X (Index Register Low) with Memory
Decrement Memory and Branch if Not Equal ($00)
Mnemonic
CPX
DBNZ
Decrement Memory
DEC
EOR
Increment Memory
INC
Jump
JMP
Jump to Subroutine
JSR
LDA
LDHX
LDX
LSL*
LSR
Negate Memory
NEG
ORA
ROL
ROR
SBC
STA
STHX
STX
SUB
TST
*ASL = LSL
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Extended
Machine
Code
Label
Operation
Operand
Comments
$50
$FF
;Start at $50
;$50 = $FF
5F
BE50
ORG
FCB
CLRX
LDX
$0050
;Load X direct
$6E00
$FF
;Start at $6E00
;$6E00 = $FF
5F
CE6E00
ORG
FCB
CLRX
LDX
$6E00
;Load X extended
Addressing Modes
65
Addressing Modes
Table 6. Extended Addressing Instructions
Instruction
Mnemonic
ADC
ADD
AND
BIT
CMP
CPX
EOR
Jump
JMP
Jump to Subroutine
JSR
LDA
LDX
ORA
SBC
STA
STX
SUB
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Indexed, No Offset
Indexed, 8-Bit
Offset
Addressing Modes
67
Addressing Modes
Indexed, 16-Bit
Offset
Machine
Code
Label
Operation
Operand
Comments
FC
JMP
,X
;No offset
;Jump to address
;pointed to by H:X
ECFF
JMP
$FF,X
;8-bit offset
;Jump to address
;pointed to by H:X +
$FF
DC10FF
JMP
$10FF,X
;16-bit offset
;Jump to address
;pointed to by H:X +
$10FF
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
No Offset
8-Bit
Offset
16-Bit
Offset
ADC
ADD
AND
ASL*
ASR
BIT
Clear Memory
CLR
CMP
Complement Memory
COM
CPX
DBNZ
Decrement Memory
DEC
EOR
Increment Memory
INC
Jump
JMP
Jump to Subroutine
JSR
LDA
LDX
LSL*
LSR
Negate Memory
NEG
ORA
ROL
Instruction
Addressing Modes
69
Addressing Modes
Table 7. Indexed Addressing Instructions (Continued)
Instruction
Mnemonic
No Offset
8-Bit
Offset
16-Bit
Offset
ROR
SBC
STA
STX
SUB
TST
*ASL = LSL
Stack Pointer,
8-Bit Offset
Stack Pointer,
16-Bit Offset
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
bytes following the opcode. The sum is the effective address of the
operand.
As with direct and extended addressing, most assemblers determine the
shortest form of stack pointer addressing. Due to the pre-byte, stack
pointer relative instructions take one cycle longer than their index
relative counterparts. Table 8 lists the instructions that can be used in
the stack pointer, 16-bit offset addressing mode.
Examples of the 8-bit and 16-bit offset stack pointer addressing modes
are shown below. The first example stores the value of $20 in location
$10, SP = $10 + $FF = $10F and then decrements that location until
equal to zero. The second example loads the accumulator with the
contents of memory location $250, SP = $250 + $FF = $34F.
Machine
Code
Label
Operation
Operand
450100
94
LDHX
TXS
#$0100
A620
9EE710
9E6B10FC
LDA
STA
DBNZ
#$20
$10,SP
$10,SP,L
P
450100
94
LDHX
TXS
#$0100
9ED60250
LDA
$0250,SP
LP
Comments
Stack pointer, 16-bit offset instructions are useful in selecting the kth
element in an n-element table. The table can begin anywhere and can
extend anywhere in memory. With this four-byte instruction, the k value
would typically be in the stack pointer register, and the address of the
beginning of the table is located in the two bytes following the two-byte
opcode.
Addressing Modes
71
Addressing Modes
Table 8. Stack Pointer Addressing Instructions
Mnemonic
8-Bit
Offset
16-Bit
Offset
ADC
ADD
AND
ASL*
ASR
BIT
CBEQ
Clear Memory
CLR
CMP
Complement Memory
COM
CPX
DBNZ
Decrement Memory
DEC
EOR
Increment Memory
INC
LDA
LDX
LSL*
LSR
Negate Memory
NEG
ORA
ROL
ROR
SBC
Instruction
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
8-Bit
Offset
16-Bit
Offset
STA
STX
SUB
TST
Instruction
*ASL = LSL
Relative
Addressing Modes
73
Addressing Modes
compared to the signed value 2. Because #1 is greater than 2, the
branch to TAG will not occur.
Machine
Code
A601
Label
Operation
TAG
A1FE
91FA
20FE
HERE
Operand
Comments
LDA
#1
;A = 1
CMP
BLT
#-2
TAG
;Compare with -2
;Branch if value of A
;is less than -2
BRA
HERE
;Branch always
Mnemonic
BCC
BCS
Branch if Equal
BEQ
BGE
BGT
BHCC
BHCS
Branch if Higher
BHI
BHS (BCC)
BIH
BIL
BLE
Branch if Lower
BLO (BCS)
BLS
BLT
BMC
Branch if Minus
BMI
BMS
BNE
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Memory
to Memory
Immediate
to Direct
Mnemonic
Branch if Plus
BPL
Branch Always
BRA
BRCLR
BRSET
Branch Never
BRN
Branch to Subroutine
BSR
(2 cycles)
PSHA
A622
B7F0
B650
(2
(3
(2
9
LDA
STA
PULA
cycles)
cycles)
cycles)
cycles
#$22
$F0
Comments
;Save current A
; value
;A = $22
;Store $22 into $F0
;Restore A value
(4
cycles)
MOV
#$22,$
F0
;Location $F0
;= $22
Addressing Modes
75
Addressing Modes
Memory
to Memory Direct
to Direct
(2 cycles)
(3 cycles)
PSHA
LDA
B7F1
B650
(3 cycles)
(2 cycles)
10 cycles
STA
PULA
Operand
$F0
$F1
Comments
;Save A value
;Get contents
;of $F0
;Location $F1=$F0
;Restore A value
;Move contents of
;$F0 to $F1
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Memory to
Memory Indexed
to Direct with Post
Increment
NOTE:
55 50
B6 16
Label
Operation Operand
SIZE
EQU
16
SCSR1
EQU
$16
SCDR
EQU
$18
ORG
PTR_OUT RMB
$50
2
PTR_IN
RMB
Comments
;TX circular
;buffer length
;SCI status
;register 1
;SCI transmit
;data register
;Circular buffer
;data out pointer
;Circular buffer
;data in pointer
;Circular buffer
TX_B
RMB
SIZE
*
* SCI transmit data register empty interrupt
* service routine
*
ORG
$6E00
TX_INT LDHX
PTR_OUT ;Load pointer
LDA
SCSR1
;Dummy read of
;SCSR1 as part of
;the TDRE reset
Addressing Modes
77
Addressing Modes
Machine
Code
7E 18
Operation Operand
MOV
65 00 64
CPHX
23 03
45 00 54
BLS
LDHX
35 50
80
Memory to
Memory Direct to
Indexed with Post
Increment
Label
NOLOOP
STHX
RTI
Comments
X+,
SCDR
NOTE:
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Machine
Code
55 72
B6 16
Label
Operation
Operand
SIZE
EQU
16
SCSR1
SCDR
EQU
EQU
$16
$18
PTR_OUT
ORG
RMB
$70
2
PTR_IN
RMB
RX_B
RMB
*
* SCI receive data
* service routine
*
ORG
RX_INT
LDHX
LDA
;RX circular
;buffer length
;SCI status reg.1
;SCI receive
;data reg.
SIZE
$6E00
PTR_IN
SCSR1
MOV
SCDR ,X+
65 00 64
CPHX
23 03
45 00 54
BLS
LDHX
#RX_B +
SIZE
NOLOOP
#RX_B
STHX
PTR_IN
80
NOLOOP
;Circular buffer
;data out pointer
;Circular buffer
;data in pointer
;Circular buffer
5E 18
35 52
Comments
RTI
;Load pointer
;Dummy read of
;SCSR1 as part of
;the RDRF reset
;Move new byte from
;SCI data reg.
;Clear RDRF. Post
;increment H:X.
;Gone past end of
;circular buffer?
;If not continue
;Else reset to
;start of buffer
;Save new
;pointer value
;Return
Mnemonic
MOV
MOV
MOV
MOV
Addressing Modes
79
Addressing Modes
Indexed with Post
Increment
NOTE:
Indexed, 8-Bit
Offset with Post
Increment
NOTE:
Label
Operation
LDA
STA
MOV
CLRX
Operand
#$FF
$10
$10,$60
Comments
;A = $FF
;LOC $10 = $FF
;LOC $60 = $FF
;Zero X
Addressing Modes
MOTOROLA
Addressing Modes
Addressing Modes
Machine
Code
7102
20FC
5F
Label
Operation
LOOP
CBEQ
BRA
TAG
CLRX
Operand
X+,TAG
LOOP
Comments
;No offset
;Check next location
;Zero X
LOOP2
TG1
CBEQ
BRA
BRA
$50,X+,TG1
LOOP2
TG1
;8-bit offset
;Check next location
;Finished
Mnemonic
CBEQ
CBEQ
MOV
MOV
Addressing Modes
81
Addressing Modes
Addressing Modes
MOTOROLA
Instruction Set
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Nomenclature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Convention Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Instruction Set Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
Opcode Map and Instruction Set Summary . . . . . . . . . . . . . . . . . . . .90
ADC Add with Carry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
ADD Add without Carry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
AIS Add Immediate Value (Signed) to Stack Pointer . . . . . . . .93
AIX Add Immediate Value (Signed) to Index Register. . . . . . . .94
AND Logical AND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
ASL Arithmetic Shift Left . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
ASR Arithmetic Shift Right. . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
BCC Branch if Carry Bit Clear . . . . . . . . . . . . . . . . . . . . . . . . . .98
BCLR n Clear Bit n in Memory . . . . . . . . . . . . . . . . . . . . . . . . .99
BCS Branch if Carry Bit Set. . . . . . . . . . . . . . . . . . . . . . . . . . .100
BEQ Branch if Equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
BGE Branch if Greater Than or Equal To . . . . . . . . . . . . . . . .102
BGT Branch if Greater Than . . . . . . . . . . . . . . . . . . . . . . . . . .103
BHCC Branch if Half Carry Bit Clear . . . . . . . . . . . . . . . . . . . .104
BHCS Branch if Half Carry Bit Set. . . . . . . . . . . . . . . . . . . . . .105
BHI Branch if Higher . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
BHS Branch if Higher or Same . . . . . . . . . . . . . . . . . . . . . . . .107
BIH Branch if IRQ Pin High . . . . . . . . . . . . . . . . . . . . . . . . . . .108
BIL Branch if IRQ Pin Low. . . . . . . . . . . . . . . . . . . . . . . . . . . .109
BIT Bit Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
BLE Branch if Less Than or Equal To . . . . . . . . . . . . . . . . . . .111
BLO Branch if Lower . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112
BLS Branch if Lower or Same . . . . . . . . . . . . . . . . . . . . . . . . .113
BLT Branch if Less Than . . . . . . . . . . . . . . . . . . . . . . . . . . . . .114
CPU08 Reference Manual Rev. 2.0
MOTOROLA
Instruction Set
83
Instruction Set
BMC Branch if Interrupt Mask Clear . . . . . . . . . . . . . . . . . . . .115
BMI Branch if Minus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .116
BMS Branch if Interrupt Mask Set . . . . . . . . . . . . . . . . . . . . . .117
BNE Branch if Not Equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118
BPL Branch if Plus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
BRA Branch Always . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120
BRCLR n Branch if Bit n in Memory Clear. . . . . . . . . . . . . . . .121
BRN Branch Never . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
BRSET n Branch if Bit n in Memory Set . . . . . . . . . . . . . . . . .123
BSET n Set Bit n in Memory . . . . . . . . . . . . . . . . . . . . . . . . . .124
BSR Branch to Subroutine . . . . . . . . . . . . . . . . . . . . . . . . . . .125
CBEQ Compare and Branch if Equal . . . . . . . . . . . . . . . . . . .126
CLC Clear Carry Bit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
CLI Clear Interrupt Mask Bit . . . . . . . . . . . . . . . . . . . . . . . . . .128
CLR Clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129
CMP Compare Accumulator with Memory . . . . . . . . . . . . . . .130
COM Complement (Ones Complement) . . . . . . . . . . . . . . . .131
CPHX Compare Index Register with Memory . . . . . . . . . . . . .132
CPX Compare X (Index Register Low) with Memory . . . . . . .133
DAA Decimal Adjust Accumulator . . . . . . . . . . . . . . . . . . . . . .134
DAA Decimal Adjust Accumulator . . . . . . . . . . . . . . . . . . . . . .135
DBNZ Decrement and Branch if Not Zero . . . . . . . . . . . . . . . .136
DEC Decrement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137
DIV Divide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
EOR Exclusive-OR Memory with Accumulator . . . . . . . . . . . .139
INC Increment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140
JMP Jump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
JSR Jump to Subroutine . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
LDA Load Accumulator from Memory . . . . . . . . . . . . . . . . . . .143
LDHX Load Index Register from Memory . . . . . . . . . . . . . . . .144
LDX Load X (Index Register Low) from Memory. . . . . . . . . . .145
LSL Logical Shift Left. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146
LSR Logical Shift Right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
MOV Move. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148
MUL Unsigned Multiply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149
NEG Negate (Twos Complement) . . . . . . . . . . . . . . . . . . . . .150
NOP No Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151
NSA Nibble Swap Accumulator . . . . . . . . . . . . . . . . . . . . . . . .152
CPU08 Reference Manual Rev. 2.0
84
Instruction Set
MOTOROLA
Instruction Set
Contents
Instruction Set
85
Instruction Set
Introduction
This section contains complete detailed information for all M68HC08
Family instructions. The instructions are arranged in alphabetical order
with the instruction mnemonic set in larger type for easy reference.
Nomenclature
The nomenclature listed below is used in the instruction descriptions
throughout this section.
Operators
()
&
|
:
+
=
=
=
=
=
=
=
=
=
=
=
=
Instruction Set
MOTOROLA
Instruction Set
Nomenclature
CPU Registers
A =
CCR =
H =
X =
PC =
PCH =
PCL =
SP =
Accumulator
Condition code register
Index register, higher order (most significant) 8 bits
Index register, lower order (least significant) 8 bits
Program counter
Program counter, higher order (most significant) 8 bits
Program counter, lower order (least significant) 8 bits
Stack pointer
addressing mode
Relative offset (i.e., the two's complement number
stored in the last byte of machine code corresponding
to a branch instruction)
Instruction Set
87
Instruction Set
Bit status AFTER execution of an instruction
For two-byte operations such as LDHX, STHX, and CPHX, n = 15
refers to bit 15 of the two-byte word, or bit 7 of the most significant
(first) byte.
Rn = Bit n of the result of operation (n = 7, 6, 5, 0)
CCR activity figure notation
= Bit not affected
0 = Bit forced to zero
1 = Bit forced to one
= Bit set or cleared according to results of operation
Machine coding notation
dd = Low-order 8 bits of a direct address $0000$00FF
(high byte assumed to be $00)
ee = Upper 8 bits of 16-bit offset
ff = Lower 8 bits of 16-bit offset or 8-bit offset
ii = One byte of immediate data
hh = High-order byte of 16-bit extended address
ll = Low-order byte of 16-bit extended address
rr = Relative offset
Source form notation
opr
rel
Instruction Set
MOTOROLA
Instruction Set
Nomenclature
Address modes
INH = Inherent (no operands)
IMM = 8-bit immediate
DIR = 8-bit direct
EXT = 16-bit extended
IX = 16-bit indexed no offset
IX+ = 16-bit indexed no offset, post increment
IX1 = 16-bit indexed with 8-bit offset
IX1+ = 16-bit indexed with 8-bit offset, post increment
IX2 = 16-bit indexed with 16-bit offset
REL = 8-bit relative offset
DD = Direct source to direct destination
IMD = Immediate to direct
IX+D = 16-bit indexed, post increment source to direct
destination
DIX+ = Direct source to 16-bit indexed, post increment
destination
SP1 = Stack pointer with 8-bit offset
SP2 = Stack pointer with 16-bit offset
Instruction Set
89
Instruction Set
Convention Definition
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.
A specific bit is referred to by mnemonic and bit number. A7 is bit 7 of
accumulator A. A range of bits is referred to by mnemonic and the bit
numbers that define the range. A [7:4] are bits 7 to 4 of the accumulator.
Parentheses indicate the contents of a register or memory location,
rather than the register or memory location itself. (A) is the contents of
the accumulator.
LSB means least significant bit or bits.
MSB means most significant bit or bits. References to high and low
bytes are spelled out.
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
ADC
ADC
Operation
Description
Adds the contents of the C bit to the sum of the contents of A and M and
places the result in A.
Condition Codes
and Boolean
Formulae
V: A7&M7&R7 | A7&M7&R7
Set if a twos complement overflow resulted from the operation;
cleared otherwise.
H: A3&M3 | M3&R3 | R3&A3
Set if there was a carry from bit 3; cleared otherwise.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: A7&M7 | M7&R7 | R7&A7
Set if there was a carry from the MSB of the result; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
ADC
#opr
IMM
A9
ii
ADC
opr
DIR
B9
dd
hh
ADC
opr
EXT
C9
ADC
,X
IX
F9
ADC
opr,X
IX1
E9
ff
ADC
opr,X
IX2
D9
ee
ADC
opr,SP
SP1
9EE9
ff
ADC
opr,SP
SP2
9ED9
ee
ll
4
2
3
ff
4
4
ff
Instruction Set
91
Instruction Set
ADD
ADD
Operation
A (A) + (M)
Description
Condition Codes
and Boolean
Formulae
V: A7&M7&R7 | A7&M7&R7
Set if a twos complement overflow resulted from the operation;
cleared otherwise.
H: A3&M3 | M3&R3 | R3&A3
Set if there was a carry from bit 3; cleared otherwise.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: A7&M7 | M7&R7 | R7&A7
Set if there was a carry from the MSB of the result; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
ADD
#opr
IMM
AB
ii
ADD
opr
DIR
BB
dd
hh
ADD
opr
EXT
CB
ADD
,X
IX
FB
ADD
opr,X
IX1
EB
ff
ADD
opr,X
IX2
DB
ee
ADD
opr,SP
SP1
9EEB
ff
ADD
opr,SP
SP2
9EDB
ee
ll
4
2
3
ff
ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
AIS
AIS
Operation
SP (SP) + (16 M)
Description
Adds the immediate operand to the stack pointer (SP). The immediate
value is an 8-bit two's complement signed operand. The 8-bit operand is
sign-extended to 16 bits prior to the addition. The AIS instruction can be
used to create and remove a stack frame buffer that is used to store
temporary variables.
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
AIS
#opr
Addr
Mode
IMM
Machine Code
Opcode
Operand(s)
A7
ii
HC08
Cycles
2
Instruction Set
93
Instruction Set
AIX
AIX
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
AIX
#opr
Addr
Mode
IMM
Machine Code
Opcode
AF
Operand(s)
ii
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
AND
AND
Logical AND
Operation
Description
Performs the logical AND between the contents of A and the contents of
M and places the result in A. (Each bit of A after the operation will be the
logical AND of the corresponding bits of M and of A before the
operation.)
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
AND
#opr
IMM
A4
ii
AND
opr
DIR
B4
dd
AND
opr
EXT
C4
hh
AND
,X
IX
F4
AND
opr,X
IX1
E4
ff
AND
opr,X
IX2
D4
ee
AND
opr,SP
SP1
9EE4
ff
AND
opr,SP
SP2
9ED4
ee
ll
4
2
3
ff
4
4
ff
Instruction Set
95
Instruction Set
ASL
Operation
Description
ASL
b7
b0
Shifts all bits of A, X, or M one place to the left. Bit 0 is loaded with a
zero. The C bit in the CCR is loaded from the most significant bit of A,
X, or M.
Condition Codes
and Boolean
Formulae
V: R7b7
Set if the exclusive-OR of the resulting N and C flags is one;
cleared otherwise.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: b7
Set if, before the shift, the MSB of A, X, or M was set; cleared
otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
ASLA
INH (A)
48
ASLX
INH (X)
58
ASL
opr
DIR
38
ASL
,X
IX
78
ASL
opr,X
IX1
68
ff
ASL
opr,SP
SP1
9E68
ff
dd
4
3
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
ASR
ASR
Operation
Description
Condition Codes
and Boolean
Formulae
b7
b0
Shifts all bits of A, X, or M one place to the right. Bit 7 is held constant.
Bit 0 is loaded into the C bit of the CCR. 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.
:
V: R7b0
Set if the exclusive-OR of the resulting N and C flags is one;
cleared otherwise.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: b0
Set if, before the shift, the LSB of A, X, or M was set; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
ASRA
INH (A)
47
ASRX
INH (X)
57
DIR
37
ASR
opr
dd
ASR
,X
IX
77
ASR
opr,X
IX1
67
ff
3
4
ASR
opr,SP
SP1
9E67
ff
Instruction Set
97
Instruction Set
BCC
BCC
Operation
Description
Tests state of C bit in CCR and causes a branch if C is clear. (See BRA
instruction for further details of the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
if (C) = 0
Machine Code
Opcode
rel
BCC
HC08
Cycles
Operand(s)
24
rr
Complementary Branch
Mnemonic Opcode
Test
Type
Test
Boolean
Mnemonic Opcode
r>m
Z | (NV)=0
BGT
92
rm
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BCLR n
BCLR n
Operation
Mn 0
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Operand(s)
dd
HC08
Cycles
BCLR
0,opr
DIR b0
Opcode
11
BCLR
1,opr
DIR b1
13
dd
BCLR
2,opr
DIR b2
15
dd
BCLR
3,opr
DIR b3
17
dd
BCLR
4,opr
DIR b4
19
dd
BCLR
5,opr
DIR b5
1B
dd
BCLR
6,opr
DIR b6
1D
dd
BCLR
7,opr
DIR b7
1F
dd
Instruction Set
99
Instruction Set
BCS
BCS
Operation
Description
Tests the state of the C bit in the CCR and causes a branch if C is set.
(See BRA instruction for further details of the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BCS rel
REL
if (C) = 1
Machine Code
Opcode
Operand(s)
25 rr
HC08
Cycles
3
Complementary Branch
Test
Boolean
r>m
Z | (NV)=0
Mnemonic Opcode
BGT
92
Test
rm
Type
Mnemonic Opcode
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BEQ
BEQ
Branch if Equal
Operation
Description
Tests the state of the Z bit in the CCR and causes a branch if Z is set.
After a CMP or SUB instruction, BEQ will cause a branch if the
arguments were equal. (See BRA instruction for further details of the
execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BEQ rel
REL
if (Z) = 1
NBRA
Machine Code
Opcode
Operand(s)
27 rr
HC08
Cycles
3
Complementary Branch
Test
Boolean
r>m
Z | (NV)=0
Mnemonic Opcode
BGT
92
Test
rm
Type
Mnemonic Opcode
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
101
Instruction Set
BGE
BGE
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BGE opr
Addr
Mode
REL
Machine Code
Opcode
Operand(s)
90 rr
HC08
Cycles
3
Complementary Branch
Mnemonic Opcode
Test
Type
Test
Boolean
Mnemonic Opcode
r>m
Z | (NV)=0
BGT
92
rm
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BGT
BGT
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BGT opr
Addr
Mode
REL
Machine Code
Opcode
Operand(s)
92 rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
Instruction Set
103
Instruction Set
BHCC
BHCC
Operation
Description
Tests the state of the H bit in the CCR and causes a branch if H is clear.
This instruction is used in algorithms involving BCD numbers. (See BRA
instruction for further details of the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BHCC rel
REL
if (H) = 0
Machine Code
Opcode
Operand(s)
28 rr
HC08
Cycles
3
Complementary Branch
Test
Boolean
r>m
Z | (NV)=0
Mnemonic Opcode
BGT
92
Test
rm
Type
Mnemonic Opcode
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BHCS
BHCS
Operation
Description
Tests the state of the H bit in the CCR and causes a branch if H is set.
This instruction is used in algorithms involving BCD numbers. (See BRA
instruction for further details of the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BHCS rel
REL
if (H) = 1
Machine Code
Opcode
Operand(s)
29 rr
HC08
Cycles
3
Complementary Branch
Test
Boolean
r>m
Z | (NV)=0
Mnemonic Opcode
BGT
92
Test
rm
Type
Mnemonic Opcode
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
105
Instruction Set
BHI
BHI
Branch if Higher
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BHI rel
Addr
Mode
REL
if (C) | (Z) = 0
(unsigned binary numbers)
Machine Code
Opcode
Operand(s)
22 rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BHS
BHS
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BHS rel
Addr
Mode
REL
if (C) = 0
(unsigned binary numbers)
Machine Code
Opcode
Operand(s)
24 rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
Instruction Set
107
Instruction Set
BIH
BIH
Operation
Description
Tests the state of the external interrupt pin and causes a branch if the
pin is high. (See BRA instruction for further details of the execution of
the branch.)
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BIH rel
REL
if IRQ1 = 1
Machine Code
Opcode
Operand(s)
2F rr
HC08
Cycles
3
Complementary Branch
Test
Boolean
r>m
Z | (NV)=0
Mnemonic Opcode
BGT
92
Test
rm
Type
Mnemonic Opcode
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BIL
BIL
Operation
Description
Tests the state of the external interrupt pin and causes a branch if the
pin is low. (See BRA instruction for further details of the execution of the
branch.)
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BIL rel
REL
if IRQ = 0
Machine Code
Opcode
Operand(s)
2E rr
HC08
Cycles
3
Complementary Branch
Test
Boolean
r>m
Z | (NV)=0
Mnemonic Opcode
BGT
92
Test
rm
Type
Mnemonic Opcode
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
109
Instruction Set
BIT
BIT
Bit Test
Operation
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
A5 ii
BIT opr
IMM
BIT opr
DIR
B5 dd
C5 hh
BIT opr
EXT
BIT ,X
IX
BIT opr,X
IX1
E5 ff
BIT opr,X
IX2
D5 ee
BIT opr,SP
SP1
9EE5 ff
BIT opr,SP
SP2
9ED5 ee
HC08
Cycles
2
3
ll
F5
4
2
3
ff
4
4
ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BLE
BLE
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BLE opr
Addr
Mode
REL
Machine Code
Opcode
Operand(s)
93 rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
Instruction Set
111
Instruction Set
BLO
BLO
Branch if Lower
(Same as BCS)
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BLO rel
Addr
Mode
REL
if (C) = 1
(unsigned binary numbers)
Machine Code
Opcode
Operand(s)
25 rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BLS
BLS
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BLS rel
Addr
Mode
REL
if (C) | (Z) = 1
(unsigned binary numbers)
Machine Code
Opcode
Operand(s)
23 rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
Instruction Set
113
Instruction Set
BLT
BLT
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BLT opr
Addr
Mode
REL
Machine Code
Opcode
Operand(s)
91 rr
HC08
Cycles
3
Branch
Boolean
Mnemonic Opcode
Z | (NV)=0
BGT
92
rm
r=m
rm
r<m
r>m
rm
r=m
rm
r<m
Carry
r=0
Negative
I Mask
(NV)=0
Z=1
Z | (NV)=1
(NV)=1
C | Z=0
C=0
Z=1
C | Z=1
C=1
C=1
Z=1
N=1
I=1
BGE
BEQ
BLE
BLT
BHI
BHS/BCC
BEQ
BLS
BLO/BCS
BCS
BEQ
BMI
BMS
90
27
93
91
22
24
27
23
25
25
27
2B
2D
H-Bit
H=1
BHCS
29
IRQ High
BIH
2F
Always
BRA
20
r=register: A, X, or H:X (after CPHX instruction)
Complementary Branch
Test
Mnemonic Opcode
rm
BLE
93
r<m
BLT
rm
BNE
r>m
BGT
rm
BGE
rm
BLS
r<m
BLO/BCS
rm
BNE
r>m
BHI
rm
BHS/BCC
No Carry
BCC
r0
BNE
Plus
BPL
I Mask=0
BMC
H=0
BHCC
BIL
Never
BRN
m=memory operand
91
26
92
90
23
25
26
22
24
24
26
2A
2C
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
28
Simple
2E
21
Simple
Uncond.
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BMC
BMC
Operation
Description
Tests the state of the I bit in the CCR and causes a branch if I is clear
(i.e., if interrupts are enabled). (See BRA instruction for further details
of the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BMC rel
REL
if (I) = 0
Machine Code
Opcode
Operand(s)
2C rr
HC08
Cycles
3
Complementary Branch
Mnemonic Opcode
Test
Type
Test
Boolean
Mnemonic Opcode
r>m
Z | (NV)=0
BGT
92
rm
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
115
Instruction Set
BMI
BMI
Branch if Minus
Operation
Description
Tests the state of the N bit in the CCR and causes a branch if N is set.
(See BRA instruction for further details of the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BMI rel
REL
if (N) = 1
Machine Code
Opcode
Operand(s)
2B rr
HC08
Cycles
3
Complementary Branch
Mnemonic Opcode
Test
Type
Test
Boolean
Mnemonic Opcode
r>m
Z | (NV)=0
BGT
92
rm
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BMS
BMS
Operation
Description
Tests the state of the I bit in the CCR and causes a branch if I is set (i.e.,
if interrupts are disabled). (See BRA instruction for further details of the
execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BMS rel
REL
if (I) = 1
Machine Code
Opcode
Operand(s)
2D rr
HC08
Cycles
3
Complementary Branch
Mnemonic Opcode
Test
Type
Test
Boolean
Mnemonic Opcode
r>m
Z | (NV)=0
BGT
92
rm
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
117
Instruction Set
BNE
BNE
Operation
Description
Tests the state of the Z bit in the CCR and causes a branch if Z is clear.
Following a compare or subtract instruction, the branch will occur if the
arguments were not equal. (See BRA instruction for further details of
the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BNE rel
REL
if (Z) = 0
Machine Code
Opcode
Operand(s)
26 rr
HC08
Cycles
3
Complementary Branch
Mnemonic Opcode
Test
Type
Test
Boolean
Mnemonic Opcode
r>m
Z | (NV)=0
BGT
92
rm
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BPL
BPL
Branch if Plus
Operation
Description
Tests the state of the N bit in the CCR and causes a branch if N is clear.
(See BRA instruction for further details of the execution of the branch.)
Condition Codes
and Boolean
Formulae
None affected.
V
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BPL rel
REL
if (N) = 0
Machine Code
Opcode
Operand(s)
2A rr
HC08
Cycles
3
Complementary Branch
Mnemonic Opcode
Test
Type
Test
Boolean
Mnemonic Opcode
r>m
Z | (NV)=0
BGT
92
rm
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
119
Instruction Set
BRA
BRA
Branch Always
Operation
Description
Condition Codes
and Boolean
Formulae
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
None affected.
V
Source
Forms
BRA rel
Addr
Mode
REL
Machine Code
Opcode
Operand(s)
20 rr
HC08
Cycles
3
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BRCLR n
BRCLR n
Operation
Description
if bit n of M = 0
The C bit is set to the state of the tested bit. When used with an
appropriate rotate instruction, BRCLR n provides an easy method for
performing serial to parallel conversions.
Condition Codes
and Boolean
Formulae
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
01 dd
rr
HC08
Cycles
BRCLR 0,opr,rel
DIR b0
BRCLR 1,opr,rel
DIR b1
03 dd
rr
BRCLR 2,opr,rel
DIR b2
05 dd
rr
BRCLR 3,opr,rel
DIR b3
07 dd
rr
BRCLR 4,opr,rel
DIR b4
09 dd
rr
BRCLR 5,opr,rel
DIR b5
0B dd
rr
BRCLR 6,opr,rel
DIR b6
0D dd
rr
BRCLR 7,opr,rel
DIR b7
0F dd
rr
Instruction Set
121
Instruction Set
BRN
BRN
Branch Never
Operation
PC (PC) + $0002
Description
Condition Codes
and Boolean
Formulae
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
BRN rel
REL
Machine Code
Opcode
Operand(s)
21 rr
HC08
Cycles
3
Complementary Branch
Test
Boolean
r>m
Z | (NV)=0
Mnemonic Opcode
BGT
92
Test
rm
Type
Mnemonic Opcode
BLE
93
Signed
rm
(NV)=0
BGE
90
r<m
BLT
91
Signed
r=m
Z=1
BEQ
27
rm
BNE
26
Signed
rm
Z | (NV)=1
BLE
93
r>m
BGT
92
Signed
r<m
(NV)=1
BLT
91
rm
BGE
90
Signed
r>m
C | Z=0
BHI
22
rm
BLS
23
Unsigned
rm
C=0
BHS/BCC
24
r<m
BLO/BCS
25
Unsigned
r=m
Z=1
BEQ
27
rm
BNE
26
Unsigned
rm
C | Z=1
BLS
23
r>m
BHI
22
Unsigned
r<m
C=1
BLO/BCS
25
rm
BHS/BCC
24
Unsigned
Carry
C=1
BCS
25
No Carry
BCC
24
Simple
r=0
Z=1
BEQ
27
r0
BNE
26
Simple
Negative
N=1
BMI
2B
Plus
BPL
2A
Simple
I Mask
I=1
BMS
2D
I Mask=0
BMC
2C
Simple
H-Bit
H=1
BHCS
29
H=0
BHCC
28
Simple
IRQ High
BIH
2F
BIL
2E
Simple
Always
BRA
20
Never
BRN
21
Uncond.
m=memory operand
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BRSET n
BRSET n
Operation
Description
if bit n of M = 1
The C bit is set to the state of the tested bit. When used with an
appropriate rotate instruction, BRSET n provides an easy method for
performing serial to parallel conversions.
Condition Codes
and Boolean
Formulae
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
00 dd
rr
HC08
Cycles
BRSET 0,opr,rel
DIR b0
BRSET 1,opr,rel
DIR b1
02 dd
rr
BRSET 2,opr,rel
DIR b2
04 dd
rr
BRSET 3,opr,rel
DIR b3
06 dd
rr
BRSET 4,opr,rel
DIR b4
08 dd
rr
BRSET 5,opr,rel
DIR b5
0A dd
rr
BRSET 6,opr,rel
DIR b6
0C dd
rr
BRSET 7,opr,rel
DIR b7
0E dd
rr
Instruction Set
123
Instruction Set
BSET n
BSET n
Operation
Mn 1
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
10 dd
HC08
Cycles
BSET 0,opr
DIR b0
BSET 1,opr
DIR b1
12 dd
BSET 2,opr
DIR b2
14 dd
BSET 3,opr
DIR b3
16 dd
BSET 4,opr
DIR b4
18 dd
BSET 5,opr
DIR b5
1A dd
BSET 6,opr
DIR b6
1C dd
BSET 7,opr
DIR b7
1E dd
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BSR
BSR
Branch to Subroutine
Operation
PC (PC) + $0002
(PCL); SP (SP) $0001
(PCH); SP (SP) $0001
PC (PC) + rel
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BSR rel
Addr
Mode
REL
Machine Code
Opcode
Operand(s)
AD rr
HC08
Cycles
4
Instruction Set
125
Instruction Set
CBEQ
CBEQ
Operation
Description
CBEQ compares the operand with the accumulator (or index register for
CBEQX instruction) and causes a branch if the result is zero. The CBEQ
instruction combines CMP and BEQ for faster table lookup routines.
CBEQ_IX+ compares the operand addressed by H:X to A and causes a
branch if the result is zero. H:X is then incremented regardless of
whether a branch is taken. CBEQ_IX1+ operates the same way except
that an 8-bit offset is added to the effective address of the operand.
Condition Codes
and Boolean
Formulae
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
None affected.
V
Source
Forms
Addr
Mode
DIR
IMM
Machine Code
Opcode
Operand(s)
31 dd
rr
41 ii
rr
IMM
51 ii
rr
IX+
71 rr
HC08
Cycles
5
4
4
4
IX1+
61 ff
rr
SP1
9E61 ff
rr
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
CLC
CLC
Operation
C bit 0
Description
Clears the C bit in the CCR. CLC may be used to set up the C bit prior
to a shift or rotate instruction that involves the C bit.
Condition Codes
and Boolean
Formulae
C: 0
Cleared.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
CLC
INH
Opcode
98
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
127
Instruction Set
CLI
CLI
Operation
I bit 0
Description
Clears the interrupt mask bit in the CCR. When the I bit is clear,
interrupts are enabled. There is one bus cycle delay in the clearing
mechanism for the I bit such that if interrupts were previously disabled,
then the next instruction after a CLI will always be executed even if there
was an interrupt pending prior to execution of the CLI instruction.
Condition Codes
and Boolean
Formulae
I:
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
0
Cleared.
Source
Forms
Addr
Mode
CLI
INH
Opcode
9A
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
CLR
CLR
Clear
Operation
A $00
or: M $00
or: X $00
or: H $00
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: 0
Cleared.
Z: 1
Set.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
CLRA
Addr
Mode
INH (A)
Opcode
4F
Machine Code
Operand(s)
HC08
Cycles
1
CLRX
INH (X)
5F
CLRH
INH (H)
8C
CLR opr
DIR
CLR ,X
IX
3F dd
7F
CLR opr,X
IX1
6F ff
CLR opr,SP
SP1
9E6F ff
Instruction Set
129
Instruction Set
CMP
CMP
Operation
(A) (M)
Description
Condition Codes
and Boolean
Formulae
V: A7&M7&R7 | A7&M7&R7
Set if a two's complement overflow resulted from the operation;
cleared otherwise. Literally read, an overflow condition occurs if
a negative number is subtracted from
a positive number with a negative result, or, if a positive number
is subtracted from a negative number with a positive result.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: A7&M7 | M7&R7 | R7&A7
Set if the unsigned value of the contents of memory is larger than
the unsigned value of the accumulator; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
A1 ii
CMP #opr
IMM
CMP opr
DIR
B1 dd
C1 hh
CMP opr
EXT
CMP ,X
IX
CMP opr,X
IX1
E1 ff
IX2
D1 ee
CMP opr,SP
SP1
9EE1 ff
CMP opr,SP
SP2
9ED1 ee
2
3
ll
F1
CMP opr,X
HC08
Cycles
4
2
3
ff
4
4
ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
COM
COM
Operation
A A = $FF (A)
or: X X = $FF (X)
or: M M = $FF (M)
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: 1
Set.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
COMA
INH (A)
COMX
INH (X)
COM opr
DIR
Opcode
43
Machine Code
Operand(s)
HC08
Cycles
1
53
33 dd
COM ,X
IX
73
COM opr,X
IX1
63 ff
COM opr,SP
SP1
9E63 ff
Instruction Set
131
Instruction Set
CPHX
Operation
Description
CPHX compares index register (H:X) with the 16-bit value in memory
and sets the condition code register accordingly.
Condition Codes
and Boolean
Formulae
CPHX
V: H7&M15&R15 | H7&M15&R15
Set if a two's complement overflow resulted from the operation;
cleared otherwise.
N: R15
Set if MSB of result is one; cleared otherwise.
Z: R15&R14&R13&R12&R11&R10&R9&R8
&R7&R6&R5&R4&R3&R2&R1&R0
Set if the result is $0000; cleared otherwise.
C: H7&M15 | M15&R15 | R15&H7
Set if the absolute value of the contents of memory is larger than
the absolute value of the index register; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
CPHX #opr
IMM
CPHX opr
DIR
Machine Code
Opcode
Operand(s)
65 ii
ii+1
75 dd
HC08
Cycles
3
4
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
CPX
CPX
Operation
(X) (M)
Description
Condition Codes
and Boolean
Formulae
V: X7&M7&R7 | X7&M7&R7
Set if a twos complement overflow resulted from the operation;
cleared otherwise.
N: R7
Set if MSB of result of the subtraction is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: X7&M7 | M7&R7 | R7&X7
Set if the unsigned value of the contents of memory is
larger than the unsigned value in the index register;
cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
A3 ii
CPX #opr
IMM
CPX opr
DIR
B3 dd
CPX opr
EXT
C3 hh
CPX ,X
IX
CPX opr,X
IX1
E3 ff
IX2
D3 ee
CPX opr,SP
SP1
9EE3 ff
CPX opr,SP
SP2
9ED3 ee
2
3
ll
F3
CPX opr,X
HC08
Cycles
4
2
3
ff
4
4
ff
Instruction Set
133
Instruction Set
DAA
DAA
Operation
(A)10
Description
Adjusts the contents of the accumulator and the state of the CCR carry
bit after binary-coded decimal operations, so that there is a correct BCD
sum and an accurate carry indication. The state of the CCR half carry
bit affects operation. (Refer to the DAA Function Summary table on
the following page for details of operation.)
Condition Codes
and Boolean
Formulae
V
U
V: U
Undefined.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: (Refer to the DAA Function Summary table on following page.)
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
DAA
Addr
Mode
INH
Opcode
72
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
DAA
DAA
The DAA Function Summary table below shows DAA operation for all
legal combinations of input operands. Columns 14 represent the
results of ADC or ADD operations on BCD operands. The correction
factor in column 5 is added to the accumulator to restore the result of an
operation on two BCD operands to a valid BCD value and to set or clear
the C bit. All values are in hexadecimal.
DAA Function Summary
1
Initial
C-Bit Value
Value of
A[7:4]
Initial
H-Bit Value
Value of
A[3:0]
Correction
Factor
Corrected
C-Bit Value
09
09
00
08
AF
06
09
03
06
AF
09
60
9F
AF
66
AF
03
66
02
09
60
02
AF
66
03
03
66
Instruction Set
135
Instruction Set
DBNZ
DBNZ
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
DIR
Machine Code
Opcode
Operand(s)
3B dd
rr
HC08
Cycles
5
DBNZA rel
INH
4B rr
DBNZX rel
INH
5B rr
DBNZ X, rel
IX
7B rr
IX1
6B ff
rr
SP1
9E6B ff
rr
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
DEC
DEC
Decrement
Operation
A (A) $01
or: X (X) $01
or: M (M) $01
Description
Condition Codes
and Boolean
Formulae
V: R7 & A7
Set if there was a two's complement overflow as a result of the
operation; cleared otherwise. Two's complement overflow
occurs if and only if (A), (IX), or (M) was $80 before the operation.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
DECA
INH (A)
Opcode
4A
DECX
INH (X)
5A
DEC opr
DIR
DEC ,X
IX
Machine Code
Operand(s)
HC08
Cycles
1
1
3A dd
7A
DEC opr,X
IX1
6A ff
DEC opr,SP
SP1
9E6A ff
Instruction Set
137
Instruction Set
DIV
DIV
Divide
Operation
A (H:A) (X)
H Remainder
Description
Condition Codes
and Boolean
Formulae
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result (quotient) is $00; cleared otherwise.
C: Set if a divide by zero was attempted or if an overflow occurred;
cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
DIV
Addr
Mode
INH
Opcode
52
Machine Code
Operand(s)
HC08
Cycles
7
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
EOR
EOR
Operation
A (A M)
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
EOR #opr
IMM
Machine Code
Opcode
Operand(s)
A8 ii
EOR opr
DIR
B8 dd
EOR opr
EXT
C8 hh
HC08
Cycles
2
3
ll
EOR ,X
IX
F8
EOR opr,X
IX1
E8 ff
EOR opr,X
IX2
EOR opr,SP
SP1
9EE8 ff
EOR opr,SP
SP2
9ED8 ee
D8 ee
ff
4
4
ff
Instruction Set
139
Instruction Set
INC
INC
Increment
Operation
A (A) + $01
or: X (X) + $01
or: M (M) + $01
Description
Condition Codes
and Boolean
Formulae
V: A7&R7
Set if there was a two's complement overflow as a result of the
operation; cleared otherwise. Two's complement overflow
occurs if and only if (A), (X), or (M) was $7F before the operation.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
INCA
INH (A)
INCX
INH (X)
INC opr
DIR
Opcode
4C
Machine Code
Operand(s)
HC08
Cycles
1
5C
3C dd
INC ,X
IX
7C
INC opr,X
IX1
6C ff
INC opr,SP
SP1
9E6C ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
JMP
JMP
Jump
Operation
PC Effective Address
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
JMP opr
DIR
Machine Code
Opcode
Operand(s)
BC dd
JMP opr
EXT
JMP ,X
IX
JMP opr,X
IX1
EC ff
JMP opr,X
IX2
DC ee
CC hh
ll
FC
HC08
Cycles
2
3
2
3
ff
Instruction Set
141
Instruction Set
JSR
JSR
Jump to Subroutine
Operation
PC (PC) + n
n = 1, 2, or 3 depending on address mode
(PCL); SP (SP) $0001 Push low half of return address
(PCH); SP (SP) $0001 Push high half of return address
PC Effective Address
Load PC with start address of requested
subroutine
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
JSR opr
DIR
Machine Code
Opcode
Operand(s)
BD dd
JSR opr
EXT
JSR ,X
IX
JSR opr,X
IX1
ED ff
JSR opr,X
IX2
DD ee
CD hh
ll
FD
HC08
Cycles
4
5
4
5
ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
LDA
LDA
Operation
A (M)
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
LDA #opr
IMM
Machine Code
Opcode
Operand(s)
A6 ii
LDA opr
DIR
B6 dd
LDA opr
EXT
C6 hh
HC08
Cycles
2
3
ll
LDA ,X
IX
F6
LDA opr,X
IX1
E6 ff
LDA opr,X
IX2
LDA opr,SP
SP1
9EE6 ff
LDA opr,SP
SP2
9ED6 ee
D6 ee
ff
4
4
ff
Instruction Set
143
Instruction Set
LDHX
LDHX
Operation
Description
Loads the contents of the specified memory location into the index
register (H:X). The condition codes are set according to the data.
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R15
Set if MSB of result is one; cleared otherwise.
Z: R15&R14&R13&R12&R11&R10&R9&R8
&R7&R6&R5&R4&R3&R2&R1&R0
Set if the result is $0000; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
LDHX #opr
IMM
LDHX opr
DIR
Machine Code
Opcode
Operand(s)
45 ii
jj
55 dd
HC08
Cycles
3
4
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
LDX
LDX
Operation
X (M)
Description
Loads the contents of the specified memory location into X. The N and
Z condition codes are set or cleared according to the loaded data; V is
cleared.
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
LDX #opr
IMM
Machine Code
Opcode
Operand(s)
AE ii
LDX opr
DIR
BE dd
LDX opr
EXT
CE hh
HC08
Cycles
2
3
ll
LDX ,X
IX
FE
LDX opr,X
IX1
EE ff
LDX opr,X
IX2
LDX opr,SP
SP1
9EEE ff
LDX opr,SP
SP2
9EDE ee
DE ee
ff
4
4
ff
Instruction Set
145
Instruction Set
LSL
Operation
Description
Condition Codes
and Boolean
Formulae
LSL
b7
b0
Shifts all bits of the A, X, or M one place to the left. Bit 0 is loaded with a
zero. The C bit in the CCR is loaded from the most significant bit of A, X,
or M.
V: R7b7
Set if the exclusive-OR of the resulting N and C flags is one;
cleared otherwise.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: b7
Set if, before the shift, the MSB of A, X, or M was set; cleared
otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Operand(s)
HC08
Cycles
LSLA
INH (A)
Opcode
48
LSLX
INH (X)
58
38 dd
LSL opr
DIR
LSL ,X
IX
78
LSL opr,X
IX1
68 ff
LSL opr,SP
SP1
9E68 ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
LSR
Operation
Description
Condition Codes
and Boolean
Formulae
LSR
b7
b0
Shifts all bits of A, X, or M one place to the right. Bit 7 is loaded with a
zero. Bit 0 is shifted into the C bit.
V: 0b0 = b0
Set if the exclusive-OR of the resulting N and C flags is one;
cleared otherwise.
N: 0
Cleared.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: b0
Set if, before the shift, the LSB of A, X, or M, was set; cleared
otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
LSRA
INH (A)
Opcode
44
LSRX
INH (X)
54
LSR opr
DIR
LSR ,X
IX
Machine Code
Operand(s)
HC08
Cycles
1
1
34 dd
74
LSR opr,X
IX1
64 ff
LSR opr,SP
SP1
9E64 ff
Instruction Set
147
Instruction Set
MOV
MOV
Move
Operation
(M)destination (M)source
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is set; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
6E ii
dd
HC08
Cycles
IMD
DD
4E dd
IX+D
7E dd
MOV opr, X+
DIX+
5E dd
dd
4
5
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
MUL
MUL
Unsigned Multiply
Operation
Description
Multiplies the 8-bit value in X (index register low) by the 8-bit value in the
accumulator to obtain a 16-bit unsigned result in the concatenated index
register and accumulator. After the operation, X contains the upper 8
bits of the 16-bit result and A contains the lower 8 bits of the result.
Condition Codes
and Boolean
Formulae
H: 0
Cleared.
C: 0
Cleared.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
MUL
INH
Machine Code
Opcode
Operand(s)
42
HC08
Cycles
5
Instruction Set
149
Instruction Set
NEG
NEG
Operation:
Description
Condition Codes
and Boolean
Formulae
V: M7&R7
Set if a two's complement overflow resulted from the operation;
cleared otherwise. Overflow will occur only if the operand is $80
before the operation.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: R7|R6|R5|R4|R3|R2|R1|R0
Set if there is a borrow in the implied subtraction from zero;
cleared otherwise. The C bit will be set in all cases except when
the contents of A, X, or M was $00 prior to the NEG operation.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
NEGA
INH (A)
NEGX
INH (X)
NEG opr
DIR
Opcode
40
Machine Code
Operand(s)
HC08
Cycles
1
50
30 dd
NEG ,X
IX
70
NEG opr,X
IX1
60 ff
NEG opr,SP
SP1
9E60 ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
NOP
NOP
No Operation
Operation
None
Description
This is a single byte instruction that does nothing except to consume one
CPU clock cycle while the program counter is advanced to the next
instruction. No register or memory contents are affected by this
instruction.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
NOP
INH
Opcode
9D
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
151
Instruction Set
NSA
NSA
Operation
A (A[3:0]:A[7:4])
Description
Swaps upper and lower nibbles (4 bits) of the accumulator. The NSA
instruction is used for more efficient storage and use of binary-coded
decimal operands.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
NSA
Addr
Mode
INH
Opcode
62
Machine Code
Operand(s)
HC08
Cycles
3
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
ORA
ORA
Operation
A (A) | (M)
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
ORA #opr
IMM
Machine Code
Opcode
Operand(s)
AA ii
ORA opr
DIR
BA dd
ORA opr
EXT
CA hh
HC08
Cycles
2
3
ll
ORA ,X
IX
FA
ORA opr,X
IX1
EA ff
ORA opr,X
IX2
ORA opr,SP
SP1
9EEA ff
ORA opr,SP
SP2
9EDA ee
DA ee
ff
4
4
ff
Instruction Set
153
Instruction Set
PSHA
PSHA
Operation
Description
The contents of A are pushed onto the stack at the address contained in
the stack pointer. The stack pointer is then decremented to point to the
next available location in the stack. The contents of A remain
unchanged.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PSHA
Addr
Mode
INH
Opcode
87
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
PSHH
PSHH
Operation
Description
The contents of H are pushed onto the stack at the address contained in
the stack pointer. The stack pointer is then decremented to point to the
next available location in the stack. The contents of H remain
unchanged.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PSHH
Addr
Mode
INH
Opcode
8B
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
155
Instruction Set
PSHX
PSHX
Operation
Description
The contents of X are pushed onto the stack at the address contained in
the stack pointer (SP). SP is then decremented to point to the next
available location in the stack. The contents of X remain unchanged.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PSHX
Addr
Mode
INH
Opcode
89
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
PULA
PULA
Operation
Description
The stack pointer (SP) is incremented to address the last operand on the
stack. The accumulator is then loaded with the contents of the address
pointed to by SP.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PULA
Addr
Mode
INH
Opcode
86
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
157
Instruction Set
PULH
PULH
Operation
Description
The stack pointer (SP) is incremented to address the last operand on the
stack. H is then loaded with the contents of the address pointed to by SP.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PULH
Addr
Mode
INH
Opcode
8A
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
PULX
Operation
Description
The stack pointer (SP) is incremented to address the last operand on the
stack. X is then loaded with the contents of the address pointed to by SP.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PULX
Addr
Mode
INH
PULX
Machine Code
Opcode
Operand(s)
88
HC08
Cycles
2
Instruction Set
159
Instruction Set
ROL
Operation
Description
Condition Codes
and Boolean
Formulae
ROL
b7
b0
Shifts all bits of A, X, or M one place to the left. Bit 0 is loaded from the
C bit. The C bit is loaded from the most significant bit of A, X, or M. The
rotate instructions include the carry bit to allow extension of the shift and
rotate instructions to multiple bytes. For example, to shift a 24-bit value
left one bit, 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.
V: R7 b7
Set if the exclusive-OR of the resulting N and C flags is one;
cleared otherwise.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: b7
Set if, before the rotate, the MSB of A, X, or M was set; cleared
otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Operand(s)
HC08
Cycles
ROLA
INH (A)
Opcode
49
ROLX
INH (X)
59
39 dd
79
ROL opr
DIR
ROL ,X
IX
ROL opr,X
IX1
69 ff
ROL opr,SP
SP1
9E69 ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
ROR
Operation
Description
Condition Codes
and Boolean
Formulae
ROR
b7
b0
Shifts all bits of A, X, or M one place to the right. Bit 7 is loaded from the
C bit. Bit 0 is shifted into the C bit. The rotate instructions include the
carry bit to allow extension of the shift and rotate instructions to multiple
bytes. For example, to shift a 24-bit value right one bit, the sequence
{LSR HIGH, ROR MID, 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.
V: b7 b0
Set if the exclusive-OR of the resulting N and C flags is one;
cleared otherwise.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: b0
Set if, before the shift, the LSB of A, X, or M was set; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Operand(s)
HC08
Cycles
RORA
INH (A)
Opcode
46
RORX
INH (X)
56
36 dd
76
ROR opr
DIR
ROR ,X
IX
ROR opr,X
IX1
66 ff
ROR opr,SP
SP1
9E66 ff
Instruction Set
161
Instruction Set
RSP
RSP
Operation
SP $FF
Description
Resets the low byte of the stack pointer (SP) to the top of the stack page.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
NOTE:
Source
Forms
Addr
Mode
RSP
INH
Opcode
9C
Machine Code
Operand(s)
HC08
Cycles
1
The CPU08 RSP instruction only sets the least significant byte of SP to
$FF. The most significant byte (stack page number) is unaffected. The
M6805 RSP instruction resets SP to $00FF.
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
RTI
RTI
Operation
SP SP + $0001; CCR
SP SP + $0001; A
SP SP + $0001; X
SP SP + $0001; PCH
SP SP + $0001; PCL
Description
The condition codes, the accumulator, X (index register low), and the
program counter are restored to the state previously saved on the stack.
The I bit will be reset if the corresponding bit stored on the stack is zero
(this is the normal case).
Condition Codes
and Boolean
Formulae
Set or cleared according to the byte pulled from the stack into CCR.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
RTI
INH
Opcode
80
Machine Code
Operand(s)
HC08
Cycles
7
Instruction Set
163
Instruction Set
RTS
RTS
Operation
SP SP + $0001; PCH
SP SP + $0001; PCL
Description
The stack pointer is incremented (by 1). The contents of the byte of
memory that is pointed to by the stack pointer are loaded into the
high-order byte of the program counter. The stack pointer is again
incre-mented (by 1). The contents of the byte of memory that are pointed
to by the stack pointer are loaded into the low-order 8 bits of the program
counter. Program execution resumes at the address that was just
restored from the stack.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
RTS
INH
Opcode
81
Machine Code
Operand(s)
HC08
Cycles
4
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
SBC
SBC
Operation
Description
Subtracts the contents of M and the contents of the C bit of the CCR from
the contents of A and places the result in A.
Condition Codes
and Boolean
Formulae
V: A7&M7&R7 | A7&M7&R7
Set if a two's complement overflow resulted from the operation;
cleared otherwise. Literally read, an overflow condition occurs if
a negative number is subtracted from a positive number with a
negative result, or, if a positive number is subtracted from a negative number with a positive result.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: A7&M7 | M7&R7 | R7&A7
Set if the unsigned value of the contents of memory plus the previous carry are larger than the unsigned value of the accumulator;
cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
SBC #opr
IMM
Machine Code
Opcode
Operand(s)
A2 ii
SBC opr
DIR
B2 dd
SBC opr
EXT
C2 hh
HC08
Cycles
2
3
ll
SBC ,X
IX
F2
SBC opr,X
IX1
E2 ff
SBC opr,X
IX2
SBC opr,SP
SP1
9EE2 ff
SBC opr,SP
SP2
9ED2 ee
D2 ee
ff
4
4
ff
Instruction Set
165
Instruction Set
SEC
SEC
Operation
C bit 1
Description
Sets the C bit in the condition code register (CCR). SEC may be used
to set up the C bit prior to a shift or rotate instruction that involves the C
bit.
Condition Codes
and Boolean
Formulae
C: 1
Set.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
SEC
INH
Opcode
99
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
SEI
SEI
Operation
I bit 1
Description
Sets the interrupt mask bit in the condition code register (CCR). The
microprocessor is inhibited from responding to interrupts while the I bit
is set.
Condition Codes
and Boolean
Formulae
I: 1
Set.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
SEI
INH
Opcode
9B
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
167
Instruction Set
STA
STA
Operation
M (A)
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: A7
Set if MSB of result is one; cleared otherwise.
Z: A7&A6&A5&A4&A3&A2&A1&A0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
STA opr
DIR
STA opr
EXT
STA ,X
IX
Machine Code
Opcode
Operand(s)
B7 dd
C7 hh
ll
F7
STA opr,X
IX1
E7 ff
STA opr,X
IX2
D7 ee
STA opr,SP
SP1
9EE7 ff
STA opr,SP
SP2
9ED7 ee
HC08
Cycles
3
4
2
3
ff
4
4
ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
STHX
STHX
Operation
Description
Stores H:X to the specified memory location. The condition codes are
set according to the data.
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R15
Set if MSB of result is one; cleared otherwise.
Z: R15&R14&R13&R12&R11&R10&R9&R8
&R7&R6&R5&R4&R3&R2&R1&R0
Set if the result is $0000; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
STHX opr
Addr
Mode
DIR
Machine Code
Opcode
Operand(s)
35 dd
HC08
Cycles
4
Instruction Set
169
Instruction Set
STOP
STOP
Operation
Description
Condition Codes
and Boolean
Formulae
I: 0
Cleared.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
STOP
INH
Opcode
8E
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
STX
STX
Operation
M (X)
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: X7
Set if MSB of result is one; cleared otherwise.
Z: X7&X6&X5&X4&X3&X2&X1&X0
Set if X is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
STX opr
DIR
STX opr
EXT
STX ,X
IX
Machine Code
Opcode
Operand(s)
BF dd
CF hh
ll
FF
STX opr,X
IX1
EF ff
STX opr,X
IX2
DF ee
STX opr,SP
SP1
9EEF ff
STX opr,SP
SP2
9EDF ee
HC08
Cycles
3
4
2
3
ff
4
4
ff
Instruction Set
171
Instruction Set
SUB
SUB
Subtract
Operation
A (A) (M)
Description
Condition Codes
and Boolean
Formulae
V: A7&M7&R7 | A7&M7&R7
Set if a two's complement overflow resulted from the operation;
cleared otherwise. Literally read, an overflow condition occurs if
a negative number is subtracted from a positive number with a
negative result, or, if a positive number is subtracted from a negative number with a positive result.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: A7&M7 | M7&R7 | R7&A7
Set if the unsigned value of the contents of memory is larger than
the unsigned value of the accumulator; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
A0 ii
SUB #opr
IMM
SUB opr
DIR
B0 dd
SUB opr
EXT
C0 hh
SUB X
IX
SUB opr,X
IX1
E0 ff
IX2
D0 ee
SUB opr,SP
SP1
9EE0 ff
SUB opr,SP
SP2
9ED0 ee
2
3
ll
F0
SUB opr,X
HC08
Cycles
4
2
3
ff
4
4
ff
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
SWI
SWI
Software Interrupt
Operation
PC (PC) + $0001
(PCL); SP (SP) $0001
(PCH); SP (SP) $0001
(X); SP (SP) $0001
(A); SP (SP) $0001
(CCR); SP (SP) $0001
I bit 1
PCH ($FFFC)
PCL ($FFFD)
Description
The program counter (PC) is incremented (by 1). The PC, index
register, and accumulator are pushed onto the stack. The condition
code register (CCR) bits are then pushed onto the stack, with bits V, H,
I, N, Z, and C going into bit positions 7 and 40. Bit positions 6 and 5
contain ones. The stack pointer is decremented (by 1) after each byte
of data is stored on the stack. The interrupt mask bit is then set. The
program counter is then loaded with the address stored in the SWI
vector (located at memory locations n0002 and n0003, where n is the
address corresponding to a high state on all implemented lines of the
address bus). The address of the SWI vector can be expressed as
$FFFC:$FFFD. This instruction is not maskable by the I bit.
Condition Codes
and Boolean
Formulae
I: 1
Set.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
SWI
INH
Opcode
83
Machine Code
Operand(s)
HC08
Cycles
9
Instruction Set
173
Instruction Set
TAP
TAP
Operation
CCR (A)
7
0
A
CCR
Carry/Borrow
Zero
Negative
I Interrupt
Mask
Half Carry
Overflow
(Twos
Complement)
Description
Condition Codes
and Boolean
Formulae
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TAP
INH
Machine Code
Opcode
Operand(s)
84
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
TAX
TAX
Operation
X (A)
Description
Loads X with the contents of the accumulator (A). The contents of A are
unchanged.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TAX
INH
Opcode
97
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
175
Instruction Set
TPA
TPA
Operation
A (CCR)
7
0
A
CCR
Carry/Borrow
Zero
Negative
I Interrupt
Mask
Half Carry
Overflow
(Twos
Complement)
Description
Transfers the contents of the condition code register (CCR) into the
accumulator (A).
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TPA
INH
Opcode
85
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
TST
TST
Operation
(A) $00
or: (X) $00
or: (M) $00
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: M7
Set if MSB of the tested value is one; cleared otherwise.
Z: M7&M6&M5&M4&M3&M2&M1&M0
Set if A, X, or M contains 00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TSTA
INH (A)
TSTX
INH (X)
TST opr
DIR
Opcode
4D
Machine Code
Operand(s)
HC08
Cycles
1
5D
3D dd
TST ,X
IX
7D
TST opr,X
IX1
6D ff
TST opr,SP
SP1
9E6D ff
Instruction Set
177
Instruction Set
TSX
TSX
Operation
Description
Loads index register (H:X) with 1 plus the contents of the stack pointer
(SP). The contents of SP remain unchanged. After a TSX instruction,
H:X points to the last value that was stored on the stack.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TSX
INH
Opcode
95
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
TXA
TXA
Operation
A (X)
Description
Loads the accumulator (A) with the contents of X. The contents of X are
not altered.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TXA
INH
Opcode
9F
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
179
Instruction Set
TXS
TXS
Operation
Description
Loads the stack pointer (SP) with the contents of the index register (H:X)
minus one. The contents of H:X are not altered.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TXS
INH
Opcode
94
Machine Code
Operand(s)
HC08
Cycles
2
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
WAIT
WAIT
Operation
Description
Condition Codes
and Boolean
Formulae
I: 0
Cleared.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
WAIT
INH
Opcode
8F
Machine Code
Operand(s)
HC08
Cycles
1
Instruction Set
181
Branch
REL
DIR
Read-Modify-Write
INH
IX1
INH
Control
SP1
IX
INH
INH
IMM
DIR
Register/Memory
IX2
SP2
EXT
IX1
SP1
IX
HIGH
9E6
9ED
9EE
LOW
5
BRSET0 BSET0
3
DIR 2
5
DIR 2
4
DIR 2
5
DIR 2
4
BRCLR1 BCLR1
3
DIR 2
5
DIR 2
4
BRSET2 BSET2
3
DIR 2
5
DIR 2
4
BRCLR2 BCLR2
3
DIR 2
5
DIR 2
4
BRSET3 BSET3
3
DIR 2
5
DIR 2
4
BRCLR3 BCLR3
3
Instruction Set
DIR 2
5
DIR 2
4
BRSET4 BSET4
3
DIR 2
5
DIR 2
4
BRCLR4 BCLR4
3
A
B
DIR 2
5
DIR 2
4
DIR 2
5
DIR 2
4
BRSET6 BSET6
3
DIR 2
4
BRCLR5 BCLR5
3
DIR 2
5
BRSET5 BSET5
3
DIR 2
5
DIR 2
4
BRCLR6 BCLR6
3
DIR 2
5
DIR 2
4
BRSET7 BSET7
3
DIR 2
5
DIR 2
4
BRCLR7 BCLR7
3
INH
IMM
DIR
EXT
DD
IX+D
DIR 2
4
BRSET1 BSET1
3
DIR 2
5
BRCLR0 BCLR0
DIR 2
DIR 2
BRA
REL 2
3
BRN
REL 3
3
NEG
NEGA
DIR 1
5
CBEQ
DIR 3
BCC
REL 2
3
BCS
REL 2
3
BNE
REL 2
3
BEQ
REL 2
3
BHCC
REL 2
3
BHCS
REL 2
3
BPL
REL 2
3
BMI
REL 3
3
BMC
REL 2
3
BMS
REL 2
3
1
4
COM
LSR
STHX
DIR 3
4
ASR
LSL
ROL
IMM 2
1
DIR 1
4
INH 1
1
DBNZ
INC
TST
INH 1
1
INH 1
3
CLR
DIR 1
Inherent
REL
Relative
Immediate
IX
Indexed, No Offset
Direct
IX1
Indexed, 8-Bit Offset
Extended
IX2
Indexed, 16-Bit Offset
Direct-Direct
IMD
Immediate-Direct
Indexed-Direct
DIX+ Direct-Indexed
*Pre-byte for stack pointer indexed instructions
INH 1
1
INH 1
5
DD 2
1
CLRA
INH 1
SP1
SP2
IX+
IX1+
INH 2
3
DBNZX
INH 2
1
MOV
3
INH 2
1
DECX
TSTA
DIR 1
INH 2
1
ROLX
INCA
DIR 1
3
INH 2
1
LSLX
INH 1
1
DBNZA
DIR 2
4
INH 2
1
ASRX
INH 1
1
DECA
DIR 1
5
DIR 3
1
RORX
ROLA
DEC
INH 2
4
LDHX
LSLA
DIR 1
4
INH 2
1
LSRX
INH 1
3
ASRA
DIR 1
4
INH 1
1
COMX
INH 1
1
RORA
DIR 1
4
REL
3
REL 2
INH 1
1
LDHX
ROR
IMM 3
7
DIV
LSRA
DIR 1
4
BIL
BIH
IMM 3
5
COMA
DIR 1
4
INH 2
4
CBEQX
MUL
REL
3
REL 2
3
NEGX
INH 1
4
CBEQA
BHI
BLS
INH 3
1
INCX
INH 2
1
TSTX
INH 2
4
MOV
DIX+ 3
1
CLRX
INH 2
NEG
IX1 3
5
CBEQ
IX1+ 4
3
NEG
NEG
SP1 1
6
CBEQ
SP1 2
NSA
IX1 3
4
LSR
IX1 3
3
1
5
COM
COM
LSR
ASR
IX1 3
4
LSL
IX1 3
4
ROL
IX1 3
4
DEC
IX1 3
5
DBNZ
IX1 4
4
INC
IX1 3
3
TST
IX1 3
4
LSR
2
5
ROR
SP1 1
5
ASR
IX 1
3
ASR
SP1 1
5
LSL
IX 1
3
LSL
SP1 1
5
ROL
INH 2
4
RTS
INH 2
SP1 1
5
IX 1
3
DEC
SP1 1
6
DBNZ
IX 1
4
DBNZ
SP1 2
5
INC
IX 1
3
INC
SP1 1
4
TST
SWI
CLR
SP1 1
REL 2
3
TXS
TPA
TSX
INH 1
2
INH 2
2
1
PSHA
TAX
INH 1
2
IX+D 1
2
CLR
IX 1
BIT
CLC
PSHX
SEC
INH 1
2
PULH
INH 2
2
INH 1
2
PSHH
INH 2
2
SEI
INH 1
1
EOR
IMM 2
2
ADD
INH 2
1
ADD
JMP
INH
1
BSR
INH 2
STOP
INH
1
WAIT
INH 1
2
1
TXA
INH 2
JSR
REL 2
2
LDX
AIX
DIR 3
3
STX
EXT 3
5
IX2 4
4
SBC
IX2 4
4
CPX
IX2 4
4
AND
IX2 4
4
IX2 4
4
IX2 4
4
IX2 4
4
EOR
IX2 4
4
ADC
IX2 4
4
ORA
IX2 4
4
ADD
IX2 4
4
SUB
SUB
SP2 2
5
CMP
SP2 2
5
SBC
CPX
AND
BIT
SP2 2
5
SP2 2
5
STA
EOR
ADC
SP2 2
5
SP2 2
5
ADD
JMP
EXT 3
4
EXT 3
4
IX2 4
4
STX
EXT 3
IX2 4
BIT
2
5
LDX
SP1 1
4
LDA
SP2 2
5
STX
SP2 2
STA
IX
2
EOR
SP1 1
4
ADC
IX
2
ADC
SP1 1
4
ORA
IX
2
ORA
SP1 1
4
ADD
IX
2
ADD
SP1 1
IX
2
JMP
1
IX
4
JSR
IX1
3
IX
2
LDX
IX1 3
3
LDX
SP1 1
4
STX
IX1 3
2 HC08 Cycles
Opcode Mnemonic
IX Number of Bytes / Addressing Mode
SUB
1
STA
EOR
IX
2
SP1 1
4
IX1
5
STX
IX
2
LDA
SP1 1
4
IX1 3
3
LDX
IX
2
BIT
JSR
IX2
4
LDX
AND
JMP
IX2
6
IX
2
SP1 1
4
IX1 3
3
ADD
SP2 2
CPX
AND
IX1 3
3
ORA
IX
2
SP1 1
4
IX1 3
3
ADC
ORA
CPX
IX1 3
3
EOR
SP2 2
5
IX
2
SBC
SP1 1
4
IX1 3
3
STA
SP2 2
5
SP1 1
4
IX1 3
3
LDA
IX
2
CMP
SBC
IX1 3
3
BIT
LDA
SP1 1
4
IX1 3
3
AND
SP2 2
5
SUB
CMP
IX1 3
3
CPX
SP2 2
5
SUB
IX1 3
3
SBC
SP2 2
5
IX1 3
3
CMP
JSR
STX
DIR 3
EXT 3
3
LDX
DIR 3
3
IMM 2
EXT 3
4
JSR
LDX
IMM 2
2
EXT 3
4
JMP
DIR 3
4
EXT 3
4
ADD
DIR 3
2
IX2 4
4
CMP
STA
EXT 3
4
ORA
DIR 3
3
IMM 2
RSP
INH 1
DIR 3
3
IMM 2
2
EXT 3
4
ADC
ORA
SUB
LDA
EOR
DIR 3
3
ADC
ORA
EXT 3
4
STA
DIR 3
3
IMM 2
2
ADC
CLI
DIR 3
3
BIT
LDA
STA
EOR
INH 2
1
DIR 3
3
IMM 2
2
EXT 3
4
BIT
LDA
IMM 2
2
EXT 3
4
AND
DIR 3
3
IMM 2
2
EXT 3
4
CPX
DIR 3
3
AND
AIS
INH 2
1
INH 1
2
IX
4
CPX
IMM 2
2
EXT 3
4
SBC
DIR 3
3
IMM 2
2
LDA
INH
2
DIR 3
3
IMM 2
2
EXT 3
4
CMP
SBC
BIT
PULA
DIR 3
3
IMM 2
2
AND
INH 2
2
SUB
CMP
CPX
REL 2
2
INH 1
1
IMM 2
2
SBC
NOP
MOV
4
REL 2
3
SUB
CMP
BLE
INH 2
2
TST
SP1 1
CLRH
IX 1
2
REL 2
3
BGT
9
SUB
BLT
PULX
IX 1
3
ROL
DEC
IMD
3
IX1 3
DIR 1
3
ROR
BGE
TAP
IX 1
4
CPHX
MOV
CLR
IX 1
3
SP1 1
IMM
4
IX1 3
4
RTI
INH
3
SP1 1
5
CPHX
ROR
IX+ 1
2
DAA
INH
4
COM
IX 1
4
CBEQ
SP1 1
IX
2
STX
IX
Instruction Set
182
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
ADD
ADD
ADD
ADD
ADD
ADD
ADD
ADD
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
ii
dd
hh ll
ee ff
ff
BCC rel
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
AB
BB
CB
DB
EB
FB
9EEB
9EDB
ii
dd
hh ll
ee ff
ff
ff
ee ff
2
3
4
4
3
2
4
5
ff
ee ff
2
3
4
4
3
2
4
5
IMM
A7
ii
IMM
AF
ii
ii
dd
hh ll
ee ff
ff
2
3
4
4
3
2
4
5
0
b7
ASR opr
ASRA
ASRX
ASR opr,X
ASR opr,X
ASR opr,SP
Cycles
A9
B9
C9
D9
E9
F9
9EE9
9ED9
SP (SP) + (16 M)
Logical AND
A (A) + (M)
AIX #opr
ASL opr
ASLA
ASLX
ASL opr,X
ASL ,X
ASL opr,SP
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
Effect on
CCR
Description
V H I N Z C
AIS #opr
AND
AND
AND
AND
AND
AND
AND
AND
Operand
ADC
ADC
ADC
ADC
ADC
ADC
ADC
ADC
Operation
Address
Mode
Source
Form
Opcode
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
A4
B4
C4
D4
E4
F4
9EE4
9ED4
DIR
INH
INH
IX1
IX
SP1
38 dd
48
58
68 ff
78
9E68 ff
4
1
1
4
3
5
DIR
INH
INH
IX1
IX
SP1
37 dd
47
57
67 ff
77
9E67 ff
4
1
1
4
3
5
b0
C
b7
b0
ff
ee ff
REL
24
rr
DIR (b0)
DIR (b1)
DIR (b2)
(b3)
DIR
DIR (b4)
DIR (b5)
DIR (b6)
DIR (b7)
11
13
15
17
19
1B
1D
1F
dd
dd
dd
dd
dd
dd
dd
dd
4
4
4
4
4
4
4
4
BCLR n, opr
Mn 0
BCS rel
REL
25
rr
BEQ rel
Branch if Equal
REL
27
rr
BGE opr
REL
90
rr
BGT opr
REL
92
rr
BHCC rel
REL
28
rr
Instruction Set
183
Instruction Set
Effect on
CCR
V H I N Z C
BHCS rel
BHI rel
Branch if Higher
BHS rel
Cycles
Description
Operand
Operation
Opcode
Source
Form
Address
Mode
REL
29
rr
REL
22
rr
REL
24
BIH rel
REL
2F
rr
BIL rel
REL
2E
rr
ii
dd
hh ll
ee ff
ff
ff
ee ff
2
3
4
4
3
2
4
5
BIT
BIT
BIT
BIT
BIT
BIT
BIT
BIT
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
BLE opr
Bit Test
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
rr
A5
B5
C5
D5
E5
F5
9EE5
9ED5
REL
93
rr
REL
25
rr
BLO rel
Branch if Lower
(Same as BCS)
BLS rel
REL
23
rr
BLT opr
REL
91
rr
BMC rel
REL
2C
rr
BMI rel
Branch if Minus
REL
2B
rr
BMS rel
REL
2D
rr
BNE rel
REL
26
rr
BPL rel
Branch if Plus
REL
2A
rr
BRA rel
Branch Always
REL
20
rr
DIR (b0)
DIR (b1)
DIR (b2)
(b3)
DIR
DIR (b4)
DIR (b5)
DIR (b6)
DIR (b7)
01
03
05
07
09
0B
0D
0F
dd
dd
dd
dd
dd
dd
dd
dd
REL
21
rr
DIR (b0)
DIR (b1)
DIR (b2)
(b3)
DIR
DIR (b4)
DIR (b5)
DIR (b6)
DIR (b7)
00
02
04
06
08
0A
0C
0E
dd
dd
dd
dd
dd
dd
dd
dd
Mn 1
DIR (b0)
DIR (b1)
DIR (b2)
(b3)
DIR
DIR (b4)
DIR (b5)
DIR (b6)
DIR (b7)
10
12
14
16
18
1A
1C
1E
dd
dd
dd
dd
dd
dd
dd
dd
BRN rel
BSET n, opr
Branch Never
PC (PC) + $0002
rr
rr
rr
rr
rr
rr
rr
rr
5
5
5
5
5
5
5
5
3
rr
rr
rr
rr
rr
rr
rr
rr
5
5
5
5
5
5
5
5
4
4
4
4
4
4
4
4
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
BSR rel
Effect on
CCR
V H I N Z C
Branch to Subroutine
CBEQ opr,rel
CBEQA #opr,rel
CBEQX #opr,rel Compare and Branch if
CBEQ opr,X+,rel Equal
CBEQ X+,rel
CBEQ opr,SP,rel
REL
AD
rr
DIR
IMM
IMM
IX1+
IX+
SP1
31
41
51
61
71
9E61
dd
ii
ii
ff
rr
ff
Cycles
Description
Operand
Operation
Opcode
Source
Form
Address
Mode
4
rr
rr
rr
rr
rr
5
4
4
5
4
6
CLC
C0
0 INH
98
CLI
I0
0 INH
9A
M $00
A $00
X $00
H $00
M $00
M $00
M $00
DIR
INH
INH
0 0 1 INH
IX1
IX
SP1
(A) (M)
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
CLR opr
CLRA
CLRX
CLRH
CLR opr,X
CLR ,X
CLR opr,SP
CMP
CMP
CMP
CMP
CMP
CMP
CMP
CMP
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
COM opr
COMA
COMX
COM opr,X
COM ,X
COM opr,SP
CPHX #opr
CPHX opr
CPX
CPX
CPX
CPX
CPX
CPX
CPX
CPX
#opr
opr
opr
,X
opr,X
opr,X
opr,SP
opr,SP
DAA
Clear
Compare Accumulator
with Memory
DIV
3
1
1
1
3
2
4
A1
B1
C1
D1
E1
F1
9EE1
9ED1
2
3
4
4
3
2
4
5
ii
dd
hh ll
ee ff
ff
ff
ee ff
Complement
(Ones Complement)
DIR
INH
1 INH
IX1
IX
SP1
IMM
DIR
65
75
ii ii+1
dd
3
4
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
A3
B3
C3
D3
E3
F3
9EE3
9ED3
ii
dd
hh ll
ee ff
ff
2
3
4
4
3
2
4
5
INH
72
Compare X (Index
Register Low) with
Memory
Decimal Adjust
Accumulator
(X) (M)
(A)10
(PC)
+
$0004
+
rel
if
(result)
0
for
DBNZ opr,SP,rel
SP1
DBNZ SP1
DEC opr
DECA
DECX
DEC opr,X
DEC ,X
DEC opr,SP
3F dd
4F
5F
8C
6F ff
7F
9E6F ff
Decrement
M (M) $01
A (A) $01
X (X) $01
M (M) $01
M (M) $01
M (M) $01
Divide
A (H:A)/(X)
H Remainder
DIR
INH
INH
IX1
IX
SP1
INH
33 dd
43
53
63 ff
73
9E63 ff
ff
ee ff
4
1
1
4
3
5
3B
dd rr
4B
rr
5B
rr
6B
ff rr
7B
rr
9E6B ff rr
5
3
3
5
4
6
3A dd
4A
5A
6A ff
7A
9E6A ff
4
1
1
4
3
5
52
Instruction Set
185
Instruction Set
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
INC opr
INCA
INCX
INC opr,X
INC ,X
INC opr,SP
JMP
JMP
JMP
JMP
JMP
opr
opr
opr,X
opr,X
,X
JSR
JSR
JSR
JSR
JSR
opr
opr
opr,X
opr,X
,X
LDA
LDA
LDA
LDA
LDA
LDA
LDA
LDA
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
LDHX #opr
LDHX opr
LDX
LDX
LDX
LDX
LDX
LDX
LDX
LDX
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
LSL opr
LSLA
LSLX
LSL opr,X
LSL ,X
LSL opr,SP
LSR opr
LSRA
LSRX
LSR opr,X
LSR ,X
LSR opr,SP
MOV
MOV
MOV
MOV
MUL
opr,opr
opr,X+
#opr,opr
X+,opr
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
A8
B8
C8
D8
E8
F8
9EE8
9ED8
ii
dd
hh ll
ee ff
ff
DIR
INH
INH
IX1
IX
SP1
3C
4C
5C
6C
7C
9E6C
dd
PC Jump Address
DIR
EXT
IX2
IX1
IX
BC
CC
DC
EC
FC
dd
hh ll
ee ff
ff
2
3
4
3
2
PC (PC) + n (n = 1, 2, or 3)
Push (PCL); SP (SP) $0001
Push (PCH); SP (SP) $0001
PC Unconditional Address
DIR
EXT
IX2
IX1
IX
BD
CD
DD
ED
FD
dd
hh ll
ee ff
ff
4
5
6
5
4
A6
B6
C6
D6
E6
F6
9EE6
9ED6
ii
dd
hh ll
ee ff
ff
ff
ee ff
2
3
4
4
3
2
4
5
ii jj
dd
3
4
ii
dd
hh ll
ee ff
ff
2
3
4
4
3
2
4
5
Effect on
CCR
Description
V H I N Z C
Exclusive OR
Memory with
Accumulator
A (A M)
M (M) + $01
A (A) + $01
X (X) + $01
M (M) + $01
M (M) + $01
M (M) + $01
Increment
Jump
Jump to Subroutine
A (M)
0
b7
C
b7
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
AE
BE
CE
DE
EE
FE
9EEE
9EDE
DIR
INH
INH
IX1
IX
SP1
38 dd
48
58
68 ff
78
9E68 ff
4
1
1
4
3
5
DIR
INH
INH
IX1
IX
SP1
34 dd
44
54
64 ff
74
9E64 ff
4
1
1
4
3
5
b0
(M)destination (M)source
H:X (H:X) + $001 in IX+D and DIX+ Modes
Unsigned multiply
X : A (X) (A)
ff
45
55
b0
ff
4
1
1
4
3
5
IMM
DIR
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
ff
ee ff
2
3
4
4
3
2
4
5
X (M)
Move
Cycles
Operand
EOR
EOR
EOR
EOR
EOR
EOR
EOR
EOR
Operation
Address
Mode
Source
Form
Opcode
DD
DIX+
IMD
IX+D
0 0 INH
4E
5E
6E
7E
42
ff
ee ff
dd dd
dd
ii dd
dd
5
4
4
4
5
Instruction Set
MOTOROLA
Instruction Set
Opcode Map and Instruction Set Summary
V H I N Z C
Cycles
Effect on
CCR
Description
Operand
Operation
Opcode
Source
Form
Address
Mode
NEG opr
NEGA
NEGX
NEG opr,X
NEG ,X
NEG opr,SP
Negate
(Twos Complement)
NOP
No Operation
None
INH
9D
NSA
Nibble Swap
Accumulator
A (A[3:0]:A[7:4])
INH
62
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
ORA
ORA
ORA
ORA
ORA
ORA
ORA
ORA
Inclusive OR Accumulator
and Memory
A (A) | (M)
DIR
INH
INH
IX1
IX
SP1
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
30 dd
40
50
60 ff
70
9E60 ff
AA
BA
CA
DA
EA
FA
9EEA
9EDA
ii
dd
hh ll
ee ff
ff
ff
ee ff
4
1
1
4
3
5
2
3
4
4
3
2
4
5
PSHA
INH
87
PSHH
INH
8B
PSHX
INH
89
PULA
INH
86
PULH
INH
8A
PULX
INH
88
ROL opr
ROLA
ROLX
ROL opr,X
ROL ,X
ROL opr,SP
b7
RSP
SP $FF
RTI
RTS
SEC
39 dd
49
59
69 ff
79
9E69 ff
4
1
1
4
3
5
DIR
INH
INH
IX1
IX
SP1
36 dd
46
56
66 ff
76
9E66 ff
4
1
1
4
3
5
b0
ROR opr
RORA
RORX
ROR opr,X
ROR ,X
ROR opr,SP
SBC
SBC
SBC
SBC
SBC
SBC
SBC
SBC
DIR
INH
INH
IX1
IX
SP1
C
b7
b0
C1
INH
9C
INH
80
INH
81
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
1 INH
A2
B2
C2
D2
E2
F2
9EE2
9ED2
99
ii
dd
hh ll
ee ff
ff
ff
ee ff
2
3
4
4
3
2
4
5
1
Instruction Set
187
Instruction Set
SEI
STA
STA
STA
STA
STA
STA
STA
Store Accumulator in
Memory
I1
M (A)
1 INH
DIR
EXT
IX2
IX1
IX
SP1
SP2
9B
DIR
35
STOP
0 INH
8E
STX
STX
STX
STX
STX
STX
STX
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
SUB
SUB
SUB
SUB
SUB
SUB
SUB
SUB
#opr
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
Subtract
M (X)
A (A) (M)
SWI
Software Interrupt
TAP
CCR (A)
TAX
Transfer Accumulator to
X (Index Register Low)
TPA
B7
C7
D7
E7
F7
9EE7
9ED7
STHX opr
Cycles
V H I N Z C
Set Interrupt Mask Bit
opr
opr
opr,X
opr,X
,X
opr,SP
opr,SP
Effect on
CCR
Description
Operand
Operation
Opcode
Source
Form
Address
Mode
dd
hh ll
ee ff
ff
ff
ee ff
3
4
4
3
2
4
5
dd
4
3
4
4
3
2
4
5
DIR
EXT
IX2
IX1
IX
SP1
SP2
BF
CF
DF
EF
FF
9EEF
9EDF
dd
hh ll
ee ff
ff
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
A0
B0
C0
D0
E0
F0
9EE0
9ED0
ii
dd
hh ll
ee ff
ff
ff
ee ff
ff
ee ff
2
3
4
4
3
2
4
5
1 INH
83
INH
84
X (A)
INH
97
A (CCR)
INH
85
TST opr
TSTA
TSTX
TST opr,X
TST ,X
TST opr,SP
(A) $00
(X) $00
(M) $00
TSX
INH
95
TXA
A (X)
INH
9F
TXS
INH
94
WAIT
I bit 0
0 INH
8F
DIR
INH
INH
IX1
IX
SP1
3D dd
4D
5D
6D ff
7D
9E6D ff
3
1
1
3
2
4
Instruction Set
MOTOROLA
Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190
New Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190
Code Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191
AIS Add Immediate Value (Signed) to Stack Pointer . . . . . . .192
AIX Add Immediate Value (Signed) to Index Register . . . . . .196
BGE Branch if Greater Than or Equal To . . . . . . . . . . . . . . . .198
BGT Branch if Greater Than . . . . . . . . . . . . . . . . . . . . . . . . . .200
BLE Branch if Less Than or Equal To . . . . . . . . . . . . . . . . . . .202
BLT Branch if Less Than . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204
CBEQ Compare and Branch if Equal . . . . . . . . . . . . . . . . . . .206
CBEQA Compare A with Immediate . . . . . . . . . . . . . . . . . . . .208
CBEQX Compare X with Immediate . . . . . . . . . . . . . . . . . . . .210
CLRH Clear H (Index Register High). . . . . . . . . . . . . . . . . . . .212
CPHX Compare Index Register with Memory . . . . . . . . . . . . .214
DAA Decimal Adjust Accumulator . . . . . . . . . . . . . . . . . . . . . .216
DBNZ Decrement and Branch if Not Zero . . . . . . . . . . . . . . . .218
DIV Divide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220
LDHX Load Index Register with Memory . . . . . . . . . . . . . . .224
MOV Move. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .226
NSA Nibble Swap Accumulator . . . . . . . . . . . . . . . . . . . . . . . .228
PSHA Push Accumulator onto Stack. . . . . . . . . . . . . . . . . . . .230
PSHH Push H (Index Register High) onto Stack. . . . . . . . . . .232
PSHX Push X (Index Register Low) onto Stack . . . . . . . . . . .234
PULA Pull Accumulator from Stack . . . . . . . . . . . . . . . . . . . . .236
PULH Pull H (Index Register High) from Stack . . . . . . . . . . . .238
PULX Pull X (Index Register Low) from Stack . . . . . . . . . . . .240
STHX Store Index Register . . . . . . . . . . . . . . . . . . . . . . . . . .242
TAP Transfer Accumulator to Condition Code Register . . . . .244
TPA Transfer Condition Code Register to Accumulator . . . . .246
TSX Transfer Stack Pointer to Index Register . . . . . . . . . . . .248
TXS Transfer Index Register to Stack Pointer. . . . . . . . . . . . .250
CPU08 Reference Manual Rev. 2.0
MOTOROLA
189
Introduction
The M68HC08 Family instruction set is an extension of the M68HC05
Family instruction set. This section contains the instructions unique to
the M68HC08 Family with accompanying code examples.
New Instructions
Following is a list of the new instructions.
Divide (DIV)
Move (MOV)
MOTOROLA
Code Examples
This following pages contain the instructions unique to the M68HC08
Family with accompanying code examples.
191
AIS
AIS
Operation
SP (SP) + (16 M)
Description
Adds the immediate operand to the stack pointer (SP). The immediate
value is an 8-bit two's complement signed operand. The 8-bit operand
is sign-extended to 16 bits prior to the addition. The AIS instruction can
be used to create and remove a stack frame buffer that is used to store
temporary variables.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
AIS
Addr
Mode
#opr
Machine Code
Opcode
IMM
A7
Operand(s)
ii
ii
HC08
Cycles
2
MOTOROLA
*
* AIS:
* 1) Creating local variable space on the stack
*
*
SP -->
|
|
*
--------------^
*
|
|
|
*
|
Local
|
|
*
|
Variable
|
|
*
|
Space
|
*
|
| Decreasing
*
--------------Address
*
| PC (MS byte) |
*
--------------*
| PC (LS byte) |
*
--------------*
|
|
*
* NOTE: SP must always point to next unused byte,
*
therefore do not use this byte (0,SP) for storage
*
*
Label
Operation
Operand
Comments
SUB1
*
*
*
*
AIS
.
.
.
.
AIS
#-16
#16
RTS
*
*
***********************************************************
193
Operation
Operand
PARAM1
PARAM2
*
*
RMB
RMB
1
1
LDA
PSHA
LDA
PSHA
JSR
PULA
AIS
PARAM1
BCS
.
EQU
.
ERROR
*
ERROR
*
*
Comments
MOTOROLA
**********************************
* DIVIDE: 8/8 divide
*
*
SP ---> |
|
*
--------------*
|
A
|
*
--------------*
|
X
|
^
*
--------------|
*
|
H
|
|
*
--------------|
*
| PC (MS byte) |
|
*
--------------|
*
| PC (LS byte) |
|
*
--------------|
*
|
Divisor
|
*
--------------- Decreasing
*
|
Dividend
|
Address
*
--------------*
|
|
*
*
Entry:
Dividend and divisor on stack at
*
SP,7 and SP,6 respectively
*
Exit:
8-bit result placed on stack at SP,6
*
A, H:X preserved
*
Label
Operation
DIVIDE
PSHH
PSHX
PSHA
LDX
CLRH
LDA
DIV
STA
PULA
PULX
PULH
RTS
OK
Operand
Comments
;preserve H:X, A
6,SP
7,SP
6,SP
;Divisor -> X
;0 -> MS dividend
;Dividend -> A
;Save result
;restore H:X, A
*
***********************************************************
195
AIX
AIX
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
AIX
Addr
Mode
#opr
Machine Code
Opcode
IMM
AF
Operand(s)
ii
HC08
Cycles
2
MOTOROLA
Operation
Operand
TABLE
ORG
FDB
$7000
512
ORG
LDHX
CLRA
ADD
AIX
$6E00
#511
Operation
Operand
Comments
ORG
RMB
$50
2
ORG
LDHX
AIX
AIX
$6E00
FRACT
#1
#$7F
ADDLOOP
Comments
TABLE,X
#-1
*
* NOTE:
*
*
*
*
197
BGE
BGE
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BGE
opr
Addr
Mode
REL
Opcode
90
Machine Code
Operand(s)
rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
MOTOROLA
NEG_FLG
VAR1
VAR2
*
*
S_MULT
*
POS
*
POS2
OperationOperand
Comments
ORG
RMB
RMB
RMB
$50
1
1
1
ORG
CLR
TST
BGE
INC
NEG
$6E00
NEG_FLG
VAR1
POS
NEG_FLG
VAR1
TST
BGE
INC
NEG
VAR2
POS2
NEG_FLG
VAR2
;Check VAR2
;Continue is =>0
;Else toggle negative flag
;Make into positive number
LDA
LDX
MUL
BRCLR
VAR2
VAR1
COMA
COMX
ADD
PSHA
TXA
ADC
EXIT
*
;Load VAR1
;Load VAR2
;Unsigned VAR1 x VAR2 -> X:A
0,NEG_FLG,EXIT ;Quit if operands both
;positive or both neg.
;Else one's complement A and X
#1
#0
TAX
PULA
RTS
199
BGT
BGT
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BGT
opr
Addr
Mode
Machine Code
Opcode
REL
92
HC08
Cycles
Operand(s)
rr
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
MOTOROLA
ERR_FLG
AD_RES
*
*
OUT
IN
*
Operation
Operand
Comments
ORG
RMB
RMB
$50
1
1
ORG
BCLR
LDA
EOR
CMP
BGT
CMP
$6E00
0,ERR_FLG
AD_RES
#$80
#$73
OUT
#$8D
BGT
BSET
RTS
201
BLE
BLE
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BLE
Addr
Mode
opr
REL
Opcode
93
Machine Code
Operand(s)
rr
HC08
Cycles
3
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
MOTOROLA
VAL1
VAL2
*
*
EXIT1
*
Operation
Operand
Comments
ORG
RMB
RMB
$50
2
2
ORG
LDHX
CPHX
BLE
LDHX
EQU
$6E00
VAL1
VAL2
EXIT1
VAL2
*
203
BLT
BLT
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
BLT
Addr
Mode
opr
Machine Code
Opcode
REL
91
HC08
Cycles
Operand(s)
rr
BIH
2F
BIL
2E
Always
BRA
20
Never
BRN
21
r=register: A, X, or H:X (after CPHX instruction) m=memory operand
Type
Signed
Signed
Signed
Signed
Signed
Unsigned
Unsigned
Unsigned
Unsigned
Unsigned
Simple
Simple
Simple
Simple
Simple
Simple
Uncond.
MOTOROLA
EXIT2
*
Operation
Operand
Comments
ORG
PSHX
CMP
BLT
TXA
PULX
$6E00
1,SP
EXIT2
205
CBEQ
CBEQ
Operation
Description
CBEQ compares the operand with the accumulator (A) and causes a
branch if the result is zero. The CBEQ instruction combines CMP and
BEQ for faster table lookup routines.
CBEQ_IX+ compares the operand addressed by the index register (H:X)
to A and causes a branch if the result is zero. H:X is then incremented
regardless of whether a branch is taken. CBEQ_IX1+ operates the
same way except that an 8-bit offset is added to the effective address of
the operand.
Condition Codes
and Boolean
Formulae
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
None affected.
V
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
opr, rel
DIR
31
dd
rr
CBEQA
#opr, rel
IMM
41
ii
rr
CBEQX
#opr, rel
IMM
51
ii
rr
X+, rel
IX+
71
rr
CBEQ
IX1+
61
ff
rr
CBEQ
SP1
9E61
ff
rr
CBEQ
CBEQ
MOTOROLA
Operation
Operand
Comments
SKIP
LDA
CBEQ
#$20
X+,SKIP
*
*
*
*
*
*
Label
Operation
Operand
Comments
AIX
#-1
RTS
*
207
CBEQA
CBEQA
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
opr, rel
DIR
31
dd
rr
CBEQA
#opr, rel
IMM
41
ii
rr
CBEQX
#opr, rel
IMM
51
ii
rr
X+, rel
IX+
71
rr
CBEQ
IX1+
61
ff
rr
CBEQ
SP1
9E61
ff
rr
CBEQ
CBEQ
MOTOROLA
Operation
Operand
EOT
*
DATA_RX
*
EQU
$04
EQU
LDA
CBEQA
DATA_RX
#EOT,EXIT3
Comments
*
* NOTE: CBEQ, CBEQA, CBEQX instructions do NOT modify the
* CCR. In this example, Z flag will remain in the state the
* LDA instruction left it in.
*
*
|
*
| Process
*
| data
*
|
EXIT3
RTS
*
209
CBEQX
CBEQX
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
opr, rel
DIR
31
dd
rr
CBEQA
#opr, rel
IMM
41
ii
rr
CBEQX
#opr, rel
IMM
51
ii
rr
X+, rel
IX+
71
rr
CBEQ
IX1+
61
ff
rr
CBEQ
SP1
9E61
ff
rr
CBEQ
CBEQ
MOTOROLA
Operation
Operand
ON_KEY
*
SLEEP
EQU
$02
WAIT
BSR
LDX
CBEQX
BRA
DELAY
PORTA
#ON_KEY,WAKEUP
SLEEP
EQU
*
WAKEUP
*
Comments
211
CLRH
Operation
H $00
Description
Condition Codes
and Boolean
Formulae
CLRH
V
0
V: 0
Cleared.
N: 0
Cleared.
Z: 1
Set.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
CLRH
CLR
Machine Code
Opcode
INH (H)
opr,SP
SP1
Operand(s)
8C
9E6F
HC08
Cycles
1
ff
MOTOROLA
Operation
Operand
Comments
CLRX
CLRH
*
* NOTE:
*
*
213
CPHX
CPHX
Operation
Description
CPHX compares index register (H:X) with the 16-bit value in memory
and sets the condition code register accordingly.
Condition Codes
and Boolean
Formulae
V: H7&M15&R15 | H7&M15&R15
Set if a two's complement overflow resulted from the operation;
cleared otherwise.
N: R15
Set if MSB of result is one; cleared otherwise.
Z: R15&R14&R13&R12&R11&R10&R9&R8
&R7&R6&R5&R4&R3&R2&R1&R0
Set if the result is $0000; cleared otherwise.
C: H7&M15 | M15&R15 | R15&H7
Set if the absolute value of the contents of memory is larger than
the absolute value of the index register; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
HC08
Cycles
Operand(s)
CPHX
#opr
IMM
65
ii
CPHX
opr
DIR
75
dd
ii+1
3
4
MOTOROLA
Operation
Operand
Comments
STACK
SIZE
*
EQU
EQU
$1000
$100
PSHH
PSHX
TSX
CPHX
BLO
*
PULX
PULH
*
*
*
*
*
FATAL
*
|
|
|
EQU
215
DAA
DAA
Operation
(A)10
Description
Adjusts contents of the accumulator (A) and the state of the condition
code register (CCR) carry bit after binary-coded decimal (BCD)
operations, so that there is a correct BCD sum and an accurate carry
indication. The state of the CCR half carry bit affects operation. (Refer
to the DAA Function Summary table on the following page for details
of operation.)
Condition Codes
and Boolean
Formulae
V
U
V: U
Undefined.
N: R7
Set if MSB of result is one; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
C: (Refer to the DAA Function Summary table on following page.)
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
DAA
Addr
Mode
Machine Code
Opcode
INH
72
Operand(s)
HC08
Cycles
2
MOTOROLA
The DAA Function Summary table below shows DAA operation for all
legal combinations of input operands. Columns 14 represent the
results of ADC or ADD operations on BCD operands. The correction
factor in column 5 is added to the accumulator to restore the result of an
operation on two BCD operands to a valid BCD value and to set or clear
the C bit. All values are in hexadecimal.
2
Value of
A[7:4]
09
08
09
AF
9F
AF
02
02
03
3
Initial
H-Bit Value
0
0
1
0
0
1
0
0
1
4
Value of
A[3:0]
09
AF
03
09
AF
03
09
AF
03
5
Correction
Factor
00
06
06
60
66
66
60
66
66
6
Corrected
C-Bit Value
0
0
0
1
1
1
1
1
1
Operation
Operand
VALUE1
VALUE2
*
FCB
FCB
$78
$49
LDA
ADD
DAA
VALUE1
VALUE2
Comments
;A = $78
;A = $78+$49 = $C1; C=0, H=1
;Add $66; A = $27; C=1 {=127 BCD}
217
DBNZ
DBNZ
Operation
Description
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
opr, rel
DIR
3B
dd
DBNZA
rel
INH
4B
rr
DBNZX
rel
DBNZ
rr
HC08
Cycles
5
3
INH
5B
rr
DBNZ
X, rel
IX
7B
rr
DBNZ
opr, X, rel
IX1
6B
ff
rr
DBNZ
SP1
9E6B
ff
rr
MOTOROLA
Operation
Operand
Comments
N
*
EQU
$41
ORG
RMB
$50
1
ORG
LDA
DBNZ
DBNZA
$6E00
#N
COUNT,LOOPY
LOOPY
COUNT
*
DELAY
LOOPY
*
219
DIV
DIV
Divide
Operation
A (H:A) (X)
H Remainder
Description
Condition Codes
and Boolean
Formulae
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result (quotient) is $00; cleared otherwise.
C: Set if a divide by zero was attempted or if an overflow occurred;
cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
DIV
Addr
Mode
Machine Code
Opcode
INH
52
Operand(s)
HC08
Cycles
7
MOTOROLA
Label
Operation
Operand
Comments
ORG
$50
;RAM address space
DIVID1
RMB
1
;storage for dividend
DIVISOR1
RMB
1
;storage for divisor
QUOTIENT1 RMB
1
;storage for quotient
*
ORG
$6E00
;ROM/EPROM address spcae
LDA
DIVID1
;Load dividend
CLRH
;Clear MS byte of dividend
LDX
DIVISOR1
;Load divisor
DIV
;8/8 divide
STA
QUOTIENT1
;Store result; remainder in H
*
*
*
* 2) 8/8 integer divide > 8-bit integer and 8-bit fractional
* quotient. Performs an unsigned integer divide of an 8-bit
* dividend in A by an 8-bit divisor in X. H must be
* cleared. The quotient is placed into A and the remainder
* in H. The remainder may be further resolved by executing
* additional DIV instructions as shown below. The radix point
* of the quotient will be between bits 7 and 8.
*
Label
Operation
ORG
DIVID2
RMB
DIVISOR2
RMB
QUOTIENT2 RMB
*
ORG
LDA
CLRH
LDX
DIV
STA
CLRA
DIV
STA
*
*
*
Operand
Comments
$50
1
1
2
;RAM address
;storage for
;storage for
;storage for
$6E00
DIVID2
DIVISOR2
QUOTIENT2
space
dividend
divisor
quotient
;Resolve remainder
QUOTIENT2+1
221
Label
Operation
ORG
DIVID3
RMB
DIVISOR3
RMB
QUOTIENT3 RMB
*
ORG
LDHX
CLRA
DIV
STA
CLRA
DIV
STA
*
*
*
*
*
*
*
*
*
*
*
*
*
*
Operand
Comments
$50
1
1
2
;RAM address
;storage for
;storage for
;storage for
$6E00
DIVID3
QUOTIENT3
space
dividend
divisor
quotient
;Resolve remainder
QUOTIENT3+1
Label
Operation
ORG
DIVIDEND4 RMB
DIVISOR4
RMB
QUOTIENT4 RMB
*
*
Operand
Comments
$50
2
1
3
;RAM address
;storage for
;storage for
;storage for
space
dividend
divisor
quotient
MOTOROLA
ORG
LDA
CLRH
LDX
DIV
STA
*
LDA
DIV
STA
CLRA
DIV
STA
*
*
*
*
*
*
*
*
$6E00
;ROM/EPROM address space
DIVIDEND4 ;Load MS byte of dividend into
;LS dividend reg.
;Clear H (MS dividend register)
DIVISOR4
;Load divisor
;8/8 integer divide [A/X -> A; r->H]
QUOTIENT4 ;Store result (MS result of
;complete operation)
;Remainder in H (MS dividend
;register)
DIVIDEND4+1;Load LS byte of dividend into
;LS dividend reg.
;16/8 integer divide
;[H:A/X -> A; r->H]
QUOTIENT4+1;Store result (LS result of
;complete operation)
;Clear LS dividend (prepare for
;fract. divide)
;Resolve remainder
QUOTIENT4+2;Store fractional result.
Label
Operation
ORG
DIVID5
RMB
DIVISOR5
RMB
QUOTIENT5 RMB
*
ORG
LDHX
TXA
LDX
DIV
BCS
STA
ERROR5
EQU
Operand
Comments
$50
2
1
1
;RAM address
;storage for
;storage for
;storage for
space
dividend
divisor
quotient
$6E00
DIVID5
223
LDHX
LDHX
Operation
Description
Loads the contents of the specified memory location into the index
register (H:X). The condition codes are set according to the data.
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R15
Set if MSB of result is one; cleared otherwise.
Z: R15&R14&R13&R12&R11&R10&R9&R8
&R7&R6&R5&R4&R3&R2&R1&R0
Set if the result is $0000; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
LDHX
#opr
IMM
45
ii
LDHX
opr
DIR
55
dd
jj
HC08
Cycles
3
4
MOTOROLA
Operation
Operand
Comments
RAM
SIZE1
*
EQU
EQU
$0050
$400
;Start of RAM
;Length of RAM array
LDHX
CLR
AIX
CPHX
BLO
#RAM
,X
#1
#RAM+SIZE1
loop
LOOP
225
MOV
MOV
Move
Operation
(M)destination (M)source
Description
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R7
Set if MSB of result is set; cleared otherwise.
Z: R7&R6&R5&R4&R3&R2&R1&R0
Set if result is $00; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
Operand(s)
HC08
Cycles
MOV
#opr, opr
IMD
6E
ii
dd
MOV
opr, opr
DD
4E
dd
dd
MOV
X+, opr
IX+D
7E
dd
MOV
opr, X+
DIX+
5E
dd
MOTOROLA
Operation
Operand
Comments
PORTA
PORTB
*
EQU
EQU
$0000
$0001
MOV
MOV
#$AA,PORTA
#$55,PORTB
*
*
*
* 2) Move REG1 to REG2 if REG1 positive; clear REG2*
Label
Operation
Operand
REG1
REG2
*
EQU
EQU
$0010
$0011
MOV
BMI
CLR
REG1,REG2
NEG
REG2
Comments
*
NEG
EQU
*
*
*
* 3) Move data to a page 0 location from a table anywhere in memory
*
Label
Operation
Operand
SPIOUT
*
EQU
$0012
Comments
ORG
$50
;RAM address space
TABLE_PTR RMB
2
;storage for table pointer
*
ORG
$6E00
;ROM/EPROM address space
LDHX
TABLE_PTR
;Restore table pointer
MOV
X+,SPIOUT
;Move data
*
* NOTE: X+ is a 16-bit increment of the H:X register
* NOTE: The increment occurs after the move operation is
* completed
*
STHX
TABLE_PTR
;Save modified pointer
*
227
NSA
NSA
Operation
A (A[3:0]:A[7:4])
Description
Swaps upper and lower nibbles (4 bits) of the accumulator. The NSA
instruction is used for more efficient storage and use of binary-coded
decimal operands.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
NSA
Addr
Mode
Machine Code
Opcode
INH
62
Operand(s)
HC08
Cycles
3
MOTOROLA
NSA:
Compress 2 bytes, each containing one BCD nibble, into 1
byte. Each byte contains the BCD nibble in bits 0-3. Bits
4-7 are clear.
Label
Operation
Operand
BCD1
BCD2
*
RMB
RMB
1
1
LDA
NSA
ADD
BCD1
BCD2
Comments
229
PSHA
PSHA
Operation
Description
The contents of the accumulator (A) are pushed onto the stack at the
address contained in the stack pointer (SP). SP is then decremented to
point to the next available location in the stack. The contents of A remain
unchanged.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PSHA
Addr
Mode
Machine Code
Opcode
INH
87
Operand(s)
HC08
Cycles
2
MOTOROLA
TABLE1
*
PROG_0
PROG_1
PROG_2
PROG_3
*
Operation
Operand
PSHA
LSLA
ADD
1,SP
TAX
CLRH
PULA
JMP
JMP
JMP
JMP
JMP
TABLE1,X
PROG_0
PROG_1
PROG_2
PROG_3
EQU
EQU
EQU
EQU
*
*
*
*
Comments
;Save selection number
;Multiply by 2
;Add stacked number;
;A now = A x 3
;Move to index reg
;and clear MS byte
;Clean up stack
;Jump into table....
231
PSHH
PSHH
Operation
Description
The contents of H are pushed onto the stack at the address contained in
the stack pointer (SP). SP is then decremented to point at the next
available location in the stack. The contents of H remain unchanged.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PSHH
Addr
Mode
Machine Code
Opcode
INH
8B
Operand(s)
HC08
Cycles
2
MOTOROLA
Operation
SCI_INT
PSHH
*
*
*
*
*
|
|
|
|
|
PULH
RTI
Operand
Comments
;Save H (all other registers
;already stacked)
;Restore H
;Unstack all other registers;
;return to main
*
*
* 2) Effective address calculation
*
*
Entry : H:X=pointer, A=offset
*
Exit : H:X = A + H:X (A = H)
*
Label
Operation
PSHX
PSHH
ADD
TAX
PULA
ADC
PSHA
PULH
AIS
Operand
Comments
;Push X then H onto stack
2,SP
#0
#1
;Add stacked X to A
;Move result into X
;Pull stacked H into A
;Take care of any carry
;Push modified H onto stack
;Pull back into H
;Clean up stack
233
PSHX
PSHX
Operation
Description
The contents of X are pushed onto the stack at the address contained in
the stack pointer (SP). SP is then decremented to point at the next
available location in the stack. The contents of X remain unchanged.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PSHX
Addr
Mode
Machine Code
Opcode
INH
89
Operand(s)
HC08
Cycles
2
MOTOROLA
Operation
Operand
PSHX
PULH
Comments
;Move X onto the stack
;Return back to H
*
* 2) Implement the exchange of the X register and A
*
Label
Operation
Operand
PSHX
TAX
PULA
Comments
;Move X onto the stack
;Move A into X
;Restore X into A
235
PULA
PULA
Operation
Description
The stack pointer (SP) is incremented to address the last operand on the
stack. The accumulator (A) is then loaded with the contents of the
address pointed to by SP.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PULA
Addr
Mode
Machine Code
Opcode
INH
86
Operand(s)
HC08
Cycles
2
MOTOROLA
Operation
Operand
PSHH
PULA
Comments
;Move H onto stack
;Return back to A
237
PULH
PULH
Operation
Description
The stack pointer (SP) is incremented to address the last operand on the
stack. H is then loaded with the contents of the address pointed to by SP.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PULH
Addr
Mode
Machine Code
Opcode
INH
8A
Operand(s)
HC08
Cycles
2
MOTOROLA
Operation
Operand
PSHA
PSHH
PULA
PULH
Comments
;Move
;Move
;Pull
;Pull
A
H
H
A
onto
onto
into
into
the stack
the stack
A
H
239
PULX
Operation
Description
The stack pointer (SP) is incremented to address the last operand on the
stack. X is then loaded with the contents of the address pointed to by SP.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
PULX
Addr
Mode
PULX
Machine Code
Opcode
INH
88
Operand(s)
HC08
Cycles
2
MOTOROLA
Operation
Operand
PSHA
TXA
PULX
Comments
;Move A onto the stack
;Move X into A
;Restore A into X
241
STHX
STHX
Operation
Description
Stores the index register (H:X) to the specified memory location. The
condition codes are set according to the data.
Condition Codes
and Boolean
Formulae
V
0
V: 0
Cleared.
N: R15
Set if MSB of result is one; cleared otherwise.
Z: R15&R14&R13&R12&R11&R10&R9&R8
&R7&R6&R5&R4&R3&R2&R1&R0
Set if the result is $0000; cleared otherwise.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
STHX
Addr
Mode
opr
Machine Code
Opcode
DIR
35
Operand(s)
dd
HC08
Cycles
4
MOTOROLA
TEMP
*
Operation
Operand
Comments
ORG
RMB
$50
2
ORG
STHX
ADD
TAX
LDA
ADC
PSHA
PULH
$6E00
TEMP
TEMP+1
TEMP
#0
243
TAP
TAP
Operation
CCR (A)
7
0
A
CCR
Carry/Borrow
Zero
Negative
I Interrupt
Mask
Half Carry
Overflow
(Twos
Complement)
Description
Condition Codes
and Boolean
Formulae
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
TAP
INH
84
Operand(s)
HC08
Cycles
2
MOTOROLA
245
TPA
TPA
Operation
A (CCR)
7
0
A
CCR
Carry/Borrow
Zero
Negative
I Interrupt
Mask
Half Carry
Overflow
(Twos
Complement)
Description
Transfers the contents of the condition code register (CCR) into the
accumulator (A).
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
TPA
INH
Opcode
85
Machine Code
Operand(s)
HC08
Cycles
1
MOTOROLA
Operation
Operand
Comments
TPA
*
* NOTE: Transfering the CCR to A does not modify the CCR.
*
TSTA
BMI
V_SET
*
V_SET
EQU
*
*
247
TSX
TSX
Operation
Description
Loads the index register (H:X) with 1 plus the contents of the stack
pointer (SP). The contents of SP remain unchanged. After a TSX
instruction, H:X points to the last value that was stored on the stack.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Machine Code
Opcode
TSX
INH
95
Operand(s)
HC08
Cycles
2
MOTOROLA
TSX:
Create a stack frame pointer. H:X points to the stack frame
irrespective of stack depth. Useful for handling nested
subroutine calls (e.g. recursive routines) which reference
the stack frame data.
Label
Operation
Operand
LOCAL
*
EQU
$20
AIS
#LOCAL
Comments
TSX
*
* NOTE: TSX transfers SP+1 to allow the H:X register to point
* to the first used stack byte (SP always points to the next
* available stack byte). The SP itself is not modified.
*
*
|
*
|
*
LDA
0,X
;Load the 1st byte in local space
*
*
|
*
|
*
|
*
249
TXS
TXS
Operation
Description
Loads the stack pointer (SP) with the contents of the index register (H:X)
minus one. The contents of H:X are not altered.
Condition Codes
and Boolean
Formulae
None affected.
Source Forms,
Addressing
Modes, Machine
Code, and Cycles
Source
Forms
Addr
Mode
Opcode
Machine Code
TXS
INH
94
Operand(s)
HC08
Cycles
2
MOTOROLA
Operation
Operand
STACK1
*
EQU
$0FFF
LDHX
TXS
#STACK1+1
Comments
*
* NOTE: TXS subtracts 1 from the value in H:X before it
* transfers to SP.
251
MOTOROLA
Glossary
Glossary
253
Glossary
one-to-one correspondence with the machine instruction. The
mnemonics are translated into an object code program that a
microcontroller can use.
ASCII American Standard Code for Information Interchange. A
widely accepted correlation between alphabetic and numeric
characters and specific 7-bit binary numbers.
asynchronous Refers to circuitry and operations without common
clock signals.
BCD Binary-coded decimal. See binary-coded decimal.
binary The binary number system using 2 as its base and using only
the digits 0 and 1. Binary is the numbering system used by
computers because any quantity can be represented by a series
of ones and zeros. Electrically, these ones and zeros are
represented by voltage levels of approximately VDD (input) and
VSS (ground), respectively.
binary-coded decimal (BCD) A notation that uses binary values to
represent decimal quantities. Each BCD digit uses 4 binary bits.
Six of the possible 16 binary combinations are considered illegal.
bit A single binary digit. A bit can hold a single value of zero or one.
Boolean A mathematical system of representing logic through a
series of algebraic equations that can only be true or false, using
operators such as AND, OR, and NOT.
branch instructions Computer instructions that cause the CPU to
continue processing at a memory location other than the next
sequential address. Most branch instructions are conditional.
That is, the CPU continues to the next sequential address (no
branch) if a condition is false, or continue to some other address
(branch) if the condition is true.
bus A collection of logic lines (conductor paths) used to transfer
data.
byte A set of exactly eight binary bits.
Glossary
MOTOROLA
Glossary
Glossary
255
Glossary
CPU cycles A CPU clock cycle is one period of the internal bus-rate
clock, normally derived by dividing a crystal oscillator source by
two or more so the high and low times are equal. The length of
time required to execute an instruction is measured in CPU clock
cycles.
CPU registers Memory locations that are wired directly into the CPU
logic instead of being part of the addressable memory map. The
CPU always has direct access to the information in these
registers. The CPU registers in an M68HC08 are:
A (8-bit accumulator)
H:X (16-bit accumulator)
SP (16-bit stack pointer)
PC (16-bit program counter)
CCR (condition code register containing the V, H, I, N, Z,
and C bits)
cycles See CPU cycles.
data bus A set of conductors used to convey binary information from
a CPU to a memory location or from a memory location to a
CPU.
decimal Base ten numbering system that uses the digits zero
through nine.
direct address Any address within the first 256 addresses of
memory ($0000$00FF). The high-order byte of these
addresses is always $00. Special instructions allow these
addresses to be accessed using only the low-order byte of their
address. These instructions automatically fill in the assumed
$00 value for the high-order byte of the address.
direct addressing mode Direct addressing mode uses a
program-supplied value for the low-order byte of the address of
an operand. The high-order byte of the operand address is
assumed to be $00 and so it does not have to be explicitly
specified. Most direct addressing mode instructions can access
any of the first 256 memory addresses.
CPU08 Reference Manual Rev. 2.0
256
Glossary
MOTOROLA
Glossary
Glossary
257
Glossary
H Abbreviation for half-carry in the condition code register of the
CPU08. This bit indicates a carry from the low-order four bits of
the accumulator value to the high-order four bits. The half-carry
bit is required for binary-coded decimal arithmetic operations.
The decimal adjust accumulator (DAA) instruction uses the state
of the H and C flags to determine the appropriate correction
factor.
hexadecimal Base 16 numbering system that uses the digits 0
through 9 and the letters A through F. One hexadecimal digit can
exactly represent a 4-bit binary value. Hexadecimal is used by
people to represent binary values because a 2-digit number is
easier to use than the equivalent 8-digit number.
high order The leftmost digit(s) of a number; the opposite of low
order.
H:X Abbreviation for the 16-bit index register in the CPU08. The
upper byte of H:X is called H. The lower byte is called X. In the
indexed addressing modes, the CPU uses the contents of H:X to
determine the effective address of the operand. H:X can also
serve as a temporary data storage location.
I Abbreviation for interrupt mask bit in the condition code register of
the CPU08. When I is set, all interrupts are disabled. When I is
cleared, interrupts are enabled.
immediate addressing mode In immediate addressing mode, the
operand is located in the next memory location(s) after the
opcode. The immediate value is one or two bytes, depending on
the size of the register involved in the instruction.
index register (H:X) A 16-bit register in the CPU08. The upper
byte of H:X is called H. The lower byte is called X. In the
indexed addressing modes, the CPU uses the contents of H:X to
determine the effective address of the operand. H:X can also
serve as a temporary data storage location.
indexed addressing mode Indexed addressing mode instructions
access data with variable addresses. The effective address of
the operand is determined by the current value of the H:X
register added to a 0-, 8-, or 16-bit value (offset) in the
CPU08 Reference Manual Rev. 2.0
258
Glossary
MOTOROLA
Glossary
instruction. There are separate opcodes for 0-, 8-, and 16-bit
variations of indexed mode instructions, and so the CPU knows
how many additional memory locations to read after the opcode.
indexed, post increment addressing mode In this addressing
mode, the effective address of the operand is determined by the
current value of the index register, added to a 0- or 8-bit value
(offset) in the instruction, after which the index register is
incremented. Operands with variable addresses can be
addressed with the 8-bit offset instruction.
inherent addressing mode The inherent addressing mode has no
operand because the opcode contains all the information
necessary to carry out the instruction. Most inherent instructions
are one byte long.
input/output (I/O) Input/output interfaces between a computer
system and the external world. A CPU reads an input to sense
the level of an external signal and writes to an output to change
the level on an external signal.
instructions Instructions are operations that a CPU can perform.
Instructions are expressed by programmers as assembly
language mnemonics. A CPU interprets an opcode and its
associated operand(s) and instruction(s).
instruction set The instruction set of a CPU is the set of all
operations that the CPU can perform. An instruction set is often
represented with a set of shorthand mnemonics, such as LDA,
meaning load accumulator (A). Another representation of an
instruction set is with a set of opcodes that are recognized by the
CPU.
interrupt Interrupts provide a means to temporarily suspend normal
program execution so that the CPU is freed to service sets of
instructions in response to requests (interrupts) from peripheral
devices. Normal program execution can be resumed later from
its original point of departure. The CPU08 can process up to
128 separate interrupt sources, including a software interrupt
(SWI).
I/O Input/output. See input/output.
CPU08 Reference Manual Rev. 2.0
MOTOROLA
Glossary
259
Glossary
IRQ Interrupt request. The overline indicates an active-low signal.
least significant bit (LSB) The rightmost digit of a binary value; the
opposite of most significant bit (MSB).
logic one A voltage level approximately equal to the input power
voltage (VDD).
logic zero A voltage level approximately equal to the ground voltage
(VSS).
low order The rightmost digit(s) of a number; the opposite of high
order.
LS Least significant.
LSB Least significant bit. See least significant bit.
M68HC08 A Motorola Family of 8-bit MCUs.
machine codes The binary codes processed by the CPU as
instructions. Machine code includes both opcodes and operand
data.
MCU Microcontroller unit. See microcontroller unit.
memory location In the M68HC08, each memory location holds
one byte of data and has a unique address. To store information
into a memory location, the CPU places the address of the
location on the address bus, the data information on the data
bus, and asserts the write signal. To read information from a
memory location, the CPU places the address of the location on
the address bus and asserts the read signal. In response to the
read signal, the selected memory location places its data onto
the data bus.
memory map A pictorial representation of all memory locations in a
computer system.
memory to memory addressing mode In this addressing mode,
the accumulator has been eliminated from the data transfer
process, thereby reducing execution cycles. This addressing
mode there-fore provides rapid data transfers because it does
not use the accumulator and associated load and store
CPU08 Reference Manual Rev. 2.0
260
Glossary
MOTOROLA
Glossary
Glossary
261
Glossary
operand The fundamental quantity on which a mathematical
operation is performed. Usually a statement consists of an
operator and an operand. The operator may indicate an add
instruction; the operand therefore will indicate what is to be
added.
oscillator A circuit that produces a constant frequency square wave
that is used by the computer as a timing and sequencing
reference.
page 0 The first 256 bytes of memory ($0000$00FF). Also called
direct page.
PC Program counter. See program counter.
pointer Pointer register. An index register is sometimes called a
pointer register because its contents are used in the calculation
of the address of an operand, and therefore points to the
operand.
program A set of computer instructions that cause a computer to
perform a desired operation or operations.
programming model The registers of a particular CPU.
program counter (PC) A 16-bit register in the CPU08. The PC
register holds the address of the next instruction or operand that
the CPU will use.
pull The act of reading a value from the stack. In the M68HC08, a
value is pulled by the following sequence of operations. First, the
stack pointer register is incremented so that it points to the last
value saved on the stack. Next, the value at the address
contained in the stack pointer register is read into the CPU.
push The act of storing a value at the address contained in the stack
pointer register and then decrementing the stack pointer so that
it points to the next available stack location.
random access memory (RAM) A type of memory that can be
read or written by the CPU. The contents of a RAM memory
location remain valid until the CPU writes a different value or until
power is turned off.
CPU08 Reference Manual Rev. 2.0
262
Glossary
MOTOROLA
Glossary
Glossary
263
Glossary
signed A form of binary number representation accommodating both
positive and negative numbers. The most significant bit is used
to indicate whether the number is positive or negative, normally
zero for positive and one for negative, and the other seven bits
indicate the magnitude.
SIM System integration module. See system integration module.
SP Stack pointer. See stack pointer.
stack A mechanism for temporarily saving CPU register values
during interrupts and subroutines. The CPU maintains this
structure with the stack pointer (SP) register, which contains the
address of the next available (empty) storage location on the
stack. When a subroutine is called, the CPU pushes (stores) the
low-order and high-order bytes of the return address on the stack
before starting the subroutine instructions. When the subroutine
is done, a return from subroutine (RTS) instruction causes the
CPU to recover the return address from the stack and continue
processing where it left off before the subroutine. Interrupts work
in the same way except that all CPU registers are saved on the
stack instead of just the program counter.
stack pointer (SP) A 16-bit register in the CPU08 containing the
address of the next available (empty) storage on the stack.
stack pointer addressing mode Stack pointer (SP) addressing
mode instructions operate like indexed addressing mode
instructions except that the offset is added to the stack pointer
instead of the index register (H:X). The effective address of the
operand is formed by adding the unsigned byte(s) in the stack
pointer to the unsigned byte(s) following the opcode.
subroutine A sequence of instructions to be used more than once in
the course of a program. The last instruction in a subroutine is a
return from subroutine (RTS) instruction. At each place in the
main program where the subroutine instructions are needed, a
jump or branch to subroutine (JSR or BSR) instruction is used to
call the subroutine. The CPU leaves the flow of the main
Glossary
MOTOROLA
Glossary
Glossary
265
Glossary
Z Abbreviation for zero, a bit in the condition code register of the
CPU08. The CPU08 sets the zero flag when an arithmetic
operation, logical operation, or data manipulation produces a
result of $00.
zero A logic low level, a voltage level approximately equal to the
ground voltage (VSS).
Glossary
MOTOROLA
Index
A
Accumulator (A) ............................................................................................27
Addressing modes
direct .........................................................................................................62
extended ..................................................................................................65
immediate ................................................................................................60
indexed with post increment .................................................................80
indexed, 16-bit offset .............................................................................68
indexed, 8-bit offset ................................................................................67
indexed, 8-bit offset with post increment ............................................80
indexed, no offset ...................................................................................67
inherent ....................................................................................................57
memory to memory direct to direct ......................................................76
memory to memory direct to indexed with post increment ..............78
memory to memory immediate to direct .............................................75
memory to memory indexed to direct with post increment ..............77
relative ......................................................................................................73
stack pointer, 16-bit offset .....................................................................70
stack pointer, 8-bit offset .......................................................................70
C
Carry/borrow flag (C) ...................................................................................31
Condition code register (CCR)
carry/borrow flag (C) ..............................................................................31
half-carry flag (H) ....................................................................................30
interrupt mask (I) ....................................................................................30
negative flag (N) .....................................................................................31
overflow flag (V) ......................................................................................30
zero flag (Z) .............................................................................................31
CPU08
accumulator (A) ......................................................................................27
block diagram ..........................................................................................32
CPU08 Reference Manual Rev. 2.0
MOTOROLA
Index
267
Index
condition code register (CCR) ..............................................................30
control unit ...............................................................................................34
execution unit ..........................................................................................35
features ....................................................................................................22
functional description .............................................................................32
index register (HX) .................................................................................27
instruction execution ..............................................................................35
internal timing ..........................................................................................33
low-power modes ...................................................................................24
program counter (PC) ............................................................................29
programming model ...............................................................................26
registers ...................................................................................................26
stack pointer (SP)................................................................................... 28
D
Direct addressing mode ..............................................................................62
DMA (direct memory access module) .......................................................41
E
Extended addressing mode ........................................................................65
H
HX (index register) .......................................................................................27
I
Immediate addressing mode ......................................................................60
Index register (HX) .......................................................................................27
Indexed with post increment addressing mode .......................................80
Indexed, 16-bit offset addressing mode ...................................................68
Indexed, 8-bit offset addressing mode ......................................................67
Indexed, 8-bit offset with post increment addressing mode ..................80
Indexed, no offset addressing mode .........................................................67
Inherent addressing mode ..........................................................................57
Instruction execution ....................................................................................35
instruction boundaries ...........................................................................36
Instruction set
convention definition ..............................................................................90
nomenclature ..........................................................................................86
Index
MOTOROLA
Index
Interrupts
allocating scratch space ........................................................................53
arbitration .................................................................................................43
DMA (direct memory access module) .................................................41
flow and timing ........................................................................................44
H register storage ...................................................................................42
interrupt processing ...............................................................................51
interrupt recognition ...............................................................................45
masking.................................................................................................... 45
nesting of multiple interrupts ..........................................................51, 53
priority .......................................................................................................52
recognition ...............................................................................................41
return to calling program .......................................................................47
SIM (system integration module) .........................................................43
sources ....................................................................................................52
stack frame ..............................................................................................43
stacking ....................................................................................................42
STOP mode ............................................................................................53
vectors ......................................................................................................52
WAIT mode .............................................................................................53
M
Memory to memory direct to direct addressing mode ............................76
Memory to memory direct to indexed
with post increment addressing mode ..........................................78
Memory to memory immediate
to direct addressing mode ..............................................................75
Memory to memory indexed
to direct with post increment addressing mode ...........................77
Monitor mode ................................................................................................49
N
Negative flag (N) .......................................................................................... 31
O
Opcode map.......................................................................................... 90, 182
Overflow flag (V)........................................................................................... 30
Index
269
Index
P
Program counter (PC) ................................................................................. 29
R
Registers
accumulator (A) ...................................................................................... 26
condition code (CCR) ............................................................................ 26
index (HX)................................................................................................ 26
program counter (PC)............................................................................ 26
stack pointer (SP)................................................................................... 26
Relative addressing mode
conditional branch .................................................................................. 73
Resets
arbitration................................................................................................. 43
CPU .......................................................................................................... 49
DMA (direct memory access module .................................................. 41
exiting ....................................................................................................... 48
external .................................................................................................... 50
H register storage................................................................................... 42
I bit ............................................................................................................ 51
initial conditions ...................................................................................... 49
internal ..................................................................................................... 50
local enable mask bits ........................................................................... 51
masking.................................................................................................... 45
mode selection........................................................................................ 49
monitor mode .......................................................................................... 49
recognition ............................................................................................... 41
reseting processing................................................................................ 48
SIM (system integration module) ................................................... 43, 50
sources .................................................................................................... 50
stack frame.............................................................................................. 43
stackin ...................................................................................................... 42
user mode................................................................................................ 49
S
SIM (system integration module) ......................................................... 43, 50
Stack pointer (SP) ........................................................................................ 28
Stack pointer, 16-bit offset addressing mode ..........................................70
Index
MOTOROLA
Index
T
Timing
control unit ............................................................................................... 34
internal ..................................................................................................... 33
interrupt processing flow ....................................................................... 44
U
User mode ..................................................................................................... 49
V
V (overflow flag)............................................................................................ 30
W
WAIT mode ...................................................................................................53
Z
Zero flag (Z) ..................................................................................................31
Index
271
Index
Index
MOTOROLA
CPU08RM/AD