FUJITSU MICROELECTRONICSCONTROLLER MANUAL
F2MC-16FX16-BIT MICROCONTROLLER
PROGRAMMING MANUAL
CM44-00203-1E
FUJITSU MICROELECTRONICS LIMITED
F2MC-16FX16-BIT MICROCONTROLLER
PROGRAMMING MANUAL
i
CONTENTS
■ Objectives and Intended ReadershipThe F2MC-16FX series products are original 16-bit one-chip microcontrollers that support
application specific ICs (ASICs). They are suitable for use in various types of industrial
equipment, office-automation equipment, on-vehicle equipment, and other equipment that is
required to operate at high speed in real-time mode.
■ Trademark
Note: F2MC is the abbreviation of FUJITSU Flexible Microcontroller.
The company names and brand names herein are the trademarks or registered trademarks of
their respective owners.
■ Intended ReadershipThis manual is written for engineers involved in the development of products using the F2MC-
16FX series microcontrollers. It is designed specially for programmers working in assembly
language for use with F2MC-16FX series assemblers, and describes the various instructions
used with the F2MC-16FX series products. Be sure to read the entire manual carefully.
■ Configuration of this ManualThis manual contains the following 9 chapters and appendix.
CHAPTER 1 CPU
This chapter describes an overview of the F2MC-16FX CPU core and its sample
configuration.
CHAPTER 2 MEMORY SPACE
This chapter describes memory spaces in the F2MC-16FX CPU.
CHAPTER 3 DEDICATED REGISTER
This chapter describes the dedicated registers of the F2MC-16FX CPU.
CHAPTER 4 GENERAL-PURPOSE REGISTERS
This chapter describes the general-purpose registers of the F2MC-16FX CPU.
CHAPTER 5 PREFIX CODES
This chapter describes the prefix codes.
CHAPTER 6 INTERRUPTS
This chapter describes the interrupt functions and operations of the F2MC-16FX .
CHAPTER 7 ADDRESSING
This chapter describes the addressing mode for each instruction of the F2MC-16FX.
CHAPTER 8 INSTRUCTION OVERVIEW
This chapter describes the meanings of items and symbols used in explanations in
"CHAPTER 9 DETAILED INSTRUCTIONS".
ii
CHAPTER 9 DETAILED INSTRUCTIONS
This chapter describes each execution instruction used in the assembler in a reference
format.
APPENDIX
The appendix section includes lists and maps of instructions for the F2MC-16FX.
■ ReferencesThe following manuals should be referred along with this manual:
• F2MC-16FX/16L/16/16H/16F Assembler Manual
• F2MC-16FX Model-Specific Hardware Manual
iii
Copyright ©2008 FUJITSU MICROELECTRONICS LIMITED All rights reserved.
• The contents of this document are subject to change without notice. Customers are advised to consult with sales representatives before ordering.
• The information, such as descriptions of function and application circuit examples, in this document are presentedsolely for the purpose of reference to show examples of operations and uses of FUJITSU MICROELECTRONICSdevice; FUJITSU MICROELECTRONICS does not warrant proper operation of the device with respect to usebased on such information. When you develop equipment incorporating the device based on such information, youmust assume any responsibility arising out of such use of the information. FUJITSU MICROELECTRONICSassumes no liability for any damages whatsoever arising out of the use of the information.
• Any information in this document, including descriptions of function and schematic diagrams, shall not beconstrued as license of the use or exercise of any intellectual property right, such as patent right or copyright, orany other right of FUJITSU MICROELECTRONICS or any third party or does FUJITSU MICROELECTRONICSwarrant non-infringement of any third-party's intellectual property right or other right by using such information.FUJITSU MICROELECTRONICS assumes no liability for any infringement of the intellectual property rights orother rights of third parties which would result from the use of information contained herein.
• The products described in this document are designed, developed and manufactured as contemplated for generaluse, including without limitation, ordinary industrial use, general office use, personal use, and household use, butare not designed, developed and manufactured as contemplated (1) for use accompanying fatal risks or dangersthat, unless extremely high safety is secured, could have a serious effect to the public, and could lead directly todeath, personal injury, severe physical damage or other loss (i.e., nuclear reaction control in nuclear facility,aircraft flight control, air traffic control, mass transport control, medical life support system, missile launch controlin weapon system), or (2) for use requiring extremely high reliability (i.e., submersible repeater and artificialsatellite).Please note that FUJITSU MICROELECTRONICS will not be liable against you and/or any third party for anyclaims or damages arising in connection with above-mentioned uses of the products.
• Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or lossfrom such failures by incorporating safety design measures into your facility and equipment such as redundancy,fire protection, and prevention of over-current levels and other abnormal operating conditions.
• Exportation/release of any products described in this document may require necessary procedures in accordancewith the regulations of the Foreign Exchange and Foreign Trade Control Law of Japan and/or US export controllaws.
• The company names and brand names herein are the trademarks or registered trademarks of their respectiveowners.
iv
v
CONTENTS
CHAPTER 1 CPU .................................................................................................. 11.1 Overview of CPU ................................................................................................................. 21.2 Sample Configuration .......................................................................................................... 3
CHAPTER 2 MEMORY SPACE ............................................................................ 72.1 CPU Memory Space ............................................................................................................ 82.2 Linear Addressing Mode ...................................................................................................... 92.3 Bank Addressing Mode ..................................................................................................... 112.4 Memory Space Divided into Banks and Value in Each Bank Register .............................. 132.5 Data Configuration of and Access to Multi-byte Data in Memory ...................................... 14
CHAPTER 3 DEDICATED REGISTER ............................................................... 173.1 Dedicated Registers .......................................................................................................... 183.2 Accumulator (A) ................................................................................................................. 193.3 User Stack Pointer (USP) and System Stack Pointer (SSP) ............................................. 213.4 Processor Status (PS) ....................................................................................................... 233.5 Program Counter (PC) ....................................................................................................... 273.6 Direct Page Register (DPR) .............................................................................................. 283.7 Bank register (PCB, DTB, ADB, USB, SSB) ..................................................................... 29
CHAPTER 4 GENERAL-PURPOSE REGISTERS .............................................. 314.1 Register Banks in RAM ..................................................................................................... 324.2 Calling General-purpose Registers in RAM ....................................................................... 33
CHAPTER 5 PREFIX CODES ............................................................................. 355.1 Bank Select Prefix ............................................................................................................. 365.2 Common Register Bank Prefix (CMR) ............................................................................... 385.3 Flag Change Inhibit Prefix Code (NCC) ............................................................................ 395.4 Constraints Related to the Prefix Codes ........................................................................... 40
CHAPTER 6 INTERRUPTS ................................................................................. 436.1 Overview of Interrupts ....................................................................................................... 446.2 Interrupt Vector .................................................................................................................. 466.3 Interrupt Control Registers (ICR) ....................................................................................... 496.4 Non Maskable Interrupt (NMI) ........................................................................................... 516.5 Interrupt Flow (ICR) ........................................................................................................... 536.6 Hardware Interrupts ........................................................................................................... 556.7 Software Interrupts ............................................................................................................ 586.8 Multiple interrupts .............................................................................................................. 606.9 Exceptions ......................................................................................................................... 63
CHAPTER 7 ADDRESSING ................................................................................ 677.1 Effective Address Field ...................................................................................................... 687.2 Direct Addressing .............................................................................................................. 69
vi
7.3 Indirect Addressing ............................................................................................................ 71
CHAPTER 8 INSTRUCTION OVERVIEW ........................................................... 758.1 Instruction Overview .......................................................................................................... 768.2 Symbols (Abbreviations) Used in Detailed Instructions ..................................................... 778.3 Effective Address Field ...................................................................................................... 798.4 Execution Cycles ............................................................................................................... 80
CHAPTER 9 DETAILED INSTRUCTIONS .......................................................... 839.1 ADD (Add Byte Data of Destination and Source to Destination) ....................................... 849.2 ADDC (Add Byte Data of AL and AH with Carry to AL) ..................................................... 869.3 ADDC (Add Byte Data of Accumulator and Effective Address with Carry to Accumulator)
............................................................................................................................................ 879.4 ADDCW (Add Word Data of Accumulator and Effective Address with Carry to Accumulator)
............................................................................................................................................ 899.5 ADDDC (Add Decimal Data of AL and AH with Carry to AL) ............................................ 919.6 ADDL (Add Long Word Data of Destination and Source to Destination) ........................... 929.7 ADDSP (Add Word Data of Stack Pointer and Immediate Data to Stack Pointer) ............ 949.8 ADDW (Add Word Data of AL and AH to AL) .................................................................... 959.9 ADDW (Add Word Data of Destination and Source to Destination) .................................. 969.10 AND (And Byte Data of Destination and Source to Destination) ....................................... 989.11 AND (And Byte Data of Immediate Data and Condition Code Register) ......................... 1009.12 ANDL (And Long Word Data of Destination and Source to Destination) ......................... 1029.13 ANDW (And Word Data of AH and AL to AL) .................................................................. 1049.14 ANDW (And Word Data of Destination and Source to Destination) ................................ 1059.15 ASR (Arithmetic Shift Byte Data of Accumulator to Right) .............................................. 1079.16 ASRL (Arithmetic Shift Long Word Data of Accumulator to Right) .................................. 1099.17 ASRW (Arithmetic Shift Word Data of Accumulator to Right) .......................................... 1119.18 ASRW (Arithmetic Shift Word Data of Accumulator to Right) .......................................... 1139.19 BBcc (Branch if Bit Condition satisfied) ........................................................................... 1159.20 Bcc (Branch relative if Condition satisfied) ...................................................................... 1179.21 CALL (Call Subroutine) .................................................................................................... 1199.22 CALLP (Call Physical Address) ....................................................................................... 1219.23 CALLV (Call Vectored Subroutine) .................................................................................. 1239.24 CBNE (Compare Byte Data and Branch if not equal) ...................................................... 1259.25 CLRB (Clear Bit) .............................................................................................................. 1279.26 CMP (Compare Byte Data of Destination and Source) ................................................... 1289.27 CMPL (Compare Long Word Data of Destination and Source) ....................................... 1309.28 CMPW (Compare Word Data of Destination and Source) .............................................. 1329.29 CWBNE (Compare Word Data and Branch if not Equal) ................................................ 1349.30 DBNZ (Decrement Byte Data and Branch if not "0") ....................................................... 1369.31 DEC (Decrement Byte Data) ........................................................................................... 1389.32 DECL (Decrement Long Word Data) ............................................................................... 1399.33 DECW (Decrement Word Data) ...................................................................................... 1409.34 DIV (Divide Word Data by Byte Data) ............................................................................. 1429.35 DIVW (Divide Long Word Data by Word Data) ................................................................ 1449.36 DIVU (Divide unsigned Word Data by unsigned Byte Data) ............................................ 1469.37 DIVUW (Divide unsigned Long Word Data by unsigned Word Data) .............................. 1489.38 DWBNZ (Decrement Word Data and Branch if not Zero) ................................................ 150
vii
9.39 EXT (Sign Extend from Byte Data to Word Data) ............................................................ 1529.40 EXTW (Sign Extend from Word Data to Long Word Data) .............................................. 1539.41 FILS, FILSI (Fill String Byte) ............................................................................................ 1549.42 FILSW, FILSWI (Fill String Word) .................................................................................... 1569.43 INC (Increment Byte Data (Address Specification)) ........................................................ 1589.44 INCL (Increment Long Word Data) .................................................................................. 1599.45 INCW (Increment Word Data) ......................................................................................... 1609.46 INT (Software Interrupt) ................................................................................................... 1629.47 INT (Software Interrupt (Vector Specification)) ................................................................ 1649.48 INT9 (Software Interrupt) ................................................................................................. 1669.49 INTP (Software Interrupt) ................................................................................................ 1689.50 JCTX (Jump Context) ...................................................................................................... 1709.51 JMP (Jump Destination Address) .................................................................................... 1729.52 JMPP (Jump Destination Physical Address) ................................................................... 1739.53 LINK (Link and create new stack frame) ......................................................................... 1749.54 LSL (Logical Shift Byte Data of Accumulator to Left) ...................................................... 1759.55 LSLL (Logical Shift Long Word Data of Accumulator to Left) .......................................... 1769.56 LSLW (Logical Shift Word Data of Accumulator to Left) .................................................. 1779.57 LSLW (Logical Shift Word Data of Accumulator to Left) .................................................. 1789.58 LSR (Logical Shift Byte Data of Accumulator to Right) ................................................... 1799.59 LSRL (Logical Shift Long Word Data of Accumulator to Right) ....................................... 1819.60 LSRW (Logical Shift Word Data of Accumulator to Right) ............................................... 1839.61 LSRW (Logical Shift Word Data of Accumulator to Right) ............................................... 1849.62 MOV (Move Byte Data from Source to Accumulator) ...................................................... 1869.63 MOV (Move Byte Data from Accumulator to Destination) ............................................... 1889.64 MOV (Move Byte Immediate Data to Destination) ........................................................... 1899.65 MOV (Move Byte Data from Source to Destination) ........................................................ 1919.66 MOV (Move Byte Data from AH to Memory) ................................................................... 1939.67 MOVB (Move Bit Data from Bit Address to Accumulator) ............................................... 1949.68 MOVB (Move Bit Data from Accumulator to Bit Address) ............................................... 1969.69 MOVEA (Move Effective Address to Destination) ........................................................... 1989.70 MOVL (Move Long Word Data from Source to Accumulator) ......................................... 1999.71 MOVL (Move Long Word Data from Accumulator to Destination) ................................... 2009.72 MOVN (Move Immediate Nibble Data to Accumulator) ................................................... 2019.73 MOVS, MOVSI (Move String Byte with Increment) ......................................................... 2029.74 MOVSD (Move String Byte with Decrement) ................................................................... 2049.75 MOVSW, MOVSWI (Move String Word with Increment) ................................................. 2059.76 MOVSWI (Move String Word with Decrement) ............................................................... 2079.77 MOVW (Move Word Data from Source to Accumulator) ................................................. 2089.78 MOVW (Move Word Data from Accumulator to Destination) ........................................... 2109.79 MOVW (Move Immediate Word Data to Destination) ...................................................... 2129.80 MOVW (Move Word Data from Source to Destination) ................................................... 2149.81 MOVW (Move Immediate Word Data to io) ..................................................................... 2169.82 MOVW (Move Word Data from AH to Memory) .............................................................. 2179.83 MOVX (Move Byte Data with Sign Extension from Source to Accumulator) ................... 2189.84 MUL (Multiply Byte Data of Accumulator) ........................................................................ 2209.85 MUL (Multiply Byte Data of Accumulator and Effective Address) .................................... 2219.86 MULW (Multiply Word Data of Accumulator) ................................................................... 2229.87 MULW (Multiply Word Data of Accumulator and Effective Address) ............................... 223
viii
9.88 MULU (Multiply Unsigned Byte Data of Accumulator) ..................................................... 2249.89 MULU (Multiply Unsigned Byte Data of Accumulator and Effective Address) ................. 2259.90 MULUW (Multiply Unsigned Word Data of Accumulator) ................................................ 2269.91 MULUW (Multiply Unsigned Word Data of Accumulator and Effective Address) ............ 2279.92 NEG (Negate Byte Data of Destination) .......................................................................... 2289.93 NEGW (Negate Word Data of Destination) ..................................................................... 2299.94 NOP (No Operation) ........................................................................................................ 2309.95 NOT (Not Byte Data of Destination) ................................................................................ 2319.96 NOTW (Not Word Data of Destination) ........................................................................... 2339.97 NRML (NORMALIZE Long Word) ................................................................................... 2349.98 OR (Or Byte Data of Destination and Source to Destination) .......................................... 2359.99 OR (Or Byte Data of Immediate Data and Condition Code Register to Condition Code
Register) .......................................................................................................................... 2379.100 ORL (Or Long Word Data of Destination and Source to Destination) ............................. 2399.101 ORW (Or Word Data of AH and AL to AL) ...................................................................... 2419.102 ORW (Or Word Data of Destination and Source to Destination) ..................................... 2429.103 POPW (Pop Word Data of Accumulator from Stack Memory) ......................................... 2449.104 POPW (Pop Word Data of AH from Stack Memory) ....................................................... 2469.105 POPW (Pop Word Data of Program Status from Stack Memory) .................................... 2479.106 POPW (Pop Registers from Stack Memory) ................................................................... 2489.107 PUSHW (Push Word Data of Inherent Register to Stack Memory) ................................. 2509.108 PUSHW (Push Registers to Stack Memory) ................................................................... 2529.109 RET (Return from Subroutine) ......................................................................................... 2549.110 RETI (Return from Interrupt) ............................................................................................ 2559.111 RETP (Return from Physical Address) ............................................................................ 2579.112 ROLC (Rotate Byte Data of Accumulator with Carry to Left) ........................................... 2589.113 RORC (Rotate Byte Data of Accumulator with Carry to Right) ........................................ 2609.114 SBBS (Set Bit and Branch if Bit Set) ............................................................................... 2629.115 SCEQ, SCEQI (Scan String Byte until equal with Increment) ......................................... 2639.116 SCEQD (Scan String Byte until equal with Decrement) .................................................. 2659.117 SCWEQ, SCWEQI (Scan String Word until equal with Increment) ................................. 2679.118 SCWEQD (Scan String Word until equal with Decrement) ............................................. 2699.119 SETB (Set Bit) ................................................................................................................. 2719.120 SUB (Subtract Byte Data of Source from Destination to Destination) ............................. 2729.121 SUBC (Subtract Byte Data of AL from AH with Carry to AL) ........................................... 2749.122 SUBC (Subtract Byte Data of Effective Address from Accumulator with Carry to Accumulator)
.......................................................................................................................................... 2759.123 SUBCW (Subtract Word Data of Effective Address from Accumulator with Carry to
Accumulator) ................................................................................................................... 2779.124 SUBDC (Subtract Decimal Data of AL from AH with Carry to AL) ................................... 2799.125 SUBL (Subtract Long Word Data of Source from Destination to Destination) ................. 2809.126 SUBW (Subtract Word Data of Source from Destination to Destination) ........................ 2829.127 SUBW (Subtract Word Data of AL from AH to AL) .......................................................... 2849.128 SWAP (Swap Byte Data of Accumulator) ........................................................................ 2859.129 SWAPW (Swap Word Data of Accumulator) ................................................................... 2869.130 UNLINK (Unlink and Create New Stack Frame) .............................................................. 2879.131 WBTc (Wait until Bit Condition Satisfied) ........................................................................ 2889.132 XCH (Exchange Byte Data of Source to Destination) ..................................................... 2909.133 XCHW (Exchange Word Data of Source to Destination) ................................................. 2929.134 XOR (Exclusive Or Byte Data of Destination and Source to Destination) ....................... 294
ix
9.135 XORL (Exclusive Or Long Word Data of Destination and Source to Destination) ........... 2969.136 XORW (Exclusive Or Word Data of AH and AL to AL) .................................................... 2989.137 XORW (Exclusive Or Word Data of Destination and Source to Destination) .................. 2999.138 ZEXT (Zero Extend from Byte Data to Word Data) ......................................................... 3019.139 ZEXTW (Zero Extend from Word Data to Long Word Data) ........................................... 302
APPENDIX ............................................................................................................. 303APPENDIX A Explanation of Instruction Lists ............................................................................. 304
A.1 Items Used in Instruction Lists ........................................................................................ 305A.2 Symbols Used in Instruction Lists ................................................................................... 307A.3 Effective Address Field ................................................................................................... 309A.4 Calculating the Execution Cycle Count ........................................................................... 310
APPENDIX B Instruction Lists (351 Instructions) ........................................................................ 311APPENDIX C Instruction Maps .................................................................................................... 327
C.1 Structure of the Instruction Map ...................................................................................... 328C.2 Basic Page Map .............................................................................................................. 330C.3 Bit Operation Instruction Map .......................................................................................... 332C.4 Character String Operation Instruction Map .................................................................... 334C.5 2-byte Instruction Map ..................................................................................................... 336C.6 ea-type Instruction Map ................................................................................................... 338C.7 MOVEA RWi, ea Instruction Map .................................................................................... 348C.8 MOV Ri, ea Instruction Map ............................................................................................ 350C.9 MOVW RWi, ea Instruction Map ..................................................................................... 352C.10 MOV ea, Ri Instruction Map ............................................................................................ 354C.11 MOVW ea, RWi Instruction Map ..................................................................................... 356C.12 XCH Ri, ea Instruction Map ............................................................................................. 358C.13 XCHW RWi, ea Instruction Map ...................................................................................... 360
APPENDIX D Failure of String Instructions and WBTC/WBTS Instructions ................................ 362D.1 Problem Description ........................................................................................................ 362D.2 List of affected Devices ................................................................................................... 363D.3 Details of the Failure ....................................................................................................... 364D.4 Possible workaround ....................................................................................................... 366
APPENDIX E Wrong execution of scan string instruction SCEQ/SCWEQ at Interrupt ............... 367E.1 Overview ......................................................................................................................... 367E.2 List of affected Devices ................................................................................................... 368E.3 Detailed explanation ........................................................................................................ 369E.4 Possible workaround ....................................................................................................... 370
x
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 1
CHAPTER 1CPU
This chapter describes an overview of the
F2MC-16FX CPU core and its sample configuration.
1.1 Overview of CPU
1.2 Sample Configuration
2 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 1 CPU1.1 Overview of CPU
1.1 Overview of CPU
The F2MC-16FX CPU core is a 16-bit CPU designed for applications that require high-speed real-time processing, such as home-use or vehicle-mounted
electronic appliances. The F2MC-16FX instruction set is designed for controller applications, and is capable of high-speed, highly efficient control processing.
■ Overview of CPU
In addition to 16-bit data, the F2MC-16FX CPU core can process 32-bit data by using an
internal 32-bit accumulator. 32-bit data can be processed with some instructions. Up to 16
MBytes of memory space can be used, which can be accessed by either the linear pointer or
bank method. The instruction set is compatible to F2MC-16FX. The instruction set is
compatible with high-level languages, has a rich set of addressing modes, multiplication and
division instructions, and bit processing. The features of the F2MC-16FX CPU are explained
below.
● Fast execution speed
• Minimum instruction execution time: 16 ns (when operating at an internal frequency of 64MHz)
• Basic instructions are executed in one cycle
• High speed processing using a 5 stage pipeline
• 8 byte instruction queue
● General purpose registers: 32 banks x 8 words x 16 bits
● Memory space: 16 MBytes, accessed in linear or bank method
● Instruction set optimized for controller applications
• High code efficiency
• Rich data types: Bit, byte, word, long word
• Extended addressing modes: 23 types
• High-precision operation (32-bit length) based on 32-bit accumulator
• Signed and unsigned multiplication and division instructions
● Powerful interrupt functions
• Fast response speed (about 10 clock cycles CLKB)
• Eight priority levels (programmable)
• Non maskable interrupt (NMI)
• DMA transfer can serve interrupt requests (16 channels max.) without involving CPU
● Instruction set compatible with high-level language (C)/multitasking
• System stack pointer
• Instruction set symmetry
• Barrel shift instructions
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 3
CHAPTER 1 CPU1.2 Sample Configuration
1.2 Sample Configuration
A sample configuration of the F2MC-16FX CPU and that of the MCU device are shown.
■ Hardware configuration of the F2MC-16FX CPU
● Figure 1.2-1 shows the block diagram of the F2MC-16FX CPU.
Figure 1.2-1 Block diagram of F2MC-16FX CPU
● CPU Pipeline Operation
To execute most instructions in one clock cycle, the CPU uses a five-stage instruction pipeline.
The pipeline consists of the following stages:
• Instruction fetch (IF): Fetches the instruction from instruction queue.
• Instruction decode 1 (D1): Decodes the instruction and controls address operation.
• Instruction decode 2 (D2): Decodes the instruction and selects operands and data operation.
• Execution (EX): Executes the operation.
• Write back (WB): Writes the operation result to a register or memory location.
Direct Page Register
DPR
Bank Register
USB, SSB, DTB, ADB
Stack Pointer
USP, SSP
GeneralPurpose
Register
Ri, RWi, RLi
Program Counter
PCB, PC
Processor Status
PS
Accumulator
AH, AL
Instruction
Queue
ALU
Decode Address
Operation
Operation
Decode Data
Fetch stage
Decode stage 1
Decode Stage 2
F2MC-16FX CPU
Execution stage
Write Back stage
4 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 1 CPU1.2 Sample Configuration
Figure 1.2-2 Instruction Pipeline
Instructions are not executed out of order. Therefore, if instruction A enters the pipeline ahead
of instruction B, instruction A always reaches write back stage before instruction B.
The standard instruction execution speed is one instruction per cycle. However, transfer
instructions that involve memory wait, branch instructions and multi-cycle instructions require
more than one cycle to execute. The instruction execution speed also drops if the delivery of
instructions during code fetch is slow.
● Instruction Queue
The CPU has an instruction queue of 8 byte.
The instruction queue is filled by the fetch unit. Prefetch is used on consecutive addresses for
code fetch. The prefetch mechanism removes drawbacks due to the latency of the pipelined
implementation of the CPU and the system bus of the 16FX core.
● Program counter
The program counter bank (PCB, upper 8 bits of the program address) and the program counter
(PC, lower 16 bits of the program address) are controlled by the decode stage 1.
The instruction that is executed next is specified by a 24-bit address {PCB, PC} where the
program counter bank and the program counter are concatenated.
● ALU
The ALU is controlled by decode stage 2. The operation mode of the ALU is selected and the
operands are loaded. The execution of the operation is performed in the next cycle.
The ALU is used for logical and arithmetical operations. Multiplication and division are
included.
● CPU registers and memory access
In the write back stage the result of the operation is written to CPU registers and/or to a
memory location. All CPU registers except the program counter are assigned to the last
pipeline stage.
EX
D2
D1
IF
EX
D2
D1
IF
EX
D2
D1
WB
EX
D2
WB
EX WB
WB
WB
WB
Instruction 6
Instruction 5
Instruction 4
Instruction 3
Instruction 2
Instruction 1
CLK
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 5
CHAPTER 1 CPU1.2 Sample Configuration
■ Sample Hardware configuration of F2MC-16FX Family MCU
Figure 1.2-3 shows a sample hardware configuration of the MCU device based on the F2MC-
16FX CPU.
Figure 1.2-3 MCU Device based on the F2MC-16FX Core
● Interrupt Controller
The interrupt controller evaluates the priority of incoming interrupt requests (IRQ) and selects
the interrupt number with the highest priority. If accepted, the selected interrupt service is
processed by the CPU. Each hardware IRQ has its own interrupt level register to control its
priority.
● DMA Controller
The DMA controller can also serve IRQs, but without interrupting the actual program
execution of the CPU. This can be used to automate data transfer between peripherals and
memory.
Depending on the device, up to 16 DMA channels are usable. Each DMA channel can select an
IRQ number to be served.
RAM
(data area)
ROM
(program area)
Boot ROMF2MC-16FX
CPU
Interrupt
Controller
DMA
Controller
Clock and
Mode Control
External Bus
Interface
Peripheral
Bus Bridge
Peripheral
Bus Bridge
CAN
Timer Serial ADC
16
FX
Co
re B
us
F2MC-16FX Core
User Ports
Peripheral Bus 2
Peripheral Bus 1
MCU Device
6 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 1 CPU1.2 Sample Configuration
● Clock and Mode Control
This unit has control over the operation mode and monitors correct operation of the device. It
supplies all units with their appropriate clock, depending on the operation mode.
● External Bus Interface
The external bus interface is an optional component. Its availability depends on the
configuration of the specific device.
● Boot ROM
After device initialization by reset, the program counter points to the boot ROM. The CPU
starts the execution of the boot ROM program. After further device initialization the reset
vector is fetched and the boot ROM code branches to user program execution starting at the
reset vector.
● Peripheral Bus Bridge
The peripheral bus bridge acts as an interface between the system bus of the F2MC-16FX core
and the peripheral bus connecting to all other MCU internal peripheral resources.
The peripheral bus bridge synchronizes between core clock and peripheral clock domains.
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 7
CHAPTER 2MEMORY SPACE
This chapter describes memory spaces in the
F2MC-16FX CPU.
2.1 CPU Memory Space
2.2 Linear Addressing Mode
2.3 Bank Addressing Mode
2.4 Memory Space Divided into Banks and Value in Each Bank Register
2.5 Data Configuration of and Access to Multi-byte Data in Memory
8 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 2 MEMORY SPACE2.1 CPU Memory Space
2.1 CPU Memory Space
All data, programs, and I/O areas managed in the CPU are allocated in its 16-Mbyte memory space. The CPU can access these resources using an address on the 24-bit address bus (see Figure 2.1-1 ).
The F2MC-16FX addressing mode can be classified either as a linear or bank mode. The linear mode specifies an entire 24-bit address using a instruction. The bank mode specifies the upper 8 bits of each address using a bank register, and the remaining 16-bit address using an instruction.
■ CPU Memory Space
Figure 2.1-1 Example of Relationship between the F2MC-16FX System and Memory Map
F2MC-16FX
FFFFFFH
FF8000H
810000H
800000H
0000C0H
0000B0H
000020H
000000H
Program area
Data area
Interrupt controller
Peripheral circuit
CPU
Interrupt
Data
Program
[Device]General-purpose port
⎨⎧
⎩
⎨⎧
⎩
⎨⎧
⎩
⎨⎧
⎩
⎨⎪⎧
⎩⎪⎪
⎪
General-purpose
Peripheralcircuit
port
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 9
CHAPTER 2 MEMORY SPACE2.2 Linear Addressing Mode
2.2 Linear Addressing Mode
The linear addressing mode of the F2MC-16FX specifies an entire 24-bit address using an instruction.The linear addressing mode can operate in two different ways. In the first way, an operand of an instruction directly specifies an entire 24-bit address. In the second way, the lower 24-bit of a 32-bit general-purpose register is referred as an address.
■ Linear Addressing Mode
The linear addressing mode of the F2MC-16FX specifies an entire 24-bit address using an
instruction. The address mode of the F2MC-16FX is determined according to the specification
of the effective address or instruction code (implied) of an instruction.
The linear addressing mode can operate in two different ways. In the first way, an operand of
an instruction directly specifies an entire 24-bit address. In the second way, the lower 24-bit of
a 32-bit general-purpose register is referred as an address (see Figure 2.2-1 ).
10 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 2 MEMORY SPACE2.2 Linear Addressing Mode
Figure 2.2-1 Examples of Generating an Address in the Linear Addressing Mode
Previous content of452D
17452DHJMPP 123456H
123456H
17program counter plus
Next instructionLatest content of
345612program counter plus
program bank
program bank
Example 2: Indirect Addressing Based on 32-bit Register in the Linear Addressing Mode
MOV A @RL1+7
090700H
+7
RL1(Upper 8 bits are ignored.)
XXXX
003A
3A
240906F9
Previous content of the AL
Latest contentof the AL
Example 1: 24-bit Operand Specification in the Linear Addressing Mode
JMPP 123456H
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 11
CHAPTER 2 MEMORY SPACE2.3 Bank Addressing Mode
2.3 Bank Addressing Mode
The bank addressing mode of the F2MC-16FX specifies the upper 8 bits of an address using a bank register for use, and the remaining 16 bits using an instruction.
■ Bank Addressing ModeIn the bank addressing mode, the 16-Mbyte memory space is divided into 256 banks of 64-
Kbyte, and the corresponding bank to each space is specified by the following 4 bank registers.
● Program bank register (PCB)
A 64-Kbyte bank specified using the PCB register is called a program (PC) space. It is used to
hold mainly instruction codes, vector tables, and immediate data.
● Data bank register (DTB)
A 64-Kbyte bank specified using the DTB register is called a data (DT) space. It is used to
hold mainly readable/writable data and control/data registers for internal and external
resources.
● User stack bank register (USB) and system stack bank register (SSB)
A 64-Kbyte bank specified using the USB or SSB register is called a stack (SP) space. It is
accessed when the execution of a push or pop instruction or interrupt handling is performed
and which to be used, the USB or SSB register, is determined according to the S flag in the
condition code register to save register contents and a stack access occurs.
● Additional data bank register (ADB)
A 64-Kbyte bank specified using the ADB register is called an additional (AD) space. It is
used to hold mainly data overflowing from the DT space.
Each instruction is assigned with one of the default spaces by each addressing listed in Table
2.3-1 to improve instruction code efficiency.
Table 2.3-1 Default Spaces
Default space Addressing
Program space PC-indirect, program access, branch type
Data space @A, addr16, dir, or addressing using @RW0, @RW1, @RW4, or @RW5
Stack space Addressing using PUSHW, POPW, @RW3, @RW7, or @SP
Additional space Addressing using @RW2 or @RW6
12 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 2 MEMORY SPACE2.3 Bank Addressing Mode
If a space other than a default space is used, an arbitrary bank space corresponding to a prefix
code can be accessed by specifying the prefix code before the instruction.
Table 2.3-2 lists bank select prefixes and the memory space selected using each prefix.
The DTB, USB, SSB, and ADB registers are initialized to "00H" at a reset. The PCB register is
initialized to "FFH" at a reset. After a reset, the data, stack, and additional spaces are allocated
in bank 00H (000000H to 00FFFFH), and the program space is allocated in bank FFH (FF0000Hto FFFFFFH).
Table 2.3-2 Bank Selection Prefix
Bank select prefix Selected space
PCB Program space
DTB Data space
ADB Additional space
SPBSystem or user stack space depending on the contents of the selected stack flag
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 13
CHAPTER 2 MEMORY SPACE2.4 Memory Space Divided into Banks and Value in Each Bank
Register
2.4 Memory Space Divided into Banks and Value in Each Bank Register
Figure 2.4-1 shows an example of a memory space divided into banks and a value in each register bank.
■ Memory Space Divided into Banks and Values in Each Register Bank
Figure 2.4-1 Example of the Physical Addresses of Each Space
Phy
sica
l Add
ress
FFFFFFH
FF0000H
B3FFFFH
B30000H
92FFFFH
920000H
68FFFFH
680000H
4BFFFFH
4B0000H
000000H
Program space
Additional space
User stack space
Data space
System stack space
FFH : PCB (program bank register)
B3H : ADB (additional data bank register)
92H : USB (user stack bank register)
68H : DTB (data bank register)
4BH : SSB (system stack bank register)
14 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 2 MEMORY SPACE2.5 Data Configuration of and Access to Multi-byte Data in Memory
2.5 Data Configuration of and Access to Multi-byte Data in Memory
Multi-byte data is written to memory starting at the lowest address. If the multi-byte data is 32-bit long, the lower 16 bits are written to memory first and then upper 16 bits.
■ Multi-byte Data Layout in a Memory SpaceMulti-byte data is written to memory starting at the lowest address. If the multi-byte data is
32-bit length, the lower 16 bits are written to memory first and then upper 16 bits.
If a reset signal is input immediately after the low-order data is written to memory, the high-
order data may not be written. To keep the data in integrity, it is necessary to input a reset
signal after the high-order data is written.
Figure 2.5-1 shows the layout of multi-byte data in memory. The lower 8 bits are placed at
address n, the next lower 8 bits are placed at address n + 1, and the next lower 8 bits are placed
at address n + 2, and so on.
Figure 2.5-1 Multi-byte Data Layout in Memory
H
Address n
L
01010101
MSB LSB
11001100 11111111 00010100
01010101
11001100
11111111
00010100
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 15
CHAPTER 2 MEMORY SPACE2.5 Data Configuration of and Access to Multi-byte Data in
Memory■ Access to Multi-byte Data
When multi-byte data is accessed, it is assumed that all parts of the multi-byte data are within a
single bank. To put it another way, an instruction accessing multi-byte data assumes that an
address that follows address FFFFH is 0000H in the same bank as for FFFFH.
Figure 2.5-2 shows an execution example of an instruction accessing multi-byte data.
Figure 2.5-2 Execution Example of an Instruction (MOVPW A, 080FFFFH) Accessing Multi-byte Data
Higher address
80FFFFH
800000H
AL before execution
Lower address
?? ??
AL after execution 23H 01H
···
23H
01H
16 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 2 MEMORY SPACE2.5 Data Configuration of and Access to Multi-byte Data in Memory
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 17
CHAPTER 3DEDICATED REGISTER
The F2MC-16FX CPU registers are classified into two types: dedicated registers and general-purpose registers. This chapter describes the
dedicated registers of the F2MC-16FX CPU. The dedicated registers are dedicated internal hardware of the CPU, and they have specific use defined by the CPU architecture. These registers can be accessed without using an address. The register operations are defined by specific instructions.This chapter explains the CPU.
3.1 Dedicated Registers
3.2 Accumulator (A)
3.3 User Stack Pointer (USP) and System Stack Pointer (SSP)
3.4 Processor Status (PS)
3.5 Program Counter (PC)
3.6 Direct Page Register (DPR)
3.7 Bank register (PCB, DTB, ADB, USB, SSB)
18 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 3 DEDICATED REGISTER3.1 Dedicated Registers
3.1 Dedicated RegistersThe F2MC-16FX CPU has the following dedicated registers:
• Accumulator (A=AH:AL): Two 16-bit accumulators (can be used as a single 32-bitaccumulator)
• User stack pointer (USP): 16-bit user stack pointer
• System stack pointer (SSP): 16-bit system stack pointer
• Processor status (PS): 16-bit register indicating the system status
• Program counter (PC): 16-bit register holding the address of the next instruction to beexecuted
• Program bank register (PCB): 8-bit register indicating the program bank
• Data bank register (DTB): 8-bit register indicating the data bank
• User stack bank register (USB): 8-bit register indicating the user stack bank
• System stack bank register (SSB): 8-bit register indicating the system stack bank
• Additional bank register (ADB): 8-bit register indicating the additional data bank
• Direct page register (DPR): 8-bit register indicating the page for direct access
Figure 3.1-1 "Dedicated registers" is a diagram of the dedicated registers.
Figure 3.1-1 Dedicated registers
Accumulator
User stack pointer
System stack pointer
Processor status
Program counter
Direct page register
Program bank register
Data bank register
User stack bank register
System stack bank register
Additional data bank register
USP
SSP
PS
PC
DPR
PCB
DTB
USB
SSB
ADB
8 bit16 bit
32 bit
AH AL
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 19
CHAPTER 3 DEDICATED REGISTER3.2 Accumulator (A)
3.2 Accumulator (A)
The accumulator (A) register consists of two 16-bit arithmetic operation registers (AH and AL), and is used as a temporary storage for operation results and transfer data.
■ Accumulator (A)The A register consists of two 16-bit arithmetic operation registers (AH and AL). The A
register is used as a temporary storage for operation results and transfer data. During 32-bit
data processing, AH and AL are used together. Only AL is used for word processing in 16-bit
data processing mode or for byte processing in 8-bit data processing mode (see Figure 3.2-1
“32-bit data transfer” and Figure 3.2-2 “AL-AH transfer”). The data stored in the A register
can be operated upon with the data in memory or registers (Ri, Rwi, or RLi). In the same
manner as with the F2MC-16FX, when a word or shorter data item is transferred to AL, the
previous data item in AL is automatically sent to AH (data preservation function). The data
preservation function and operation between AL and AH help to improve processing
efficiency.
When a byte or shorter data item is transferred to AL, the data is sign-extended or zero-
extended and stored as a 16-bit data item in AL. The data in AL can be handled either as word
or byte.
When a byte-processing arithmetic operation instruction is executed on AL, the high-order
eight bits of AL before the operation are ignored. After the operation the heigh-order eight bits
become zero.
The A register is not initialized by a reset. The A register holds an undefined value
immediately after a reset.
Figure 3.2-1 Example of a 32-bit data transfer
+6
MSB
A61540H
A6153EH
RW1
8FH 74H
2BH 52H
15H 38H
LSB
A6HDTB
AH AL
Previous contentof the A register
Latest contentof the A register 8F74H 2B52H
XXXXH XXXXH
MOVL A, @RW1+6
20 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 3 DEDICATED REGISTER3.2 Accumulator (A)
Figure 3.2-2 Example of AL-AH transfer by means of data preservation
+6
MSB
A61540H
A6153EH
RW1
XXXXH 1234H 8FH 74H
2BH 52H
15H 38H
LSB
A6HDTB
1234H 2B52H
AH AL
Previous contentof the A register
Latest contentof the A register
MOVW A, @RW1+6
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 21
CHAPTER 3 DEDICATED REGISTER3.3 User Stack Pointer (USP) and System Stack Pointer (SSP)
3.3 User Stack Pointer (USP) and System Stack Pointer (SSP)
USP and SSP are 16-bit registers that indicate the memory addresses for saving and restoring data when a push/pop instruction or subroutine is executed.
■ User stack pointer (USP) and system stack pointer (SSP)USP and SSP are 16-bit registers that indicate the memory addresses for saving and restoring
data in the event of a push/pop instruction or subroutine execution. The USP and SSP registers
are used by stack instructions.
The USP register is enabled when the S flag in the processor status register is “0”, and the SSP
register is enabled when the S flag is “1” (see Figure 3.3-1“Stack manipulation instruction and
stack pointer”). Since the S flag is set when an interrupt is accepted, register values are always
saved in the memory area indicated by SSP during interrupt processing. SSP is used for stack
processing in an interrupt routine, while USP is used for stack processing outside an interrupt
routine. If the stack space is not divided, use only the SSP.
During stack processing, the high-order eight bits of an address are indicated by SSB (for SSP)
or USB (for USP).
USP and SSP are not initialized by a reset. Instead, the values are undefined.
Figure 3.3-1 Stack manipulation instruction and stack pointer
AL A624 H USB USP
SSPSSB0
C6 H
56H
F328 H
1234 H
C6F326 H XXXX
AL A624 H USB USP
SSPSSB0
C6 H
56H
F326 H
1234 H C6F326 H 24HA6 H
AL A624 H USB USP
SSPSSB
C6 H
56H
F328 H
1234 H
561232 H XXXX
1
AL A624 H USB USP
SSPSSB1
C6 H
56H
F328 H
1232 H
561232 H 24HA6 H
Example 1 PUSHW A when the S flag is "0"
Before execution
S flag
After executionUser stack is used because
Example 2 PUSHW A when the S flag is "1"
System stack is used becausethe S flag is "1".
the S flag is "0".
MSB LSB
22 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 3 DEDICATED REGISTER3.3 User Stack Pointer (USP) and System Stack Pointer (SSP)
Note:
Specify an even-numbered address in the stack pointer whenever possible. An odd valuewill cause drawback in stack performance.
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 23
CHAPTER 3 DEDICATED REGISTER3.4 Processor Status (PS)
3.4 Processor Status (PS)
The PS register consists of the bits controlling the CPU Operation and indicating the CPU status.
■ Processor status (PS)As shown in Figure 3.4-1“Processor status (PS) structure”, the high-order byte of the PS
register consists of a register bank pointer (RP) and an interrupt level mask register (ILM). The
RP indicates the start address of a register bank. The low-order byte of the PS register is a
condition code register (CCR), containing the flags to be set or reset depending on the results
of instruction execution or interrupt occurrences.
Figure 3.4-1 Processor status (PS) structure
■ Condition code register (CCR)Figure 3.4-2“Condition code register (CCR) configuration” is the diagram of the condition
code register configuration.
Figure 3.4-2 Condition code register (CCR) configuration
● P: Priviledged mode flag:
P = 1 indicates user mode, P = 0 indicates privileged mode.
The P flag is cleared by a reset. However, the P flag will be set during execution of the Boot
ROM code.
Only NMI, HW-INT9 (EDSU) and DSU interrupts will clear the P flag and disable all other
hardware interrupts. If the P flag is cleared, ILM defines system interrupt levels of the
privileged mode (P0 to P7). These interrupt levels have higher priority than any ILM setting in
user mode (U0 to U7).
The P flag can be set by dedicated instructions (OR CCR #imm, POPW PS) or by restoring the
processor status (RETI, JCTX @A). Restoring P=0 is not accepted, if P has been "1" before.
● I: Interrupt enable flag:
Interrupts other than software interrupts are enabled when the I flag is "1" and are masked
when the I flag is "0". The I flag is cleared by a reset.
ILM RPPS
15 1312 87 0bit
CCR
0 0 1 0 00 0 0 initial value after reset
0 11 X X X X X value after Boot ROM execution
07 6 5 4 3 2 1
P I S T N Z V C PS: CCR
bit
24 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 3 DEDICATED REGISTER3.4 Processor Status (PS)
● S: Stack flag:
When the S flag is "0", USP is enabled as the stack pointer.
When the S flag is "1", SSP is enabled as the stack pointer.
The S flag is set by an interrupt reception or a reset.
● T: Sticky bit flag:
A value of "1" is set in the T flag when there is at least one "1" in the data shifted out from the
carry after execution of a logical right/arithmetic right shift instruction, otherwise, "0" is set in
the T flag.
In addition, "0" is set in the T flag when the shift amount is zero.
● N: Negative flag:
The N flag is set when the MSB of the operation result is "1", and is otherwise cleared.
● Z: Zero flag:
The Z flag is set when the operation result is all zeroes, and is otherwise cleared.
● V: Overflow flag:
The V flag is set when an overflow of a signed value occurs as a result of operation execution
and is otherwise cleared.
● C: Carry flag:
The C flag is set when a carry-up or carry-down from the MSB or LSB occurs as a result of
operation execution, and is otherwise cleared.
■ Register bank pointer (RP)
The RP register indicates the relationship between the general-purpose registers of the F2MC-
16FX and the internal RAM addresses. Specifically, the RP register indicates the first memory
address of the currently used register bank in the following conversion expression: [00180H +
(RP) × 10H]. The RP register consists of five bits, and can take a value between 00H and 1FH.Register banks can be allocated at addresses from 000180H to 00037FH in memory.
Figure 3.4-3 Register bank pointer (RP)
The RP register is initialized to all zeroes by a reset. An instruction may transfer an eight-bit
immediate value to the RP register; however, only the low-order five bits of that data are used.
0 00 0 0
RP
initial value
B4 B3 B2 B1 B0
15 14 13 12 11 10 9 8bit
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 25
CHAPTER 3 DEDICATED REGISTER3.4 Processor Status (PS)
■ Interrupt level mask register (ILM)
The ILM register consists of three bits, indicating the CPU interrupt masking level. An
interrupt request is accepted only when the priority of the interrupt is higher than that indicated
by the ILM register and the P flag. Highest priority interrupt is level P0 and lowest priority is
level U7. Therefore, for an interrupt to be accepted, its level value must be smaller than the
current ILM value (see Figure 3.4-4 Interrupt level register (ILM)). In addition, the P flag has
to be considered. When an interrupt is accepted, the level value of that interrupt is set in the P
flag and ILM register. Thus, an interrupt of the same or lower priority cannot be accepted
subsequently.
Figure 3.4-4 Interrupt level register (ILM)
ILM is initialized to 100B by a reset. However, during execution of the Boot ROM program
ILM is set to 000B.
An instruction may transfer an eight-bit immediate value to the ILM register, but only the low-
order three bits of that data are used (MOV ILM #imm, POPW PS, RETI, JCTX @A). If P=1
(in user level), any ILM change is possible. If P=0 (priviledged level), an ILM change is only
accepted, if the new value defines a user level U0 to U7 (with P=1) or if the privileged level
(P0 to P7) is increased. The lower levels of the privileged mode P0 to P7 can not be reached by
execution of an instruction from a higher level. Writing "0" to the P flag and reducing the level
with P=0 is only possible by NMI, HW-INT9 or a DSU interrupt.
Note:
The P flag can be understood as bit extension of ILM. Then it defines the most significantbit of the the interrupt level mask {P, ILM}.
After initialization with reset the CPU is in level P4. This disables all interrupts, including
NMI, except for the DSU. After execution of the Boot ROM program the CPU is in level U0.
Peripheral interrupts are disabled.
All privileged mode levels P0 to P7 are locked against entering or decreasing the level by an
instruction. The levels P0 to P7 can only be increased. This protects the operation of HW-
INT9, NMI and DSU operation. Only DSU can interrupt the NMI or mask its acceptance
during a debug session.
The user levels U0 to U7 are backward compatible to F2MC-16FX interrupt levels 0 to 7. The
P flag is not writeable in a user level.
15 14 13 12 11 10 9 8
ILM2 ILM1 ILM0 PS: ILM
0 initial value after reset1 0
0 0 value after Boot ROM execution0
bit
26 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 3 DEDICATED REGISTER3.4 Processor Status (PS)
Table 3.4-1 Levels indicated by the P flag and interrupt level mask (ILM) register
Level P flag ILM value Acceptable interrupt level
P0 0 0 none Interrupts disabled
P1 0 1 Level < P1 Interrupts disabled
P2 0 2 Level < P2 Interrupts disabled
P3 0 3 Level < P3 DSU
P4 0 4 Level < P4 DSU
P5 0 5 Level < P5 NMI, DSU
P6 0 6 Level < P6 NMI, DSU
P7 0 7 Level < P7 HW-INT9, NMI, DSU
U0 1 0 Level < U0 User Interrupts disabled HW-INT9, NMI, DSU
U1 1 1 Level < U1 User level 0
U2 1 2 Level < U2 User level 0, 1
U3 1 3 Level < U3 User level 0 to 2
U4 1 4 Level < U4 User level 0 to 3
U5 1 5 Level < U5 User level 0 to 4
U6 1 6 Level < U6 User level 0 to 5
U7 1 7 Level < U7 User level 0 to 6
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 27
CHAPTER 3 DEDICATED REGISTER3.5 Program Counter (PC)
3.5 Program Counter (PC)
The PC register is a 16-bit counter that indicates the low-order 16 bits of the memory address of an instruction code to be executed by the CPU.
■ Program counter (PC)The PC register is a 16-bit counter that indicates the low-order 16 bits of the memory address
of an instruction code to be executed by the CPU. The high-order eight bits of the address are
indicated by the program bank register (PCB).
The PC register is updated by a branch instruction, subroutine call instruction, interrupt or
reset. Within a linear program segment, the PC is incremented by the number of bytes of the
last instruction.
The PC register can also be used as a base pointer for operand access.
Figure 3.5-1"Program counter" shows the program counter.
Figure 3.5-1 Program counter
The reset address is fixed to the Boot ROM program start address of 0F:FC00H. At reset, the
PC is initialized to FC00H and the PCB is initialized to 0FH.
In external vector mode a value specified by the reset vector on address FF:FFDCH is loaded
when leaving the Boot ROM code execution. In internal vector mode the PCB and the PC are
loaded with fixed values defined by the product.
PCB PCFE H ABCD H
FEABCD H
Next instruction to be executed
28 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 3 DEDICATED REGISTER3.6 Direct Page Register (DPR)
3.6 Direct Page Register (DPR)
The direct page register (DPR) specifies bits 8 to 15 (addr 8 to addr 15) of the operand address for direct addressing instructions.
■ Direct page register (DPR)DPR specifies bits 8 to 15 of the instruction operands in direct addressing mode as shown in
Figure 3.6-1"Generating a physical address in direct addressing mode".
Figure 3.6-1 Generating a physical address in direct addressing mode
DPR is eight bits long, and is initialized to 01H by a reset. DPR can be read or written to by an
instruction.
α α α α α α α α β β β β β β β β γ γ γ γ γ γ γ γ
α α α α α α α α β β β β β β β β γ γ γ γ γ γ γ γ
MSB
DTB register
24-bit physicaladdress
LSB
DPR register Direct address during instruction
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 29
CHAPTER 3 DEDICATED REGISTER3.7 Bank register (PCB, DTB, ADB, USB, SSB)
3.7 Bank register (PCB, DTB, ADB, USB, SSB)
Each bank register indicates a memory bank where a program space, data space, user stack space or additional data space is allocated.
■ Bank RegisterAll bank registers are one byte long. Each bank register (PCB, DTB, USP, SSP, ADB)
indicates the memory bank where the PC, DT, SP (user), SP (system), or AD space is
allocated.
Bank registers other than PCB can be read and written to. PCB can be read but cannot be
written to. The PCB register is updated upon the JMPP or CALLP instruction, branching to the
entire 16 MByte space, upon the RETP or RETI instruction or upon an interrupt.
For details of the operation of bank registers, see section "2.3 Bank Addressing Mode".
● Program counter bank register (PCB)
Initial value: 0FH after reset, and later a value from reset vector at user program start.
● Data bank register (DTB)
Initial value: 00H.
● User stack bank register (USB)
Initial value: 00H.
● System stack bank register (SSB)
Initial value: 00H.
● Additional data bank register (ADB)
Initial value: 00H.
30 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 3 DEDICATED REGISTER3.7 Bank register (PCB, DTB, ADB, USB, SSB)
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 31
CHAPTER 4GENERAL-PURPOSE
REGISTERS
The registers of the F2MC-16FX can be grouped into two major categories: dedicated registers in the CPU and general-purpose registers allocated in memory.
This chapter describes the F2MC-16FX general-purpose registers. These registers are allocated in a RAM in address space of the CPU. Similarly to the dedicated registers, the general-purpose registers can be accessed without specifying their address. However, the user can specify the purpose for which they are used in the same manner as for ordinary memory.
4.1 Register Banks in RAM
4.2 Calling General-purpose Registers in RAM
32 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 4 GENERAL-PURPOSE REGISTERS4.1 Register Banks in RAM
4.1 Register Banks in RAM
Each register bank consists of 8 words (16 bytes). They can be used as general-purpose registers (byte registers R0 to R7, word registers RW0 to RW7, and long word registers RL0 to RL3) for performing various types of operations and specifying pointers. RL0 to RL3 can be used also as a linear pointer to gain direct access to all spaces in memory.
■ Register Banks in RAMTable 4.1-1 lists the function of each register, and Figure 4.1-1 shows relationships between the
registers.
Figure 4.1-1 Relationship between Registers
Table 4.1-1 Functions of Each Register
Register name Function
R0 to R7Used to hold an operand in various types of instructions.Note: R0 is also used as a barrel shift counter and a counter of normarize instruction.
RW0 to RW7Used to hold a pointer.Used to hold an operand in various types of instructions.Note: RW0 is used also as a string instruction counter.
RL0 to RL3Used to hold a long pointer.Used to hold an operand in various types of instructions.
RW0RL0
RW1
RW2RL1
RW3
R0RW4
R1RL2
R2RW5
R3
R4RW6
R5RL3
R6RW7
R7
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 33
CHAPTER 4 GENERAL-PURPOSE REGISTERS4.2 Calling General-purpose Registers in RAM
4.2 Calling General-purpose Registers in RAM
For general-purpose registers of the F2MC-16FX, the register bank pointer (RP) is used to specify where in internal RAM between 000180H and 00037FH the
register bank currently in use is allocated.
■ Calling General-purpose Registers in RAM
The general-purpose registers of the F2MC-16FX are allocated in internal RAM between
000180H and 00037FH (in maximum configuration). The register bank pointer (RP) is used to
indicate where in internal RAM between 000180H and 00037FH the register bank currently in
use is allocated. Each bank contains the following 3 different registers. These registers are not
independent of one another. Instead, they have the relationships shown in Figure 4.2-1 .
• R0 to R7: 8-bit general-purpose registers
• RW0 to RW7:16-bit general-purpose registers
• RL0 to RL3: 32-bit general-purpose registers
Figure 4.2-1 General-purpose Registers
The relationships among the high- and low-order bytes in word registers (RW4 to RW7) and
byte registers (R0 to R7) are represented using the following expression:
RW (i + 4) = R (i × 2 + 1) × 256 + R (i × 2) [where i = 0 to 3]
The relationships among the high- and low-order bytes in long registers (RL0 to RL3) and
word registers (RW0 to RW7) are represented using the following expression:
RL (i) = RW (i × 2 + 1) × 65536 + RW (i × 2) [where i = 0 to 3]
For example, if the data in R1 and the data in R0 are arranged as high- and low-order bytes,
respectively, the resulting data equals the data (2 bytes) in RW4.
Start address of a Lower order
MSB LSB
RW4
RL0RW0RW1RW2
R1 R0R3 R2R5 R4R7 R6
16 bits
Higher order
RW5RW6RW7
⎨⎧
⎩
⎨⎧
⎩
⎨⎧
⎩
⎨⎧
⎩
RL1
RL2
RL3
general-purpose register
000180H + RP × 10H
RW3
34 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 4 GENERAL-PURPOSE REGISTERS4.2 Calling General-purpose Registers in RAM
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 35
CHAPTER 5PREFIX CODES
The operation of an instruction can be modified by prefixing it with prefix code. The following 3 types of prefix codes are available.• Bank select prefix• Common register bank prefix• Flag change inhibit prefix codeThis chapter describes these prefixes.
5.1 Bank Select Prefix
5.2 Common Register Bank Prefix (CMR)
5.3 Flag Change Inhibit Prefix Code (NCC)
5.4 Constraints Related to the Prefix Codes
36 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 5 PREFIX CODES5.1 Bank Select Prefix
5.1 Bank Select Prefix
Placing a bank select prefix before an instruction enables selecting the memory space accessed by the instruction regardless of what the current addressing mode is.
■ Bank Select PrefixThe memory space of data to be accessed is determined according to the addressing mode.
Placing a bank select prefix before an instruction enables to select the memory space accessed
by the instruction regardless of what the current addressing mode is. Table 5.1-1 lists the bank
select prefixes and the memory space selected according to each bank select prefix.
The effect of the prefix codes is different for the following instructions.
● Transfer instructions (I/O access)
MOV A,io MOV io, A MOVX A,io MOVW A,io
MOVW io,A MOV io,#imm8 MOVW io,#imm16
These instructions access the I/O space regardless of whether there is a prefix before them.
● Branch instruction
RETI
The system stack bank (SSB) is used regardless of whether there is a prefix before the branch
instruction.
● Bit manipulation instructions (I/O access)
MOVB A,io:bp MOVB io:bp,A SETB io:bp
CLRB io:bp BBC io:bp,rel BBS io:bp,rel
WBTC WBTS
The I/O space is accessed regardless of whether there is a prefix before those instructions.
● String manipulation instructions
MOVS MOVSW SCEQ SCWEQ FILS FILSW
A bank register specified in the operand is used regardless of whether there is a prefix before
these instructions.
Table 5.1-1 Bank Select Prefixes
Bank select prefix Memory space to be selected
PCB Program counter space
DTB Data space
ADB Additional space
SPB System or user stack space depending on the state of the stack flag
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 37
CHAPTER 5 PREFIX CODES5.1 Bank Select Prefix
● Other types of control instructions (stack manipulation)
PUSHW POPW
The system stack bank (SSB) or user stack bank (USB) is used depending on the state of the S
flag, regardless of whether there is a prefix before these instructions.
POPW PS
In the following cases, the prefix of an instruction affects not only that instruction but also an
instruction that follows it.
● Other types of control instructions (flag change)
AND CCR,#imm8 OR CCR,#imm8
The operations of these instructions are performed normally. The prefix of each of these
instructions affects not only the instructions but also an instruction that follows them.
● Another type of control instruction (interrupt control)
MOV ILM,#imm8
The operation of the instruction is performed normally. The prefix of the instruction affects
not only that instruction but also an instruction that follows it.
38 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 5 PREFIX CODES5.2 Common Register Bank Prefix (CMR)
5.2 Common Register Bank Prefix (CMR)
Placing a common register bank prefix (CMR) before an instruction accessing a register bank enables to change that the instruction is to access only the registers in a common bank (register bank selected when RP = 0) allocated between 000180H and 00018FH, regardless of what the current value of the
register bank pointer (RP) is.
■ Common Register Bank Prefix (CMR)To make data exchange among tasks easier, it is necessary to use a method that can access a
certain specified register bank relatively easily no matter what value the RP register holds. To
meet this requirement, the F2MC-16FX has a register bank that can be used by all tasks in
common. It is called a common bank. The common bank is allocated in memory between
address 000180H and 00018FH. It is selected when the RP register contains a value of "0".
Placing the common register bank prefix (CMR) before an instruction accessing a register bank
enables to change that the instruction is to access only the registers in a common bank (register
bank selected when RP = 0) allocated between 000180H and 00018FH, regardless of what the
current value of the register bank pointer (RP) is.
The effect of the prefix codes is different for the following instructions.
● String instructions
MOVS NOVSW SCEQ FILS FILSW
If an interrupt is requested during execution of a string manipulation instruction attached with a
prefix code, the prefix becomes ineffective for the string manipulation instruction after a return
is made from the interrupt handling routine, possibly resulting in a malfunction. Do not place
the CMR prefix before these string manipulation instructions.
● Other types of control instructions (flag change)
AND CCR,#imm8 OR CCR,#imm8 POPW PS
The operations of these instructions are performed normally. The prefix of each of these
instructions affects not only the instructions but also an instruction that follows them.
● MOV ILM,#imm8
The operation of the instruction is performed normally. The prefix of the instruction affects
not only that instruction but also an instruction that follows it.
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 39
CHAPTER 5 PREFIX CODES5.3 Flag Change Inhibit Prefix Code (NCC)
5.3 Flag Change Inhibit Prefix Code (NCC)
Placing the flag change inhibit prefix code (NCC) before an instruction inhibits flags from changing during execution of the instruction.
■ Flag Change Inhibit Prefix Code (NCC)The flag change inhibit prefix code (NCC) is used to suppress undesired changes to flags.
Placing the NCC prefix before an instruction inhibits flags from changing during execution of
the instruction.
The effect of the prefix codes is different for the following instructions.
● Branch instructions
INT #vct8 INT9 INT addr16
INTP addr24 RETI
These instructions change the flags in the condition code register (CCR) regardless of whether
there is a prefix before them.
● String instructions
MOVE MOVSW SCEQ SCWEQ FILS FISW
If an interrupt is requested during execution of a string manipulation instruction attached with a
prefix code, the prefix becomes ineffective for the string manipulation instruction after a return
is made from the interrupt handling routine, possibly resulting in a malfunction. Do not place
the NCC prefix before these string manipulation instructions.
● Another type of control instruction (task switching)
JCTX @A
This instruction changes the flags in the CCR register regardless of whether there is a prefix
before it.
● Other types of control instructions (flag change)
AND CCR,#imm8 OR CCR,#imm8 POPW PS
These instructions change the flags in the CCR register regardless of whether there is a prefix
before them. The prefix of each of these instructions affects not only the instructions but also
an instruction that follows them.
● Another type of control instruction (interrupt control)
MOV ILM,#imm8
The operation of the instruction is performed normally. The prefix of the instruction affects
not only that instruction but also an instruction that follows it.
40 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 5 PREFIX CODES5.4 Constraints Related to the Prefix Codes
5.4 Constraints Related to the Prefix Codes
If a prefix code is placed before an instruction where interrupt and hold requests are inhibited, the effect of the prefix code lasts until an instruction where neither an interrupt nor hold request is inhibited appears for the first time, as shown in Figure 5.4-2 .If a prefix is followed by conflicting prefix codes, the last one is valid.
■ Relationships between Instructions Rejecting Interrupt Requests and Prefix Codes
The following 10 instructions/prefix codes reject interrupt and hold requests.
• MOV ILM,#imm8 • AND CCR,#imm8
• OR CCR,#imm8 • POPW PS
• PCB • ADB
• NCC • DTB
• SPB • CMR
If an interrupt or hold request is issued during execution of any of the above instructions, the
request is accepted only after any instruction not listed above appears for the first time after
that instruction and is executed, as shown in Figure 5.4-1 .
Figure 5.4-1 Instructions Rejecting Interrupt and Hold Requests
If a prefix code is placed before an instruction rejecting interrupt and hold requests, its effect
lasts until an instruction other than instructions rejecting interrupt and hold requests appears for
the first time after the prefix code and is executed, as shown in Figure 5.4-2 .
Figure 5.4-2 Instructions Rejecting Interrupt and Hold Requests and Prefix Code
Instructions rejecting interrupt and hold requests
(a)
Interrupt request issued Interrupt accepted (a):Ordinary instruction
• • • • • • • • • • •
Instructions rejecting interrupt and hold requests
ADD A,01H• • • •MOV A,FFHCCR: XXX10XX
The NCC protects the
NCC MOV ILM,#imm8CCR: XXX10XX
CCR from changing.
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 41
CHAPTER 5 PREFIX CODES5.4 Constraints Related to the Prefix Codes
■ If Two or More Prefix Codes Appear in Succession
If a prefix is followed by conflicting prefix codes, the last one is valid (see Figure 5.4-3 ).
Figure 5.4-3 Consecutive Prefix Codes
The term "conflicting prefix codes" indicates PCB, ADB, DTB, and SPB in the above figure.
Prefix codes
ADB• • • • • • • • • DTB PCB ADD A,01H
The PCB prefix code is valid for this instruction.
42 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 5 PREFIX CODES5.4 Constraints Related to the Prefix Codes
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 43
CHAPTER 6INTERRUPTS
This chapter describes the interrupt functions and operations.
6.1 Overview of Interrupts
6.2 Interrupt Vector
6.3 Interrupt Control Registers (ICR)
6.4 Non Maskable Interrupt (NMI)
6.5 Interrupt Flow (ICR)
6.6 Hardware Interrupts
6.7 Software Interrupts
6.8 Multiple interrupts
6.9 Exceptions
44 FUJITSU MICROELECTRONICS LIMITED CM44-00203-1E
CHAPTER 6 INTERRUPTS6.1 Overview of Interrupts
6.1 Overview of Interrupts
The F2MC-16FX has interrupt functions that terminate the currently executed program and transfer control to another specified program when a specific event occurs. There are four types of interrupt functions:• Hardware interrupt: Interrupt processing due to an internal resource event• Software interrupt: Interrupt processing due to a software event (instruction)• Exception: Handling of an operation exception• DMA: Data transfer without CPU interaction due to an internal resource event.
■ Hardware interruptsA hardware interrupt is activated by an interrupt request from an internal resource. A hardware
interrupt request occurs when both the interrupt request flag and the interrupt enable flag in an
internal resource are set.
● Specifying an interrupt level
An interrupt level can be specified for the hardware interrupt. To specify an interrupt level, use
the level setting bits (IL0, IL1, and IL2) in the interrupt control register ICR.
For each hardware interrupt its own interrupt level (IL) can be specified. Access to a dedicated
IL can be done by setting the index IX. Both IX and IL are accessible through the interrupt
control register ICR.
● Masking a hardware interrupt request
A hardware interrupt request can be masked by using the I flag and the ILM bits (ILM0, ILM1,
and ILM2). The interrupt is executed only, when the I flag is set and the value of the interrupt
level IL is smaller than the interrupt level mask ILM. In addition the P flag has to be set for
hardware interrupt acceptance. P, I and ILM are parts of the processor status word PS of the
CPU.
When an unmasked interrupt request occurs, the CPU saves 12 bytes of data that consists of
registers PS, PC, PCB, DTB, ADB, DPR, and A in the memory area indicated by the system
stack bank and pointer registers (SSB and SSP).
■ Software interruptsInterrupts requested by executing the INT instruction are software interrupts. An interrupt
request by the INT instruction does not have an interrupt request or enable flag. An interrupt
request is issued always by executing the INT instruction.
No interrupt level is assigned to the INT instruction. Therefore, ILM is not updated when the
INT instruction is used. Instead, the I flag is cleared and the continuing interrupt requests are
suspended.
CM44-00203-1E FUJITSU MICROELECTRONICS LIMITED 45
CHAPTER 6 INTERRUPTS6.1 Overview of Interrupts
■ Exceptions
Following software exceptions can be processed:
• Undefined instruction
• INT9
• INTE (only available on the EVA device)
Following hardware exceptions can be processed: