NEC Electronics Inc. NEC November 1986 |LiPD70616 Programmer's Reference Manual Preliminary Information ©1 986 NEC Electronics Inc/Printed in U .S.A. No part of this document may be copied or reproduced in any form or by any means without the prior wntten consent of NEC Electronics Inc. The Information in this document is preliminary and subject to change without notice. U.PD70616 PROGRAMMER'S REFERENCE MANUAL Preface The ability to integrate hundreds of thousands of transistors on to a single silicon chip represents one of the most important technological advances. This capability has greatly impacted the design of microprocessors and allowed computer architects to design systems in silicon that even a few years ago where unimaginable. As such, the increase in performance of the next generation of 32-bit microprocessors eclipses that of the current generation 16- and 32-bit devices. Using these semiconductor and computer architecture advances, NEC has been developing the V-Series microprocessor family. A new microprocessor family, the V-Series has been designed from scratch for implementation using high performance, low power CMOS VLSI technology. The V-Series microprocessors are represented in both the high integration and high performance marketplaces. Beginning in 1984 with the introduction of the V20™/V30™ microprocessors and the subsequent introduction in 1985 of the V40™/V50™ microprocessors, NEC has been the world leader in the design and production of high integration CMOS 16-bit microprocessors. This manual describes the architecture of the first of a family of high performance 32-bit microprocessors, the uPD70616 (V60™). The U.PD70616 is a general purpose microprocessor with the features of high-end mainframe and super minicomputers. Featuring a sophisticated 32-bit architecture, the jiPD70616 integrates a variety of powerful instructions, data types, addressing modes, virtual memory and a four stage instruction pipeline. Aimed at a wide variety of applications, the U.PD70616 will find widespread use in sophisticated office, real-time and engineering systems. r V20m V30™, V40™, V50™ and V60™ are trademarks of NEC Corporation 1.0 PRELIMINARY INFORMATION HPD70616 PROGRAMMER'S REFERENCE MANUAL -0 PRELIMINARY INFORMATION 1 }iPD70616 PROGRAMMER'S REFERENCE MANUAL Table of Contents Section 1 Introduction 1-1 V-Series 1-1 U.PD70616 Architecture Overview 1-3 Basic Architecture 1-3 Virtual Memory Management 1-8 Data Types 1-12 Instruction Set 1-14 System Support Features 1-15 U.PD70616 Architecture Implementation 1-17 Processor Features 1-17 Pipeline Operation 1-18 Notational Conventions 1-20 Numerical Values 1-20 Data Organization 1-20 Memory Organization 1-21 Abbreviations and Special Terminology 1-22 Section 2 Data Types 2-1 Addressing 2-1 Byte Addressing t 2-1 Register Addressing 2-3 Bit Addressing 2-4 Data Types 2-5 Signed Integers 2-5 Unsigned Integers 2-6 Bit 2-6 Short Real 2-6 Long Real 2-7 Decimal 2-7 Characters 2-7 Bit Fields 2-8 Bit Strings 2-9 Stacks 2-9 •j i PRELIMINARY INFORMATION U.PD70616 PROGRAMMER'S REFERENCE MANUAL Section 3 Register Set 3-1 Program Register Set • 3-3 General Purpose Registers 3-3 Program Counter (PC) 3-3 Program Status Word (PSW) 3-3 Privileged Register Set 3-7 Stack Pointers 3-8 System Base Register (SBR) 3-8 Task Register (TR) 3-9 Task Control Word (TKCW) 3-9 System Control Word (SYCW) 3-11 Processor ID Register (PIR) 3-12 Area Table Registers 3-12 Area Table Base Registers (ATBR) 3-13 Area Table Length Registers (ATLR) 3-13 Address Trap Registers 3-14 Trap Mode Register (TRMOD) 3-14 Address Trap Registers (ADTR) 3-15 Address Trap Mask Registers (ADTMR) 3-15 Program Status Word 2 (PSW2) 3-15 Section 4 Address Spaces 4-1 Introduction : 4-1 Virtual Address Space 4-2 Sections 4-3 Areas 4-4 Pages 4-5 Address Space Notes 4-6 Section Notes 4-6 Area Notes 4-7 Protection 4 ~9 Execution Levels 4_ 9 Area Protections 4-9 Page Protections 4-9 Memory Address Space 4-10 I/O Address Space 4-10 I/O Space Access 4-10 Virtual Address Space Mapping 4-10 Multiple Virtual Address Spaces 4-11 Address Translation 4-13 Area Table Register Pair 4-14 -0 PRELIMINARY INFORMATION ii 1 UPD70616 PROGRAMMER'S REFERENCE MANUAL Area Tables 4-14 Area Table Entries (ATE) 4-14 Page Tables 4-15 Page Table Entries (PTE) 4-16 Sections Task Management 5-1 Context Switching 5-1 Instruction Set Support 5-3 Section 6 Instruction Formats and Addressing Modes 6-1 Instruction Formats 6-1 Format I 6-2 Format II 6-3 Format III 6-4 Format IV 6-5 Format V 6-6 Format VI 6-7 Format VII 6-8 Addressing Modes 6-11 Calculation of Bit Addresses 6-12 Addressing Mode Encoding 6-13 UPD70616 Addressing Modes 6-15 Register 6-16 Register Indirect 6-17 Register Indirect Indexed 6-18 Autoincrement 6-19 Autodecrement 6-20 Displacement 6-21 Displacement Indexed 6-22 PC Displacement 6-23 PC Displacement Indexed 6-24 Displacement Indirect 6-25 Displacement Indirect Indexed 6-26 PC Displacement Indirect 6-27 PC Displacement Indirect Indexed 6-28 Double Displacement 6-29 PC Double Displacement 6-30 Direct Address 6-31 Direct Address Indexed 6-32 Direct Address Deferred 6-33 Direct Address Deferred Indexed 6-34 1_0 iii PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL Immediate 6-35 Immediate Quick 6-36 Addressing Mode Restrictions 6-37 Section 7 U.PD70616 Instruction Set Section 8 Interrupts and Exceptions 8-1 System Base Table 8-1 Interrupt and Exception Processing 8-3 Interrupts 8-4 Exceptions 8-4 U.PD70616 Exception Processing 8-5 Serious System Faults 8-5 System Faults 8-5 Stack Invalid Exceptions 8-5 Memory Management Exceptions 8-6 Instruction Exceptions 8-7 Arithmetic Exceptions 8-8 Software Debug Exceptions 8-9 Change Execution Level Exceptions 8-11 Asynchronous Traps 8-11 Emulation Mode Exceptions 8-12 Software Traps 8-13 Interrupt/Exception Stack Formats 8-14 Exception Codes 8-19 Reset 8-20 Interrupt/Exception Nesting 8-21 Interrupt/Exception Stacks 8-27 Section9 Software Debug Support 9-1 Instruction Trace 9-2 Instruction Trace Control 9-2 Instruction Trace Operation 9-2 Instruction Trace Pending 9-2 UPDPSW.W Instruction 9-3 Instruction Trace Note 9-3 Breakpoint Traps 9-4 .0 PRELIMINARY INFORMATION iv 1 U.PD70616 PROGRAMMER'S REFERENCE MANUAL Address Traps 9_5 Address Trap Operation 9_5 Address Trap Registers 9_5 Address Trap Setup 9_6 Address Trap Generation 9_7 Virtual/Physical Mode Address Traps 9_7 Address Trap Stack Contents 9_7 Address Trap Notes 9_8 Section 10 V20/V30 Emulation Mode 10-1 Virtual and Physical Address Modes 10-1 Emulation Mode 10-1 Program Status Word (PSW2) 10-2 Program Counter (PC) 10-4 I/O Emulation Option 10-4 Register Allocation 10_4 Emulation Mode Instruction Set 10-6 Instruction Set Summary 10-6 Mode Transitions 10-8 Native Mode to Emulation Mode 10-8 Emulation Mode to Native Mode 10-9 Memory Address Space 10-9 Address Generation 10_g I/O Address Space 10-10 Emulation Mode Notes 10-10 Section 1 1 Functional Redundancy Monitor (FRM) 1-1 Fault Tolerant System Configuration 1-1 Functional Redundancy Monitor 1-2 Bus Freeze Interrupt 1-3 FRM Applications 1-4 Bibliography 1-6 Appendix Appendix A Instruction Set Summary A-1 Appendix B Instruction Formats B-1 Appendix C Addressing Mode Encodings C-1 1.0 PRELIMINARY INFORMATION HPD70616 PROGRAMMER'S REFERENCE MANUAL PRELIMINARY INFORMATION vi 1 -0 HPD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Section 1 Introduction The U.PD70616 (V60) is the first member of a family of high performance CMOS 32-bit microprocessors. This section introduces the major features and capabilities of the U.PD70616. V-Series The V-Series is a set of original, high performance CMOS microprocessors. The V-Series consists of two distinct families, a family of high integration 16-bit microprocessors and a family of high performance 32-bit microprocessors. The high integration family consists of the U.PD70108/116 (V20/V30) and the |iPD70208/216 (V40/V50) microprocessors. Using internal 16-bit data paths, these processors have been designed to improve system performance and reduced power consumption while maintaining software compatibility with the previous generation of 1 6-bit microprocessors. Figure 1-1. V-Series Microprocessors 1987 1.0 1-1 PRELIMINARY INFORMATION INTRODUCTION U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL The high performance family of 32-bit V-Series microprocessors extend the performance capabilities of the 1 6-bit V-Series microprocessors. Beginning with the U.PD70616 microprocessor, these VLSI devices have been designed from scratch to take advantage of the ability to integrate nearly 400,000 transistors on a single die. The four main objectives which drove the design of the U.PD70616 architecture were: • general purpose architecture • application hardware support • expandable • high performance These objectives were established in anticipation of the severe performance requirements that will be placed on 32-bit microprocessors by the next generation of applications. Currently, microprocessors can be found in a wide variety of applications. Because the range of applications is continuing to grow larger, it isbecoming increasing difficult for VLSI designers to predict what will be the requirements of the next generation of machines. This suggests that the design of a microprocessor must take into account flexibility, the ability to mold a microprocessor architecture into many different applications. Support for high level languages is another design objective given the fact that software is increasingly written using high level languages. Operating systems will also need assistance from the architecture as the complexity and sophistication of both application and system software increases. Virtual memory is a necessary requirement as program complexity grows. Without the protection facilities of a virtual memory system, the development, debug and verification of a large software system would become nearly impossible. For a variety of reasons, the next generation of applications will standardize on 32-bit architectures that can fit into each market segment. In office automation, it is the ability to manipulate text and numbers that sets one microprocessor over another. In the field of CAD/CAM, the ability to perform high speed numerical calculations dominates the other uses for the systems. In artificial intelligence applications, management of large virtual address spaces and pointers must be efficiently implemented. At the same time, new applications must be accommodated by the architecture. The conventional architectures which are unable to adapt to an ever changing design environment will be quickly left behind. Microprocessors which do not implement a general purpose architecture, orthogonality or application support are doomed to failure. The U.PD70616 microprocessor has been designed with these goals in mind. Unlike other 32-bit processors which are based on obsolete 8- or 16-bit architectures, the U.PD70616 has introduced a new architecture rather than extending an architecture that is unsuited for VLSI implementation. PRELIMINARY INFORMATION 1-2 1 -° U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION uPD70616 Architecture Overview Generally speaking, the architecture of a computer refers to the structure and resources available to the programmer and more specifically to the instruction set, register set and address spaces. Thus the U.PD70616 architecture refers to the U.PD70616 microprocessor facilities and resources as viewed by the programmer. When the U.PD70616 architecture is realized in silicon, it becomes an implementation of the architecture. Because of various economic and technical restrictions, the complete architecture may not be fully realized until some later date. Basic Architecture The basic U.PD70616 architecture is characterized by a general purpose register architecture based on thirty-two 32- bit general purpose registers. The large instruction set is designed to be orthogonal and make full utilization for the register resources. The large number of general purpose registers enables compilers to efficiently allocate registers to improve performance. The jiPD70616 has four execution levels to allow hardware to distinguish between programs with different levels of permissions. Level has complete control of the hardware and is said to be privileged. The other three execution levels are non-privileged and the capabilities of programs at these execution levels is restricted. Figure 1-2 shows the set of u,PD70616 registers, each being a full 32-bits in length. The register set is divided into two parts, the program register set and the privileged register set. Use of the program register set is unrestricted but system level permissions are required to access the privileged register set. • Program Register Set The program register set consists of the thirty-two general purpose registers, the PC (program counter) and PSW (program status word). The general purpose registers are each identified by a register ID ranging from to 31 and can be used as temporary storage, accumulators, stacks, base and index registers without restriction. General purpose registers can also be used with the floating point data type making the register set truly versatile. Of the general purpose registers, three are implicitly selected by instructions and have alternate names. R31 is the SP (stack pointer) and points to the TOS (top of stack) for the current task context. R30 is the FP (frame pointer) and points to the frame activation record of the current procedure context. R29 is called the AP (argument pointer) and points to the list of arguments for the current procedure. The PC is a 32-bit register that contains the address of the first byte of the current instruction. The PSW is a 32-bit register which is shared by both the program and privileged register sets. The lower halfword (16-bits) of the PSW contains the condition codes for integer and floating point operations. The upper halfword of the PSW contains system information such as execution level and controls for the software debug and maskable interrupts. The PSW is shown in Figure 1-3. • Privileged Register Set Privileged registers are accessible by programs executing at execution level and are used primarily by the operating system to manage the system. The privileged registers are broken down into four functional groups: - stack pointers - memory management registers - system management registers - software debug registers 10 1-3 PRELIMINARY INFORMATION INTRODUCTION tlPD70616 PROGRAMMER'S REFERENCE MANUAL Figure 1-2. (iPD70616 Register Set Program Register Set Privileged Register Set 31 31 R31 (SP:Stack Pointer) LOSP (Level Stack Pointer) R30 (FP:Frame Pointer) L1SP (Level 1 Stack Pointer) R29 (APArgument Pointer) L2SP (Level 2 Stack Pointer) R28 L3SP (Level 3 Stack Pointer) R27 ISP (Interrupt Stack Pointer) R26 R25 31 R24 SBR (System Base Register) R23 R22 31 R21 SYCW (System Control Word) R20 31 R19 TR (Task Register) R18 TKCW (Task Control Word) R17 R16 31 R15 PIR (Processor ID Register) R14 R13 R12 ATBRO (Area Table Base Register 0) R11 ATLRO (Area Table Length Register 0) R10 ATBR1 (Area Table Base Register 1) R9 ATLR1 (Area Table Length Register 1) RS ATBR2 (Area Table Base Register 2) R7 ATLR2 (Area Table Length Register 2) R6 ATBR3 (Area Table Base Register 3) R5 ATLR3 (Area Table Length Register 3) R4 R3 31 R2 TRMOD (Trap Mode Register) R1 ADTRO (Address Trap Register 0) RO ADTMRO (Address Trap Mask Register 0) AOTR1 (Address Trap Register 1) ADTMR1 (Address Trap Mask Register 1) PC (Program Counter) PSW (Program Status Word) PSW2 (Program Status Word 2) PRELIMINARY INFORMATION 1-4 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-3. PSW Format Status Field • • Control Field *\* Floating Point Field *|« Integer Field *\ 31 30 29 28 27 26 25 24 18 17 16 12 11 10 9 8 A A F F F F F S T E I T I EL I A T Z O U P C O S Z A A M S P P E E E I V D V D R Y V Zero Sign Overflow Carry Precision Underflow Overflow Zero Divide Invalid Operation • Trace Enable Address Trap Enable • Interrupt Enable Execution Level Instruction Pending Trace Pending Interrupt Stack Emulation Mode Asynchronous Task Trap Active Asynchronous System Trap Active Each of the execution levels has its own stack pointer with a separate interrupt stack pointer for a combined total of five stack pointers. The SP register is actually one of these registers depending on the current execution level. Each time the execution level changes or an interrupt occurs, the U.PD7061 6 will automatically save the current stack pointer and switch to the new stack pointer. The memory management registers are used to keep the base address and length information for the memory resident address translation.tables. The memory management register set consists of four pairs of area table base and length registers. The system management registers are used to control to operation of the system. The task register points to the task control block of the current task context while the task control word defines the operating environment for the task. The system-wide operating environment for virtual address spaces and asynchronous traps is contained in the system control word. The system base register holds the base address of the system interrupt.exception vectors. PSW2 is the PSW used by emulation mode programs. The five software debug registers are used for controlling address traps. One register is used as an enable for the traps and the other four consist of two pairs of address and address mask registers. Instruction Formats A U.PD70616 instruction can range in length from 1 to 22 bytes depending on the type instruction, the number of operands and the operand addressing modes. The U.PD70616 is a two address machine with the addressing mode assignment specified independently for each operand. Using independent operand addressing modes, a single ADD opcode can be used to implement register-register, memory- register and memory-memory operations. 1.0 1-5 PRELIMINARY INFORMATION INTRODUCTION U.PD70616 PROGRAMMER'S REFERENCE MANUAL Addressing Modes A large number of powerful addressing modes is another distinguishing characteristic of the U.PD70616 architecture. The U.PD70616 has 21 addressing modes for byte addressable data and 18 addressing modes for bit addressable data. In addition to the standard addressing modes, other enhancements have been made. Three different size displacements can be specified allowing an assembler to optimize the size of the displacement field. Indirect memory addressing supports the use of pointers and any of the general purpose registers can serve as a base or scaled index register. To promote the use of position independent PC relative addressing, the PC can also be specified as a base register. Table 1-1 and Figure 1-4 depict the various addressing modes available. Table 1-1. uPD70616 Addressing Modes Addressing Mode Syntax Register Rn Register Indirect [Rn] Register Indirect Indexed [Rn](Rx) Autoincrement [Rn+] Autodecrement [-Rn] Displacement disp [ Rn ] PC Displacement disp [ PC ] Displacement Indexed disp [ Rn ] ( Rx ) PC Displacement Indexed disp [ PC ] ( Rx ) Displacement Indirect [ disp [ Rn ] ] PC Displacement Indirect [disp[PC]] Displacement Indirect Indexed [ disp [ Rn ] ] ( Rx ) PC Displacement Indirect Indexed [disp[PC]](Rx) Double Displacement displ [ disp2 [ Rn ] ] PC Double Displacement displ [ disp2 [ PC ] ] Direct Address /addr Direct Address Indexed /addr ( Rx Direct Address Deferred [ /addr Direct Address Deferred Indexed [ /addr ] ( Rx ) Immediate #value Immediate Quick #value(1-15) PRELIMINARY INFORMATION 1-6 1.0 ^PD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-4. Addressing Mode Operations Addressing Mode Operand Addressing Addressing Mode Operand Addressing Instruction Rn Insfrucian l^ ™* #value Rn I ||| #value (0-15) II ^^A J I 1 Inskuctian Rn Memory Instruction [Rn] +- :=<». (RnKRx) UfeJ^I—J-s ^ [Rn+l Instruction r Rn of-* 1 Memory [-Rn] 1 Instruction 't1 —'n H' ' i Rn 1/N |0 Memory Instruction Rn Memory mskuctlon PC Memory disp[ Rn ] I lfJJj*T =3-2 disp[ PC ] U^Jj^L-3-* disp disp v.. Instruction Rn Memory Insfruction PC Memory disp[ Rn ]( Rx r ItJJj-h =*2 disp disp[ PC ]( Rx L^Uj*i_ cNtp Rxxsize > Rxxstze Instruction Rn Memory Memory Insfrucbcn PC Memory Memory disp[ Rn ] ] If fdisp[PC]] 1 lfl IfH 3~* [ disp e- [J' disp e- r Instruction Rn Memory Memory Insfruction PC Memory Memory [ disp{ Rn ] ]( Rx i itLLrr =3^ disp r \ Rxxstee (disp[PC]](Rx) 1 lfl I IrH J 3-* disp e- r \Rx xsize o- Instruction Rn Memory Memory lns»uction PC Memory Memory <4_* disp1[disp2[Rn]] ' /- Ndisp2 displ [disp2[ PC]] 1 \\\ \f\ displ c- r displ e- r disp2 Insfruction Memory Instruction Memory •> lfl 1 , UjLJj- 1 1 /addr /addr( Rx 'I \ Rx xsize Memory Memory Instruction Memory — Memory Insfructon lfl ¥ — •> U|Ut- 1 1 / [ /addr ] & [/addr](Rx) ' 'I' ' J Rx xsize 1.0 1-7 PRELIMINARY INFORMATION INTRODUCTION UPD70616 PROGRAMMER'S REFERENCE MANUAL Virtual Memory Management The |iPD7061 6 incorporates an on-chip MMU (memory management unit) which maps each 4GB virtual address space into a 16MB physical address space. The MMU permits each task to have an independent virtual address space or to share a subset with one or more other tasks. Protection, preventing tasks with insufficient privilege from accessing code or data, is also enforced by the MMU. The linear 4GB virtual address space is divided into 4KB pages for the purpose of demand paging. Demand paging permits portions of the virtual address to be swapped out to low cost secondary storage. This allows programs to be written without regard to the amount of physical memory because the operating system and MMU provides an illusion of a full 4GB physical memory. • Address Space Structure The size of a virtual address space can range as high as 4GB. An operating system is capable of managing multiple virtual address spaces where each space is independent or shared as shown in Figure 1-6. Address space sharing can be implemented at different levels depending on the individual requirements. Each virtual address space is split into four 1GB sections. A section is the first unit of shared virtual address space. For example, sections 10 and 1 1 can be common to all tasks and contain the system utility and operating system programs while section 00 and 01 are unique to each task. Each section is further divided into 1024 areas. An area is a 1MB region and can be shared between two tasks and used for inter-task communication. An area is broken down into 256 pages, each 4KB in size. The page is the basic unit of memory management and the virtual memory facility is implemented by swapping pages. Figure 1-5. uPD70616 Address Space Virtual Address Space (4GB) Section Area Page (1GB) (1MB) (4KB) Offset 4095 11 Page 255 Area 1023 Offset 4094 section Area 1022 Page 254 • • • • • • • 10 • • section Areai Pagej Offset n 1 byte ,,, • • \ «.. t • • • ( 01 • • • section • Area 1 Page 1 Offset 1 AreaO PageO Offset 00 section 1-8 1.0 PRELIMINARY INFORMATION fiPD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-6. Multiple Virtual Address Spaces 4GB Operating System 3GB Shared Application Routines 2GB Application 1GB tasks Task 4 Taskl TaskO Protection Mechanisms Protection mechanisms are implemented at the both the area and page levels. Area level protections compare the current execution level with the execution level required for the particular access. Page level protections are used to mark the page as readable, writable or executable. An access is permitted only when both protection criteria have been satisfied, otherwise a memory management exception will occur. 1.0 1-9 PRELIMINARY INFORMATION INTRODUCTION U.PD70616 PROGRAMMER'S REFERENCE MANUAL Address Translation When virtual mode is enabled, virtual addresses must be translated into physical addresses before the access is performed. Address translation involves an area table register pair, an area table and a page table.Refer to Figure 1-7 for an example of address translation. Figure 1-7. Address Translation 20 10 12 —————— i ; i i i i -i — — — — — — —r— — — — — i • i i i i i i j i i i i —r— i Virtual Address Page Frame Area Table Register Area Table Page Table ^ » ATBR/ATLR -4 ATE +0 PTE *& The 32-bit virtual address is split into fields for the purpose of address translation. First, the upper two bits are used to identify the section by selecting one of the four area table registers pairs. The area tabel register pair contains a the base address and length of the memory resident area table to be used in the next step of the translation. Using the base address from the previous step, bits 20:29 of the virtual address are used as the offset into the area table to select the ATE (area table entry). The selected ATE contains the base address of the page table to be used in the second level of translation and the permissions required to access this area. If the access permissions are not met, the translation is aborted and an exception will occur. Next, bits 12:19 of the virtual address are used as an offset in the page table to select a PTE (page table entry). The PTE contains the physical base address of the page, whether it is physical present and the page level access permissions. If the page level protections are met, the access can occur and low order 12 bits of the virtual address are concatenated with the page base address obtained from the PTE to form the physical memory address. Address translation and the associated table lookups are an inherently slow process and a hardware assist is required. Accesses to programs and data are generally sequential and localized. The U.PD70616 can take advantage of this and cache the last 16 address translations on-chip in a high speed TLB (translation look-aside buffer). If the section, area and page ID fields match an entry in the TLB and the permissions are satisfied, the address translation will occur immediately and without any performance penalty. 1-10 1.0 PRELIMINARY INFORMATION liPD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-8. Virtual -> Physical Address Translation 31 30 29 t —i— — — — — 20 n— — —i—i— — i i i i 19 i i i 12 11 i i —r— —i— — i i i i i i— O Q 1 Page Offset. — Page ID rpTn 7^ — Area ID ATE] Page Table 4 KB Page Frame Area Table Base Register Area Table Base Register 1 — Section ID Area Table Base Register 2 © Area Table Area Table Base Register 3 Virtual Address Attrbutes Physical Address ' Matchll! -Real Page Number Translation Lookaside Buffer Processor Resident Memory Resident 86-203 1.0 1-11 PRELIMINARY INFORMATION INTRODUCTION U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL Data Types The jjPD7061 6 supports a wide range of data types and instructions to operate on each data type. These data types include not only the widely used integer and character string data types but also bit, bit field and bit string data types. The U.PD70616 also supports IEEE standard floating point arithmetic as part of the basic instruction set. • Signed Integer Signed integers are represented in two's complement format in byte (8-b'rt), halfword (16-bit), word (32-bit) and doubleword (64-bit) sizes. A wide range of data transfer and arithmetic operations on signed integers are supported. • Unsigned Integer Unsigned integers are available in byte (8-bit), halfword (16-bit), word (32-b'rt) and doubleword (64-bit) sizes.A wide range of data transfer, arithmetic and logical operations on unsigned integers are supported. • Floating Point The U.PD70616 floating point data types and operations conform to the IEEE 754 standard. Floating point data can be represented in either the short real (32-bit) or long real (64-bit) formats. Like integers, floating point data can reside in any of the general purpose registers. Instruction set support for floating point data types includes data transfer, arithmetic and conversion operations. • Pointer In the U.PD70616 a pointer is represented as an unsigned 32-bit integer. Instruction set support for the pointer data type allows calculation of the effective address of operands for parameter passing. • Decimal The decimal data type is used for calculations in BCD format. Addition, subtraction and conversion instructions are available for the decimal data type. • Bit The bit data type refers to a single bit within a word. Bits are typically used as Boolean variables and can be set, cleared, complemented and tested. • Bit Field Bit fields are variable length data structures that are a subset of the integer data types. Bit fields range from to 32 bits in length and are used to pack signed and unsigned integers. Instructions are available to insert, extract and compare bit fields. • Bit String to 4 gigabits in length. Bit strings begin Bit strings are variable length logical data structures ranging from and end on any arbitrary bit boundary. Any logical operation can be performed on bit strings as well as searching bit strings for a or 1 bit. • Character String Character strings are used to efficiently manipulate text using either byte or halfword characters. Operations on character data include data transfer, comparison and searching. PRELIMINARY INFORMATION 1-12 1.0 I1PD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-9. Data Type Formats Bit - bit number - 1 1 1 1 1 1 Byte MSB LSB 15 Halfword MSB LSB 31 l l l l l l l | l l l l l l l | l l l l l l l | t l l l i i l Word MSB LSB 63 i i i i i i i i r i i i i i | i i i i i i i | i i i i i i | i i i i i i i | i i i 1 1 i i | i i i i i t i | i i i t i i | Doubleword MSB LSB 31 22 I I I I I I i i i i i i i i i i 1 1 i i | I | Short Real exp mantissa 63 i i i i i i i i i i i i i i i i i | i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i | | | | | | Long Real exp mantissa 7 Packed DH DL 15 1 l 1 1 1 1 Unpacked DL DH c A+n-1 A+n-2 , . A+1 A r /' ! I i i i i l l I l l l l Byte A+2n-2 A+2n-3 A+1 i i i i i i i | i i i i i i i TT>f- l I l I l | i I I I I I I Halfword •B' 'A' e u r i i \ ff i i | i i i i i i i | i i i i i i i Bit Field V/////A length —H*- offset - rf f T^^y////A— i i \ i r i i i i i i i i i i i | \ Bit String -tt- length - -•+«- • offset - M 1.0 1-13 PRELIMINARY INFORMATION INTRODUCTION uPD7061 6 PROGRAMMER'S REFERENCE MANUAL Instruction Set Besides the comprehensive instruction set for each of the data types, the U.PD7061 6 instruction set contains support for high level languages, context switching and other applications. Instructions which manipulate system hardware or data structures are privileged and require the processor to be at execution level 0. • Control Transfer Control transfer instruction set support includes conditional and unconditional branches, looping and subroutine call/return instructions. • Procedure Calling Procedure calling is an important requirement for the efficient execution of high level languages. The U.PD70616 supports procedure calls and returns as well as instructions for the management of the local stack frames. Figure 1-10 is an example of a typical procedure call and return. • Context Switching Rapid switching of task contexts is a requirement of any multi-tasking operating system. The U.PD70616 instruction set supports this requirement by loading and storing task contexts with a single instruction. • Virtual Memory Management Virtual memory requires the maintenance of translation tables and the TLB (translation look-aside buffers). A number of instructions are dedicated to read and update table entries, translate a virtual address to a physical address and control the operation of the memory management unit. • Input/Output Input/output instructions are used to communicate with external peripheral devices in the I/O address space. Peripherals can be accessed either using the standard I/O instructions or via the virtual I/O facility by any instruction that references memory. • Multiprocessing In order tosupport the efficient implementation of multiprocessor systems, the instruction set primitives for test and set and compare and exchange operations are provided. 1-14 1 ° PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-10. Procedure Call/Return FP ; parameters Return AP AP 2 PC Z : - Pop General Purpose Registers Multiple FP FP o Dispose Local Variables - SP - Temporary Storage Area - System Support Features System support features are those facilities that assist in the development of both system and application software. The U.PD7061 6 provides a number of aids for the implementation of operating systems and the debug of programs. • Asynchronous Traps Asynchronous traps are designed to simplify the implementation of multi-tasking operating systems. Many operating system services are interrupt driven and a dilemma is presented by how to inform the operating system of asynchronous events in a well defined and consistent manner. Asynchronous traps provide this consistent interface between operating system routines. This communication between operating system routines is called an AST (Asynchronous System Trap). The ATT (Asynchronous Task Trap) is a similar facility used by the operating system to inform a task of an event. 1.0 1-15 PRELIMINARY INFORMATION INTRODUCTION UPD70616 PROGRAMMER'S REFERENCE MANUAL Software Debug Support As the size and complexity of application and system software grows, so to does the task of debugging the program. The U.PD70616 architecture provides three powerful software debug aids designed to minimize the amount of time spent debugging programs. Instruction trace and instruction breakpoints are standard tools used in software debug. In addition, a powerful tool called address traps is also available. Address traps combine a region of addresses with the type access (read/write/execute). Each memory access is checked and a trap will occur whenever the trap criteria is met. The capabilities are further enhanced by providing two independent sets of address trap registers for use in software debug. Figure 1-11. Address Traps Memory Memory Program Address Trap Reference Handier ?mm [7] Active address trap range PRELIMINARY INFORMATION 1-16 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION uPD7061 6 Architecture Implementation The uPD70616 is the first realization of the V-Series 32-bit architecture in a high performance CMOS VLSI process. Processor Features In addition to the implementation of the 32-bit V-Series architecture, the U.PD70616 includes the following additional features: • Emulation Mode Emulation mode allows software developed for the U.PD70108/116 (V20/V30) microprocessors to be executed. Emulation mode is directly compatible with object code and no re-assembly or re-compliation is required. During emulation mode, all of the software debug, memory management and protection mechanisms are fully functional, thus multiple emulation mode programs can co-exist in the same virtual address space without interference. • Functional Redundancy Monitor (FRM) A functional redundancy monitor is a technique used to increase the reliability of a system by allowing a redundant processor to check the operation of the master processor. Using FRM techniques, the design of fault tolerant computing systems is simplified. Figure 1-12. Functional Redundancy Monitor F auH Outp ut (MSMAT) Data Bus Address Bus System Halt (BFREZ) 1.0 1-17 PRELIMINARY INFORMATION INTRODUCTION U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL Pipeline Operation The concurrent processing of multiple instructions is made possible by using independent functional units with interlocks. Extensive instruction pipelining is used in the U.PD70616 to keep each functional unit busy and maximize the instruction throughput. Each instruction utilizes the following functional blocks during the course of execution: • PFU (Pre-fetch Unit) The pre-fetch unit is designed to load the 16 byte instruction queue from external memory during idle bus periods. Since instruction execution is generally a sequential process, the latency to fetch an instruction from memory can be reduced to zero if the instruction is found in the pre-fetch queue. • IDU (Instruction Decode Unit) Pre-fetched instructions are fed to the instruction decode unit to be decoded. Each instruction is examined for operands and the addressing mode information is stripped out and sent to the effective address generator to calculate the addresses for processing. The decoded instruction is then queued up for processing by the execution unit. • EAG (Effective Address Generator) The effective address generator uses a high speed multi-way adder to quickly compute the virtual address of an operand and sends to the memory management unit for translation. it • MMU (Memory Management Unit) In the virtual mode, addresses must be converted to a physical address. Using a 16 entry TLB (translation look-aside buffer) and pipelining the address translation, the effective address translation time is zero. Meanwhile, in parallel with the address translation, the access permission is verified. The output of the MMU is a physical address for the bus control unit. • BCU (Bus Control Unit) The bus control unit acts the interface for each internal bus requester. Additional logic allows the BCU to re-run faulty bus cycles in the event of an memory ECC error and to use a short cycle bus mode for accessing fast cache memories. The functional redundancy monitor is also implemented in the BCU. • EXU (Execution Unit) The actual execution of an instruction occurs in the execution unit. Instruction execution begins when the instruction has been decoded and all operands have been fetched. The EXU is composed of a 32-bit microprogrammable ALU with the thirty-two general purpose registers, and a high speed barrel shifter. 1-18 1-0 PRELIMINARY INFORMATION |iPD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-13. ^PD70616 Functional Blocks and Pipeline PFU BCU Prefetch Data Queue c rO Bus Interface IDU EAG MMU \7 Iz Decoder ^> ^> H Queue Effective Address Generator Translation Lookaside Buffer c> Address Bus Interface 7\ \7 sz jiSEQ 5 General Barrel UROM Purpose ALU Shifter Registers EXU l_ 1-19 PRELIMINARY INFORMATION 1.0 INTRODUCTION U.PD70616 PROGRAMMER'S REFERENCE MANUAL Notational Conventions The terminology and abbreviations used in this document are defined for the reader's convenience in this section. Numerical Values Numerical values are normally expressed as decimal numbers, but it is sometimes clearer to use other notations. The suffixes 'b' and 'H' will sometimes be used to indicate numbers written in binary (base 2) and in hexidecimal (base 16). This provides three ways of writing numbers. For example, the (decimal) number 118 can be represented as 01110110b or 76H. The prefixes "kilo", "mega" and "giga" are also widely employed. They correspond to the following values: Table 1-2. Numeric Prefix Values Symbol Prefix Value 10 K kilo 1,024 -2 20 M mega 1 ,048,576 -2 30 G giga 1,073,741,824 - 2 wist Data Organization The fundamental unit for the addressing of data in memory is the byte. Data that spans multiple bytes are addressed by the address of the least significant byte. • Byte Representation A byte consists of eight bits which are numbered from right to left starting with 0. When a byte contains an integer, the MSB (most significant bit) is bit 7 and the LSB (least significant bit) is bit 0. Figure 1-14. Bit Position within a Byte 7 6 5 4 3 2 1 1 1 1 1 1 1 1 Multiple Byte Representations When representing larger data types, the ordering of bits and bytes is again from right to left. The rightmost bit is the LSB and the leftmost bit is the MSB. The rightmost byte is the least significant byte and its address is used to access the data. PRELIMINARY INFORMATION 1-20 1.0 U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-15. Multiple Byte Representations 7 Byte I I 15 I I 31 Word F" 63 DouWeword I 79 Semi-quadword I 127 Quadword I Bit Expressions Bits are expressed by a bit number. When expressing several consecutive bits within a register or memory location, the bit field expression is used. For example, the bits from bit position 3 to bit position 5 can be identified as bits 3:5. Register Expressions Registers are fixed length internal data storage locations. Like memory, registers consist of bits and bytes starting from and numbered from the left. Data stored in a register has the same representation as when that data is stored in memory. Figure 1-16. Register Representation 31 24 23 16 15 8 7 -i 1 1 1 1 1 r -i t 1 1 1 1 r Memory Organization ! • Addresses Each byte in memory is identified by an address. Starting from address 0, addresses are assigned sequentially up to address 4,294,967,295 (232 - 1, or 4 gigabytes). Before address translation, an address is a virtual address while after address translation it is a memory or I/O physical address. • Data Organization Data is stored in memory in byte units with the address of the lowest byte used to address the data. For example, in Figure 1-18, a word is a four byte data structure and is addressed by the least significant byte of the word. 1.0 1-21 PRELIMINARY INFORMATION INTRODUCTION uPD7061 6 PROGRAMMER'S REFERENCE MANUAL • Bit Data Data types that use a bit addressing mode require a 35-bit address. A bit address consists of 32 bits used to address the byte while the remaining 3 bits are used to select the bit within the byte. A bit address can be formed by simply appending the bit offset within a byte to the byte address. • Data in Memory When the address of data is a multiple of the size of the data type in bytes, the data is said to be aligned. Byte data is always aligned and halfword, word, doubleword and quadword data are aligned when they have addresses that are a multiples of 2, 4, 8 and 16 respectively. Semi-quadword data is a special case and is aligned on quadword boundaries. In some special cases, instructions and data must be aligned. However, generally there are no alignment requirements and only the performance is affected by not aligning data on its boundary. Abbreviations and Special Terminology • U.PD70616 The terms uPD70616 architecture and U.PD70616 microprocessor are used throughout this document. The U.PD70616 architecture is used to refer to the specification of the 32-bit V-Series microprocessor family. The term p.PD70616 microprocessor is used to refer to the silicon implementation of this architecture. • UNPREDICTABLE The results of an operation designated by the word "UNPREDICTABLE" may vary, depending on the implementation of the processor. Such operations are considered abnormal and illegal, and there is no guarantee that the operation will be handled consistently across all microprocessors. • MBZ (Must Be Zero) MBZ indicates that all the bits in the specified data field must be 0. If software sets a value which is non- zero, the results are UNPREDICTABLE. • RFU (Reserved for Future Use) RFU indicates that a data field is reserved for future use by NEC. Fields marked as RFU are implicitly selected as MBZ. Software which uses such fields is not portable and the results of such use are UNPREDICTABLE. 1-22 1 -° PRELIMINARY INFORMATION ^iPD70616 PROGRAMMER'S REFERENCE MANUAL INTRODUCTION Figure 1-17. Address Space Representation 4GB 3GB 2GB Addresses 1GB Figure 1-18. Byte Addressed Data Quadword Semi-quadword Doubleword Word Halfword Byte 1.0 1-23 PRELIMINARY INFORMATION INTRODUCTION HPD7061 6 PROGRAMMER'S REFERENCE MANUAL PRELIMINARY INFORMATION 1-24 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL DATATYPES Section 2 Data Types This section describes the hardware supported data types of the U.PD7061 6 microprocessor. A total of eight separate fixed and variable length data types are supported by the U.PD70616 microprocessor. Fixed length and variable length data types are distinguished by two major characteristics. Fixed length data types have a size characteristic that is constant and determined by the instruction opcodes. Variable length data types are dynamic data structures whose length can vary during program execution. Another distinguishing characteristic is that the fixed length data types may reside in either the general purpose register set or in memory. Variable length data types can be represented in their entirety only as memory resident data types. Fixed Length Data Types • Integer • Unsigned Integer • Bit • Floating Point • Decimal Variable Length Data Types • Character String • Bit String • Bit Field Also important is the organization of the data types. Data type organization describes the layout of a data type in a register or in memory. The |iPD7061 6 architecture is flexible in that both byte and bit addressing modes are available. Byte addressing uses the byte (8-bits) as the basic addressing unit and supports the byte aligned data types. Bit addressing is a special addressing mode using the bit as the basic addressing unit and supports the bit aligned data types (bit fields and bit strings). Byte Addressing The addressing model for the U.PD70616 virtual address space is based on the unit of a byte. The uPD7061 6 address space is viewed as a sequence of bytes starting from location and continuing linearly to the location 232 - 1. All memory management, instruction fetches, stack operations and software debug operations use byte addresses. A+3 A+2 A+1 1.0 2-1 PRELIMINARY INFORMATION DATA TYPES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Byte addressing is also used for fixed length data types and for the variable length character string data type. These data types share the characteristic that they are always aligned on a byte boundary, irregardless of the size of the data type. Since byte addresses are 32-bits wide, a byte address corresponds to the location of a byte anywhere within a four gigabyte virtual address space. Byte Address Byte aligned memory operands are physically accessed using one of four access types, each of which can be located anywhere within the virtual address space without restriction. However, instruction throughput is optimized when an access type is aligned on a boundary that is a multiple of its size in bytes. Byte A byte consists of 8 contiguous bits starting on any byte boundary. The individual bits within a byte are labeled to 7 with bit designated as the LSB (least significant bit) and bit 7 as the MSB (most significant b'rt). A byte is completely identified by its address. Halfword A halfword consists of 16 contiguous bits starting on any byte boundary. The individual bits within a byte are labeled to 15 with bit designated as the LSB (least significant bit) and bit 15 as the MSB (most significant bit). A halfword occupies two contiguous bytes and is identified by the address of the low order byte. A+1 Word A word consists of 32 contiguous bits starting on any byte boundary. The individual bits within a byte are labeled to 31 with bit designated as the LSB (least significant bit) and bit 31 as the MSB (most significant bit). A word occupies four contiguous bytes and is identified by the address of the low order byte. 24 23 16 15 8 7 -i 1 1 r "T 1 i i 1 I ~t 1 i r i 1 1 i A+3 A+2 A+1 PRELIMINARY INFORMATION 2-2 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL DATA TYPES Doubleword A doubleword consists of 64 contiguous bits starting on any byte boundary. The individual bits within a byte are labeled to 63 with bit designated as the LSB (least significant bit) and bit 63 as the MSB (most significant bit) A doubleword occupies eight contiguous bytes and is identified by the address of the low order byte. A+7 A+6 A+5 A+4 63 56 55 48 47 40 39 32 i i r -i 1 i 1 * I I L. 31 24 23 16 15 8 7 A+3 A+2 A+1 Fixed length data types can also reside in one the U.PD7061 6 general purpose registers. In place of a byte address a register number is used to identify the to be the source or destination for an operand. All fixed length data types can fit in a register or pair of consecutive registers. The organization of the four data access types in the register set is shown below: i ' « 1 1 1 1 1 1 1 1 1 r 1 1 1 1 1 1 1 1 , , -i 1 1 1 r Unaffected -i —— i Byte i i_ Rn 15 o ~i 1 1 1 1 1 1 1 1 1 1 1 1 r | | y , 1 , , 1 , , , , , , , Unaffected Halfword Rn 31 -i 1 1 1 r "i ' i—i ' r— i 1 1 1 1 1 1 r Word Rn — 63 i r -, 1 , , , , r "i i 1 1 1 1 1 1 1 1 1 1 r -i 1 r 32 MSB Rn + 1 - Doubleword 31 -i——— i i i i_ -i- — i 1 1 1 1 i i i LSB Rn The lengths of the byte and halfword access types are shorter than the register length. These access types are right Only the lower portion of the register corresponding to the access type is significant and justified within the register. the upper portion will remain unaffected. In the case of the doubleword access type, the operand occupies a pair of general purpose registers. The lower numbered register contains the least significant word while the higher numbered register contains the most significant word. However, since R31 cannot be used as the least significant register of a doubleword register pair, the results of using R31 as the source or destination operand of a doubleword access type is unpredictable. 1.0 2-3 PRELIMINARY INFORMATION DATATYPES UPD70616 PROGRAMMER'S REFERENCE MANUAL Bit Addressing Bit addressing is employed to address data structures that are bit aligned, i.e., are aligned on an arbitrary bit boundary. However, unlike byte addressing which uses the byte as the atomic unit for memory addressing, bit addressing uses the bit as the basic addressing unit. Instead of using a four gigabyte virtual address space, bit addressing views the virtual address space as a thirty-two gigabit address space. co + m+ c\J + 03 CO CO CO CO m cd co To address an arbitrary bit within a thirty-two gigabit address space requires a 35-bit address since there are 232 bytes, each containing eight bits. A bit address is composed of two separate components, a 32-bit byte base address and a 32-bit bit offset. These components are combined to generate the 35-bit bit address. -i 1 1 1 1 r -i 1 1 r 1 1 1 1 1 1 1 1 1 1 1 r Bit Address The byte address is zero extended on the right to 35-bit length. The bwb (bit within byte) field is initialized to zero to address the first bit (bit within the byte. The sign extended 32-bit bit offset is added to form the bit address. ) 3 2 CM t 1 1 1 1 1 1 1 1 1 1 1 1 r -i 1 1 1 1 i i 1 1 1 1 r i i Byte Address bwb bwb - bit within byte Once formed, the upper 32-bits of the bit address is used to identify the byte address of the operand with the lower three bits identifying the bit offset within the byte. The process of bit address generation is shown below: 34 r 1 1 1 r -i 1 1 r t 1 1 1 1 1 1 1 1 1 1 1 1 Byte Address 34 31 i—i r 1 1 t 1 1 1 r 1 1 1 1 r -i 1 1 1 1 1 1 1 1 1 1 i i i ' i sign Bit Offset extension 3 2 T , , , , , 1 1 1 1 1 1 1 1 T 1 1 1 1 1 I—I 1 1 I I I ' I • r Byte Address bwb 2-4 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL DATA TYPES Data Types The uPD70616 recognizes a wide variety data types, typical of those utilized in most applications. Supported data types are listed below in Table 2.1 Table 2. 1. uPD70616 Data Types Data Type Length Bit Data bit 1-bit byte 8-bits half word 16-bits Integer word 32-bits doubleword 64-bits byte 8-bits half word 16-bits Unsigned Integer word 32-bits doubleword 64-bits short real 32-bits Floating Point long real 64-bits byte string 8-bit characters 1 to 4 gigacharacters Character String half word string 1 6-bit characters 1 to 2 gigacharacters bit variable Bit String 1 to 4 gigabits bit variable Bit Field to 32 bits Signed Integers Signed integers are expressed in two's complement binary notation. Four signed integer lengths are supported, byte, halfword, word and doubleword. Signed integer representation consists of a sign bit field and a magnitude field. The MSB (most significant bit) of a signed integer is the sign bit and indicates whether the number is positive or negative. The magnitude field contains the absolute value or magnitude of the signed integer. Data Type Ftenge Byte -128 - 127 Halfword -32768 ~ 32767 Word -2147483648 ~ 2147483647 Doubleword -9223372036854775808 ~ 9223372036854775807 1.0 2-5 PRELIMINARY INFORMATION DATA TYPES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Unsigned Integers Unsigned integers represent natural numbers (non-negative integers) in binary notation. There are four unsigned integer data types: byte, halfword, word, and doubleword. Unsigned integers consist of only a magnitude field which is the same size as the data type. Unsigned integers are also used to represent the logical data types used for the bit- wise logical operations. Data Type Range Byte 0-255 Halfword ~ 65535 Word - 4294967295 Doubleword ~ 18446744073709551615 Bit purposes. In the U.PD70616, bit data is identified by a byte Bit data is often used to efficiently store data for control base address and a separate bit offset. The byte base address component selects the address of the word that contains the bit in question. The addressing mode is used to determine whether the operand is in a general purpose register (register addressing mode) or memory (all other addressing modes). The bit offset is then used to identify the particular bit within the register/word that is to be manipulated. The bit offset is specified as a value in the range of [0..31]. Specifying any other value for the bit offset will cause an exception. 31 d 4| b As a fixed length data type, bit data can reside in either a register or in memory. is also possible to manipulate bit data It using the bit string or bit field data types by specifying a length of 1 for these variable length data types. Binary Floating Point Binary floating point formats provide a wide range of numerical values over a specified level of precision. Floating point data types are useful for scientific and engineering calculations, numerical control, and any application requiring high performance numeric calculations such as graphics. The U.PD70616 microprocessor supports basic floating point operations on two IEEE compatible binary floating point formats. Short Real The short real data type is a 32-bit binary floating point representation conforming to the IEEE single precision format. The short real format consists of a mantissa sign bit, an 8-bit biased exponent and a 23-bit mantissa as shown below: 31 30 23 22 s exponent mantissa PRELIMINARY INFORMATION 2-6 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL DATA TYPES Long Real The long real data type Is a 64-bit binary floating point representation conforming to the IEEE double precision format. The long real format consists of a mantissa sign bit, an 1 1-bit biased exponent and a 52-bit mantissa as shown below: 52 51 exponent mantissa Decimal Data Type The decimal data type is used for the manipulation of both packed and unpacked decimal numeric strings. The decimal data type divides each byte into two 4-bit fields (nibbles). In the packed decimal representation, each 4-bit field is assumed to contain a valid BCD (binary code decimal) digit in the range [0..9]. In the unpacked (or zoned) decimal representation, only the lower 4-bit field is assumed to contain a digit and the higher 4-bit bit field is called the zone field. When a nibble is expected to contain a digit, only the valid BCD values [0..9] can be specified. Any other value will cause an illegal decimal format exception to occur. There is no restriction on the contents of the zone field. Character Strings Two types of character strings are recognized by the U.PD70616 microprocessor, byte character strings and halfword character strings. Byte character strings are used to express standard ASCII text. Halfword character strings are also "supported to express text needing a much wider range of characters than available with an 8-bit character set. Instructions are provided for operating on character strings of either type and include: • transfer • comparison • scanning • skipping Being a variable length data structure, a character string is fully defined by: • the address of the start of the string • the number of characters in the string In addition to the above attributes, a character string must also obey the following restriction: • the sum of the starting address and the length of a character string (in bytes) must be less than 232 _ 1 Note that the number of characters and the length of a byte character string are the same while a halfword character has a byte length twice the number of characters in the string. Some instruction permit specifying the direction of string processing. The direction within a character string in which addresses become larger is called the upward direction while the direction in which addresses become smaller is the downward direction. In all cases the ordering of characters within the string is in the upward (increasing addresses) direction. Only the direction of processing changes. 1.0 2-7 PRELIMINARY INFORMATION DATA TYPES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Examples of both byte and halfword character strings are shown below. Byte character string (N=4) 7 7 7 t 1 1 1 1 r -i 1 1 r I I 1 1 I 'e' V 'B' A+3 A+2 A+1 A « Upward Direction Downward Direction Halfword character string (N=2) 15 15 -i-, , , , , 1 1 1 1 1 1 1 1 1 1 1 1 r— — 1 r 1 1 1 1 1 1 1 1 1 1 i 1 i 1 i 1 i 1 1 r- SP bits 0:31 SP The SP (stack pointer) contains the 32-bit virtual address to the current top of stack. System Base Register The System Base Register (SBR) contains the pointer to the first entry of the system base table. The system base table is a table of vectors used for interrupt and exception processing. The system base register contains the physical address of the start of this table which must be aligned on a page boundary. -i 1 1 1 1 r 00000000 SBA 000000000000 bits 0:31 SBA The SBA (system base address) is the physical address of the system base table. The system base table is aligned on a page boundary and the twelve low order bits (bits 0:11) must be zero, otherwise the results are UNPREDICTABLE. The upper eight bits (bits 24:31) are unused by the U.PD70616 but should zero for compatibility with future microprocessors. PRELIMINARY INFORMATION 3-8 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL REGISTER SET Task Register The Task Register (TR) holds the virtual address of the task control block (TCB) for the currently installed context. The Task Register is a 32-bit read-only register and is loaded automatically by the load task context instruction. i i i——— — i i i i i i i i — -i i i i r i 1 i TCBB bits 0:31 TCBB The TCBB (Task Control Block Base) is the virtual address of the TCB for the current context. A task control block must be aligned on a word boundary, thus TCBB field (bits 0:1) must be zero, otherwise the results are UNPREDICTABLE. Task Control Word The Task Control Word (TKCW) contains task specific information and is swapped in and out out as part of the task context. 31 16 15 13 12 10 9 8 7 5 4 3 2 1 -i 1 1 1 1 1 r -I 1 1 1 r F F F F F R R RFU ATT RFU T I Z V U P F D RD M T T T T T u I bits 0:1 RD The RD (float rounding control) field controls the direction of rounding during floating point calculations. RD = 00 round toward nearest RD = 01 round toward -~> RD = 1 round toward +°° RD = 1 round toward zero bit 2 RDI The RDI (integer rounding control) field controls the direction of rounding during floating point to integer conversions. RDI = use RD field rounding mode RDI = 1 round toward zero bit 3 RFU Reserved for future use bit 4 FPT The FPT (floating point precision trap e handling of precision errors. FPT = floating point precision traps disabled FPT = 1 floating point precision traps enabled bit 5 FUT The FUT (floating point underflow trap enable) flag selects the desired mode for the handling a floating point underflow condition. FUT = floating point underflow traps disabled FUT = 1 floating point underflow traps enabled 3-9 PRELIMINARY INFORMATION 1.0 REGISTER SET U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL bit 6 FVT The FVT (floating point overflow trap enable) flag selects the desired mode for the handling of overflow errors. FVT = floating point overflow traps disabled FVT = 1 floating point overflow traps enabled bit 7 FZT The FZT (floating point zero divide trap enable) flag selects the desired mode for the handling of a zero floating point divisor. FZT = floating point zero divide traps disabled FZT = 1 floating point zero divide traps enabled bit 8 FIT The FIT (floating point invalid operation trap enable) flag selects the desired mode for the handling an invalid floating point operation. FIT = invalid floating point operation traps disabled FIT = 1 invalid floating point operation traps enabled bit 9 OTM The OTM (operand trap mask) flag controls the handling of reserved floating point operands such as infinities or NaNs. OTM = trapping enabled OTM = 1 trapping disabled This flag has a different than other flags associated with floating point operation traps. This field is cleared to in the uPD70616 microprocessor. bits 10:1 2 RFU Reserved for future use bits 13:15 ATT The ATT (asynchronous task trap level) field contains the value of the execution level required to trigger an asynchronous task trap (ATT). ATT[ 15:13] = level ATT 1 level 1 ATT 1 level 2 ATT 1 1 level 3 ATT 1 ATT disabled 1 1 ATT disabled 1 1 ATT disabled 1 1 1 ATT disabled bits 16:31 RFU Reserved for future use PRELIMINARY INFORMATION 3-10 10 U.PD70616 PROGRAMMER'S REFERENCE MANUAL REGISTER SET System Control Word The System Control Word (SYCW) is the system-wide register for the control of the operating environment. 31 t 1 1 1 1 i r -l 1 r 16 15 -i 1 i 12 11 8 7 6 4 3 10 RFU ATRSI SPSI AST RFU bit VM The VM (virtual mode) field controls the operating mode of the processor. VM = physical address mode VM = 1 virtual address mode bits 1 :3 RFU Reserved for future use bits 4:6 AST The AST (asynchronous system trap level) field contains the value of the execution level required to trigger an asynchronous system trap (AST). AST[ 6:4 ] = level AST 1 level 1AST 1 level 2 AST 1 1 level 3 AST 1 AST disabled 1 1 AST disabled 1 1 AST disabled 1 1 1 AST disabled bits 8:11 SPSI The SPSI (stack point switching inhibited) field controls the change of the stack pointers during context switching. SPSI[ 8 ] = level stack pointer is fixed 1 level stack pointer is switched SPSI[9] = level 1 stack pointer is fixed 1 level 1 stack pointer is switched SPSI[10] = level 2 stack pointer is fixed 1 level 2 stack pointer is switched SPSI[11] = level 3 stack pointer is fixed 1 level 3 stack pointer is switched 1.0 3-11 PRELIMINARY INFORMATION REGISTER SET J1PD70616 PROGRAMMER'S REFERENCE MANUAL bits 12:15 ATRSI The ATRSI (area table register switching inhibited) field controls the change of the area table registers during context switching. ATRSI[12] = the section 00 area table registers are fixed 1 the section 00 area table registers are switched ATRSI[13] = the section 01 area table registers are fixed 1 the section 01 area table registers are switched ATRSI[14] = the section 1 area table registers are fixed 1 the section 10 area table registers are switched ATRSI[15] = the section 1 1 area table registers are fixed 1 the section 1 1 area table registers are switched bits 16:31 RFU Reserved for future use Processor ID Register The Processor ID Register (PIR) is a read-only register containing identification information about the processor. 31 16 15 8 7 RFU PT NECRV bits 0:7 NECRV This field is reserved for use by NEC. bits 8:15 PT The PT (processor type) field contains information identifying the CPU. bits 16:31 RFU Reserved for future use The contents of the PIR register for the U.PD70616 (V60) microprocessor is 31 16 15 8 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -i r 1 1 1 1 r 0000000000000000 r 1 1 1 1 1 1 i 1 1 Area Table Registers The uPD70616 includes a on-chip demand paged memory management unit for applications requiring a large virtual address space (refer to section 4 for detailed information). The virtual address is divided into four one gigabyte sections. Each section has a pair of registers defining the location and size of the associated area tables. Since the area table base (ATBR0-ATBR3) registers and area table length registers (ATLR0-ATLR3) are used as pair, they are commonly referred to as area table registers (ATBR/ATLR). PRELIMINARY INFORMATION 3-12 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL REGISTER SET Area Table Base Registers The four Area Table Base Registers (ATBR0-ATBR3) contain the base address and control information for managing the four area tables. 31 24 23 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 00000000 ATB R F U D V bit The V (valid) field determines if the contents of the area table registers are valid. An exception will occur if an address translation is attempted using an invalid ATBR/ATLR pair. bit 1 D The D (direction) field determines the direction of growth for this section. D= growth direction is positive (increasing addresses) D= 1 growth direction is negative (decreasing addresses) bit 2 RFU Reserved for future use bits 3:31 ATB The ATB (area table base address) is a 29-bit physical address of the first area table entry for the associated section. The lower order three address bits (bits 0:2) are zero and the area table must be aligned on a doubleword boundary. The high order eight bits (bits 24:31) are ignored by the |iPD70616 microprocessor but must be zero for compatibility with future versions. Area Table Length Registers The four Area Table Length Registers (ATLR0-ATLR3) contain information about the size of the associated area table as shown below. 31 13 12 3 2 RFU LOS RFU 8^169 bits 0:2 RFU Reserved for future use bits 3:1 2 LOS The LOS (limit of section) field is used by the hardware to determine the number of valid area table entries in an area table. If the D bit is cleared (positive growth direction), area table entries from < n < LOS are considered valid. If the D bit is set (negative growth direction), area table entries rn the range LOS < n < 1023 are valid. bits 13:31 RFU Reserved for future use 1.0 3-13 PRELIMINARY INFORMATION REGISTER SET U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL Address Trap Registers The five address trap registers provide a powerful tool for the debugging and verification of software. These registers can be programmed so that an exception (refer to section 9 for details) occurs when a matching selected and access type is generated. The five address trap registers are: • trap mode register • trap address registers • trap address mask registers Trap Mode Register The trap mode register specifies what kinds of memory access (read, write and execute), if any, are to generate traps. 31 1 1 1 1 — 1 1 1 1 1 1 J— — 1 1 1 1 1 1 1 12 T— 11 10 9 8 1 1 1 1 4 3 2 10 R RFU E R W RFU E R W F U bit RFU Reserved for future use bit 1 W The W (write) field controls the trapping of a write access into the region defined by the ADTRO/ADTMRO registers. W= ADTRO write access traps disabled W= 1 ADTRO write access traps enabled bit 2 R The R (read) field controls the trapping of a write access into the region defined by the ADTRO/ADTMRO registers. R= ADTRO read access traps disabled R=1 ADTRO read access traps enabled bit 3 E The E (execute) field controls the trapping of a write access into the region defined by the ADTRO/ADTMRO registers. E= ADTRO execute access traps disabled E= 1 ADTRO execute access traps enabled bits 4:8 RFU Reserved for future use bit 9 W The W (write) field controls the trapping of a write access into the region defined by the ADTR1/ADTMR1 registers. W= ADTR1 write access traps disabled W= 1 ADTR1 write access traps enabled bit 1 R The R (read) field controls the trapping of a write access into the region defined by the ADTR1/ADTMR1 registers. R= ADTR1 read access traps disabled R= 1 ADTR1 read access traps enabled PRELIMINARY INFORMATION 3-14 10 U.PD70616 PROGRAMMER'S REFERENCE MANUAL REGISTER SET bit 1 1 E The E (execute) field controls the trapping of a write access into the region defined by the ADTR1/ADTMR1 registers. E= ADTR1 execute access traps disabled E= 1 ADTR1 execute access traps enabled bits 12:31 RFU Reserved for future use Address Mask Registers The Address Trap Registers (ADTR0/ADTR1) are used to specify the base address of the range of addresses to be trapped. 31 1 1 It 1 T -I-""' 1 TA bits 0:31 TA The TA (trap address) field holds the target virtual address to cause a trap. Address Trap Mask Registers The Address Trap Mask Registers (ADTMR0/ADTMR1) are used to mark address bits in the associated ADTR register as "don't care", allowing accesses in a range of addresses to be trapped. 31 2 1 1 TAM 1 1 bit 0:31 TAM The TAM (trap address mask) field contains the mask pattern used to specify a range of trap addresses. Note that the lower two bits of the TAM field (bits 0:1 ) must be set, otherwise the results are UNPREDICTABLE. Program Status Word 2 Program Status Word 2 (PSW2) functions as the V20/V30 emulation mode program status word. Refer to section 10 for details on the operation of this register. 31 c — 30 r~ r" i i i i i t "r ~r- ~r 1 1 1 16 15 14 13 12 11 10 D 9 8 B 7 6 5 4 3 2 1 T RFU 1 1 1 1 V I I R S Z A p 1 c L R E K c Y 1.0 3-15 PRELIMINARY INFORMATION REGISTER SET ^PD70616 PROGRAMMER'S REFERENCE MANUAL PRELIMINARY INFORMATION 3-16 1.0 M.PD7061 6 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES Section 4 Address Spaces This section describes the configuration and operation of the different U.PD70616 address spaces. The p.PD70616 microprocessor provides three separate address spaces: • a sixteen megabyte (16MB) memory address space • a sixteen megabyte (16MB) I/O address space • a four gigabyte (4GB) virtual address space The implementation of the four gigabyte virtual address space is supported by an on-chip memory management unit (MMU). Memory management is utilized to give each program or task the illusion of exclusive access to a four gigabyte (4 billion byte) linear address space. A virtual address space is mapped onto the memory address space (physical memory addresses) or I/O address space (peripheral device addresses) by the MMU in a process known as address translation. Address translation is a two-level process where a virtual address is converted to a physical address (in either the memory or I/O spaces) and all associated permissions are verified prior to the actual execution of the bus cycle. Introduction The memory address space uses the physical addresses of memory devices and limits the size to the maximum number of addressable bytes of memory. Since the U.PD70616 microprocessor has twenty-four external address lines, the memory address space ranges from physical address (0x000000) to an upper address of 224 _ 1 ^OxFFFFFF) in units of one byte. Because most systems do not implement a full sixteen megabyte memory address space since the actual size of the physical memory sub-system is determined by the application. There are no requirements for the alignment of data within the memory address space. The I/O address space is used to access and control peripheral devices. Like the memory address space, the I/O address space uses all of the U.PD70616 address lines and supports a 16 megabyte address space. The I/O address space is accessed by the execution of I/O instructions or by mapping a portion of the virtual address into the I/O address space. The virtual address space is a much larger address space using 32-bit virtual addresses. By the process of address translation, the virtual address space is mapped onto one of the physical address spaces by the memory management unit. To aid in the task of managing such a large address space, the virtual address space is paged using a four kilobyte (4KB) page size. -j 4-1 PRELIMINARY INFORMATION ADDRESS SPACES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Virtual Address Space The virtual address space is viewed by programs as a byte addressable four gigabyte (232 bytes) linear address space. Figure 4-1. Virtual Address Space 4GB OFFFFFFFFH 3GB 2GB Addresses 1GB 00000000H PRELIMINARY INFORMATION 4-2 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES Sections The four gigabyte virtual address space is divided into four one gigabyte (1GB) sections. The lowest address section is the 00 section and the remaining sections are called the 01, 10, and 11 sections respectively. In the U.PD70616 microprocessor, a section is a unit of sharing for a common virtual space in a system employing multiple virtual spaces. Figure 4-2. Sections 4GB 0FFFFFFFFH 11 section 3GB 10 section 2GB Addresses 01 section 1GB 00 section 00000000H 4-3 PRELIMINARY INFORMATION 1.0 ADDRESS SPACES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Areas Each section is divided into 1 024 areas. Each area is one megabyte (1 MB) in size . The lowest numbered area within a section is area and numbering proceeds up to the last area, area 1023. The area permits protection of system resources and private sharing of virtual address space at the task level. Figure 4-3. Areas 4GB OFFFFFFFFH 3GB 2GB Addresses area 1023 • 01 • section • area 1 areaO 1GB 00000000H PRELIMINARY INFORMATION 4-4 1.0 JIPD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES Pages Each area consists of 256 pages, each page four kilobytes (4KB) in size. Pages are numbered from page in ascending order to page 255 within an area. The page is the smallest unit of virtual memory management. Pages are also the unit of mapping a portion of the virtual space into the I/O address space. Figure 4-4. Pages 4GB OFFFFFFFFH 3GB 2GB Addresses area 1023 01 section area 1 rV page page 1 1GB V page 255 00000000H 1.0 4-5 PRELIMINARY INFORMATION ADDRESS SPACES UPD70616 PROGRAMMER'S REFERENCE MANUAL Sections A section is a 1GB segment of the virtual address space and is the basic memory management unit for a system having multiple virtual spaces. Consider the following virtual memory configuration: • section 11 operating system • section 10 common system and utilities • section 01 task control information • section 00 taskwork region In this example, all tasks share the virtual space defined by section 10 and 11 and have private virtual spaces defined by sections 00 and 01 The U.PD70616 microprocessor places no restrictions on the assignment of virtual spaces to tasks. Each task can have a unique virtual space or multiple tasks can share a common virtual address space. When several tasks share a virtual space, the virtual space (defined by one or more area table register pairs) remains static while the tasks are swapped in and out of the processor. Virtual spaces are switched only when the virtual spaces differ between tasks. Because the operating system is shared by all tasks, it can reside in a fixed section. Fixing of a section is selected by the ATRSI fields in the SYCW (System Control Word). Section Length A section need not occupy the entire 1 GB virtual address space and is usually much smaller. The U.PD70616 can limit the size of a section such that the number and size of the address translation tables is minimized. Setting the size of a section requires specifying a length of section (LOS) value in the area table register. The LOS field selects the maximum number of areas that comprise a section. Along with the D (direction) bit, the LOS field determines which areas are defined and whether growth is from the bottom or top of the section. When the D bit is cleared, the growth direction is positive and areas are measured from the base of the section (area 0) and continuing to area LOS-1 When . the D bit is set, the growth direction is negative and areas are allocated from the top of the section (area 1023) and continue down to area 1023-LOS. Legitimate area table references require the following conditions be met: • positive growth area offset < LOS • negative growth area offset > LOS An attempt to reference an area outside the these regions will cause a Section Length Violation exception, Refer to figure 4-5 for details of section limits and organization. Table 4-T. Section Limits and Ranges Positive Growth Direction Negative Growth Direction LOS Areas Range Areas Range LOS = 1 area areaO 1 024 areas areas 1 023 - LOS-1 2 areas areas - 1 023 areas areas 1 023 - 1 LOS = 1023 1 024 areas areas 0-1023 1 area area 1 023 86-197 4-6 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES Figure 4-5. Section Limits and Ranges Growth Direction Positive Negative 7 z;'/, Addresses // // LOS '///, LOS Y~X Effective section Undefined Sections > A section which has not been defined is called an undefined section. A section is considered to be undefined the V if (valid) bit in the associated area table register is cleared. An Invalid Section exception will be raised an attempt to if access an undefined section is made. Areas An area is a 1MB segment of the virtual address space and is available for private sharing of a virtual space such as between two tasks. An area can be shared by simply copying the area table entry. The area is also a unit of protection between tasks. Both execution level and access types are checked prior to a references to an area. Swapping of entire areas is also supported. Area Length An area need not occupy the entire 1 MB virtual address space. The uPD70616 can limit the size of an area such that the number and size of the page tables is minimized. Setting the size of a area requires specifying a length of area (LOA) value in the area table entry (ATE). The LOA field selects the maximum number of pages that comprise an area. Along with the ATE D (direction) bit, the LOA field determines which pages are defined and whether growth is from the bottom or top of the area. When the D bit is cleared, the growth direction is positive and pages are allocated from the base of the area (page 0) and continuing to page LOA-1 . When the D bit is set, the growth direction is negative and pages are measured from the top of the area (page 255) and continuing down to area 255-LOA. 4-7 PRELIMINARY INFORMATION 1.0 ADDRESS SPACES UPD70616 PROGRAMMER'S REFERENCE MANUAL Legitimate page table references require the following conditions be met: • positive growth page offset < LOA • negative growth page offset > LOA An attempt to reference an page outside these regions will cause a Area Length Violation exception. Refer to figure 4-6 for details of area limits and organization. Table 4-2. Area Limits and Ranges Positive Growth Direction Negative Growth Direction LOA Pages Range Pages Range LOA = 1 page pageO 256 pages pages 255 - LOA-1 2 pages pages - 255 pages pages 255 - LOA - 255 256 pages pages - 255 1 page page 255 Figure 4-6. Area Limits and Ranges Growth Direction Positive Negative Addresses LOA LOA '///, /// '///, Y~X Effective area PRELIMINARY INFORMATION 4-8 1.0 U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES Protection Protection and separation of tasks from each other and the operating system is one of the primary advantages of a virtualmemory system. Protection mechanisms enhance the operation of the system by detecting and preventing attempts by tasks to access programs and data without first having established the necessary permissions. The uPD70616 protection mechanisms are implemented using three levels. First an execution level is established which determines the relative trustworthiness of a task. A check of execution level and access type permission are performed at the area level while an independent access type permission check is performed again at the page level. Execution Levels The execution level of a task determines whether a task is privileged or non-privileged. The execution level (EL) is a 2- bit field in the PSW register which contains the current execution level. Execution levels are numbered from to 3 with level being the most privileged and level 3 being the least privileged. Programs execution at level are said to be privileged and can execute the entire U.PD70616 instruction set. Programs executing at other execution levels (levels 1 2 and 3) are are said to be non-privileged and attempts to execute a privileged instruction will cause an , exception. In a typical system, the operating system kernel is executed at level while tasks and non-privileged operating system utilities are executed at levels 1 to 3. Area Protection Protection for an area (1MB region) is defined by the corresponding entry in the area table. Area level protection is specified independently for each access method (Read, Write and Execute) by a 2-bit field. Each of these protection three fields contain the minimum execution level necessary to allow access to the area. For example, if Read level 2 Write level Execute level 1 are specified, then access to the area by program execution level is: level Read, Write and Execute level 1 Read and Execute level 2 Read level 3 no access The area protection mechanisms provide a flexible means to restrict access to an area by execution level and access type. Page Protections Page protection defines the permissions required to access a page (4KB) and are specified in the corresponding page table entry. Page protections permit or deny access on the basis of contents of the page. For example, the if page protections are Read true Write true Execute false then the contents of the page are readable and writable but not executable. An access is possible only when both area and page permissions have been granted. Any attempt at access without both sets of permissions will cause an exception. Protection mechanisms are enabled only when the processor is operating in the virtual mode. In the physical address mode, all protection mechanisms are disabled and no exceptions occur. 4-9 PRELIMINARY INFORMATION 1.0 ADDRESS SPACES U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL Memory Address Space The memory address space is the space all physical memory accesses occur in and defines the maximum amount of addressable memory. Because of the restrictions imposed on the memory address space by the processor model and and system requirements, the memory address space will vary from system to system. The U.PD70616 microprocessor has a memory address space of sixteen megabytes (16MB) starting from address 0x000000 and proceeding linearly to an upper address of OxFFFFFF in units of a single byte. The U.PD70616 can access the memory address space from both the virtual and physical modes. In the physical address mode, a logical address and physical address are the same and are output without modification. In virtual mode, the virtual address is first translated to a physical address before being output. The selection of virtual/physical addresses is done by the SYCW register (refer to section 3 for details). Previously, all descriptions have assumed operation in the virtual address mode. When operated in the physical address mode the following address space differences should be noted: • only one address space • no protection • address size is restricted • system/processor dependent design The U.PD70616 instruction set is fully functional in the physical address mode. However, because a physical memory address is 24-bits, the upper eight bits of an address (bits 24:31) must be zero (MBZ). The U.PD7061 6 will tolerate the upper order eight bits becoming non-zero during effective address calculation but the results may be unpredictable. I/O Address Space The I/O address space is used for the placement and control of peripheral devices without requiring the reservation of a portion of the memory address space. Like the memory address space, the I/O address space is 16MB in size with addresses ranging from 0x000000 to OxFFFFFFFF in byte units. The valid I/O address space access ranges are completely determined by each individual system. Two different methods are provided to generate I/O space accesses to maximize system software flexibility. The first approach uses the traditional method of dedicated I/O instructions to generate I/O address space accesses. The alternate approach uses the memory management and address translation logic to map a portion of the virtual space into the I/O address space. I/O Space Access I/O space accesses are always generated by the execution of the privileged IN and OUT instructions. An I/O port address is specified as a 32-bit operand but because of the external address bus size restriction, bits 24:31 of a port address must be zero. The operation using an I/O port address outside the range 0x00000000 to OxOOFFFFFF is unpredictable. Virtual Address Space Mapping Placement of I/O devices in the memory address space (memory-mapped I/O) is an old technique to allow the use any instruction that references memory to manipulate I/O ports at any execution level. The uPD70616 permits a new form of I/O peripheral access which maps a portion of the virtual address space into the I/O address space using the memory management logic. PRELIMINARY INFORMATION 4-10 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES The I/O mapping process is defined by: • unit of mapping The mapping of the virtual address space to the I/O address space is done using the page as the basic unit of mapping. A 4KB segment of the virtual space is I/O mapped by setting the bit within the corresponding page I table entry. The uPD70616 has 4096 I/O pages within the 16MB I/O address space. • access type Access to an I/O mapped page is controlled by the read and write permissions defined for the page. An execute access is undefined for an I/O mapped page and attempted will cause an exception. if • protection The area table entry execution level permissions operate identically when compared to a memory-mapped page. Both read and write execution levels are independently specified. • privilege By I/O mapping a page of virtual space, the area table entries control which tasks can access to the I/O device. This allows non-privileged tasks to perform I/O accesses on a task by task basis as determined by the operating system. Multiple Virtual Spaces A multitasking operating system presents a dichotomy. Each installed task must be provided with an independent same time there are virtual address spaces for protection and separation from other tasks in the system while at the common operating system services which are required to be shared by all tasks in the system. The U.PD70616 microprocessor solves this dichotomy by allowing tasks to share a portion of their virtual address space. Virtual address spaces can be shared at the section, area or page level. The operating system virtual space can be •shared at the section level by dedicating section 1 1 (1GB) as a common section and using sections 00, 01 and 10 for a total of 3GB of independent virtual space. Virtual space need not be shared among all tasks on a global basis. Private sharing of virtual address space (such as a UNIX fork) can be accomplished by using the area as the basis for sharing. An example of a multiple virtual address spaces is shown in figure 4-7. -I 4-1 1 PRELIMINARY INFORMATION ADDRESS SPACES ^iPD70616 PROGRAMMER'S REFERENCE MANUAL Figure 4-7. Multiple Virtual Address Spaces Task 2 virtual address space 4GB OS Section 3GB Shared Utility Section 2GB Individual 1GB Task Sections Task 4 Task 2 Task PRELIMINARY INFORMATION 4-12 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES Address Translation The uPD70616 microprocessor translates virtual addresses using the on-chip memory management unit. Normally, address translation requires the uPD70616 firmware to translate an address using the on-chip memory management registers (area table base and length registers) and the memory resident translation tables (area table/page table). Address Translation Method Reference Information area table register pair - Normal Translation area table (firmware) page table Address Translation - Translation Look-aside Buffer (TLB) TLB contents (hardware) Address translation incurs a great deal of overhead and is unacceptable to perform for each access so the results of a Caching of a virtual/physical address pair allows the high translation are cached in a translation look-aside buffer (TLB). speed TLB hardware to perform the translation the next time the page is referenced, eliminating the address translation overhead. An example of the address translation process is shown in figure 4-8. Figure 4-6. Address Translation 31 30 29 -i ————i i i 20 19 12 11 -i— i i i—— i Q I iPPTEig® 4 KB Page £8 ATE Page Table Frame Area Table Base Register Area Table Base Register 1 Area Table Base Register 2 o Area Table Area Table Base Register 3 Virtual Address Physical Address Match!!! Translation Lookaside Buffers Processor Resident Memory Resident 86-203 1.0 4-13 PRELIMINARY INFORMATION ADDRESS SPACES (IPD70616 PROGRAMMER'S REFERENCE MANUAL Area Table Register Pair Associated with each of the four sections is a pair of privileged registers labelled ATBRO/ATLRO (section 00) to ATBR3/ATLR3 (section 11). Each of area table register pairs contains the base address (physical address) of an associated area table in memory along with length and validity information for the section. The area table registers were described in detail in section 3 of this manual. Area Tables Each valid section of a virtual address space has an associated area table. Area tables contain up to 1024 entries which correspond to the area to area 1023. Each entry in an area table is called an area table entry (ATE). An area table entry is eight bytes in size and a complete area table would occupy 8KB of memory. The limit of section (LOS) field in the area table base register permits the section size to be reduced along with size of the corresponding area table. Area tables exist in the memory address space and must aligned on a doubleword boundary. An area table entry is shown figure 4-9. Figure 4-9. Area Table Entry (A TE) 63 1 1 1 1 1 t 1 1 1 1 1 r—— 1 1 1 1 i—l 1 1 1 — 40 39 i 38 37 i 36 35 34 33 R 32 RFU LOA EXL WRL RDL F D U 00000000 PTB P V 31 24 23 2 1 86204 bit V The V (valid) bit indicates whether the ATE contents are valid. V= ATE contents are undefined V= 1 ATE contents are valid In the case where the V bit is cleared, the remainder of the ATE is undefined and available. The following definitions only apply when the V bit is set. bit 1 P The P (present) bit indicates whether the page table specified by the ATE currently exists in memory. P= page table not present P= 1 page table present An Area Not Present Exception will occur if an ATE is referenced during an address translation with the P bit cleared. bits 2:31 PTB The PTB (page table base) field contains the physical address of a word aligned page table. In the |iPD70616 microprocessor, the high order bits of the PTB (bits 24:31) must be zero. 4-14 1.0 PRELIMINARY INFORMATION U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES bit 32 D The D (direction) bit specifies the growth direction of the area defined by this ATE. D= positive area growth direction (increasing addresses) D- 1 negative area growth direction(decreasing addresses) bit 33 RFU Reserved for future use bits 34:35 RDL The RDL (read execution level) field contains the execution level required for read access. RDL[ 35:34] = level 1 level 0, 1 level 0, 1,2 1 1 level 0, 1,2,3 bits 36:37 WRL The WRL (write execution level) field contains the execution level required for write access. WRL[ 37:36 ] = level 1 level 0, 1 level 0, 1,2 1 1 level 0,1,2,3 bits 38:39 EXL The EXL (execute execution level) field contains the execution level required for read access. EXL[ 39:38 ] = level 1 level 0, 1 level 0,1,2 1 1 level 0, 1,2,3 bits 40 :47 LOA The LOA (limit of area) field specifies the range of valid pages for the area defined by this ATE. If the D bit is cleared, pages in the range < N < LOA are defined. If the D is set, pages in the range 255 > N > LOA are defined. bits 48:63 RFU Reserved for future use Page Tables Each valid area of a virtual address space has an associated page table. Page tables contain up to 256 entries which correspond to the page to page 255 within an area. Each entry in a page table is called an page table entry (PTE). Page tables need not be present in memory and can be swapped out to secondary storage desired by marking the if area as not present and allowing the operating system to load the page table and restarting the address translation. When an area is shared by multiple virtual spaces, several ATEs may contain references to the same PTE. An page table entry is four bytes in size and a complete page table occupies 1KB of memory. The limit of area (LOA) field in the area table entry permits the area size to be reduced along with size of the corresponding page table. Page word boundary. An page table entry is shown tables exist in the memory address space and must aligned on a figure 4-10. 1.0 4_1 5 PRELIMINARY INFORMATION ADDRESS SPACES UPD70616 PROGRAMMER'S REFERENCE MANUAL Figure 4-10. Page Table Entry (PTE) 31 24 23 12 11 10 9 8 1 1 1 1 1 n 1 r 1 r 00000000 RPV w R M U RFU bit V The V (valid) bit indicates whether the PTE contents are valid. V= PTE contents are undefined V=1 PTE contents are valid In the case where the V bit is cleared, the remainder of the PTE is undefined and available. The following definitions only apply when the V bit is set. If an address translation using an invalid PTE is attempted, an Invalid Page exception will occur. bit 1 I The I (I/O mapped) bit determines if the page specified by this PTE is mapped into the memory or I/O address space. 1 = page is not I/O mapped 1 = 1 page is I/O mapped bit 2 The P (present) bit indicates whether or not the page specified by this PTE is in memory. A Page Not Present Exception will occur an address translation is if attempted using a PTE with the P bit cleared. P= page not present P= 1 page present If the I bit is set in this PTE, the P bit is undefined and disregarded. bit 3 The L (lock) bit is used to specify when the page is involved in an I/O operation such as a DMA transfer. All CPU accesses to a page marked as locked are prohibited and an Invalid Page Exception will occur an address translation is attempted using a PTE rf with the L bit set. L= page is not locked for I/O L= 1 page is locked for I/O This field is undefined if the page is I/O mapped (1 = 1). bits 4:5 RFU Reserved for future use bit 6 U The U (user) field is user definable by the operating system and is ignored during address translation. 4-16 1.0 PRELIMINARY INFORMATION |iPD7061 6 PROGRAMMER'S REFERENCE MANUAL ADDRESS SPACES bit 7 A The A (accessed) bit indicates whether the page associated with this PTE has been referenced. A= not accessed A= 1 accessed This field is undefined if the page is I/O mapped (1 = 1). bit 8 M The M (modified) bit indicates whether a Write access has occurred to the page associated with this PTE. M= no Write accesses occurred M=1 Write access occurred This field is undefined if the page is I/O mapped (1 = 1). bit 9 R The R (readable) bit determines if a Read access can be made to the page associated with this PTE. R= no Read access R=1 Read access permitted bit 1 W The W (writable) bit determines if a Write access can be made to the page associated with this PTE. W= no Write access W= 1 Write access permitted bit 1 E The E (executable) bit determines if a Execute access can be made to the page associated with this PTE. E= no Execute access E= 1 Execute access permitted No Execute access is permitted if the page is I/O mapped (1 = 1). bits 12:31 RPN The RPN (real page number) field has the base address (physical address) of the page associated with this PTE. Pages are aligned on a 4KB page boundary and the lower twelve bits of the physical address are zero. In the U.PD7061 6 microprocessor, the higher order eight bits must be zero. The RPN is a physical address in the memory address space if the field is cleared, otherwise it is a physical address in the I I/O address space. 4_17 PRELIMINARY INFORMATION 1.0 ADDRESS SPACES HPD7061 6 PROGRAMMER'S REFERENCE MANUAL 4-18 1 ° PRELIMINARY INFORMATION U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL TASK MANAGEMENT Section 5 Task Management A task is the smallest unit of concurrency in a U.PD70616 system. In a modern multitasking operating system, multiple tasks can exist simultaneously with the illusion of exclusive control of the processor and system resources. In fact, the operating system is rapidly switching from one task to another based on the relative priorities assigned to each task. At any given moment, one task is the highest priority task and is physically installed on the U.PD7061 6 microprocessor. In a multitasking system there must be a mechanism for the current task to be suspended so that a higher priority task can use the processor. Context Switching Each task has a context which completely describes the state of the task. A context switch saves the current context and loads the context of the next task. A task context consists of the following information: • the program register set • the virtual address space • information specific to the task • other task related information The task's context is completely defined by a task control block (TCB) and any associated memory management tables.The following is a list of the registers included in the TCB. The full uPD70616 TCB is shown in Figure 5-1 • Program Register Set - R0-R30 - L0SP-L3SP • Memory Management (virtual mode only) - ATBR0-ATBR3 - ATBL0-ATBL3 • Task Information - TR - TKCW The privileged Task Register (TR) contains the virtual address of the TCB for the current context. The task register is read only and is updated with a new TCB address by the privileged LDTASK instruction. 1.0 5_1 PRELIMINARY INFORMATION TASK MANAGEMENT UPD70616 PROGRAMMER'S REFERENCE MANUAL Figure 5-1. jjPD70616 Task Control Block 31 ATLR3 ATBR3 ATLR2 ATBR2 ATLR1 ATBR1 ATLRO ATBRO R30(FP) R29 (AP) Specified by the SYCW register R28 R27 R26 Specified by the R25 D LDTASK/STTASK instructions R24 R23 R22 R21 R20 R19 R18 R17 R16 R15 R14 R13 R12 R11 R10 R9 R8 R7 R6 R5 R4 R3 R2 R1 RO L3SP L2SP L1SP LOSP TKCW TCB Base Address Since not all applications require the use of the full task context, the U.PD70616 architecture provides for the elimination of registers from the TCB on a task by task basis. For example, tasks sharing common execution levels and virtual address spaces are not required to maintain the shared registers in their respective task control blocks. Applications requiring fast context switching times can also restrict the size of the general purpose register set. This allows the application designer to trade-off the register set size against the context switch overhead and design a system optimized with respect to some goal. The inclusion of the area table registers and stack pointers is controlled by information programmed in the System Control Word (SYCW). Control of the size of the general purpose register set is done by specifying a register list operand for the context switch instructions. An example of a reduced TCB where a single virtual address space and only execution levels and 3 are implemented is shown in Figure 5-2. PRELIMINARY INFORMATION 5-2 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL TASK MANAGEMENT Figure 5-2. Shared Virtual Space TCB 31 R30 (FP) R29(AP) Specified by the SYCW register R28 R27 R26 Specified by the R25 D LDTASK/STTASK Instructions R24 R23 R22 R21 R20 R19 R18 R17 R16 R15 R14 R13 R12 R11 R10 R9 R8 R7 R6 R5 R4 R3 R2 R1 RO L3SP LOSP TKCW TCB Base Address 85-027 The real advantage in having these options available is that it makes it possible to customize the uPD70616 context switching to a large range of applications without imposing unnecessary limitations on context switching performance. Instruction Set Support The U.PD70616 instruction set contains two instructions which support and simplify context switching operations. The Store Task (STTASK) instruction saves the current task context in the TCB defined in the Task Register. The Load Task (LDTASK) instruction sets the Task Register to a new TCB and loads the new context into the processor. These instructions are described in detail in the instruction set section of this manual. 5-3 PRELIMINARY INFORMATION 1.0 TASK MANAGEMENT HPD7061 6 PROGRAMMER'S REFERENCE MANUAL PRELIMINARY INFORMATION 5-4 1.0 U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL INSTRUCTION FORMATS Section 6 Instruction Formats and Addressing Modes Instruction Formats The U.PD70616 microprocessor can execute 273 variations of 1 19 basic instructions. Each of these 1 19 instructions is encoded using one of seven instruction formats. The instruction format contains useful information on the type of instruction as well as the number and data type of the operands. The u,PD70616 instruction formats have been carefully selected and optimized for use in a full 32-bit environment. Considerations such as minimizing the length of frequently executed instructions, a special format for the register/register and register/memory instructions and the use of implicit addressing modes for frequently referenced operands have been employed to reduce the code size and maximize instruction throughput. It is the purpose of this chapter to describe the structure and format of the binary strings which are referred to as U.PD7061 6 machine code. Instructions and operand addressing information are encoded as binary strings (always an integer number of bytes in length) for the jiPD70616 microprocessor to execute. In order to efficiently encode instructions with differing numbers of operands, several different machine instruction formats are provided. The actual format used is determined by the instruction and the operand addressing modes. In most cases, there is the freedom to use any addressing mode within a given instruction format. However, for reasons of efficiency, one of the two operand formats is required to use a register operand for one of its two operands. Using a two operand instruction as a typical example, a uPD70616 instruction sequence consists of an opcode field ollowed by addressing information for the first (source) operand followed by the addressing information for the second (destination) operand. In the case of variable length data types, a length field is also provided for the operands. Ill Operand 2 (read/write) I>|<| Operand 1 (read) i>| Length Addressing Mode Length Addressing Mode Opcode Increasing Addresses F""j Variable Length Data Types Only 85-001 In many current microprocessor architectures, restrictions are applied to the use of registers, restricting some registers to hold operands and others to hold pointers or indexes. In the U.PD70616 architecture, orthogonality is guaranteed by permitting any one of the thirty-two 32-bit general purpose registers to contain a data operand, a pointer (base register) or an index (index register) value. The orthogonal U.PD70616 instruction set means that with but a few exceptions, there is complete freedom to use any addressing mode with any operand. Source operands may be referenced using any one of the twenty-one byte addressing modes (eighteen bit addressing modes) while destination operands, for obvious reasons, are restricted from using the immediate addressing modes. The remainder of this section is devoted to describing the instruction formats and addressing modes used by the U.PD70616 microprocessor. Condensed versions of this information is also summarized in Appendix B and Appendix C. 6-1 PRELIMINARY INFORMATION 1.0 INSTRUCTION FORMATS HPD70616 PROGRAMMER'S REFERENCE MANUAL Instruction Format I Instruction Format Is an optimized format used for two operand instructions in the register/register and I register/memory operand classes. The minimum instruction length of this instruction format is three bytes, but it may be extended to greater length, depending upon the addressing mode field of the second operand. 15 14 13 12 8 7 mod m d reg op Format I 65-029 bits 0:7 op The opcode field specifies the instruction to be executed. bits 8:1 reg This field identifies the register to be used as the source or destination operand for this instruction. bit 13 The direction bit specifies whether the register field is treated as the source or destination operand as follows: d= reg field identifies the source operand d= 1 reg field identifies the destination operand bit 14 m This field is used in determining the addressing mode of the second operand. bit 15 This field is cleared in all Format I instructions. mod This field specifies the addressing mode for the second operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. The hexidecimal representation used for the opcode field of Format I instructions is op where op is the eight bit wide opcode field. An example of this format is the integer addition instruction which is represented as Inst ru ction Opcode add.b 80 PRELIMINARY INFORMATION 6-2 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL INSTRUCTION FORMATS Instruction Format II Instruction Format II is a more general form of Format and can be used for two operand instructions using any I addressing modes or when the opcode field must be extended as in the floating point arithmetic instructions. The minimum instruction length of a Format II instruction is four bytes, but may be extended to greater length, depending upon the addressing modes of the operands. 15 14 13 12 8 7 mod' mod 1 m m' subop op Format II 85-030 bits 0:7 op The opcode field specifies the instruction to be executed. bits 8:1 subop This field specifies additional opcode information for extended opcode instructions. bit 13 m' This field is used in determining the addressing mode of the second operand. bit 14 m This field is used in determining the addressing mode of the first operand. bit 15 1 This field is set in all Format II instructions. mod This field specifies the addressing mode for the first operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. mod' This field specifies the addressing mode for the second operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. The hexidecimal representation used for the opcode field of Format II instructions is op Format l/l instructions I op«subop Format instructions II where op is the eight bit wide opcode field and subop is the five bit wide opcode extension field. A typical example of this format is the floating point addition instruction. Instruction Opcode addf . 5018 Unless otherwise specified, the subop field of a Format l/ll instruction is zero. 1.0 6-3 PRELIMINARY INFORMATION INSTRUCTION FORMATS UPD70616 PROGRAMMER'S REFERENCE MANUAL Instruction Format III Instruction Format III is used for instructions accepting a single operand. The minimum length of this instruction format is two bytes, but it may be extended to greater length, depending upon the selected addressing mode of the operand. bit m This field is used in determining the addressing mode of the operand. bits 1 :7 op The opcode field specifies the instruction to be executed. mod This field specifies the addressing mode for the specified operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. An example of the hexidecimal representation used for the opcode field of Format III instructions is Instruction Opcode pop E6/7 where the value of the second digit of the opcode field is determined by the addressing mode. 6-4 1.0 PRELIMINARY INFORMATION U.PD70616 PROGRAMMER'S REFERENCE MANUAL INSTRUCTION FORMATS Instruction Format IV Instruction Format IV is used for instructions which use the PC relative addressing mode. The instruction length of this format is two or three bytes, depending on the size of the displacement field. 15 i 1 1 1 i 9. 7 t 1 1 1 r disp8 op *- Format IV 13 1 i i i — _8 7 t 1 1 1 1 r disp16 op ' i 1 j- _l I I L_ 85-032 bits 0:7 op The opcode field specifies the instruction to be executed. bits 8:1 5(23) disp This field contains the 8/16-bit displacement which is sign extended to 32 bit length and added to the contents of the PC to compute the next PC. The hexidecimal representation used for the opcode field of Format IV instructions is op instruction which is where op is the eight bit wide opcode field. An example of this format is the branch to subroutine represented as Instruction Opcode bsr 48 6-5 PRELIMINARY INFORMATION 1.0 INSTRUCTION FORMATS UPD70616 PROGRAMMER'S REFERENCE MANUAL Instruction Format V Instruction Format V is used for instructions which take no operands. The instruction length of these instructions is one byte. 7 op Format V 85-033 bits 0:7 op The opcode field specifies the instruction to be executed. The hexidecimal representation used for the opcode field of Format V instructions is op where op is the eight bit wide opcode field. An example of this format is the NOP instruction which is represented as Instruction Opcode nop CD PRELIMINARY INFORMATION 6-6 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL INSTRUCTION FORMATS Instruction Format VI Instruction Format VI is used for the loop instructions and contains both control register and displacement fields. The length of instruction format VI instructions is four bytes. 31 16 15 13 12 8 7 disp16 subop reg op Format VI 85-034 bits 0:7 op The opcode field specifies the instruction to be executed. bits 8:1 reg This field identifies the register to be used as the control register. bit 13:15 subop This field contains additional instruction identification information. bits 16:31 disp16 This field contains the 16-bit displacement which is sign extended to 32 bit length and used as an offset from the current contents of the PC. The hexidecimal representation used for the opcode field of Format VI instructions is op»subop where op is the eight bit wide opcode field and subop is a three bit wide opcode extension field. An example of this format is the decrement and branch not zero instruction. if Instruction Opcode dbnz C7«2 1.0 6-7 PRELIMINARY INFORMATION INSTRUCTION FORMATS U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL Instruction Format VII Instruction Format VII is used for instructions manipulating variable length data types such as character strings and bit strings as well as the decimal arithmetic instructions. Format VII instructions are subdivided into three subtypes depending the number and location of the variable length operands. Format Vila Used with instructions that reference two variable length operands. Format Vllb Used when the source operand is a variable length data type and the destination operand is a fixed length data type. Format Vile Used when the source operand is a fixed length data type and the destination operand is a variable length data type or with decimal arithmetic instructions. Format VII instructions contain an 8-bit extension field which is used to determine the length of a variable length character or bit string operand. The most significant bit of the extension field is used to determine whether the direct mode (the operand length is in the lower seven bits of the extension field) or the indirect mode (the operand length is contained in the general purpose register identified by the lower seven bits of the extension field) is specified. This field is also used to store the mask pattern for the ADDDC, SUBDC, SUBRDC, and CVTD instructions. i r length 86-096 bit 7 r The r (register) bit determines whether the length field contains the operand length (direct mode) or contains a pointer to a general purpose register containing the operand length. This field is decoded as follows: r= Direct mode, length field contains the operand length. r = 1 Indirect mode, length field contains the number of a general purpose register (0-31) that contains the operand length. bits 6:0 length The length operand (0-127) or the register ID (0-31) resides in this field, as determined by the r field. AllFormat VII instructions use a 12-bit instruction field. The hexidecimal representation used for the opcode field of Format VII instructions is op*subop where op is the eight bit wide opcode field and subop is the five bit wide opcode extension field. A typical example of this format is the AND bit string (upward) instruction. Instruction Opcode andbsu 5B-10 PRELIMINARY INFORMATION 6-8 1 .0 UPD70616 PROGRAMMER'S REFERENCE MANUAL INSTRUCTION FORMATS Format Vila 15 14 13 12 8 7 len' mod' len mod 1 m m' subop op Format Vila i i i i i i i 85-035 bits 0:7 op The opcode field specifies the Instruction to be executed. bits 8:1 subop This field specifies additional opcode information for the instruction. bit 13 nY This field is used in determining the addressing mode of the second operand. bit 14 m This field is used in determining the addressing mode of the first operand. bit 15 1 This field is set in all Format Vila instructions. mod This field specifies the addressing mode for the first operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. len First operand length field. mod' This field specifies the addressing mode for the second operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. len' Second operand length field. 1.0 6-9 PRELIMINARY INFORMATION INSTRUCTION FORMATS UPD70616 PROGRAMMER'S REFERENCE MANUAL Format VI lb 15 14 13 12 8 7 mod' ten mod 1 m m' subop op Format Vllb 85-036 bits 0:7 op The opcode field specifies the instruction to be executed. bits 8:1 subop This field specifies additional opcode information for the instruction. bit 13 m' This field is used to determine the addressing mode of the second operand. bit 14 m This field is used to determine the addressing mode of the first operand. bit 15 1 This field is set in all Format Vllb instructions. mod This field specifies the addressing mode for the first operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. len Variable length operand length field. mod' This field specifies the byte addressing mode for the second operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. Format Vile 15 U 13 12 8 7 exr mod' mod 1 m m' subop op Format Vile 85-003 bits 0:7 op The opcode field specifies the instruction to be executed. bits 8:1 subop This field specifies additional opcode information for the instruction. bit 13 m' This field is used in determining the addressing mode of the second operand. bit 14 m This field is used in determining the addressing mode of the first operand. bit 15 1 This field is set in all Format Vile instructions. mod This field specifies the addressing mode for the first operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. mod' This field specifies the addressing mode for the second operand. This field ranges in length from 1 to 9 bytes depending on the specified addressing mode. exf Operand extension field containing either a length operand or a mask pattern (decimgj arithmetic instructions). PRELIMINARY INFORMATION 6-10 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Addressing Modes The uPD70616 microprocessor provides fourteen basic addressing modes for referencing byte aligned data. These basic addressing modes include: Register Register Indirect Autoincrement Autodecrement Displacement PC Displacement Displacement Indirect PC Displacement Indirect Double Displacement PC Double Displacement Direct Address Direct Address Deferred Immediate Immediate Quick Registers are often used to hold an index to select a particular member of an array. Unfortunately, an index is the same as an offset only when the members of an array occupy exactly one byte. The U.PD70616 architecture offers a number of scaled index addressing modes to help ease this problem with the management of indexes. With seven of the basic addressing modes, it is possible to specify an additional index register. The contents of an index register is multiplied by the size of the operand (in bytes) and added to the base address. Thus, any of these seven addressing modes can be used to specify the base address of an array, and then use the index register (which can be any of the 32 general purpose registers) to index into the array. The value used to scale a register in the autoincrement, autodecrement and scaled index addressing modes depends on the data type of the operand. The following table summarizes this information: Scaling Constant Data Type Increment/Decrement Scaled Index Byte 1 1 Halfword 2 2 Word 4 3 Doubleword 8 8 Short Real 4 4 Long Real 8 8 Packed Decimal 1 1 Unpacked Decimal 2 2 Byte Character 1 1 Halfword Character 2 2 Bit 4 4 Bit Field 4 Bit String 1 - Not Available 86-020 The U.PD70616 also supports eighteen bit addressing modes for addressing bit-aligned data types such as bit lields and bit strings. Bit addressing modes enable the programmer to specify a byte base address and a 32-bit bit otfs H in a single operand. The notations for these twenty-one byte addressing modes and the eighteen bit addressing modes are surorm rized in the following table. 1.0 6-11 PRELIMINARY INFORMATION ADDRESSING MODES UPD70616 PROGRAMMER'S REFERENCE MANUAL Syntax Addressing Mode Byte Addressing Bit Addressing Register Rn — Register Indirect [Rn] @[Rn] Register Indirect Indexed [ Rn ]( Rx Rx@[ Rn ] Autoincrement [Rn+] @[ Rn+ Autodecrement [-Rn] @[-Rn] Displacement disp [ Rn ] offset@[ Rn ] PC Displacement disp [ PC ] offset@[ PC ] Displacement Indexed disp [ Rn ]( Rx Rx@disp[ Rn ] PC Displacement Indexed disp [ PC ]( Rx ) Rx@disp[ PC ] Displacement Indirect [disp[ Rn]] @[ disp Rn [ ] ] PC Displacement Indirect [ disp [ PC ] ] @[ disp [PC]] Displacement Indirect Indexed [ disp [ Rn ] ]( Rx ) Rx@[ disp Rn [ ] ] PC Displacement Indirect Indexed [disp[PC]](Rx) Rx@[ disp PC [ ] ] Double Displacement displ [ disp2 [ Rn ] ] offset@[ disp Rn[ ] ] PC Double Displacement displ [ disp2 [ PC ] ] offset@[ disp [ PC ] ] Direct Address /addr @/addr Direct Address Indexed /addr ( Rx Rx@/addr Direct Address Deferred [ /addr ] @[ /addr ] Direct Address Deferred Indexed [/addr](Rx) Rx<5>[ /addr ] Immediate #value - Immediate Quick #value(1-15) - - Not Available 86-097 Calculation of Bit Addresses A virtual address for byte aligned data consists of 32 bits. Since the identification of a particular bit within a byte requires an additional three bits, a total of 35 bits is needed to address an arbitrary bit in virtual memory. This means that the address of a bit cannot be expressed in a single 32-bit word. Two 32-bit words can be used to form a bit address, and a convenient convention for this is to interpret one of the words as a byte base address and the other as a bit offset from the base address. To form the necessary 35-bit bit address, the byte base address is zero extended on the right to form a 35-bit base address. The 32-bit bit offset is then sign extended to 35 bit length and added to the base address. The 35-bit sum is then used to address the start of the bit data type in memory. PRELIMINARY INFORMATION 6-12 1.0 UPD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES 31 -, 1 i 1 1——| 1 i 1 1 1 1 1 1 1 1 1 1 T 1 1" T" Base Address i i i i i i i -i i i i i i , i , i i i i i I I I I 31 "T 1 "'r-'""f" — -t -- j t -*"• Sign Extended Bit Offset i , i __i i j j i i i i i i L -J l_ Sign Extension 34 T I n t I i n t 1 1 r ~\ 1 1 1 1 r Bit Address ' -I I I L. Eighteen of the byte addressing modes (the exceptions are register and the two immediate addressing modes) discussed in the preceding section require two 32-bit values (often one of the values is implicitly 0) to be added in order to obtain the address of the operand. The U.PD70616 re-interprets these addressing modes as suggested by v he above diagram for instructions which operate on bit fields and bit strings. The bit addressing modes can be Classified into bit displacement and bit index modes. The bit displacement modes are re-interpretations of the byte displacement addressing modes. The displacement field is interpreted as the bit offset from the base address. In the case of instructions with no displacement field, an offset of is The other exception is the double displacement addressing mode which uses one substituted. displacement field to locate a memory based pointer and the second displacement field as the bit offset. The bit index modes are re-interpretations of the scaled index addressing modes. When used where a bit address is required, the index register Rx is interpreted as a bit displacement and any base register and displacement fields form the byte base address. Notice that this addressing mode is not inconsistent with its other uses, since the index register is scaled to the size of the data, which in this case is a single bit. Addressing Mode Encoding The uPD70616 addressing modes for denoting byte aligned data are described in the next section. The minimum encoding of any of the fourteen basic addressing modes requires nine bits. It is convenient to divide these nine bits into three fields, mod, Rn and m. The m and mod fields together define the addressing mode. The five bit Rn field is used to specify a register number, or may provide other information if the addressing mode uses no register as in the case of the PC relative and it immediate addressing modes. The scaled index extension modes all require an index register, Rx, in addition to the base register, Rn. Five bits are needed to specify the register itself, and three extra bits beyond that are used to indicate the fact that the scaled index addressing mode is being used. The placement of these additional eight bits is shown in the diagram below. 1.0 6-13 PRELIMINARY INFORMATION ADDRESSING MODES |lPD70616 PROGRAMMER'S REFERENCE MANUAL mod Addressing Mode 71 •63- •55 •47- 39 31 •23- 15- 011*-Rn Rn 001 * Rn •> [Rn] 100* Rn» [Rn + ] 101*Rn* [-Rn] 1110«val« immed.4 4— disp 000*- Rn ^ disp.8[Rn] 4— disp 11110000 disp.8[PC] #— disp 100*-Rn-l [ disp.8[Rn]] *— disp 11111000 [disp.8[PCJ] 011*- Rn*. 110*-Rx-l (Rn](Rx) *— val 11110100 immed.8 001* RnH disp.16[Rn] 11110001 disp.l6[PC] 101*Rn-H [disp.16[Rn]j 11111001 [disp.16[PC]] 11110100 immed.16 displ disp2 —4 000* Rn* displ .8[disp2.8[Rn]] displ disp2-4 11111100 displ .8[ disp2.8[Rnj] disp 000* Rn« 110*Rx-H disp.8[Rn](Rx) *- disp 11110000 110* Rx disp.8[PC](Rx) disp 100*Rn< 110* Rx [ disp.8[Rn]](Rx) disp 11111000 110* Rx [ disp.8[PC]](Rx) disp- 001*-Rn-*|110*Rx- disp.16[Rn](Rx) disp- 11110001 110*Rx- disp.16[PC (Rx) disp- 100*Rn-W110*Rx- [disp.16[Rn]](Rx) •disp- 11111000 110*Rx- [disp.16[PC]](Rx) > disp - 010*Rn-i disp.32[Rn] disp- 11110010 disp.32[PC] disp - 110*Rn-« [disp.32[Rn]] disp 11111010 [disp.32[PC]] displ »>*- •disp2- 001*Rn* displ. 16[disp2.16[Rnj] displ -w*- -disp2- 11111101 displ .16[disp2.16[PC]] addr- 11110011 /addr addr- 11111011 [/addr] - val 11110100 immed.32 - disp 010*Rn-H 110* Rx -l disp.32[Rn](Rx) disp 11110010 110* Rxh disp.32[PC](Rx) disp - 110*Rn-H 110* Rxh (disp.32[Rn]](Rx) disp - 11111010 110*Rx-( [disp.32[PC]](Rx) addr- 11110011 110* Rx 4 /addr(Rx) addr- 11111011 110* Rxh [/addr](Rx) displ disp2- -H 010*Rn* displ .32[ disp2.32[Rn]] -displ disp2- -* 11111110 displ .32[disp2.32[PC]] 86-041 PRELIMINARY INFORMATION 6-14 1.0 U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES The remainder of this section describes in detail the uPD70616 addressing modes. A sample of the format used to describe each of the addressing modes is shown below. Addressing Mode Format Format This field describes the assembly language format for the byte (bit) addressing modes. Description A description of the byte (bit) addressing mode appears in this area. mod Field Encoding The format of the mod field is contained in this section. Individual fields can be identified using the following keys: Rn Register n Rx Index register x disp Displacement val Immediate value addr 32-bit address Notes Any additional information relevant to the addressing mode is supplied in this section. 1.0 6-15 PRELIMINARY INFORMATION ADDRESSING MODES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Format Rn Byte Addressing Description Byte The operand is found in the specified register (or pair of consecutive registers). This addressing mode allows the contents of any of the 32 general purpose registers to be used as the operand in an instruction. For byte or halfword data, the low order portion of the register is used (bits 7:0 or 15:0). For doubleword (64-bit) data, the operand resides in the registers Rn and Rn+1 with the least significant word located in register Rn. The , use of R31 for doubleword data is unpredictable. Instruction Rn V////////A Bit Prohibited mod Field Encoding mod m 7 o Rn 11 «•— Rn-* 1 Notes The use of this addressing mode with a variable length data type will generate an Illegal Addressing Mode exception. PRELIMINARY INFORMATION 6-16 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Register Indirect [Rn] Format [Rn] Byte Addressing <2>[Rn] Bit Addressing Description Byte This addressing mode allows the contents of any general purpose register to be used as a pointer to an operand located in memory. Instruction Rn Memory O Bit The base address of the operand in Rn is combined with a default bit offset of to generate the bit address of the operand. Instruction Rn Q Memory offset m mod Field Encoding mod m 7 o [Rn] 1 1 *_Rn-* 1.0 6-17 PRELIMINARY INFORMATION ADDRESSING MODES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Register Indirect Indexed [Rn](Rx) Formal [Rn](Rx) Byte Addressing Rx@[Rn] Bit Addressing Description Byte This addressing mode is similar to the register indirect mode. The contents of a general purpose register is used as a pointer to a word location which is scaled by the contents of the specified index register. Instruction Rn Memory r*\ » * \j ( J Rx * size Bit The index register Rx is is used as the bit offset from the byte base address contained in Rn. Instruction Rn o t\.Vi Memory -W Rx- mod Field Encoding mod- - m 15 7 o [Rn](Rx) 011 «-Rn-* 110 ««-Rx-* 1 PRELIMINARY INFORMATION 6-18 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Autoincrement [Rn+] Format [Rn+] Byte Addressing @[Rn+] Bit Addressing Description Byte This mode is similar to the register indirect mode, except that the contents of the register is incremented, after the access is made, by the size (in bytes) in the operand. Any of the 32 general purpose registers may be used for this addressing mode. Instruction Rn Memory - >w O \J i ' /•j&^v^.V:?^. size »«0 X j Bit The contents of register Rn and a bit offset of are used to compute the bit address of the operand. The contents of Rn are then incremented by 1 for the bit string data type or by 4 for the bit field data type. Instruction Rn O size- - Memory offset « mod Field Encoding mod m 7 o [Rn+] 1 0«#— Rn-* 1 Notes The use of the autoincrement addressing mode in combination with certain other addressing modes may lead to unpredictable results. In particular, if the first operand of an instruction uses the autoincrement mode, the second operand should not use the same register for an index register. Moreover, two operands of an instruction should both not use the same register in the autoincrement (or autodecrement) mode. For further information, see the description of the addressing mode restrictions at the end of this section. 1.0 6-19 PRELIMINARY INFORMATION ADDRESSING MODES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Autodecrement [-Rn] Format [-Rn] Byte Addressing @[-Rn] Bit Addressing Description Byte This addressing mode is similar to the register indirect mode, except that the contents of the register is decremented, before the operand access is made, by the size (in bytes) of the operand. Any of the 32 general purpose registers may be used with this addressing mode. Instruction Rn Memory V///////A size- 3 a Bit The contents of base register Rn is first decremented (count determined by the data type) and the result is added to a bit offset of to generate the operand bit address. Instruction Rn size- 4 o '/////////A" offset = — mod Field Encoding mod- m [-Rn] 1 1 Rn- Notes The use of the autodecrement addressing mode in combination with certain other addressing modes may lead to unpredictable results. In particular, if the first operand of an instruction uses the autodecrement mode, the second operand should not use the same register for an index register. Moreover, two operands of an instruction should both not use the same register in the autodecrement (or autoincrement) mode. For further information, see the description of the addressing mode restrictions at the end of this section. PRELIMINARY INFORMATION 6-20 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Displacement disp[Rn] Formal disp[Rn] Byte Addressing offset@[Rn] Bit Addressing Description Byte The 8-, 16-, or 32-bit displacement is sign extended (if 8- or 16-bits) to 32-bit length and added to the contents of the specified register. The resulting value is then used as the address of the operand. Instruction Rn Memory O disp Bit The 8-, 16-, or 32-bit bit offset is combined with the contents of base register Rn to generate the bit address. Instruction Rn r O t-tWtt -\.V- Memory offset mod Field Encoding mod- -*> m 39 23 15 7 o disp8[Rn] «#— disp8 — 000 «4-Rn-* disp16[Rn] <« disp16 00 1 «*-Rn-+> disp32[Rn] +- disp32 010 <-Rn-^ 1.0 6-21 PRELIMINARY INFORMATION ADDRESSING MODES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Displacement Indexed disp[Rn](Rx) Format disp[Rn](Rx) Byte Addressing Rx@disp[Rn]....B"rt Addressing Description Byte The operand located at the sum of the base register Rn, the displacement field and the scaled contents of index register Rx is addressed. Instruction Rn Memory O disp Rx * size Bit The base address of the operand is formed by the sum of the base register Rn and the displacement field. This value is combined with the bit offset in register Rx to form the operand bit address. Instruction Rn O t-tWt AV Memory AV AV Rx- •disp- mod Field Encoding mod- -* m 47 31 23 15 disp8[Rn](Rx) disp8- -* 000 Rn-*110 Rx-* 1 disp16[Rn](Rx) •disp16- -* 001 Rn-*110 Rx-* 1 disp32[Rn](Rx) disp32- -* 010 Rn-* 110 Rx-* 1 PRELIMINARY INFORMATION 6-22 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES PC Displacement disp[PC] Formal disp[PC] Byte Addressing offset@[PC] Bit Addressing Description Byte This addressing mode permits the program counter to be used in the place of one of the 32 general purpose registers in the displacement mode. The use of the PC displacement addressing mode generates position independent code, since the displacement from the PC is the same without regard to the actual value of the PC. Instruction PC Memory a disp Bit The contents of the PC is used as the base address and is combined with the offset field to generate the bit address of the operand. Instruction PC O T-rVtr- Memory • offset- mod Field Encoding mod- +> m 39 23 15 7 disp8[PC] — disp8 —^1 1110 -* disp16[PC] ^ disp16 *1 1110 1 disp32[PC] *- disp32 *1 1110 10 6-23 PRELIMINARY INFORMATION 1.0 ADDRESSING MODES U.PD70616 PROGRAMMER'S REFERENCE MANUAL PC Displacement Indexed disp[PC](Rx) Formal disp[PC](Rx) Byte Addressing Rx@disp[PC]....Bit Addressing Description Byte The sum of the PC, the displacment field and the scaled contents of index register Rx is used as the address of the operand. Instruction PC Memory a disp > Rx * size Bit The sum of the PC and displacement field is used as the base address and is combined with the bit offset in register Rx to form the operand bit address. Instruction PC a 1 1 1 1 1 1 r\.\r AV Memory \V -\v Rx- •disp- mod Field Encoding mod- -*> m 47 31 23 15 7 disp8[PC](Rx) +— disp8—*1 1110 110 Rx-^ 1 disp16[PC](Rx) M disp16 *1 1110 1 110 Rx-^ 1 disp32[PC](Rx) disp32- 11110010 11 0^-Rx-^ 1 PRELIMINARY INFORMATION 6-24 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Displacement Indirect [disp[Rn]] Format [disp[Rn]] Byte Addressing <5>[disp[Rn] Bit Addressing Description Byte The word contents of the location addressed by the sum of the base register Rn and the 8-, 1 6-, or 32-bit sign extended displacement field is used as the address of the operand. Instruction Rn Memory Memory O disp a Bit The word contents of the location addressed by the sum of the base register Rn and the 8-, 16-, or 32-bit sign extended displacement field is used as the bit address of the bit operand. No bit offset is specified in this addressing mode. Instruction Rn Memory O disp o Memory offset - mod Field Encoding mod- m 39 23 15 [disp8[Rn]] disp8» 1 00 Rn- [disp16[Rn]] disp16- 1 01 Rn- [disp32[Rn]] disp32- 1 1 •Rn- 1.0 6-25 PRELIMINARY INFORMATION ADDRESSING MODES UPD70616 PROGRAMMER'S REFERENCE MANUAL Displacement Indirect Indexed [disp[Rn]](Rx) Format [disp[Rn]](Rx) Byte Addressing Rx@[disp[Rn]] Bit Addressing Description Byte The word contents of the memory iocation addressed by the sum of the base register Rn and the displacement field is added to the scaled contents of index register Rx and used as the address of the operand. Instruction Rn Memory Memory r\ 1 10^-Rx-*- 1 [disp16[Rn]](Rx) • disp16- 1 01 -*-Rn-+- 1 1 0*-Rx-*> 1 [disp32[Rn]](Rx) <«- •disp32- 1 1 0««-Rn-* 1 1 0««-Rx-* 1 PRELIMINARY INFORMATION 6-26 1.0 HPD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES PC Displacement Indirect [disp[PC]] Format [disp[PC]] Byte Addressing @[disp[PC]] Bit Addressing Description Byte The word contents of the location addressed by the sum of the PC and the sign extended displacement field is used as the address of the operand. Instruction PC Memory Memory O disp o Bit The word contents of the location addressed by the sum of the PC and the sign extended displacement field is used as the base address component for the bit address. There is no bit offset field specified by the addressing mode. Instruction PC Memory a disp o Memory offset = mod Field Encoding mod m 39 23 15 7 o [disp8[PC]] +— disp8—*1 11110 [disp16[PC]] disp16 *1 11110 1 [disp32[PC]] «*- disp32 *1 11110 10 1.0 6-27 PRELIMINARY INFORMATION ADDRESSING MODES |iPD70616 PROGRAMMER'S REFERENCE MANUAL PC Displacement Indirect Indexed [disp[PC]J(Rx) Formal [disp[PC]](Rx) Byte Addressing Rx@[disp[PC]] Bit Addressing Description Byte The word contents of the location addressed by the sum of the PC and the sign extended displacement field is added to the scaled contents of the specified index register Rx to form the address of the operand. Instruction PC Memory Memory O disp r Rx * size a Bit The word contents of the location addressed by the sum of the PC and the sign extended displacement field is treated as the byte component of the bit address and is combined with the bit offset in register Rx to form the bit address of the operand. Instruction PC Memory O disp o i r i i i i r I r\V, I V S. I I Memory A.V Rx- mod Field Encoding mod- m 47 31 23 15 7 [disp8[PC]](Rx) ^— disp8—*>1 11110 110 Rx-* 1 [disp16[PC]](Rx) + disp16 *111110 1 110 Rx-* 1 [disp32[PC]](Rx) +- disp32- ! 11110 10 110 Rx-* 1 6-28 1.0 PRELIMINARY INFORMATION U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Double Displacement disp1[disp2[Rn]] Format disp1[disp2[Rn]] Byte Addressing offset@[disp[Rn]] Bit Addressing Description Byte This addressing mode is like the displacement indirect mode except that an additional displacement value is provided to be added to the address of the operand. An 8-, 16-, or 32-bit displacement field, disp2, is sign extended and added to the contents of a general purpose register to form an address. The word contents of that location is then fetched and added to the first displacement field, displ to form the address of the , operand. Instruction Rn Memory Memory a r disp2 displ a Bit The word contents of the memory location addressed by the sum of the base register Rn and the displacement field is treated as the byte component of the bit address. This value is then combined with the bit offset field to generate the bit address of the operand. Instruction Rn Memory O disp a A.V, i i i i i Memory A.V offset- mod Field Encoding mod- m 71 39 23 15 7 o displ .8[disp2.8[Rn]] <«-disp1-*-*-disp2-* 00 -Rn--* 1 displ. 16[disp2.16[Rn]] •displ —*-* disp2 001 «4-Rn-*> 1 displ .32[disp2.32[Rn]] •displ disp2 010 *-Rn-*- 1 1.0 6-29 PRELIMINARY INFORMATION ADDRESSING MODES U.PD70616 PROGRAMMER'S REFERENCE MANUAL PC Double Displacement disp1[disp2[PC]] Format disp1[disp2[PC]] Byte Addressing offset@[disp[PC]] Bit Addressing Description Byte This addressing mode is similar to the displacement indirect mode except that an additional displacement value is provided to be added to the address of the operand. An 8-, 16-, or 32-bit displacement field, disp2, is sign extended and added to the contents of PC to form an address. The word contents of that address is then fetched and added to the first displacement field, displ to form the address of the operand. , Instruction PC Memory Memory Q r disp2 TT-rrrA CJlSpl o Bit The word contents of the memory location addressed by the sum of the PC and the sign extended displacement field is treated as the byte component of the bit address. This value is then combined with the bit offset field to generate the bit address of the operand. Instruction PC Memory a disp a A.V. i i i r i i Memory A.V- • offset mod Field Encoding mod- m 71 39 23 15 7 displ. 8[disp2.8[Rn]] ««-disp1-*~«-disp2-*1 111110 displ. 16[disp2.16[Rn]] displ —++ disp2 *1 111110 1 displ. 32[disp2.32[Rn]] «- displ .disp2 *1 1111110 PRELIMINARY INFORMATION 6-30 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Direct Address /addr Format /addr Byte Addressing @/addr Bit Addressing Description Byte The 32-bit address of the operand is explicitly contained in the instruction. Instruction Memory ? I J Bit The 32-bit address in the instruction is used as the byte address component of a bit address. The bit offset in this addressing mode is 0. Instruction 9 I ) Memory offset = mod Field Encoding mod- - m 39 23 15 7 o /addr +- addr.32- -11110011 1.0 6-31 PRELIMINARY INFORMATION ADDRESSING MODES U.PD70616 PROGRAMMER'S REFERENCE MANUAL Direct Address Indexed /addr(Rx) Format /addr(Rx) Byte Addressing Rx@/addr Bit Addressing Description Byte The sum of the operand address contained in the instruction and the scaled contents of index register Rx is used as the operand address. Instruction Memory Rx * size Bit The 32-bit address in the instruction is treated as the byte component of a bit address and is combined with the bit offset located in register Rx to form the bit address of the operand. Instruction 1 1 1 1 1 1 ttWt Memory Rx- mod Field Encoding mod- -* m 47 31 23 15 7 /addr(Rx) <+- — addr32 11110011 11 0«*-Rx-* 1 6-32 1.0 PRELIMINARY INFORMATION U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Direct Address Deferred [/addr] Format [/addr] Byte Addressing @[/addr] Bit Addressing Description Byte As with the direct addressing mode, an address is specified explicitly in the instruction. The word contents of that location is then used as the address of the operand. Instruction Memory Memory a Bit The word contents of the location addressed by the instruction is treated as the byte component of the bit operand and is combined with a bit offset of to address the operand. Instruction Memory o Memory offset - mod Field Encoding •4 mod- - m 39 23 15 7 o [/addr] ««- addr.32- -11111011 6-33 PRELIMINARY INFORMATION 1.0 ADDRESSING MODES HPD70616 PROGRAMMER'S REFERENCE MANUAL Direct Address Deferred Indexed [/addr](Rx) Formal [/addr](Rx) Byte Addressing Rx@[/addr] Bit Addressing Description Byte The sum of the word contents of the memory location addressed by the instruction and the scaled contents of index register Rx is used as the address of the operand. Instruction Memory Memory o Rx * size Bit The word contents of the location addressed by the instruction is treated as the byte component and combined with the bit offset located in register Rx to form the bit address of the operand. Instruction Memory o A.Vi 1 I I I I I I Memory -w Rx- mod Field Encoding mod- m 47 31 23 15 7 o f/addr](Rx) «*- — addr32 *1 11110 11 110 <«-Rx-+- 1 6-34 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Immediate #value Format #value Byte Addressing Description Byte With the immediate addressing mode, the operand is contained in the instruction. This addressing mode is useful for expressing constant values to be used as source data for instructions. The immediate addressing mode cannot be used with doubleword data. Instruction Bit Prohibited mod Field Encoding mod- - m 39 23 15 7 o #immed8 «-immed8-*1 1110 10 #immed16 immed16 *1 1110 10 #immed32 <•- immed32 I 1110 10 Notes The use of the immediate mode as the destination operand addressing mode will result in a Illegal Addressing Mode exception. The attempted use of the immediate addressing mode as a doubleword source operand will result in a Reserved Addressing Mode exception. 6-35 PRELIMINARY INFORMATION 1.0 ADDRESSING MODES UPD70616 PROGRAMMER'S REFERENCE MANUAL Immediate Quick #value Formal #value Byte Addressing Description Byte This is a variant of the immediate addressing mode in which the immediate value is abbreviated to four bits and zero extended to the source operand length prior to instruction execution. The immediate quick addressing mode cannot be used with doubleword data. Instruction Bit Prohibited mod Field Encoding mod- m 7 o #immed4 1 1 1 r>«-val-* Notes The use of the immediate quick mode as the destination operand addressing mode will result in a Illegal Addressing Mode exception. The attempted use of the immediate addressing mode as a doubleword source operand will result in a Reserved Addressing Mode exception. PRELIMINARY INFORMATION 6-36 1.0 U.PD70616 PROGRAMMER'S REFERENCE MANUAL ADDRESSING MODES Addressing Mode Restrictions Under certain conditions, restrictions are applied to the use of certain addressing modes in two operand instructions. Whenever the operand addressing modes are completely independent of each other, no restrictions apply to the selection and use of the U.PD70616 addressing modes. However, the two addressing modes have a mutual if dependancy on a common base or index register, the operation may have unpredictable results. Restrictions apply to two operand instructions when an autoincrement/autodecrement addressing mode is specified for the first operand and the second operand is addressed using a register modified by the first operand. Should this situation occur, the u,PD7061 6 will calculate the effective addresses of the operands using the folowing two rules: • the effective address of the first operand is evaluated and any modification are made then, • the effective address of the second address is calculated and any modifications made. For example, consider the following instruction. mov.w [ r3+ ], [ r3+ ] ; OK Using the preceding guidelines, if the contents of the r3 is Oxioo prior to the execution of the instruction then the address of the first operand is Oxioo, the address of the second operand is 0x104 and the contents of r3 following the execution of the instruction is 0x108. However, under the following conditions, the U.PD70616 cannot reliably calculate the operand address and the festrictions below apply 1 Autoincrement/autodecrement - scaled index If the autoincrement/autodecrement addressing mode is specified for the first operand and the same register is specified as the index register in a scaled index addressing mode for the second operand, the results are unpredictable. mov.w [ r3+ ] , [ r4 ] ( r3 ) ; unpredictable 2. Autoincrement/autodecrement - autoincrement/autodecrement If the same register is specified for an autoincrement/autodecrement addressing mode for both the first and second operands of an instruction in which the lengths of the operand data types differ, the results are unpredictable. movs.bw [ -r20 ], [ -r20 ] ; unpredictable cvt.lw [ r20+ ], [ r20+ ] ; unpredictable 1,0 6-37 PRELIMINARY INFORMATION ADDRESSING MODES |iPD7061 6 PROGRAMMER'S REFERENCE MANUAL PRELIMINARY INFORMATION 6-38 1 .0 UPD70616 PROGRAMMER'S REFERENCE MANUAL INSTRUCTION SET Section 7 |iPD70616 Instruction Set A major goal of the uPD7061 6 design was to provide a comprehensive instruction set with full support for a variety of data types. A large variety of data transfer, arithmetic, logical, control transfer, and stack instructions are represented. The comprehensive instruction set coupled with the flexible addressing modes permit an optimizing compiler to extract maximum performance from the U.PD70616 architecture, providing a performance increase over less sophisticated microprocessors. Additional instructions support system activities such as memory management and task swapping. These instructions are part of the privileged instruction set. Instruction Set Description Prior to introducing the instruction set descriptions, a number of commonly used definitions and an example should prove helpful. Mnemonic -*> MOV Move MOV Syntax luetjuclwi Opcode The assembler syntax for the instruction and mov.b src.b/, dstb.w Move Byte 00 mov.h arch/, dsth.w Move HeJhwxd 1B any associated operands. The operand field mov.w src.w.r, dstw.w Move Word 2D contain three components, the operand name, mov.d erc.dj, dstd.w Move Doubleword 3F data type and access fields. See the tables in the text for additional information on these Operation Pilili—fcHjMod— fields. dst «- src Addressing Made arc dsl ft! O A concise description of the instruction. Description [Rn| O [Hn+1 The data designated by tie source operand It copied to the destination operand. (-*"! o A detailed description of the instruction with Iftie Immediate qulok addressing mode If specified for tie diepiRn/PC] o additional information concerning the source operand, the Immedl ate data It zero extended to the [dip[RnrPC]l operation, effects on the flags and potential source operand length before being fransferred to tie diep1|disp2|Rrvt>C]l destination. /addr o exception conditions. On tie jiPD70616 microprocessor, a Reserved Addressing I'addrl o Mode excepfon v4l occur If tie Immediate or hnmed^to [RnKR*) quick addressing mode is specified for a doubleword source dtaplRn/PCKRn) o operand. [d»p[Rn/PC])(Ri) o o /sddr(Rs) o This field contains information on the effect of -*> Condition Code* [/arJdrl(Ri) o the instruction execution on the flags. Any Iflvnsdide.Ouick A X - flags not listed are unmodified by the I - I - l Hrvrwduls A X instruction. CY Unchanged X llegal Addressing Mode OV Unchanged A Reserved Addressing Mode S Unchanged Z Unchanged tnstruceon romtsi The permissible instruction formats for this Format I, II instruction. A list of the permissible addressing modes for each operand. Symbol Definitions O Valid addressing mode Illegal addressing mode A list of any exceptions that might occur as a A Reserved addressing mode result of the execution of this instruction. This - Unavailable addressing mode list only includes the instruction exceptions and does not contain any of the memory management exceptions which can occur on any memory access. 1.0 7-1 PRELIMINARY INFORMATION INSTRUCTION SET U.PD70616 PROGRAMMER'S REFERENCE MANUAL Data Type Abbreviations Operand Access Abbreviations Symbol Data Type Symbol Access Type b Byte (8-bit) r Read access h Half word (16-bit) w Write access w Word (32-b'rt) rw Read and write access d Doubleword (64-bit) rwi Read-modify-write interlocked access s Short Real (32-b'rt) ex Execute access I Long Real (64-bit) n No access (MOVEA instruction) 1 -" 66-135 P Pointer (32-bit) 86-136 The U.PD70616 instruction set description is presented in alphabetical order. Appendix A provides a summary of the instruction set and also lists the instructions by functional grouping. 7-2 1.0 PRELIMINARY INFORMATION ABSF Absolute Value ABSF Syntax Instruction Opcode absf.s src.s.r, dst.s.w Absolute Value Short Real 5C-0A absf.l src.l.r, dst.l.w Absolute Value Long Real 5E-0A Operation Addressing Modes dst |src Addressing Mode src dst Rn O O Description [Rn] O O The absolute value of the source operand is stored in [Rn+] the destination operand. Both the integer condition [-Rn] O O codes and the floating point condition codes are disp [ Rn/PC ] O O updated to reflect the result of the operation. [ disp [ Rn/PC ] ] If the source operand is a NaN or an infinity, a Reserved displ [ disp2 [ Rn/PC ] ] O O Floating Point Operand exception will occur and the flags /addr O O and destination will remain unchanged. [/addr] O O [Rn](Rx) O Condition Codes disp [ Rn/PC ]( Rx ) O [ disp [ Rn/PC ] ]( Rx ) O CY OV s z /addr ( Rx O * [ /addr ]( Rx ) O O Immediate.Quick A X CY Clejired Immediate A X OV Cleared X Illegal Addressing Mode 86-045 S Cleared A Reserved Addressing Mode Z Set if the res>ult is ze ro, otherwise cle ared FIV FZD FOV FUD FPR Exceptions * _ _ * _ Reserved Floating Point Operand Floating Point Underflow FIV Set if an invalid operation is attempted, otherwise unchanged FZD Unchanged FOV Unchanged FUD Set if the result is denormal otherwise unchanged FPR Unchanged Instruction Format Format II 1.0 7-3 PRELIMINARY INFORMATION ADD Add ADD Syntax Instruction Opcode add.b src.b.r, dst.b.rw Add Byte 80 add.h src.h.r, dst.h.rw Add Harfword 82 add.w src.w.r, dst.w.rw Add Word 84 Operation Addressing Modes dst dst + src Addressing Mode src dst Rn O O Description [Rn] O The sum of the source and destination operands is [Rn+] O stored in the destination operand. [-Rn] O O disp [ Rn/PC ] If the immediate quick addressing mode is specified for the source operand, the immediate data is zero [ disp [ Rn/PC ] ] O O displ [ disp2 [ Rn/PC ] ] extended to the source operand length before performing the operation. /addr O [/addr] O O [Rn](Rx) O O Condition Codes disp [ Rn/PC ]( Rx ) O o CY OV [ disp [ Rn/PC ] ]( Rx ) O * * * * /addr ( Rx O o [ /addr ]( Rx ) O o 1 CY Set if a carry is generated, otherwise cleared Immediate.Quick X OV Set if integer overflow occurs, otherwise cleared Immediate O X S Set if the result is negative, otherwise cleared 86-046 X Illegal Addressing Mode Z Set if the result is zero, otherwise cleared Exceptions Instruction Format None Format I, II PRELIMINARY INFORMATION 7-4 1.0 ADDC Add with Carry ADDC Syntax Instruction Opcode addc.b src.b.r, dst.b.rw Add Byte with Carry 90 addc.h src.h.r, dst.h.rw Add Halfword with Carry 92 addc.w src.w.r, dst.w.rw Add Word with Carry 94 Operation Addressing dst <- dst + src + CY Addressing Mode src dst Rn O O Description [Rn] O The sum of the CY flag, source, and destination [Rn + ] O operands is stored in the destination operand. [-Rn] O O If the immediate quick addressing mode is specified for disp [ Rn/PC ] O the source operand, the immediate data is zero [ disp [ Rn/PC ] ] O O extended to the source operand length before displ [ disp2 [ Rn/PC ] ] O O performing the operation. /addr O O [/addr] O O Condition Codes [Rn](Rx) O o disp [ Rn/PC ]( Rx ) O CY OV [ disp [ Rn/PC ] ]( Rx O o * * * * /addr ( Rx O o [ /addr ]( Rx O o CY Set if a carry is generated, otherwise cleared Immediate.Quick O X OV Set if integer overflow occurs, otherwise cleared S Set if the result is negative, otherwise cleared Immediate O X z Set if the result is zero, otherwise cleared X Illegal Addressing Mode 66-646 Instruction Format Exceptions Format I, II None 1.0 7-5 PRELIMINARY INFORMATION ADDDC Add Decimal with Carry ADDDC Syntax Instruction Opcode adddc src.b.r, dst.b.rw, pat.b.r Add Decimal with Carry 59*00 Operation Addressing Modes dst dst + src + CY using mask pattern Addressing Mode src dst pat Rn O O Description [Rn] O O The CY flag and the decimal source operand are added [Rn+] O o to the decimal destination operand and the result is [-Rn] O o stored in the destination operand. The decimal addition disp [ Rn/PC ] O o operation occurs only for the unmasked portion of the [ disp [ Rn/PC ] ] O o operands, as determined by the mask pattern. displ [ disp2 [ Rn/PC ] ] O o The CY flag will be set if there is a carry out of the addition /addr O o operation. If the result is non-zero or a carry is [/addr] O o generated, the Z flag will be cleared, otherwise it remains [Rn](Rx) O o unchanged. disp [ Rn/PC ]( Rx ) O o disp [ Rn/PC ] ]( Rx ) O o Following the addition operation, the result is checked to [ verify that a valid BCD representation exists in the /addr ( Rx O o unmasked portion of the result. If either value is not a [ /addr ]( Rx ) O o valid BCD digit (0-9), a Decimal Format exception will Immediate.Quick O X occur and the destination will remain unchanged. Immediate O X 86-054 X Illegal Addressing Mode - Unavailable Addressing Mode Condition Codes CY OV Exceptions * _ - * Decimal Format CY Set if a carry is generated, otherwise cleared OV Unchanged S Unchanged z Unchanged if the result is zero, otherwise cleared Instruction Format Format VI Ic 7-6 1.0 PRELIMINARY INFORMATION ADDF Add Floating ADDF Syntax Instruction Opcode addf.s src.s.r, dst.s.rw Add Short Real 5C-18 addf.l src.l.r, dst.l.rw Add Long Real 5E-18 Operation Addressing Modes dst src + dst Addressing Mode src dst Rn O O Description [Rn] o The sum of the source and destination operands is [Rn+] O o stored in the destination operand. Both the integer [-Rn] O condition codes and the floating point condition codes disp [ Rn/PC ] O are updated to reflect the result of the operation. [ disp [ Rn/PC ] ] O If the absolute values of the source and destination displ [ disp2 [ Rn/PC ] ] O o operands are equal but differ in sign, the sign of the zero /addr O o result will be determined by the programmed rounding [ /addr O O mode. [Rn](Rx) O o a source or destination operand is a NaN or an infinity, a If disp [ Rn/PC ]( Rx ) O O Reserved Floating Point Operand exception will occur [ disp [ Rn/PC ] ]( Rx ) O o and the flags and destination will remain unchanged. /addr ( Rx O [/addr](Rx) O o "Condition Codes Immediate.Quick A X Immediate A X CY OV X lllanal Aridressinn MnHa 86-045 * * * A Reserved Addressing Mode CY Set if the result is negative and non-zero, Exceptions otherwise cleared Reserved Floating Point Operand OV Cleared Floating Point Overflow S Set if the mantissa sign bit of the result is set, Floating Point Underflow otherwise cleared Floating Point Precision Z Set if the result is zero, otherwise cleared FIV FZD FOV FUD FPR * — * * * FIV Set if an invalid operation is attempted, otherwise unchanged FZD Unchanged FOV Set if the result is infinite, otherwise unchanged FUD Set if the destination result is denormal, otherwise unchanged FPR Set if a precision error occurs, otherwise unchanged Instruction Format Format II 1.0 7-7 PRELIMINARY INFORMATION AND Logical AND AND Syntax Instruction Opcode and.b src.b.r, dst.b.rw AND Byte AO and.h src.h.r, dst.h.rw AND Halfword A2 and.w src.w.r, dst.w.rw AND Word A4 Operation Addressing Modes dst dst a src Addressing Mode src dst Rn O O Description [Rn] O O [Rn + O O The bit-wise AND of the source operand and destination ] operands is stored in the destination operand. [-Rn] O O disp [ Rn/PC ] O O If the immediate quick addressing mode is specified for [ disp [ Rn/PC ] ] O o the source operand, the immediate data is zero displ [ disp2 [ Rn/PC ] ] O o extended to the source operand length before /addr O O performing the operation. [/addr] O o [Rn](Rx) O O Condition Codes disp [ Rn/PC ]( Rx ) O o CY OV [ disp [ Rn/PC ] ]( Rx O O - * * /addr ( Rx O O [/addr](Rx) O o i CY Unchanged Immediate.Quick O X OV Cleared Immediate O X I S Set if the MSB of the result is set, otherwise 86-046 cleared X Illegal Addressing Mode Z Set if the result is zero, otherwise cleared Exceptions Instruction Format None Format I, II 7-8 1.0 PRELIMINARY INFORMATION ANDBS AND Bit String ANDBS Syntax Instruction Opcode andbsu bsrc.b.r, blen.b.r, bdst.b.rw AND Bit String (Upward) 5B-10 andbsd bsrc.b.r, blen.b.r, bdst.b.rw AND Bit String (Downward) 5B-11 Operation Addressing Modes bdst bsrc a bdst Addressing Mode bsrc blen bdst Rn X o X Description @[Rn] o - o @[ Rn+ o - o The bit-wise AND of the source and destination bit ] Specifying (5>[-Rn] o - strings is stored in the destination bit string. offset@[ Rn/PC ] o - o the direction of the operation allows the correct result to Rn/PC ] ] - o be computed, even when the source and destination bit [ disp [ strings overlap. offset@[ disp [ Rn/PC ] ] o - o @/addr o - o To minimize the interrupt latency time, the ANDBS @[/addr] o - o instruction allows the service of interrupts and faults Rx@[ Rn o - o following the completion of a bus cycle. After servicing ] Rx@[ Rn/PC - o the interrupt or correction of the fault condition, ] instruction execution continues from the point of Rx<3>[ disp [ Rn/PC ] ] o - o interruption. Rx@/addr o - o Rx@[ /addr o - o During the execution of the ANDBS instruction, registers ] Immediate.Quick X - X R28 and R27 contain pointers to the bytes within the source and destination bit strings to be processed next. Immediate X o X 86-052 Following the execution of the instruction, R28 contains - Unavailable Addressing Mode the address of the byte containing the final bit of the source bit string while R27 contains the address of the byte containing the final bit of the destination bit string. Exceptions None Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged z Unchanged Instruction Format Format VI lb 7-9 PRELIMINARY INFORMATION 1.0 ANDNBS AND Complemented Bit String ANDNBS Syntax Instruction Opcode andnbsu bsrc.b.r, blen.b.r, bdst.b.rw AND Complemented Bit String (Upward) 5B-12 andnbsd bsrc.b.r, blen.b.r, bdst.b.rw AND Complemented Bit String (Downward) 5B-13 Operation Addressing Modes bdst ~bsrc a bdst Addressing Mode bsrc blen bdst Rn X O X Description <§>[ Rn ] O - O The bit-wise AND of the complemented source bit string <§>[ Rn+ ] O - o and the destination bit string is stored in the destination @[-Rn] O - bit string. Specifying the direction of the operation offset@[ Rn/PC ] O - o allows the correct result to be computed, even when the @[ disp Rn/PC [ ] ] O - o source and destination bit strings overlap. offset@[ disp [ Rn/PC ] ] O - To minimize the interrupt latency time, the ANDNBS @/addr O - o instruction allows the service of interrupts and faults @[/addr] O - o following the completion of a bus cycle. After servicing Rx@[ Rn ] O - o the interrupt or correction of the fault condition, Rx@[ Rn/PC ] O - o instruction execution continues from the point of Rx<3>[ disp [ Rn/PC ] ] O - o interruption. Rx@/addr O - o During the execution of the ANDNBS instruction, Rx@[/addr] O - registers R28 and R27 contain pointers to the bytes Immediate.Quick X - X within the source and destination bit strings to be Immediate X O X processed next. Following the execution of the X Illegal Addressing Mode 86-052 - Unavailable Addressing Mode instruction, R28 contains the address of the byte containing the final bit of the source bit string while R27 contains the address of the byte containing the final bit Exceptions of the destination bit string. None Condition Codes CY OV s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format VI lb PRELIMINARY INFORMATION 7-10 1.0 Bcc Conditional Branch Bcc Syntax Instruction Opcode bcc disp8 Branch on Condition (byte displacement) 6x bcc disp16 Branch on Condition (halfword displacement) 7x Operation Condition Codes if condition then CY OV S z PC <- PC + sign_extended( disp else PC <- NextPC CY Unchanged OV Unchanged Description S Unchanged The specified condition is tested and true a branch is if Z Unchanged taken. The target address is computed by sign extending the 8- or 16-bit displacement field to 32 bit Instruction Format length and adding it to the PC. Format IV The PC relative addressing mode is implicitedly selected by these instructions. The value of the PC used to Mnemonic Condition Opcodes compute the target address is the first byte of the branch BGT S OV ) v Z - 6F/7F ( ( ) instruction. BGE ( S ® OV - ) 6D/7D BLT ( S © OV « 1 ) 6C/7C BLE ( (S © OV v Z - 1 ) ) 6E/7E Mnemonic Condition BH ( CY v Z ) - 67/77 Signed BGT Branch if Greater BNL CY - 63/73 BGE Branch if Greater or Equal BL CY - 1 62/72 BLT Branch if Less BNH (CY v Z ) - 1 66/76 BLE Branch if Less or Equal BE Z-1 64/74 BNE Z- 65/75 Unsigned BH Branch if Higher BV OV - 1 60/70 BNL Branch if Not Lower BNV OV-0 61/71 BL Branch if Lower BN S- 1 68/78 BNH Branch if Hot Higher BP S- 69/79 Flags BE Branch Equal if BC CY « 1 62/72 BNE Branch if Not Equal BNC CY - 63/73 BV Branch Overflow if BZ Z-1 64/74 BNV Branch No Overflow if BNZ Z= 65/75 BN Branch if Negative BR Always 6A/7A BP Branch Positive if BC Branch if Carry BNC Branch if No Carry Exceptions BZ Branch Zero if None BNZ Branch if Not Zero BR Unconditional Branch 1.0 7-11 PRELIMINARY INFORMATION BRK Break BRK Syntax Instruction Opcode brk Breakpoint Trap C8 Operation [-SP] <- Exception Code [_SP] <- PSW [-SP] <- NextPC PC <- [ Exception Vector 13 ] Description The breakpoint trap is asserted and program control is transferred to the breakpoint trap exception handler. Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged z Unchanged Instruction Format Format V Exceptions Breakpoint Trap PRELIMINARY INFORMATDN 7-12 1.0 BRKV Break on Overflow BRKV Syntax Instruction Opcode brkv Break on Overflow C9 Operation [-SP] *- CurrentPC [-SP] <- Exception Code [_SP] <- PSW [-SP] <- NextPC PC <- [ Exception Vector 21 ] Description The OV flag is tested and if set, an Integer Overflow Exception occurs. Otherwise, instruction execution continues witht the next instruction. Condition Codes CY OV s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format V Exceptions Integer Overflow 1.0 7-13 PRELIMINARY INFORMATION BSR Branch to Subroutine BSR Syntax Instruction Opcode bsr disp16 Branch to Subroutine 48 Operation [-SP] <- NextPC PC «- PC + sign_extended(disp16) Description The address of the next instruction is pushed onto the stack and control is transferred to the address computed by adding the sign extendedl 6-bit displacement to the PC. The PC relative addressing mode is implicitedly selected by this instructions. The value of the PC used to compute the target address is the first byte of the branch instruction. Condition Codes CY OV s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format IV Exceptions None 7-14 1.0 PRELIMINARY INFORMATION CALL Call Procedure CALL Syntax Instruction Opcode call target.b.ex, arg.w.r Call Procedure 49 Operation Addressing Modes tmpl <- effective_address( target Addressing Mode target arg tmp2 <- effective_address( arg Rn X X [-SP] <-AP [Rn] o o AP <- tmp2 [Rn+] o [-SP] <-NextPC [-Rn] o o PC <- tmpl disp [ Rn/PC ] o o [ disp [ Rn/PC ] ] o Description displ [ disp2 [ Rn/PC ] ] o The CALL instruction is high level language oriented /addr o instruction for transferring control to a subordinate [ /addr ] procedure. [Rn](Rx) o The instruction operates by first calculating the effective disp [ Rn/PC ]( Rx ) o addresses of the target procedure and argument list and [ disp [ Rn/PC ] ]( Rx ) o saving the current AP and PC registers on the stack, /addr ( Rx ) o "he newly calculated values then replace the contents of [ /addr ]( Rx ) o "fhe AP and PC registers. Immediate.Quick X X Immediate X X When the autoincrement, autodecrement, or scaled index addressing modes are used for either the target or X Illegal Addressing Mode 86-073 argument operands, the contents of the pointer are modified by four. Also, the result is unpredictable if the Exceptions autoincrement or autodecrement addressing mode is None specified using SP as the base register. Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format I, II 7-15 PRELIMINARY INFORMATION 1.0 CAXI Compare and Exchange Interlocked CAXI Syntax Instruction Opcode caxi Rn.w.rw, dst.w.rwi Compare and Exchange Interlocked 4C Operation Condition Codes lock CY ov flags <- dst-Rn * * * * if ( Z=1 ) then dst <- R28 else CY Set if a borrow is generated, otherwise cleared Rn <- dst OV Set if integer overflow occurs, otherwise cleared unlock S Set if the results are negative, otherwise cleared Z Set if the results are zero, otherwise cleared Description Addressing Modes This instruction used to synchronize processes or is Addressing Mode src dst provide mutual exclusion in a multiple processor configuration. CAXI is a more general form of the TASI Rn O instruction. [Rn] X O [Rn+] X The processor informs other bus masters in the system [-Rn] X that an indivisible operation will take place by asserting disp [ Rn/PC ] X ° the bus lock output signal. The destination operand is J then fetched and compared with Rn and equal, the if [ disp [ Rn/PC ] ] X o R28 are stored the destination. Otherwise displ [ disp2 [ Rn/PC ] ] X contents of in the destination contents are placed in Rn. The bus lock /addr X o output is then negated, indicating that other bus masters [/addr] X may again access the shared data. [Rn](Rx) X o disp [ Rn/PC ]( Rx ) X If the register addressing mode is specified for the instruction [ disp [ Rn/PC ] ]( Rx ) X destination, the execution of the is /addr ( Rx X meaningless but the operation is carried out. [ /addr ]( Rx ) X This instruction is not allowed to use Format II and Immediate.Quick X X furthermore, the Format I direction field must be zero. Immediate X X B6-093 X Illegal Addressing Mode Instruction Format Format I Exceptions None 7-16 1.0 PRELIMINARY INFORMATION CHKA Check Access Permission CHKA Syntax Instruction Opcode chkar va.p.r, level.b.r Check Read Access Permission 4D chkaw va.p.r, level.b.r Check Write Access Permission 4E chkae va.p.r, level.b.r Check Execute Access Permission 4F Operation Addressing Modes check memory access permissions Addressing Mode va level Rn O O Description [Rn] O O A check is made if the byte data addressed by the virtual [Rn+] O O address can be accessed at the specified execution [-Rn] O O level. The Z flag will be set if the specified access is disp [ Rn/PC ] O O permitted. The CY flag indicates whether the virtual [disp[Rn/PC]] O O address is mapped into the I/O address space. The S displ [ disp2 [ Rn/PC ] ] O O flag will be set if the MMU was unable to complete the /addr O O address translation. [ /addr ] O An Illegal Data Field exception will occur if the execution [Rn](Rx) O level operand is not in the range disp [ Rn/PC ]( Rx ) O < level < 3 [ disp [ Rn/PC ] ]( Rx ) O /addr ( Rx O or the current execution level is less privileged than the /addr ]( Rx ) [ level operand Immediate.Quick level < PSW.EL Immediate o The absence of the area or page tables will cause a memory management fault just as in a normal data Exceptions access, however, the page need not be physical present Illegal Data Field for access rights to be checked. When executed in the real mode, the Z flag will be set and the CY and S flags cleared. Condition Codes CY OV * — * * CY Set if the page is I/O mapped, otherwise cleared OV Unchanged S Set if the translation fails, otherwise cleared z Set if operation is permissible, otherwise cleared Instruction Format Format I, II 7-17 PRELIMINARY INFORMATION 1.0 CHLVL Change Level CHLVL Syntax Instruction Opcode chlvl level.b.r, arg.b.r Change Execution Level 4B ion Addressing Modes [-SP] «— zero_extended( arg Addressing Mode level arg [-SP] <— Exception Code Rn O O [-SP] <— PSW [Rn] O O [-SP] <— NextPC [Rn+] O O PC <- [ Exception Vector ( 24 + level ) ] [-Rn] O disp [ Rn/PC ] O O Description [ disp [ Rn/PC ] ] O This instruction provides a protected method of displ [ disp2 [ Rn/PC ] ] O O accessing more privileged execution levels. /addr O The execution level is changed to the new level and the [ /addr ] O byte argument is zero extended to word length pushed [ Rn ]( Rx O on the target execution level stack. The change disp [ Rn/PC ]( Rx ) execution level exception processing then pushes the [ disp [ Rn/PC ] ]( Rx ) O exception code, PSW and PC of the next instruction on /addr ( Rx O O the stack and transfers control to the appropiate [ /addr ]( Rx ) O exception handler. Immediate. Quick O An Illegal Data Field exception will occur if the level Immediate operand is not in the range < level < 3 Exceptions or the current execution level is less than the level Illegal Data Field operand level < PSW.EL Operands are zero extended to byte length if the immediate quick addressing mode is specified. Condition Codes CY OV s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format I, II 7-18 1.0 PRELIMINARY INFORMATION CLR1 Clear Bit CLR1 Syntax Instruction Opcode clrl offset.w.r, base.w.rw Bit Test and Clear A7 Operation Addressing Modes CY <- bit( base, offset Addressing Mode base Z < — blt( base, offset bit( base, offset ) <- Rn offset O O [Rn] O O [Rn + ] O Description [-Rn] O O The bit located at the sum of the byte base address and disp [ Rn/PC ] O O bit offset is tested and then cleared. The CY and Z flags [ disp [ Rn/PC ] ] O O reflect the state of the bit prior to the execution of the displ [ disp2 [ Rn/PC ] ] O instruction. /addr O O The location of the designated bit is determined by the [ /addr ] O O base operand. If the register addressing mode is used [Rn](Rx) O O for the base operand, the designated bit is located within disp [ Rn/PC ]( Rx ) O O a general purpose register at the specified bit offset. For [ disp [ Rn/PC ] ]( Rx ) O O any other addressing mode, the designated bit is in /addr ( Rx O memory at the specified bit offset from the base address. [ /addr ]( Rx ) O O An Illegal Data Field exception occurs the bit offset is if Immediate.Quick O X outside the range to 31 Immediate O X If the autoincrement or autodecrement addressing mode X Illegal Addressing Mode 86-095 is specified for the base operand, the base operand is treated as word data and is incremented or decremented Exceptions by four. When the immediate quick addressing mode is Illegal Data Field specified, the immediate data is zero extended to word length and used as the bit offset. Condition Codes CY OV * — — * CY Set if the designated bit is 1 otherwise cleared , OV Unchanged S Unchanged Z Set if the designated bit is 0, otherwise cleared Instruction Format Format I, II 1.0 7-19 PRELIMINARY INFORMATION CLRTLB Clear TLB Entry CLRTLB Syntax Instruction Opcode clrtlb va.p.r Clear TLB Entry FE/F Operation Addressing Modes TLBEntry(va) <- Invalid Addressing Mode va Rn Description [Rn] The virtual address and the section designator (R28) are [Rn+] used to identify a TLB entry to be marked as invalid. The [-Rn] CLRTLB instruction only clears a TLB entry that has a disp [ Rn/PC ] O matching virtual to physical address translation. [ disp [ Rn/PC ] ] displ [ disp2 [ Rn/PC ] ] If the contents of R28 are OFFFFFFFFH, the virtual /addr address operand is translated using the current virtual [/addr] address space. Otherwise, R28 is assumed to contain an area table base address and the virtual address is (Rn](Rx) O translated by ignoring the lower 3 bits of the area table disp [ Rn/PC ]( Rx O base register and performing no area table length [ disp [ Rn/PC ] ]( Rx ) checking. /addr ( Rx If the immediate quick addressing mode is specified for [ /addr ]( Rx ) O the virtual address operand, the immediate data is zero Immediate.Quick O Immediate extended to 32-bit length and used as the virtual 86-077 address. This instruction can be executed in either the real or Exceptions virtual address mode. Privileged Instruction Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged z Unchanged Instruction Format Format III 7-20 1.0 PRELIMINARY INFORMATION CLRTLBA Clear All TLB Entries CLRTLBA Syntax Instruction Opcode clrtlba Clear All TLB Entries 10 Operation All TLB Entries <- Invalid Description Each translation lookaside buffer entry Is voided. This instruction can be executed in either the real or the virtual address mode. Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format V Exceptions Privileged Instruction 1.0 7-21 PRELIMINARY INFORMATION CMP Compare CMP Syntax Instruction Opcode cmp.b srcl.b.r, src2.b.r Compare Byte B8 cmp.h srd.h.r, src2.h.r Compare Halfword BA cmp.w srd.w.r, src2.w.r Compare Word BC Operation Addressing Modes src2 - srd Addressing Mode srd src2 Rn O O Description [Rn] O The source operands are compared by subtracting the [Rn+] O first source operand from the second source operand [-Rn] O and updating the flags in the PSW. disp [ Rn/PC ] O If the immediate quick addressing mode is specified for [ disp [ Rn/PC ] ] O the source pperand, the immediate data is zero displ [ disp2 [ Rn/PC ] ] O O extended to the source operand length before /addr O O performing the operation. [/addr] O O [Rn](Rx) O O disp [ Rn/PC ]( Rx ) O Condition Codes [ disp [ Rn/PC ] ]( Rx ) O CY OV /addr ( Rx O O * * * * [/addr](Rx) O o Immediate.Quick o CY Set if a borrow is generated, otherwise cleared Immediate OV Set if integer overflow occurs, otherwise cleared 86-062 S Set if the result is negative, otherwise cleared Z Set if the result is zero, otherwise cleared Exceptions None Instruction Format Format I, II 7-22 1.0 PRELIMINARY INFORMATION CMPBF Compare Bit Field CMPBF Syntax Instruction Opcode cmpbfs bsrc.w.r, blen.b.r, src.w.r Compare Sign Extended Bit Field 5D-00 cmpbfz bsrc.w.r, blen.b.r, src.w.r Compare Zero Extended Bit Field 5D-01 cmpbfl bsrc.w.r, blen.b.r, src.w.r Compare Left Justified Bit Field 5D-02 Operation Addressing Modes flags src - bitfield Bit Address bsrc blen src Byte Address Rn X O Rn Description @[Rn] O - O [Rn] The designated bit field is extracted using the specified @[ Rn+ ] O - [Rn+] mode and compared to the source operand. The <3>[-Rn] O - O [-Rn] comparison is made by subtracting the bit field data from offset@[ Rn ] O - O disp[ Rn ] the word length source operand and storing the result in offset@[ PC ] O - O disp[ PC ] the condition codes. @[ disp[ Rn ] ] O - O [disp[Rn]] If the bit field length is zero, zero will be subtracted from [ disp[ PC ] ] O - O [disp[PC]] the source operand. offset(2>[ disp[ Rn ] ] O - disp1[disp2[Rn]] The sum of the bit offset and the bit field length must not offset@[ disp[ PC ] ] O - O disp1[disp2[PC]] exceed thirty-two, otherwise an Illegal Data Field @/addr O - O /addr exception will occur. @[ /addr ] O - O [ /addr ] Rx@[ Rn O - [Rn](Rx) If the immediate quick addressing mode is specified for ] Rx<3>[ Rn O - O disp [ Rn ]( Rx ) 'he source operand, the immediate data is zero ] Rx<3>[ PC o - O disp [ PC ]( Rx ) extended to the word length before performing the ] comparison operation. Rx@[ disp[ Rn ] ] o - O [ disp[ Rn ] ]( Rx ) Rx@[ disp[ PC ] ] o - O [ disp[ PC ] ]( Rx ) Rx@/addr - O /addr ( Rx Condition Codes Rx@[ /addr ] o - [ /addr ]( Rx ) CY OV Immediate.Quick X - O Immediate.Quick * * * * Immediate X o O Immediate X Illegal Addressing Mode 86-051 CY Set if a borrow is generated, otherwise cleared - Unavailable Addressing Mode OV Set if integer overflow occurs, otherwise cleared S Set if the result is negative, otherwise cleared Exceptions Z Set if the result is zero, otherwise cleared Illegal Data Field Instruction Format Format VI lb 1.0 7-23 PRELIMINARY INFORMATION CMPC Compare Character CMPC Syntax Instruction Opcode cmpc.b src.b.r, slen.b.r, dst.b.r, dlen.b.r Compare Byte Character String 58*00 cmpc.h src.h.r, slen.b.r, dst.h.r, dlen.b.r Compare Halfword Character String 5A-00 Operation Condition Codes flags <- dst-src CY OV — * * Description The character string designated by the source operand CY Unchanged is compared to the character string designated by the OV Unchanged destination operand. The comparison continues until S Set if src > dst, otherwise cleared Z Set if src = dst, otherwise cleared the end of either character string is reached or there is a disagreement between the string contents. Following Instruction Format the execution of the instruction, the S and Z flags are updated to reflect the relationship between the character Format Vila strings. The S flag reflects the lexical ordering of the character Addressing Modes strings. If the compare instruction terminates with Addressing Mode src slen dst dlen different then the S flag reflects the characters, Rn X O X o unsigned comparison of the two strings. If the compare - [Rn] o instruction terminates by reaching the of either string, 1 [Rn+] - ~ the S flag will indicate the shorter string. The Z flag will be - [-Rn] o - set if and only if the character strings are of identical disp [ Rn/PC ] - o - length and contents. [ disp [ Rn/PC ] ] o - - During the comparison operation, registers R28 and R27 - - displ [ disp2 [ Rn/PC ] ] o o are used to maintain the source and destination - - /addr o addresses respectively. Following the execution of the - - [ /addr CMPC instruction, these registers contain the addresses Rn ]( Rx ) o - o - [ of the characters immediately following the the strings if - disp [ Rn/PC ]( Rx ) o - the end of either string was reached. Otherwise, R28 disp [ Rn/PC ] ]( Rx ) o - o - and R27 will contain the addresses of the characters in [ /addr ( Rx o - o - disagreement. - [/addr](Rx) o - o To minimize the interrupt latency time, the CMPC - X - Immediate. Quick X instruction allows the service of interrupts and faults Immediate X o x following the completion of a bus cycle. After servicing 86-048 condition, X Illegal Addressing Mode the interrupt or correction of the fault - Unavailable Addressing Mode instruction execution continues from the point of interruption. Exceptions Illegal Data Field 7-24 1.0 PRELIMINARY INFORMATION CMPCF Compare Character with Filler CMPCF Syntax Instruction Opcode cmpcf.b src.b.r, slen.b.r, dst.b.r, dlen.b.r Compare Byte Character String with Filler 58*0 cmpcf.h src.h.r, slen.b.r, dst.h.r, dlen.b.r Compare HaKword Character String with Filler 5A-01 Operation Condition Codes flags <- dst-src CY OV — — * * Description The character string designated by the source operand CY Unchanged is compared to the character string designated by the OV Unchanged destination operand. The comparison operation S Set if src > dst, otherwise cleared Z Set if src = dst, otherwise cleared continues until a disagreement between the string contents is detected or both strings are exhausted. If the source and destination characterstrings are not of Instruction Format equal length, the shorter string will be automatically Format Vila extended using the fill character in R26 to the longer string length. Following the execution of the instruction, Addressing Modes the S and Z flags are updated to reflect the relationship Addressing Mode src slen dst dlen between the character strings. Rn X X The S flag reflects the lexical ordering of the character [Rn] O - o - strings. If the compare instruction terminates with [Rn+] o - o - different characters, then the S flag reflects the [-Rn] o - o - unsigned comparison of the two strings. the compare If disp [ Rn/PC ] o - o - instruction terminates by reaching the of either string, disp [ Rn/PC ] ] o - o - the S flag will indicate the shorter string. The Z flag will be [ displ [ disp2 [ Rn/PC ] ] o - - set and only if the character strings are of identical if length and contents. /addr o - o - /addr ] o - o - During the comparison operation, registers R28 and R27 [ [Rn](Rx) o - o - are used to maintain the source and destination disp [ Rn/PC ]( Rx ) - o - addresses respectively. Following the execution of the disp [ Rn/PC ] ]( Rx ) o - o - CMPCF instruction, these registers contain the [ /addr ( Rx o - o - addresses of the characters immediately following the [ /addr ]( Rx ) o - o - the strings if the end of either string was reached. Immediate. Quick X - X - Otherwise, R28 and R27 will contain the addresses of the characters in disagreement. Immediate X o X O 86-048 To minimize the interrupt latency time, the CMPCF - Unavailable Addressing Mode instruction allows the service of interrupts and faults following the completion of a bus cycle. After servicing the interrupt or correction of the fault condition, Exceptions Illegal Data Field instruction execution continues from the point of interruption. 1.0 7-25 PRELIMINARY INFORMATION CMPCS Compare Character with Stopper CMPCS Syntax Instruction Opcode cmpcs.b src.b.r, slen.b.r, dst.b.r, dlen.b.r Compare Byte Character String with Stopper 58«02 cmpcs.h src.h.r, slen.b.r, dst.h.r, dlen.b.r Compare Halfword Character String with Stopper 5A«02 Operation Condition Codes flags <- dst-src CY OV * - * * Description The character string designated by the source operand CY Set if the compare operation terminates without is compared to the character string designated by the detecting the stop character in either string, destination operand. The comparison operation otherwise cleared continues until a disagreement between the string OV Unchanged s Set if src > dst, otherwise cleared contents is detected a string is exhausted or the stop z Set if src = dst, otherwise cleared character in R26 is detected in either string. Following the execution of this instruction, the S, Z, and CY flags Instruction Format are updated to reflect the relationship between the character strings. Format Vila The S flag reflects the lexical ordering of the character strings. If the compare instruction terminates with Addressing Modes different characters, then the S flag reflects the Addressing Mode src slen dst dlen unsigned comparison of the two strings. If the compare Rn X O X instruction terminates by reaching the end of either - - [Rn] o string without detecting the stop character, the S flag will [Rn+] - o - indicate the shorter string. The Z flag will be set and if - [-Rn] o - only the character strings are of identical length and if disp [ Rn/PC ] - o - content. The CY flag is cleared the stop character is if [ disp [ Rn/PC ] ] - - detected in either string, otherwise it is set. displ [ disp2 [ Rn/PC ] ] - - During the comparison operation, registers R28 and R27 - /addr o o - are used to maintain the source and destination - [ /addr o - addresses respectively. Following the execution of the - [Rn](Rx) o - CMPCS instruction, these registers contain the - disp [ Rn/PC ]( Rx ) o - addresses of the characters immediately following the [ disp [ Rn/PC ] ]( Rx ) - - the strings if the end of either string was reached. - /addr ( Rx ) o o - Otherwise, R28 and R27 will contain the addresses of [ /addr ]( Rx ) o - - the characters in disagreement. Immediate.Quick X - X - To minimize the interrupt latency time, the CMPCS Immediate X X instruction allows the service of interrupts and faults 66-646 following the completion of a bus cycle. After servicing - Unavailable Addressing Mode the interrupt or correction of the fault condition, instruction execution continues from the point of Exceptions interruption. Illegal Data Field PRELIMINARY INFORMATION 7-26 1.0 CMPF Compare Floating CMPF Syntax Instruction Opcode cmpf.s srd.s.r, src2.s.r Compare Short Real 5C-00 cmpf.l srd.l.r, src2.l.r Compare Long Real 5E-00 Operation Addressing Modes Flags src2 - srd Addressing Mode srd src2 Rn O o Description [Rn] O o The difference of the two source operands is computed [Rn+] o o and the Integer and floating point condition codes are [-Rn] o o updated to reflect the result of the operation. disp [ Rn/PC ] o If source operand is a NaN or an infinity, a either [ disp [ Rn/PC ] ] o o Reserved Floating Point Operand exception will occur displ [ disp2 [ Rn/PC ] ] o and the flags will remain unmodified. /addr o o [ /addr ] o o Condition Codes [Rn](Rx) o o disp [ Rn/PC ]( Rx ) o o CY OV [ disp [ Rn/PC ] ]( Rx ) o o * * * * /addr ( Rx o o [ /addr ]( Rx ) o o CY Set if the result is negative, otherwise cleared Immediate.Quick A A OV Set if unordered, otherwise cleared S Set to the MSB of the result Immediate A A z Set if the result is zero, otherwise cleared A Reserved Addressing Mode 86-068 FIV FZD FOV FUD FPR Exceptions * — _ _ _ Reserved Floating Point Operand Invalid Floating Point Operation FIV Set if an invalid operation is attempted, otherwise unchanged FZD Unchanged FOV Unchanged FUD Unchanged FPR Unchanged Instruction Format Format II 1.0 7-27 PRELIMINARY INFORMATION CVT Convert CVT Syntax Instruction Opcode cvt.sl src.s.r, dst.l.w Convert Short Real to Long Real 5F-10 cvt.ls src.l.r, dst.s.w Convert Long Real to Short Real 5F-08 Operation Addressing Modes dst src Addressing Mode src dst Rn O Description [Rn] O The source operand is converted to the destination [Rn*] operand format. The integer and floating point condition [-Rn] O codes are updated to reflect the result of the operation. disp [ Rn/PC ] O O [ disp [ Rn/PC ] ] O O Condition Codes displ [ disp2 [ Rn/PC ] ] O /addr O O CY OV [/addr] O * * * [Rn](Rx) O O disp [ Rn/PC ]( Rx O CY Set if the result is negative and non-zero, [ disp [ Rn/PC ] ]( Rx O otherwise cleared /addr ( Rx O OV Cleared /addr ]( Rx O O S Set if the mantissa sign bit of the result is set, [ otherwise cleared Immediate.Quick A X Set if the destination is zero, otherwise cleared Immediate A * 86-045 X Illegal Addressing Mode FIV FZD FOV FUD FPR A Reserved Addressing Mode * — * # * Exceptions FIV Set if an invalid operation is attempted, Reserved Floating Point Operand otherwise unchanged Floating Point Overflow FZD Unchanged Floating Point Underflow FOV Set if the result is infinite, otherwise unchanged Floating Point Precision FUD Set if the destination result is denormal, otherwise unchanged FPR Set if a precision error occurs, otherwise unchanged Instruction Format Format II PRELIMINARY INFORMATDN 7-28 1.0 CVT Convert CVT Syntax Instruction Opcode cvt.ws src.w.r, dst.l.w Convert Word to Short Real 5F-00 cvt.wl src.w.r, dst.l.w Convert Word to Long Real 5F-11 Operation Addressing Modes dst src Addressing Mode src dst Rn O o Description [Rn] O o The word source operand is converted to the destination [Rn+] O o operand format. The integer and floating point condition [-Rn] O codes are updated to reflect the result of the operation. disp [ Rn/PC ] O o [ disp [ Rn/PC ] ] o Condition Codes displ [ disp2 [ Rn/PC ] ] o /addr o CY OV [ /addr ] O o * * * [Rn](Rx) O disp [ Rn/PC ]( Rx ) o CY Set if the result is negative and non-zero, [ disp [ Rn/PC ] ]( Rx ) o otherwise cleared /addr ( Rx O OV Cleared /addr ]( Rx ) O S Set if the mantissa sign bit of the result is set, [ otherwise cleared Immediate.Quick A X Z Set if the result is zero, otherwise cleared Immediate A X 86-045 X Illegal Addressing Mode FIV FZD FOV FUD FPR A Reserved Addressing Mode _ _ _ * Exceptions FIV Unchanged Floating Point Precision FZD Unchanged FOV Unchanged FUD Unchanged FPR Set if a precision error occurs, otherwise unchanged Instruction Format Format II 1.0 7-29 PRELIMINARY INFORMATION CVT Convert CVT Syntax Instruction Opcode cvt.sw src.s.r, dst.w.w Convert Short Real to Word 5F-01 cvt.lw src.l.r, dst.w.w Convert Long Real to Word 5F-09 Operation Addressing Modes dst src Addressing Mode src dst Rn O Description [Rn] O O The source operand is converted to the word data type. [Rn + ] O The integer and floating point condition codes are [-Rn] O O updated to reflect the result of the operation. disp [ Rn/PC ] O [ disp [ Rn/PC ] ] O Condition Codes displ [ disp2 [ Rn/PC ] ] O /addr O O CY OV [ /addr ] O O — * * * [Rn](Rx) O O disp [ Rn/PC ]( Rx ) O O CY Unchanged [ disp [ Rn/PC ] ]( Rx ) O O OV Set if integer overflow occurs, otherwise cleared /addr ( Rx O O S Set if the result is negative, otherwise cleared [ /addr ]( Rx ) O ° , z Set if the result is zero, otherwise cleared Immediate.Quick A X Immediate A X FIV FZD FOV FUD FPR 86-045 * _ _ _ X Illegal Addressing Mode * A Reserved Addressing Mode FIV Set if an invalid operation is attempted, Exceptions otherwise unchanged Reserved Floating Point Operand FZD Unchanged Invalid Floating Point Operation FOV Unchanged Floating Point Precision FUD Unchanged FPR Set if a precision error occurs, otherwise unchanged Instruction Format Format II PRELIMINARY INFORMATION 7-30 1.0 CVTD.PZ Convert Decimal CVTD.PZ Syntax Instruct ton Opcode cvtd.pz src.b.r, dst.h.w, pat.b.r Convert Packed to Zoned Decimal 59*10 Operation Addressing Modes tmp[3:0] <- src[7:4] Addressing Mode src dst pat tmp[7:4] <- Rn O O - tmp[11:8] «- src[3:0] - [Rn] O O tmp[15:12] <- [Rn+] O O - dst[7:0] <- tmp[7:0] v pat[7:0] [-Rn] O O - dst[15:8] <- tmp[15:8] vpat[7:0] disp [ Rn/PC ] O - if src = then [ disp [ Rn/PC ] ] O O - Z <- Z else displ [ disp2 [ Rn/PC ] ] O O - /addr O o - Z 9 ) or ( src[1 1 :8] > 9 ) then [Rn] O o Decimal_Format_Exception [Rn+] O o dst[3:0] <- src[11:8] [-Rn] O o dst[7:4] <- src[3:0] disp [ Rn/PC ] O o if dst = then [ disp [ Rn/PC ] ] O o Z <- Z displ [ disp2 [ Rn/PC ] ] O o else /addr O o Z <- [ /addr ] O o [Rn](Rx) O o Description disp [ Rn/PC ]( Rx O o The halfword source operand is converted from zoned [ disp [ Rn/PC ] ]( Rx O o decimal format to packed decimal format and stored in /addr ( Rx O o the destination operand. [/addr](Rx) O o Prior to the conversion, the source operand is checked Immediate.Quick O X to verify thata valid BCD representation exists in the Immediate O X lower nibbles of the upper and lower bytes. The upper 86-054 X Addressing Mode Illegal nibbles are then compared upper nibble of the to the - Unavailable Addressing Mode mask pattern. If either condition exists, a Decimal Format exception will occur and the destination will remain Exceptions unchanged. Decimal Format Condition Codes CY OV _ _ — * CY Unchanged OV Unchanged S Unchanged Z Unchanged if the destination is zero, otherwise cleared Instruction Format Format Vile 7-32 1.0 PRELIMINARY INFORMATION DBcc Decrement and Conditionally Branch DBcc Syntax Instruction Opcode dbcc Rn.w.rw, disp16 Decrement and Branch on Condition C6«x/C7«x Operation Condition Codes Rn <- Rn - 1 CY OV s z if ( condition and Rn * ) then PC <- PC + sign_extended( disp16 else PC <- NextPC CY Unchanged OV Unchanged S Unchanged Description Z Unchanged The specified general purpose register is decremented and not zero and the specified condition is met, the if Instruction Format branch is taken. Format VI The PC relative addressing mode is implicitedly selected by these instructions. The 16-bit displacement field is Mnemonic Condition Opcode sign extended to 32 bit length and added to the PC to DBGT ( ( S © OV ) v Z ) = C7«7 compute the target address. The value of the PC used DBGE ( S © OV ) = C7»6 DBLT ( S © OV ) - 1 C6.6 to compute the target address is the first byte of the DBLE ( ( S © OV v Z - 1 ) ) C6-7 decrement and branch instruction. DBH ( CY v Z - ) C7«3 DBNL CY = C7«1 Mnemonic Condition DBL CY=1 C6»1 DBNH ( CY v Z ) = 1 C6<3 Signed DBGT Branch Greater if DBE Z=1 C6-2 DBGE Branch Greater or Equal if DBNE Z- C7«2 DBLT Branch if Less DBV OV » 1 C6«0 DBLE Branch if Less or Equal DBNV OV = C7-0 Unsigned DBH Branch ifHigher DBN S = 1 C6»4 DBNL Branch if Not Lower DBP S- C7»4 DBL Branch Lower if DBC CY=1 C6-1 DBNH Branch ifHot Higher DBNC CY - C7»1 DBZ Z= 1 C6»2 Flags DBE Branch Equal if DBNZ Z= C7-2 DBNE Branch if Not Equal DBR Always C6«5 DBV Branch Overflow if DBNV Branch No Overflow if DBN Branch if Negative Exceptions DBP Branch Positive if None DBC Branch Carry if DBNC Branch if No Carry DBZ Branch Zero if DBNZ Branch if Not Zero DBR Unconditional Branch 7-33 PRELIMINARY INFORMATION 1.0 DEC Decrement DEC Syntax Instruction Opcode dec.b dst.b.rw Decrement Byte DO/1 dec.h dst.h.rw Decrement Halfword D2/3 dec.w dst.w.rw Decrement Word D4/5 Operation Addressing Modes dst dst-1 Addressing Mode dst Rn O Description [Rn] O The contents, of the destination operand are [Rn+] O decremented. [-Rn] If the immediate quick addressing mode is specified for disp [ Rn/PC ] O the source operand, the immediate data is zero [ disp [ Rn/PC ] ] O extended to the source operand length before displ [ disp2 [ Rn/PC ] ] performing the operation. /addr The DEC instruction is a shorter encoding for the more [/addr] O general instruction [Rn](Rx) disp [ Rn/PC ]( Rx ) sub #1,dst disp [ Rn/PC ] ]( Rx ) O [ /addr ( Rx O Condition Codes [ /addr ]( Rx ) O CY OV Immediate.Quick X * * * * Immediate X X Illegal Addressing Mode B6-056 CY Set if a borrow is generated, otherwise cleared OV Set if integer overflow occurs, otherwise cleared Exceptions S Set if the result is negative, otherwise cleared None Z Set if the result is zero, otherwise cleared Instruction Format Format III PRELIMINARY INFORMATION 7-34 1.0 DISPOSE Dispose DISPOSE Syntax Instruction Opcode dispose Dispose Stack Frame CC Operation SP <- FP FP <- [SP+] Description The DISPOSE instruction deletes the current stack frame by copying the contents of the frame pointer (R30) to the stack pointer (R31) and restoring the original frame pointer from the stack. Condition Codes CY OV S z CY Unc hanged OV Unc hanged S Unc hanged Z Unc hanged Instruction Format Format V Exceptions None 1.0 7-35 PRELIMINARY INFORMATION DIV Divide DIV Syntax Instruction Opcode div.b src.b.r, dst.b.rw Divide Byte A1 div.h src.h.r, dst.h.rw Divide Halfword A3 div.w src.w.r, dst.w.rw Divide Word A5 Operation Addressing Modes dst dst + src Addressing Mode src dst Rn O O Description [Rn] The contents of the destination operand is replaced with [Rn+] O O the quotient of the source and destination operands. [-Rn] O The quotient is computed according to the rules of disp [ Rn/PC ] O O signed division. Overflow occurs when the negative [ disp [ Rn/PC ] ] maximum integer is divided by -1 displ [ disp2 [ Rn/PC ] ] O The destination will remain unchanged if an integer /addr O O overflow or Zero Divide exception occurs. [ /addr O [Rn](Rx) If the immediate quick addressing mode is specified for disp [ Rn/PC ]( Rx ) the source operand, the immediate data is zero disp [ Rn/PC ] ]( Rx ) extended to the source operand length before [ performing the operation. /addr ( Rx O [ /addr ]( Rx ) Condition Codes Immediate.Quick O X Immediate X CY OV X Illegal Addressing Mode 86-046 _ * * * Exceptions CY Unchanged Zero Divide OV Set if integer overflow occurs, otherwise cleared S Set if the result is negative, otherwise cleared z Set if the result is zero, otherwise cleared Instruction Format Format I, II PRELIMINARY INFORMATDN 7-36 1.0 DIVF Divide Floating DIVF Syntax Instruction Opcode divf.s src.s.r, dst.s.rw Divide Short Real 501B divf.l src.l.r, dst.l.rw Divide Long Real 5E-1B Operation Addressing Modes dst dst + src Addressing Mode src dst Rn O Description [Rn] O O The quotient of the source operand and destination [Rn + ] operand is stored in the destination operand. Both the [-Rn] O O integer and floating point condition codes are updated to disp [ Rn/PC ] O reflect the result of the operation. [ disp [ Rn/PC ] ] O O If the destination operand is zero and the source displ [ disp2 [ Rn/PC ] ] O O operand a non-zero normalized number, the result is /addr O O zero with the sign determined by the exclusive OR of the [/addr] O O source and destination signs. [Rn](Rx) O O disp [ Rn/PC ]( Rx ) O O Condition Codes [ disp [ Rn/PC ] ]( Rx ) O O /addr ( Rx O O CY OV [/addr](Rx) O o * * * Immediate.Quick A X Immediate A X CY Set if the result is negative and non-zero, X Illegal Addressing Mode otherwise cleared A Reserved Addressing Mode OV Cleared S Set if the mantissa sign bit of the result is set, otherwise cleared Instruction Exceptions Z Set if the result is zero, otherwise cleared Reserved Floating Point Operand Invalid Floating Point Operation FIV FZD FOV FUD FPR Floating Point Divide by Zero * * * * * Floating Point Overflow Floating Point Underflow Floating Point Precision FIV Set if an invalid operation occurs, otherwise unchanged FZD Set if division by zero occurs* otherwise unchanged FOV Set if the result is infinite, otherwise unchanged FUD Set if the destination result is denormal, otherwise unchanged FPR Set if a precision error occurs, otherwise unchanged Instruction Format Format II 1.0 7-37 PRELIMINARY INFORMATION DIVU Unsigned Divide DIVU Syntax Instruction Opcode divu.b src.b.r, dst.b.rw Divide Unsigned Byte B1 divu.h src.h.r, dst.h.rw Divide Unsigned Hatfword B3 divu.w src.w.r, dst.w.rw Divide Unsigned Word B5 Operation Addressing Modes dst dst + src (unsigned) Addressing Mode src dst Rn O Description [Rn] O The contents of the destination operand is replaced with [Rn+] the quotient of the source and destination operands. [-Rn] The quotient is computed according to the rules of disp [ Rn/PC ] O unsigned division. [ disp [ Rn/PC ] ] O The destination will remain unchanged if a Zero Divide displ [ disp2 [ Rn/PC ] ] O O exception occurs. /addr O O If the immediate quick addressing mode is specified for [ /addr ] O O the source operand, the immediate data is zero [Rn](Rx) o extended to the source operand length before disp [ Rn/PC ]( Rx ) O o performing the operation. [ disp [ Rn/PC ] ]( Rx ) o /addr ( Rx O o [ /addr ]( Rx ) O o Condition Codes Immediate.Quick X CY ov Immediate O X - * * X Illegal Addressing Mode 86-046 CY Unchanged Exceptions OV Cleared Zero Divide S Set if the result is negative, otherwise cleared Z Set if the result is zero, otherwise cleared Instruction Format Format I, II PRELIMINARY INFORMATION 7-38 1.0 DIVX Divide Extended DIVX Syntax Instruction Opcode divx src.w.r, dst.d.rw Divide Extended A6 Operation Addressing Modes dst dst + src Addressing Mode src dst Rn O Description [Rn] O The doubleword contents of the destination operand is [Rn+] divided by the word contents of the source operand [-Rn] O according to the rules of signed division. The resulting disp [ Rn/PC ] O 32-bit quotient is stored in the lower word of the [ disp [ Rn/PC ] ] O O destination and the 32-bit remainder is stored in the displ [ disp2 [ Rn/PC ] ] O O upper word of the destination. /addr O O 63 [ /addr ] O O Dividend dst [Rn](Rx) O O disp [ Rn/PC ]( Rx ) O O 31 [ disp [ Rn/PC ] ]( Rx ) O O • Divisor src /addr ( Rx O O [ /addr ]( Rx ) O O 31 31 Immediate. Quick X Remainder Quotient dst Immediate O X X Illegal Addressing Mode 86-046 • Upper Word/Register • Lower Word/Register Exceptions Overflow occurs when the negative maximum integer is divided by -1 . The destination operand does not change Zero Divide when an overflow or a Zero Divide exception occurs. If the immediate quick addressing mode is specified for the source operand, the data is zero extended to the source operand length before performing the operation. Condition Codes CY OV — * * * CY Unchanged OV Set if integer overflow occurs, otherwise cleared S Set if the result is negative, otherwise cleared Z Set if the result is zero, otherwise cleared Instruction Format Format I, II 1.0 7-39 PRELIMINARY INFORMATION DIVUX Unsigned Divide Extended DiVUX Syntax Instruction Opcode divux src.w.r, dst.d.rw Divide Extended Unsigned B6 Operation Addressing Modes dst dst + src (unsigned) Addressing Mode src dst Rn O Description [Rn] O The doubleword contents of the destination operand is [Rn+] O divided by the word contents of the source operand [-Rn] according to the rules of unsigned division. The disp [ Rn/PC ] O resulting 32-bit quotient is stored in the lower word of the [ disp [ Rn/PC ] ] O O destination and the 32-bit remainder is stored in the displ [ disp2 [ Rn/PC ] ] O upper word of the destination. /addr O O The destination operand does not change when an [ /addr O O overflow or a Zero Divide exception occurs. [Rn](Rx) O disp [ Rn/PC ]( Rx ) If the immediate quick addressing mode is specified for disp [ Rn/PC ] ]( Rx ) O o source operand, the immediate data is zero [ the /addr ( Rx o extended to the source operand length before performing the operation. [ /addr ]( Rx ) o Immediate. Quick o X Immediate X Condition Codes 86-046 X Illegal Addressing Mode CY OV _ * * * Exceptions Zero Divide CY Unchanged OV Set if integer overflow occurs, otherwise cleared S Set if the result is negative, otherwise cleared z Set if the result is zero, otherwise cleared Instruction Format Format I, II 7-40 1.0 PRELIMINARY INFORMATION EXTBF Extract Bit Field EXTBF Syntax Instruction Opcode extbfs bsrc.w.r, blen.b.r, dst.w.w Extract Sign Extended Bit Field 5D-08 extbfz bsrc.w.r, blen.b.r, dst.w.w Extract Zero Extended Bit Field 5D-09 extbfl bsrc.w.r, blen.b.r, dst.w.w Extract Left Justified Bit Field 5D-0A Operation Addressing Modes dst bitfield Bit Address bsrc blen dst Byte Address Rn X O O Rn Description @[Rn] O - [Rn] @[ Rn+ o - o [Rn+] The designated bit field is extracted using the specified ] @[-Rn] - o [-Rn] mode and stored in the destination operand. offset@[ Rn ] o - o disp[ Rn ] If the bit field length is zero, zero will be stored in the offset@[ PC ] o - disp[ PC ] destination operand. @[ disp[ Rn ] ] o - o [dbpIRn]] The sum of the bit offset and the bit field length must not - @[disp[PC]] o [disp[PC]] exceed thirty-two, otherwise an Illegal Data Field - offset<3>[ disp[ Rn ] ] o o disp1[disp2[Rn]] exception will occur. offset@[ disp[ PC ] ] o - o disp1[disp2[PC]] @/addr o - o /addr Condition Codes - @[ /addr ] o o [ /addr ] CY ov s z Rx@[ Rn ] o - o [Rn](Rx) - - - - Rx(3>[ Rn ] o - o disp [ Rn ]( Rx ) Rx@[ PC ] o - o disp [ PC ]( Rx ) Rx@[ disp[ Rn o - o disp[ Rn ] ]( Rx ) CY Unchanged ] ] [ OV Unchanged Rx@[ disp[ PC ] ] o - o [ disp[ PC ] ]( Rx ) S Unchanged Rx(2>/addr o - /addr ( Rx z Unchanged Rx@[ /addr o - o /addr ]( Rx ) ] [ Immediate. Quick X - X Immediate.Quick Instruction Format Immediate X X Immediate Format VI lb X Illegal Addressing Mode - Unavailable Addressing Mode Exceptions Illegal Data Field 7-41 PRELIMINARY INFORMATION 1.0 GETATE Get Area Table Entry GETATE Syntax Instruction Opcode getate va.ptr.r, dst.d.w Get Area Table Entry 05 Operation Addressing Modes dst ATE(va) Addressing Mode va dst Rn O Description [Rn] The contents of specified ATE are transferred to the [Rm-1 O O doubleword destination operand. The virtual address [-Rn] O O and the section designator register (R28) are used to disp [ Rn/PC ] O identify the ATE to be referenced. [ disp [ Rn/PC ] ] If the contents of R28 are OFFFFFFFFH, the virtual displ [ disp2 [ Rn/PC ] ] O o address operand is translated using the current virtual /addr O address space. Following the execution of the [/addr] o instruction, the Z flag updated to reflect the result of is [Rn](Rx) O the translation operation. The Z flag is cleared if the disp [ Rn/PC ]( Rx ) o translation is successful and set if the referenced [ disp [ Rn/PC ] ]( Rx ) O o ATBR/ATLR is invalid. /addr ( Rx O o Otherwise, R28 is assumed to contain a pointer to an [ /addr ]( Rx ) O o area table and a lookup of the specifed ATE is Immediate.Quick X performed. No validity checks are performed on the Immediate O X contents of the ATE. X Illegal Addressing Mode 86-078 Ifthe immediate quick addressing mode is specified, the immediate data is zero extended to 32-bit length and Exceptions used as the virtual address. Privileged Instruction This instruction can be executed in either the real or virtual address mode. Condition Codes CY OV _ _ — * CY Unchanged OV Unchanged S Unchanged Z Set if the address translation is invalid, otherwise cleared Instruction Format Format I, II 7-42 1.0 PRELIMINARY INFORMATION GETPSW Get PSW GETPSW Syntax Instruction Opcode getpsw dst.w.w Get Program Status Word F6/7 Operation Addressing Modes dst PSW Addressing Mode dst Rn O Description [Rn] O The contents of the Program Status Word (PSW) are [Rn+] O copied to the destination operand. [-Rn] O disp [ Rn/PC ] Condition Codes [ disp [ Rn/PC ] ] displ [ disp2 [ Rn/PC ] ] O CY ov s z /addr - - - - [/addr] o [Rn](Rx) o CY Unchanged disp [ Rn/PC ]( Rx ) o OV Unchanged disp [ Rn/PC ] ]( Rx ) [ S Unchanged Z Unchanged /addr ( Rx ) o [ /addr ]( Rx ) o Immediate.Quick X Instruction Format Immediate X Format III X Illegal Addressing Mode 86-056 Exceptions None 1.0 7-43 PRELIMINARY INFORMATION GETPTE Get Page Table Entry GETPTE Syntax Instruction Opcode getpte va.ptr.r, dst.w.w Get Page Table Entry 04 Operation 1 nstruction Format dst <- PTE( va Format 1, II Description i Addressing Modes Addressing Mode va dst The contents of specified PTE are transferred to the word destination operand. The virtual address and the Rn O section designator register (R28) are used to identify the [Rn] O O PTE to be referenced. [Rn+] O Ifthe contents of R28 are OFFFFFFFFH, the virtual I-Rn] O o address operand is translated using the current virtual disp [ Rn/PC ] O o address space. Following the execution of the [ disp [ Rn/PC ] ] O o instruction, the CY and Z flags are updated to reflect the displ [ disp2 [ Rn/PC ] ] O o result of the translation operation. The CY flag will be set /addr O o if the area is not present (i.e. swapped out to a disk) while [/addr] O o the Z flag is set if the referenced address translation fails. [Rn](Rx) O o If either the Z or CY flags are set, the destination remains disp [ Rn/PC ]( Rx ) o * unchanged. [ disp [ Rn/PC ] ]( Rx ) O o Otherwise,R28 is assumed to contain a pointer to an /addr ( Rx area table and a lookup of the specifed PTE is [ /addr ]( Rx ) O o performed. No validity checks are performed on the Immediate. Quick X contents of the PTE. Immediate X the immediate quick addressing mode is specified, the If X Illegal Addressing Mode 66-078 immediate data is zero extended to 32-bit length and used as the virtual address. Exceptions This instruction can be executed in either the real or Privileged Instruction virtual address mode Condition Codes CY OV * _ - * CY Set if the area is not present, otherwise cleared OV Unchanged S Unchanged z Set if the address translation is invalid, otherwise cleared 7-44 1.0 PRELIMINARY INFORMATION GETRA Get Real Address GETRA Syntax Instruction Opcode getra va.ptr.r, dst.w.w Get Real Address 03 Operation Condition Codes dst real_address( va CY OV * — — * Description The physical address of the source virtual address is CY Set if the area is not present, otherwise cleared computed and transferred to the destination operand. OV Unchanged The virtual address and the section designator register S Unchanged Z Set if the address translation is invalid, otherwise (R28) are used to identify the area table used to perform cleared the address translation. If the contents of R28 are OFFFFFFFFH, the virtual Addressing Modes address operand is translated using the current virtual Addressing Mode va dst address space. Following the execution of the instruction, the CY and Z flags are updated to reflect the Rn O result of the translation operation. The CY flag will be set [Rn] O ifthe area or page is not present (i.e. swapped out to a [Rn+] O disk) while the Z flag is set if the address translation fails [-Rn] O ,/i.e, an invalid area table or the page is I/O mapped). If disp [ Rn/PC ] O either the Z or CY flags are set, the destination operand [ disp [ Rn/PC ] ] O remains unchanged. displ [ disp2 [ Rn/PC ] ] O Otherwise, R28 is assumed to contain a pointer to an /addr area table and the PTE is located in the specified page [/addr] table. No validity checks are performed on the contents [Rn](Rx) O of the PTE and no data reference is made. disp [ Rn/PC ]( Rx ) O If the immediate quick addressing mode is specified, the [ disp [ Rn/PC ] ]( Rx ) O immediate data is zero extended to 32-bit length and /addr ( Rx O O used as the virtual address. [ /addr ]( Rx ) O O Immediate. Quick X This instruction can be executed in either the real or the virtual address mode. Immediate O X X Illegal Addressing Mode Instruction Format Exceptions Format I, II Privileged Instruction 1.0 7-45 PRELIMINARY INFORMATION HALT Halt HALT Syntax Instruction Opcode halt Halt and Wait for Interrupt 00 Operation halt Description The processor halts and waits for an interrupt. Following the execution of the interrupt handler, program execution will continue with the instruction following the HALT instruction. Condition Codes CY OV s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format V Exceptions Privileged Instruction PRELIMINARY INFORMATION 7-46 1.0 IN Input IN Syntax Instruction Opcode in.b port.b.r, dst.b.w Input Byte 21 in.h port.h.r, dst.h.w Input Halfword 23 In.w port.w.r, dst.w.w Input Word 25 Operation Addressing Modes dst <- port Addressing Mode port dst Rn X o Description [Rn] O o The contents of the specified input port are copied to [Rn+] o o the destination operand. [-Rn] o o disp [ Rn/PC ] o o Condition Codes [ disp [ Rn/PC ] ] o o displ [ disp2 [ Rn/PC ] ] o o CY ov s z /addr o o - - - - [/addr] o o [Rn](Rx) o o CY Unchanged disp [ Rn/PC ]( Rx ) o o OV Unchanged [ disp [ Rn/PC ] ]( Rx ) o o S Unchanged Unchanged /addr ( Rx o Z [ /addr ]( Rx ) o o Immediate.Quick X X Instruction Format Immediate X X Format I, II X Illegal Addressing Mode Exceptions Privileged Instruction 7-47 PRELIMINARY INFORMATION 1.0 INC Increment INC Syntax Instruction Opcode inc.b dst.b.rw Increment Byte D8/9 inch dst.h.rw Increment Halfword DA/B inc.w dst.w.rw Increment Word DC/D Operation Addressing Modes dst <- dst + Addressing Mode dst Rn Description [Rn] O The contents of the destination operand are [Rn+] O incremented. [-Rn] disp [ Rn/PC ] If the immediate quick addressing mode is specified for the source operand, the immediate data is zero [ disp [ Rn/PC ] ] O displ [ disp2 [ Rn/PC ] ] extended to the source operand length before /addr performing the operation. [ /addr ] The INC instruction is a shorter encoding for the more [Rn](Rx) general instruction disp [ Rn/PC ]( Rx ) add #1 , dst [ disp [ Rn/PC ]](Rx) /addr ( Rx O Condition Codes [ /addr ]( Rx ) o J Immediate.Quick X CY OV * * Immediate X * * X Illegal Addressing Mode 86-056 CY Set if a carry is generated, otherwise cleared OV Set if integer overflow occurs, otherwise cleared Instruction Exceptions S Set if the result is negative, otherwise cleared None z Set if the result is zero, otherwise cleared Instruction Format Format III 7-48 1.0 PRELIMINARY INFORMATION INSBF Insert Bit Field INSBF Syntax Instruction Opcode insbfr src.w.r, bdst.w.rw, blen.b.r Insert Right Justified Bit Field 5D-18 insbfl src.w.r, bdst.w.rw, blen.b.r Insert Left Justified Bit Field 5D-19 Operation Addressing Modes bitfield src Bit Address bsrc blen src Byte Address Rn X o Rn Description @[ Rn ] O - o [Rn] Rn+ ] O - o [Rn+] The source operand is converted to a bit field of <§>[ specified length and stored in the destination operand. @[-Rn] - [-Rn] offset@[ Rn ] O - o disp[ Rn ] No transfer will occur if the bit field length is zero. offset@[ PC ] O - o disp[ PC ] The sum of the bit offset and the bit field length must not - @[ disp[ Rn ] ] O o [ disp[ Rn ] ] exceed thirty-two, otherwise an Illegal Data Field @[disp[PC]] O - o [disp[PC]] exception will occur. offset@[ disp[ Rn ] ] o - o disp1[disp2[Rn]] If the immediate quick addressing mode is specified for - offset@[ disp[ PC ] ] o disp1[disp2[PC]] the source operand, the immediate data is zero - @/addr o o /addr extended to the word length before performing the - <3>[ /addr ] o [ /addr ] insertion operation. Rx@[ Rn ] o - o [Rn](Rx) Rx<3>[ Rn ] o - o disp [ Rn ]( Rx ) Condition Codes Rx@[ PC o - o disp [ PC ]( Rx ) ] CY ov s z Rx@[ disp[ Rn ] ] o - o [ disp[ Rn ] ]( Rx ) - - - - Rx<3>[ disp{ PC ] ] - o [disp[PC]](Rx) Rx@/addr o - o /addr ( Rx Rx<3>[ /addr ] o - o /addr ]( Rx ) CY Unchanged [ OV Unchanged Immediate. Quick X - o Immediate.Quick S Unchanged Immediate X o o Immediate z Unchanged X Illegal Addressing Mode 86-051 - Unavailable Addressing Mode Instruction Format Format Vile Exceptions Illegal Data Field 1.0 7-49 PRELIMINARY INFORMATION JMP Jump JMP Syntax Instruction Opcode jmp target.b.ex Jump D6/7 Operation Addressina Modes PC <- target Addressing Mode target Rn X Description [Rn] O The effective address of the destination is computed [Rn+] and program control is transferred unconditionally to the [-Rn] o destination. disp [ Rn/PC ] o The destination operand is treated as byte data for the [ disp [ Rn/PC ] ] o purpose of computing pointer changes for the displ [ disp2 [ Rn/PC ] ] autoincrement, autodecrement, or scaled indexed /addr addressing modes. [ /addr ] [RnKRx) disp [ Rn/PC ]( Rx ) Condition Codes [ disp [ Rn/PC ] ]( Rx ) o CY ov s z /addr ( Rx - - - - [/addr](Rx) Immediate.Quick X CY Unchanged Immediate X OV Unchanged X Illegal Addressing Mode 66-671 S Unchanged z Unchanged Exceptions Instruction Format None Format III PRELIMINARY INFORMATION 7-50 1.0 JSR Jump to Subroutine JSR Syntax Instruction Opcode jsr target. b.ex Jump to Subroutine E8/9 Operation Addressing Modes temp <- target Addressing Mode target [-SP] <- NextPC Rn X PC <- temp [Rn] O [Rn+] Description [-Rn] o The effective address of the destination is computed disp [ Rn/PC ] o and the address of the next instruction is pushed onto [ disp [ Rn/PC ] ] o the stack. Program control is then transferred to the displ [ disp2 [ Rn/PC ] ] o destination. /addr o The destination operand is treated as byte data for the [ /addr ] o purpose of computing pointer changes for the [Rn](Rx) autoincrement, autodecrement, or scaled indexed disp [ Rn/PC ]( Rx ) addressing modes. [ disp [ Rn/PC ] ]( Rx ) If the destination operand is addressed using R31 (SP) /addr ( Rx o In conjunction with an autoincrement/autodecrement [ /addr ]( Rx ) o addressing mode, the result is unpredicable. Immediate.Quick X Immediate x Condition Codes X Illegal Addressing Mode 66-671 CY ov s z Exceptions - - - - None CY Unchanged OV Unchanged S Unchanged Z Unchanged instruction Format Format III 1.0 7-51 PRELIMINARY INFORMATION LDPR Load Privileged Register LDPR Syntax Instruction Opcode Idpr src.w.r, reglD.w.w Load Privileged Register 12 Operation Condition Codes PrivilegedRegister( regID src CY ov Description The source operand is loaded into the specified CY Unchanged privileged register. OV Unchanged S Unchanged ID Register Name z Unchanged ISP Interrupt Stack Pointer 1 LOSP Level Stack Pointer L1SP Level 1 Stack Pointer Instruction Format 2 3 L2SP Level 2 Stack Pointer Format I, II 4 L3SP Level 3 Stack Pointer 5 SBR System Base Register 7 SYCW System Control Word Addressing Modes 8 TKCW Task Control Word Addressing Mode src regID 15 PSW2 Emulation Mode Program Status Word 16 ATBRO Area Table Base Register Rn O 17 ATLRO Area Table Length Register [Rn] O ' 18 ATBR1 Area Table Base Register 1 [Rn+] O o 19 ATLR1 Area Table Length Register 1 [-Rn] o 20 ATBR2 Area Table Base Register 2 disp [ Rn/PC ] O o 21 ATLR2 Area Table Length Register 2 [ disp [ Rn/PC ] ] O 22 ATBR3 Area Table Base Register 3 23 ATLR3 Area Table Length Register 3 displ [ disp2 [ Rn/PC ] ] o 24 TRMOD Trap Mode Register /addr O o 25 ADTRO Address Trap Register [ /addr ] O 26 ADTR1 Address Trap Register 1 [Rn](Rx) o 27 ADTRMO Address Trap Mask Register disp [ Rn/PC ]( Rx ) O 28 ADTRM1 Address Trap Mask Register 1 [ disp [ Rn/PC ] ]( Rx ) o /addr ( Rx O o A number of restrictions and precautions relating to the [ /addr ]( Rx ) o execution of the LDPR instruction are listed below : Immediate.Quick O Immediate • Loading to area table base and length registers 86-086 clears TLB entries with corresponding section numbers. • The TLB is cleared if the virtual mode is changed to Exceptions physical mode in the STCW register. Privileged Instruction Illegal Data Field Instruction execution results are unpredicatable if an invalid register ID is specified. 7-52 1.0 PRELIMINARY INFORMATION LDTASK Load Task LDTASK Syntax Instruction Opcode Idtask list.w.r, TCBptr.w.r Load Task Context 01 Operation Condition Codes TaskContext <- [TCBJ CY OV s z - - - - Description CY Unchanged The context designated by the TCB pointer is installed OV Unchanged as the current task context. The task context consists of: S Unchanged • General purpose registers (R30-R0) 2 Unchanged The general purpose registers of the new task context controlled by the list operand. is The Instruction Format register list is scanned sequentially from the LSB to Format I, II the MSB. The bits set in the list operand Identify which general purpose registers are restored. Bit 31 of the register list is Reserved for Future Use and Addressing Modes must be zero. Addressing Mode list TCBptr J rrrrRRRRRRRRRRRRRRRRRRRRRRRRRRRR i i i i i mi i i i i i i i i i i ii i i i i ' ' ' ' ' ' Rn O O F322 2222222 211111111119876S43210 [Rn] O O 00987654 3-2109876543210 86-130 [Rn + ] O O [-Rn] O O Area table register pairs disp [ Rn/PC ] O O The base and length registers area table [ disp [ Rn/PC ] O O (ATBR0/ATLR0 to ATBR3/ATLR3) are restored as displ [ disp2 [ Rn/PC ] ] O O specified by the STCW register if virtual mode is /addr o O enabled and any TLB entries associated with the 3 [/addr] o o updated sections are marked as invalid. In real mode, area table registers are not stored in the task [Rn](Rx> o o context. disp [ Rn/PC ]( Rx o o [ disp [ Rn/PC ] ]( Rx ) o o Stack pointers (L0SP-L3SP) /addr ( Rx o o The stack pointers enabled for switching in the [ /addr ]( Rx ) o o STCW are restored- If the current context is using Immediate.Quick o o the interrupt stack, LOSP will become the new stack Immediate o o pointer. 86-083 Task Control Word (TKCW) The TKCW is updated with the Task Control Word for Exceptions the new context. Privileged Instruction 7-53 PRELIMINARY INFORMATION 1.0 MOV Move MOV Syntax Instruction Opcode mov.b src.b.r, dst.b.w Move Byte 09 mov.h src.h.r, dst.h.w Move Hatfword 1B mov.w src.w.r dst.w.w Move Word 2D mov.d src.d.r, dst.d.w Move Doubleword 3F Operati on Addressing Modes dst <- src Addressing Mode src dst Rn Description [Rn] O The data designated by the source operand is copied to [Rn + ] O the destination operand. [-Rn] O If the immediate quick addressing mode is specified for disp [ Rn/PC ] O O the source operand, the immediate data is zero [ disp [ Rn/PC ] ] O O extended to the source operand length before being displ [ disp2 [ Rn/PC ] ] O O transferred to the destination. /addr O O On the nPD70616 microprocessor, a Reserved [/addr] O O Addressing Mode exception will occur the immediate or if [Rn](Rx) O O disp [ Rn/PC ]( Rx ) immediate quick addressing mode is specified for a doubleword source operand. [ disp [ Rn/PC ] ]( Rx ) O o /addr ( Rx O o [ /addr ]( Rx ) O Condition Codes Immediate.Quick A X CY ov s z Immediate A X - - - - X Illegal Addressing Mode A Reserved Addressing Mode CY Unchanged OV Unchanged Exceptions S Unchanged None Z Unchanged Instruction Format Format I, II PRELIMINARY INFORMATION 7-54 1.0 MOVBS MOve Bit String MOVBS Syntax Inst met ion Opcode movbsu bsrc.b.r, blen.b.r, bdst.b.w Move Bit String (Upward) 5B-08 movbsd bsrc.b.r, blen.b.r, bdsT.b.w Move Bit String (Downward) 5B-09 Operation Addressing Modes bdst bsrc Addressing Mode bsrc blen bdst Rn X O X Description @[Rn] O - O The source bit string is copied to the destination bit <§>[ Rn+ ] o - o string. Specifying the direction of the operation allows @[-Rn] - the correct result to be computed when the two bit offset@[ Rn/PC ] o - o strings overlap. @[ disp Rn/PC [ ] ] o - o offset@[ disp [ Rn/PC ] ] o - o To minimize the interrupt latency time, the MOVBS and faults @/addr o - o instruction allows the service of interrupts following the completion of a bus cycle. After servicing <§>[ /addr ] o - o the interrupt or correction of the fault condition, Rx<3>[ Rn ] o - o instruction execution continues from the point of Rx@[ Rn/PC ] - o interruption. Rx@[ disp Rn/PC [ ] ] o - o Rx@/addr o - During the execution of the MOVBS instruction, Rx@[ /addr o - o registers R28 and R27 contain pointers to the bytes ] within the source and destination bit strings to be Immediate.Quick X - X processed next. Following the execution of the Immediate X o X instruction, R28 contains the address of the byte X Illegal Addressing Mode - Unavailable Addressing Mode containing the final bit of the source bit string while R27 contains the address of the byte containing the final bit of the destination bit string. Exceptions None Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format Vllb 1.0 7-55 PRELIMINARY INFORMATION MOVC Move Character MOVC Syntax Instruction Opcode movcu.b src.b.r, slen.b.r, dst.b.w, dlen.b.r Move Byte Character Upward 58-08 moved, b src.b.r, slen.b.r, dst.b.w, dlen.b.r Move Byte Character Downward 58-09 movcu.h src.h.r, slen.b.r, dst.h.w, dlen.b.r Move Halfword Character Upward 5A-08 moved, h src.h.r, slen.b.r, dst.h.w, dlen.b.r Move Halfword Character Downward 5A-09 Operation Addressing Modes dst sre Addressing Mode sre slen dst dlen Rn X X Description [Rn] - O - The source character string is copied to the destination [Rn+] - - character string. The source and destination length [-Rn] o - o - parameters indicate the number of characters to be disp [ Rn/PC ] o - - transferred rather than the number of bytes to be [ disp [ Rn/PC ] ] o - - transferred. displ [ disp2 [ Rn/PC ] ] o - o - Character string transfers are initiated from the head of /addr o - o - the strings in the address increment mode and from the [/addr] o - - end of the strings in the address decrement mode. tail [Rn](Rx) o - o - The number of characters copied is the minimum of the disp [ Rn/PC ]( Rx ) - - source and the destination string lengths. [ disp [ Rn/PC ] ]( Rx o - - /addr ( Rx - o ~ This instruction is and resumable with interruptable [/addr](Rx) o - o - registers R28 and R27 used to maintain the source and J destination addresses respectively. Following the Immediate.Quick X - X - execution of the MOVC instruction, these registers Immediate X o X 86-048 contain the address of the next logical character to be X Illegal Addressing Mode - Unavailable Addressing Mode transferred. Condition Codes Exceptions Illegal Data Field CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format Vila PRELIMINARY INFORMATION 7-56 1.0 MOVCF Move Character with Filler MOVCF Syntax Instruction Opcode movcfu.b src.b.r, slen.b.r, dst.b.w, dlen.b.r Move Byte Character with Filler Upward 58*0 A movcfd.b src.b.r, slen.b.r, dst.b.w, dlen.b.r Move Byte Character with Filler Downward 58- OB movcfu.h src.h.r, slen.b.r, dst.h.w, dlen.b.r Move Halfword Character with Filler Upward 5A»0A movcfd.h src.h.r, slen.b.r, dst.h.w, dlen.b.r Move Halfword Character with Filler Downward 5A»0B Operation Addressing Modes dst src Addressing Mode src slen dst dlen Rn X o X Description [Rn] o - o - [Rn+] o - o - The source character string is copied to the destination The shorter of the source and [-Rn] o - o - character string. destination lengths determines the number of characters disp [ Rn/PC ] o - o - to be transferred with any additional positions in the [ disp [ Rn/PC ] ] o - o - destination string filled using the fill character in R26. displ [ disp2 [ Rn/PC ] ] o - o - /addr o - o - Character string transfers are initiated from the head of [/addr] o - o - the strings in the address increment mode and from the (Rn](Rx) o - o - tail end of the strings in the address decrement mode. disp [ Rn/PC ]( Rx ) - - This instruction is and resumable with interruptable disp [ Rn/PC ]](Rx) o - o - registers R28 and R27 used to maintain the source and [ /addr ( Rx - o - destination addresses respectively. Following the /addr ]( Rx ) o - o - execution of the MOVCF instruction, these registers [ Immediate.Quick X - X - contain the address of the next logical character to be transferred. Immediate X o X 86^048 - Unavailable Addressing Mode Condition Codes CY ov s z Exceptions - - - - Illegal Data Field CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format Vila 7-57 PRELIMINARY INFORMATION 1.0 MOVCS Move Character with Stopper MOVCS Syntax Instruction Opcode moves. src.b.r, slen.b.r, dst.b.w, dlen.b.r Move Byte Character with Stopper 58«0C movcs.h src.h.r, slen.b.r, dst.h.w, dlen.b.r Move Halfword Character with Stopper 5A-0C Operation Addressing Modes dst sre Addressing Mode sre slen dst dlen Rn X O X Description [Rn] O - - The source character string is copied to the destination [Rn+] O - - string until the end of the source or destination string is [-Rn] O o - reached or the stop character specified by R26 is disp [ Rn/PC ] O - - detected in the source string. The source and [ disp [ Rn/PC ] ] O - o - destination length parameters indicate the number of displ [ disp2 [ Rn/PC ] ] O - o - characters to be transferred rather than the number of /addr O - o - bytes to be transferred. [ /addr ] O - o - This instruction is and resumable with interruptable [Rn](Rx) O - o - registers R28 and R27 used to maintain the source and disp [ Rn/PC ]( Rx O - - destination addresses respectively. Following the [ disp [ Rn/PC ]](Rx) - o - execution of the MOVCS instruction, these registers /addr ( Rx - - contain the address of the next logical character to be [ /addr ]( Rx ) O - o ~ | transferred. Immediate.Quick X - X Immediate X O X I Condition Codes X Illegal Addressing Mode 86-048 - Unavailable Addressing Mode CY OV * _ _ _ Exceptions Illegal Data Field CY Cleared if the stop character is found, otherwise set OV Unchanged S Unchanged z Unchanged Instruction Format Format Vila PRELIMINARY INFORMATION 7-58 1.0 MOVEA Move Effective Address MOVEA Syntax Instruction Opcode movea.b src.b.n, dst.w.w Move Byte Effective Address 40 movea.h src.h.n, dst.w.w Move Halfword Effective Address 42 movea.w src.w.n, dst.w.w Move Word Effective Address 44 Operation Addressing Modes dst effective_address( src Addressing Mode src dst Rn X Description [Rn] o The effective address source operand is of the [Rn+] o transferred to the destination operand. The source [-Rn] o o operand is not referenced and remains unchanged. disp [ Rn/PC ] o [ disp [ Rn/PC ] ] o Separate instructions are provided for byte, halfword and displ [ disp2 [ Rn/PC ] ] o word operands to permit correct computation of effective /addr o o addresses using the autoincrement, autodecrement and scaled index addressing modes. [/addr] o o [Rn](Rx) o o disp [ Rn/PC ]( Rx ) o o Condition Codes disp [ Rn/PC ]](Rx) o o [ CY ov s z /addr ( Rx o o - - - - [ /addr ]( Rx ) o o Immediate.Quick X X Immediate X X CY Unchanged 86-04 OV Unchanged X Illegal Addressing Mode S Unchanged Z Unchanged Exceptions None Instruction Format Format I, II 7-59 PRELIMINARY INFORMATION 1.0 MOVF Move Floating MOVF Syntax Instruction Opcode movf.s src.s.r, dst.s.w Move Short Real 5O08 movf.l src.l.r, dst.l.w Move Long Real 5E-08 Operation Addressing Modes dst src Addressing Mode src dst Rn O Description [Rn] O The source operand copied to the destination is [Rn+] O operand and the flags updated to reflect the state of the [-Rn] O destination. disp [ Rn/PC ] O [ disp [ Rn/PC ] ] o Condition Codes displ [ disp2 [ Rn/PC ] ] O /addr o CY OV [/addr] O * + * [ Rn ]( Rx ) O disp [ Rn/PC ]( Rx ) O o CY Set if the destination is negative and non-zero, [ disp [ Rn/PC ]](Rx) O otherwise cleared /addr ( Rx O o OV Cleared S Set if the destination mantissa sign bit is set, [ /addr ]( Rx O 1 otherwise cleared Immediate.Quick A X Z Set if the destination is zero, otherwise cleared Immediate A X X Illegal Addressing Mode 86-045 FIV FZD FOV FUD FPR A Reserved Addressing Mode * _ _ * _ Exceptions FIV Set if the destination is a NaN or infinite, Reserved Floating Point Operand otherwise unchanged Floating Point Underflow FZD Unchanged FOV Unchanged FUD Set if the destination is denormal, otherwise unchanged FPR Unchanged Instruction Format Format II PRELIMINARY INFORMATION 7-60 1.0 MOVS Move Sign Extended MOVS Syntax Instruction Opcode movs.bh src.b.r, dst.h.w Move Sign Extended Byte to Halfword OA movs.bw src.b.r, dst.w.w Move Sign Extended Byte to Word OC movs.hw src.h.r, dst.w.w Move Sign Extended Halfword to Word 1C Operation Addressing Modes dst sign_extend( src Addressing Mode src dst Rn O Description [Rn] O The contents of the source operand are sign extended [Rn+] O to the destination length and copied to the destination [-Rn] O operand. disp [ Rn/PC ] The source and destination operand lengths differ in this [ disp [ Rn/PC ] ] O instruction. When specified, the autoincrement, displ [ disp2 [ Rn/PC ] ] O autodecrement and scaled index addressing modes are /addr O independently calculated for each operand. [/addr] O When the immediate quick addressing mode is specified [Rn](Rx) O O for thesource operand, the immediata data is zero disp [ Rn/PC ]( Rx ) O O extended to the source operand length before being [ disp [ Rn/PC ]](Rx) O O sign extended to the destination operand length. /addr ( Rx O [ /addr ]( Rx ) O O Immediate.Quick O X Condition Codes Immediate O X CY ov s z X llleg al Addressing Mode 86-046 - - - - Exceptions CY Unchanged None OV Unchanged S Unchanged Z Unchanged Instruction Format Format I, II 7-61 PRELIMINARY INFORMATION 1.0 MOVT Move Truncated MOVT Syntax Instruction Opcode movt.hb src.h.r, dst.b.w Move Truncated Halfword to Byte 19 movt.wb src.w.r, dst.b.w Move Truncated Word to Byte 29 movt.wh src.w.r, dst.h.w Move Truncated Word to Halfword 2B Operation Addressing Modes dst truncate( src Addressing Mode src dst Rn O Description [Rn] O The contents of the source operand are truncated to the [Rn+] destination operand length and copied to the [-Rn] O destination operand. If any of the truncated bits do not disp [ Rn/PC ] O match the sign of the result, an integer overflow has [ disp [ Rn/PC ] ] O O occurred and the OV flag is set. In the event of an displ [ disp2 [ Rn/PC ] ] O o overflow, the destination operand is replaced with the /addr low order bits of the true result. [/addr] o The source and destination operand lengths differ in this [Rn](Rx) O instruction. When specified, the autoincrement, disp [ Rn/PC ]( Rx ) O autodecrement and indexed addressing modes are [ disp [ Rn/PC ]](Rx) O o independently calculated for each operand. /addr ( Rx O o [ /addr ]( Rx ) O ° Condition Codes Immediate.Quick O X Immediate O X | CY OV X Illegal Addressing Mode 86-046 _ * — — Exceptions None CY Unchanged OV Set if integer overflow occurs, otherwise cleared S Unchanged Z Unchanged Instruction Format Format I, II PRELIMINARY INFORMATION 7-62 1.0 MOVZ Move Zero Extended MOVZ Syntax Instruction Opcode movz.bh src.b.r, dst.h.w Move Zero Extended Byte to Halfword OB movz.bw src.b.r, dst.w.w Move Zero Extended Byte to Word OD movz.hw src.h.r, dst.w.w Move Zero Extended Halfword to Word 1D Operation Addressing Modes dst zero_extend( src Addressing Mode src dst Rn Description [Rn] O The contents of the source operand are zero extended [Rn + ] O and copied to the destination operand. [-Rn] O disp Rn/PC [ O The source and destination operand lengths differ in this ] instruction. When specified, the autoincrement, disp [ Rn/PC ] [ ] O autodecrement and scaled index addressing modes are displ [ disp2 [ Rn/PC ] ] O o /addr independently calculated for each operand. [/addr] O When the immediate quick addressing mode is specified [Rn](Rx) O for thesource operand, the immediate data is zero extended to the destination operand length. disp [ Rn/PC ]( Rx ) O [ disp [ Rn/PC ] ]( Rx ) O /addr ( Rx o Condition Codes [ /addr ]( Rx ) O o CY ov s z Immediate.Quick O X - - - - Immediate O X 66-046 CY Unchanged OV Unchanged Exceptions S Unchanged z Unchanged None Instruction Format Format I, II 7-63 PRELIMINARY INFORMATION 1.0 MUL Signed Multiply MUL Syntax Instruction Opcode mul.b src.b.r, dst.b.rw Multiply Byte 81 mul.h src.h.r, dst.h.rw Multiply Hatfword 83 mul.w src.w.r, dst.w.rw Multiply Word 85 Operation Addressing Modes dst dst * src Addressing Mode src dst Rn O O Description [Rn] O The product of the source and destination operands is [Rn+] O O stored in the destination operand. An overflow occurs [-Rn] O when the double length intermediate product does fit disp [ Rn/PC ] O within the precision of the destination operand. [ disp [ Rn/PC ] ] O If the immediate quick addressing mode is specified for displ [ disp2 [ Rn/PC ] ] O o the source operand, the immediate data is zero /addr O extended to the source operand length before [/addr] O o performing the operation. [Rn](Rx) O o disp [ Rn/PC ]( Rx ) O o Condition Codes [ disp [ Rn/PC ] ]( Rx ) /addr ( Rx o CY OV o [ /addr ]( Rx ) — * * * Immediate.Quick O X Immediate O X I CY Unchanged V lllonal AHHroccinn Mnrlo 86-046 OV Set if integer overflow occurs, otherwise cleared S Set if the result is negative, otherwise cleared Z Set if the result is zero, otherwise cleared Exceptions None Instruction Format Format I, II PRELIMINARY INFORMATION 7-64 1.0 MULF Multiply Floating MULF Syntax Instruction Opcode mulf.s src.s.r, dst.s.rw Multiply Short Real 501A mulf.l src.l.r, dst.l.rw Multiply Long Real 5E-1A Operation Addressing Modes dst src * dst Addressing Mode src dst Rn O O Description [Rn] O O The product of the source operand and destination [Rn+] O O operand is stored in the destination operand. Both the [-Rn] o O integer and floating point condition codes are updated to disp [ Rn/PC ] O O reflect the result of the operation. [ disp [ Rn/PC ] ] o O displ [ disp2 [ Rn/PC ] ] o o If either of the operands is zero and the other operand is either zero or normal, the result is zero with the sign /addr o O determined by the exclusive OR of the source and [/addr] O O destination signs. [Rn](Rx) O O disp [ Rn/PC ]( Rx ) O o [ disp [ Rn/PC ] ]( Rx ) o o Condition Codes /addr ( Rx O o CY OV [ /addr ]( Rx ) O O * * * Immediate.Quick A X Immediate A X CY Set if the result is negative and non-zero, X Illegal Addressing Mode B6-045 otherwise cleared A Reserved Addressing Mode OV Cleared S Set if the mantissa sign bit of the result is set, Exceptions otherwise cleared Z Set if the result is zero, otherwise cleared Reserved Floating Point Operand Floating Point Overflow FIV FZD FOV FUD FPR Floating Point Underflow _ * * * Floating Point Precision * FIV Set if an invalid operation is attempted, otherwise unchanged FZD Unchanged FOV Set if the result is infinite, otherwise unchanged FUD Set if the result is denormal, otherwise unchanged FPR Set if a precision error occurs, otherwise unchanged Instruction Format Format II 7-65 PRELIMINARY INFORMATION 1.0 MULU Unsigned Multiply MULU Syntax Instruction Opcode mulu.b src.b.r, dst.b.rw Multiply Unsigned Byte 91 mulu.h src.h.r, dst.h.rw Multiply Unsigned Haffword 93 mulu.w src.w.r, dst.w.rw Multiply Unsigned Word 95 Operation Addressing Modes dst dst*src (unsigned) Addressing Mode src dst Rn O Description [Rn] O The product of the unsigned source and destination [Rn+] O operands isin the destination operand. stored An [-Rn] O o overflow occurs when the product cannot fit within the disp [ Rn/PC ] O o precision of the destination operand. [ disp [ Rn/PC ] ] o If the immediate quick addressing mode is specified for displ [ disp2 [ Rn/PC ] ] O o the source operand, the immediate data is zero /addr O extended to the source operand length before [/addr] O o performing the operation. [Rn](Rx) disp [ Rn/PC ]( Rx ) O [ disp [ Rn/PC ]](Rx) Condition Codes /addr ( Rx O CY OV [ /addr ]( Rx ) O o J — * * * Immediate.Quick O X Immediate O X CY Unchanged X Illegal Addressing Mode OV Set if integer overflow occurs, otherwise cleared S Set if the MSB of the result is set, otherwise cleared Exceptions Set if the result is zero, otherwise cleared None Instruction Format Format I, II PRELIMINARY INFORMATION 7-66 1.0 MULX Multiply Extended MULX Syntax Instruction Opcode mulx src.w.r, dst.d.rw Multiply Extended Word 86 Operation Addressing Modes dst dst * src Addressing Mode src dst Rn O Description [Rn] O The word designated by the destination operand is [Rn + ] O multiplied by the word contents of the source operand. [-Rn] O The resulting doubleword product is stored in disp [ Rn/PC ] O destination operand. [ disp [ Rn/PC ] ] O If the immediate quick addressing mode is specified for displ [ disp2 [ Rn/PC ] ] O O the source operand, the immediate data is zero /addr O extended to the source operand length before [/addr] O performing the operation. [Rn](Rx) O disp [ Rn/PC ]( Rx ) O Condition Codes [ disp [ Rn/PC ] ]( Rx ) O /addr ( Rx O CY ov [ /addr ]( Rx ) O o - * * Immediate.Quick O X Immediate O X CY Unchanged X Illegal Addressing Mode 86-046 OV Cleared S Set if the result is negative, otherwise cleared Z Set if the result is zero, otherwise cleared Exceptions None Instruction Format Format I, II 1.0 7-67 PRELIMINARY INFORMATION MULUX Unsigned Multiply Extended MULUX Syntax Instruction Opcode mulux src.w.r, dst.d.rw Multiply Extended Unsigned Word 96 Operation Addressing Modes dst dst*src (unsigned) Addressing Mode src dst Rn O Description [Rn] O O The unsigned word contents of the destination operand [Rn + ] O is multiply by the unsigned word contents of the source [-Rn] O operand. The resulting doubleword product is stored in disp [ Rn/PC ] O O the destination. [ disp [ Rn/PC ] ] O O If the immediate quick addressing mode is specified for displ [ disp2 [ Rn/PC ] ] O /addr the source operand, the immediate data is zero extended to the source operand length before [/addr] O performing the operation. [Rn](Rx) O disp [ Rn/PC ]( Rx ) O O [ disp [ Rn/PC ]](Rx) Condition Codes /addr ( Rx O CY ov [/addr](Rx) O O 1 - * * Immediate.Quick O X Immediate O X CY Unchanged X Illegal Addressing Mode 86-046 OV Cleared S Set if the MSB of the result is set, otherwise cleared Exceptions Z Set if the result is zero, otherwise cleared None instruction Format Format I, II 7-68 1.0 PRELIMINARY INFORMATION NEG Negate NEG Syntax Instruction Opcode neg.b src.b.r, dst.b.w Negate Byte 39 neg.h src.h.r, dst.h.w Negate Halfword 3B neg.w src.w.r, dst.w.w Negate Word 3D Operation Addressing Modes dst <- 0-src Addressing Mode src dst Rn o Description [Rn] O o The two's complement of the source operand is stored in [Rn+] o the destination operand. [-Rn] o disp [ Rn/PC ] o Integer overflow will occur if the source operand is the largest negative integer which has no counterpart in the [ disp [ Rn/PC ] ] o two's complement number system. On overflow, the displ [ disp2 [ Rn/PC ] ] o o source operand is copied to the destination operand. /addr o o [/addr] o o If the immediate quick addressing mode is specified for [Rn](Rx) o the source operand, the immediate data is zero extended to the source operand length before disp [ Rn/PC ]( Rx ) o performing the operation. [ disp [ Rn/PC ]](Rx) o o /addr ( Rx o o [/addr](Rx) o o Condition Codes Immediate.Quick o X CY OV Immediate o X * * * * X Illegal Addressing Mode CY Set if the result is non-zero, otherwise cleared Exceptions OV Set if integer overflow occurs, otherwise cleared None S Set if the result is negative, otherwise cleared z Set if the result is zero, otherwise cleared Instruction Format Format I, II 7-69 PRELIMINARY INFORMATION 1.0 NEGF Negate Floating NEGF Syntax Instruction Opcode negf.s src.s.r, dst.s.w Negate Short Real 5O09 negf.l src.l.r, dst.l.w Negate Long Real 5E-09 Operation Addressing Modes dst « — src Addressing Mode src dst Rn O Description [Rn] O O The negation of the source operand is stored in the [Rn+] destination operand. Both the integer and floating point [-Rn] O o condition codes are updated to reflect the result of the disp [ Rn/PC ] operation. [ disp [ Rn/PC ] ] O o displ [ disp2 [ Rn/PC ] ] O Condition Codes /addr O o [/addr] O o CY OV (Rn](Rx) O o * * * disp [ Rn/PC ]( Rx ) o [ disp [ Rn/PC ]](Rx) O CY Set if the result is negative and non-zero, /addr ( Rx O o otherwise cleared OV Cleared [ /addr ]( Rx ) O o S Set if the mantissa sign bit of the result is set, Immediate.Quick A X otherwise cleared Immediate A X I Z Set if the result is zero, otherwise cleared XlUegal Addressing Mode 86-045 A Reserved Addressing Mode FIV FZD FOV FUD FPR * — — * — Exceptions Reserved Floating Point Operand FIV Set if an invalid operation is attempted, Floating Point Underflow otherwise unchanged FZD Unchanged FOV Unchanged FUD Set if the result is denormal otherwise unchanged FPR Unchanged instruction Format Format II PRELIMINARY INFORMATION 7-70 1.0 NOP No Operation NOP Syntax Instruction Opcode nop No Operation CD Operation PC <- PC + 1 Description No action is taken. The NOP instruction can be used to secure a place in the code stream or to create a program delay. Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged instruction Format Format V Exceptions None 7-71 PRELIMINARY INFORMATION 1.0 NOT One's Complement NOT Instruction Opcode not.b src.b.r, dst.b.w One's Complement Byte 38 not.h src.h.r, dst.h.w One's Complement Halfword 3A not.w src.w.r, dst.w.w One's Complement Word 3C Operat on Addressing Modes dst +- -src Addressing Mode src dst Rn o Description [Rn] O The one's complement of the source operand is stored [Rn+] O in the destination operand. [-Rn] O If the immediate quick addressing mode is specified for disp [ Rn/PC ] O the source operand, the immediate data is zero [ disp [ Rn/PC ] ] O o extended to the source operand length before displ [ disp2 [ Rn/PC ] ] O performing the operation. /addr O [/addr] o O Condition Codes [ Rn ]( Rx ) o O disp [ Rn/PC ]( Rx ) O CY OV [ disp [ Rn/PC ]](Rx) O - * * /addr ( Rx o [ /addr ]( Rx ) c J CY Unchanged Immediate.Quick X OV Cleared Immediate o X S Set if the MSB of the result is set, otherwise 66-046 cleared X Illegal Addressing Mode Z Set if the result is zero, otherwise cleared Exceptions Instruction Format None Format I, II PRELIMINARY INFORMATION 7-72 1.0 N0T1 Complement Bit NOT1 Syntax Instruction Opcode notl offset.w.r, base.w.rw Bit Test and Complement B7 Operation Addressing Modes CY <- bit( base, offset Addressing Mode offset base Z <- ~bit( base, offset Rn O O bit( base, offset ) <- ~bit( base, offset [Rn] O O [Rn+] O O Description [-Rn] O O The bit located at the sum of the byte base address and disp [ Rn/PC ] O bit offset is tested and then complemented. The CY and [ disp [ Rn/PC ] ] O O Z flags reflect the state of the bit prior to the execution of displ [ disp2 [ Rn/PC ] ] O the instruction. /addr O The location of the designated bit is decided by the base [/addr] O O operand. If the register addressing mode is used for the [Rn](Rx) O base operand, the designated bit is located within a disp [ Rn/PC ]( Rx ) O O general purpose register at the specified bit offset. For [ disp [ Rn/PC ] ]( Rx ) O any other addressing mode, the designated bit is at the /addr ( Rx O specified bit offset from the base address. An Illegal Data [ /addr ]( Rx O O Field exception occurs if the bit offset is outside the Immediate.Quick O X range 0to31. Immediate O X If the autoincrement or autodecrement addressing mode X Illegal Addressing Mode 86-095 is specified for the base operand, the base operand is treated as word data and is incremented or decremented Exceptions by four. When the immediate quick addressing mode is Illegal Data Field specified, the immediate data is zero extended to word length and used as the bit offset. Condition Codes CY OV * _ _ * CY Set if the designated bit is 1 otherwise cleared , OV Unchanged S Unchanged Z Set if the designated bit is 0, otherwise cleared Instruction Format Format I, II 7-73 PRELIMINARY INFORMATION 1.0 NOTBS Negate Bit String NOTBS Syntax Instruction Opcode notbsu bsrc.b.r, blen.b.r, bdst.b.w Negate Bit String (Upward) 5B-0A notbsd bsrc.b.r, blen.b.r, bdst.b.w Negate Bit String (Downward) 5B-0B Operation Addressing Modes bdst <- -bsrc Addressing Mode bsrc blen bdst Rn X X Description @[Rn] o - o The complement of the source bit string is stored in the @[ Rn+ - destination bit string. Specifying the direction of the <3>[-Rn] o - o operation allows the correct result to be computed when offset@[ Rn/PC ] - bit strings overlap. @[ disp Rn/PC ]] [ - o To minimize the interrupt latency time, the ANDBS offset@[ disp [ Rn/PC ] ] o - o instruction allows the service of interrupts and faults @/addr o - following the completion of a bus cycle. After servicing @[/addr] o - the interrupt or correction of the fault condition, Rx<3>[ Rn ] o - instruction execution continues from the point of Rx<3>[ Rn/PC ] o - interruption. Rx@[ disp Rn/PC [ ] ] - o During the execution of the NOTBS instruction, registers Rx(3>/addr o - R28 and R27 contain pointers to the bytes within the Rx<3>[ /addr ] o - o 1 source and destination bit strings to be processed next. Immediate.Quick X - X Following the execution of the instruction, R28 contains Immediate X o X the address of the byte containing the final bit of the X Illegal Addressing Mode 86-052 source bit string while R27 contains the address of the - Unavailable Addressing Mode byte containing the final bit of the destination bit string. Exceptions Condition Codes None CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged z Unchanged Instruction Format Format Vllb PRELIMINARY INFORMATION 7-74 1.0 OR Logical OR OR Syntax Instruction Opcode or.b src.b.r, dst.b rw OR Byte 88 or.h src.h.r, dst.h rw OR Halfword 8A or.w src.w.r dst.w.rw OR Word 8C Operation Addressing Modes dst <- dst'• src Addressing Mode src dst Rn O Description [Rn] o The bit-wise OR of the source and destination operands [Rn+] o is stored in the destination operand. [-Rn] If the immediate quick addressing mode is specified for disp [ Rn/PC ] o the source operand, the immediate data is zero [ disp [ Rn/PC ] ] o extended to the source operand length before displ [ disp2 [ Rn/PC ] ] o o performing the operation. /addr o [/addr] o Condition Codes [Rn](Rx) o disp [ Rn/PC ]( Rx ) o CY OV [ disp [ Rn/PC ] ]( Rx ) o - * * /addr ( Rx o [ /addr ]( Rx ) o CY Unchanged Immediate.Quick o X OV Cleared Immediate o X S Set if the MSB of the result is set, otherwise cleared X Illegal Addressing Mode B6-046 Set if the result is zero, otherwise cleared Exceptions Instruction Format None Format I, II 1.0 7-75 PRELIMINARY INFORMATION ORBS OR Bit String ORBS Syntax Instruction Opcode orbsu bsrc.b.r, blen.b.r, bdst.b.rw OR Bit String (Upward) 5B-14 orbsd bsrc.b.r, blen.b.r, bdst.b.rw OR Bit String (Downward) 5B-15 Operation Addressing Modes bdst bsrc v bdst Addressing Mode bsrc blen bdst Rn X O X Description @[Rn] O - @[ Rn+ ] - o The bit-wise OR of the source and destination bit strings Specifying the @[-Rn] O - is stored in the destination bit string. offset@[ Rn/PC ] - o direction of the operation allows the correct result to be computed when bit strings overlap. @[ disp Rn/PC [ ] ] O - offset<3>[ disp [ Rn/PC ] ] O - To minimize the interrupt latency time, the ORBS @/addr O - o instruction allows the service of interrupts and faults @[ /addr O - o following the completion of a bus cycle. After servicing ] Rx@[ Rn o - o the interrupt or correction of the fault condition, ] Rx<3>[ Rn/PC ] O - o instruction execution continues from the point of interruption. Rx@[ disp Rn/PC [ ] ] o - o Rx@/addr O - o During the execution of the ORBS instruction, registers Rx@[/addr] - o R28 and R27 contain pointers to the bytes within the Immediate.Quick X - X source and destination bit strings to be processed next. Following the execution of the instruction, R28 contains Immediate X ° x 86-052 the address of the byte containing the final bit of the - Unavailable Addressing Mode source bit string while R27 contains the address of the byte containing the final bit of the destination bit string. Instruction Exceptions Condition Codes None CY OV s z - - - - CY Unchanged OV Unchanged S Unchanged z Unchanged Instruction Format Format Vllb 7-76 1.0 PRELIMINARY INFORMATION ORNBS OR Complemented Bit String ORNBS Syntax Instruction Opcode ornbsu bsrc.b.r, blen.b.r, bdst.b.rw OR Complemented Bit String (Upward) 5B-16 ornbsd bsrcb.r, blen.b.r, bdst.b.rw OR Complemented Bit String (Downward) 5B-17 Operation Addressing Modes bdst -bsrc v bdst Addressing Mode bsrc blen bdst Rn X O X Description <3>[Rn] O - o @[ Rn+ O - The bit-wise OR of the complemented source bit string @[-Rn] O - and the destination bit string is stored in the destination Specifying the direction of the operation offset@[ Rn/PC O - bit string. allows the correct result to be computed when bit strings @[ disp Rn/PC [ ] ] O - overlap. offset@[ disp [ Rn/PC ] ] O - @/addr O - To minimize the interrupt latency time, the ORNBS <5>[/addr] o - instruction allows the service of interrupts and faults Rx@[ Rn o - o following the completion of a bus cycle. After servicing ] Rx@[ Rn/PC - the interrupt or correction of the fault condition, ] instruction execution continues from the point of Rx@[ disp Rn/PC [ ] ] O - o interruption. Rx@/addr O - o Rx@[ /addr O - o During the execution of the ORNBS instruction, ] Immediate.Quick X - X registers R28 and R27 contain pointers to the bytes within the source and destination bit strings to be Immediate X o x 86-052 processed next. Following the execution of the - Unavailable Addressing Mode instruction, R28 contains the address of the byte containing the final bit of the source bit string while R27 contains the address of the byte containing the final bit Exceptions of the destination bit string. None Condition Codes CY OV s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format Vllb 1.0 7-77 PRELIMINARY INFORMATION OUT Output OUT Syntax Instruction Opcode out.b src.b.r, port.b.w Output Byte 21 out.h src.h.r, port.h.w Output Halfword 23 out.w src.w.r, port.w.w Output Word 25 Operation Addressing Modes port «- src Addressing Mode src port Rn O X Description [Rn] O o The source operand is copied to output port. [Rn+] O o [-Rn] O o disp [ Rn/PC ] o o Condition Codes [ disp [ Rn/PC ] ] O o CY ov s z displ [ disp2 [ Rn/PC ] ] o o - - - - /addr O o [ /addr o o CY Unchanged [Rn](Rx) O o OV Unchanged disp [ Rn/PC ]( Rx ) o o S Unchanged disp [ Rn/PC ] ]( Rx ) o o [ Z Unchanged /addr ( Rx o o [/addr](Rx) o o Instruction Format Immediate.Quick o X Format I, II Immediate o X 66-082 X Illegal Addressing Mode Exceptions Privileged Instruction 7-78 1.0 PRELIMINARY INFORMATION POP Pop Word POP Syntax Instruction Opcode pop dst.w.w Pop Word E6/7 Operation Addressing Modes dst SP+] Addressing Mode dst Rn O Description [Rn] The word data located on the top of the stack is copied to [Rn+] O the destination operand. The stack pointer (R31) is then [-Rn] incremented by four. disp [ Rn/PC ] The POP instruction is a shorter encoding of the more [ disp [ Rn/PC ] ] general instruction displ [ disp2 [ Rn/PC ] ] O mov.w [ sp+ ], dst /addr O [ /addr [Rn](Rx) O Condition Codes disp [ Rn/PC ]( Rx ) CY OV [ disp [ Rn/PC ] ]( Rx ) /addr ( Rx O [/addr](Rx) o CY Unchanged Immediate.Quick X OV Unchanged Immediate X S Unchanged X Illegal Addressing Mode 86-056 Z Unchanged Exceptions Instruction Format None Format III 1.0 7-79 PRELIMINARY INFORMATION POPM Pop Multiple POPM Syntax Instruction Opcode popm list.w.r Pop Multiple Registers E4/5 Operation Addressing Modes registers [SP+] Addressing Mode list Rn O Description [Rn] O This instruction permits a programmer to pop from 1 to 32 [Rn+] registers from the stack with a single instruction. A [-Rn] register will be restored if and only if its corresponding bit disp [ Rn/PC ] in the register list is set. [ disp [ Rn/PC ] ] O displ [ disp2 [ Rn/PC ] ] O PRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i /addr S3222222222211111111119876543210 W098765432109876543210 [/addr] O 86-074 [Rn](Rx) O disp [ Rn/PC ]( Rx ) O The register list is searched sequentially from the LSB [ disp [ Rn/PC ]](Rx) (RO) to the MSB (PSW) with only the designated /addr ( Rx registers being restored from the stack. If the PSW [ /addr ]( Rx ) * register is specified, only the lower halfword is modified. Immediate.Quick O The register list is extended to word length if the Immediate immediate quick addressing mode is specified. S6-667 Condition Codes Exceptions CY OV None R R R R CY Restored if list:31 is set, otherwise unchanged OV Restored list:31 is set, otherwise unchanged if S Restored if list:31 is set, otherwise unchanged z Restored if list:31 is set, otherwise unchanged Instruction Format Format III 7-80 1.0 PRELIMINARY INFORMATION PREPARE Prepare Stack Frame PREPARE Syntax Instruction Opcode prepare num.w.r Prepare Stack Frame DE/F Operation Address Modes tmp <- num Addressing Mode num [-SP] <- FP Rn O FP <- SP [Rn] O SP .r, dst.b.rw Remainder Byte 50 rem.h sflc.h.r, dst.h.rw Remainder Halfword 52 rem.w src.w.r, dst.w.rw Remainder Word 54 Operation Addressing Modes dst dst % src Addressing Mode src dst Rn O Description [Rn] O O The integer remainder of the destination operand [Rn+] O o (dividend) divided by the source operand (divisor) is [-Rn] O o stored in the destination operand. The sign of the disp [ Rn/PC ] O remainder is the same as the sign of the dividend. [ disp [ Rn/PC ] ] O o The destination operand remains unchanged when a displ [ disp2 [ Rn/PC ] ] O o Zero Divide exception occurs. /addr O [/addr] If the immediate quick addressing mode is specified for the source operand, the immediate data is zero [Rn](Rx) O disp [ Rn/PC ]( Rx ) extended to the source operand length before performing the operation. [ disp [ Rn/PC ] ]( Rx ) O /addr ( Rx O [/addr](Rx) o Condition Codes Immediate.Quick O X CY OV Immediate O X - * * 86-046 CY Unchanged Exceptions OV Cleared Zero Divide S Set if the result is negative, otherwise cleared Z Set if the result is zero, otherwise cleared Instruction Format Format I, II PRELIMINARY INFORMATION 7-84 1.0 REMU Unsigned Remainder REMU Syntax Instruction Opcode remu.b src.b.r, dst.b.rw Unsigned Remainder Byte 51 remu.h src.h.r, dst.h.rw Unsigned Remainder Halfword 53 remu.w src.w.r, dst.w.rw Unsigned Remainder Word 55 Operation Addressing Modes dst dst%src (unsigned) Addressing Mode src dst Rn O Description [Rn] O The remainder of the destination operand (dividend) [Rn+] O divided by the source operand (divisor) is stored in the [-Rn] O destination operand. operands are treated as All disp [ Rn/PC ] o unsigned data, however, the condition code flags are set [ disp [ Rn/PC ] ] o as if the remainder is a signed value. displ [ disp2 [ Rn/PC ] ] o The destination operand remains unchanged when a /addr o Zero Divide exception occurs. [/addr] o o If the immediate quick addressing mode is specified for [Rn](Rx) o the source operand, the immediate data is zero disp [ Rn/PC ]( Rx ) o extended to the source operand length before [ disp [ Rn/PC ]](Rx) performing the operation. /addr ( Rx o o [ /addr ]( Rx ) o Immediate.Quick X Condition Codes Immediate o X CY OV B6-046 - * * Exceptions CY Unchanged Zero Divide OV Cleared S Set the MSB of the result is set, otherwise if cleared Z Set if the result is zero, otherwise cleared Instruction Format Format I, II 1.0 7-85 PRELIMINARY INFORMATION RET Return from Procedure RET Syntax Instruction Opcode ret num.w.h Return from Procedure E2/3 Operation Addressina Modes tmp1 <- num Addressing Mode num tmp2 <- [SP+] Rn O AP <- [SP+] [Rn] SP CY MSB LSB [Rn] O O [Rn+] o [-Rn] o disp [ Rn/PC ] O o [ disp [ Rn/PC ] ] O count < MSB LSB CY i i displ [ disp2 [ Rn/PC ] ] O /addr O [/addr] O 86-131 [Rn](Rx) O o disp [ Rn/PC ]( Rx ) O o [ disp [ Rn/PC ] ]( Rx ) O If the immediate quick addressing mode is specified for /addr ( Rx O the count operand, the immediate data is zero extended [ /addr ]( Rx ) O o to byte length before its use as the rotate count. Immediate.Quick O X To minimize the instruction execution time and interrupt Immediate O X latency, the actual rotate count is computed modulo the X Illegal Addressing Mode destination operand size. Exceptions Instruction Format None Format I, II 7-89 PRELIMINARY INFORMATION 1.0 ROTC Rotate with Carry ROTC Syntax Instruction Opcode rotc.b count.b.r, dst.b.rw Rotate Byte through Carry 99 rotc.h count.b.r, dst.h.rw Rotate Halfword through Carry 9B rotc.w count.b.r, dst.w.rw Rotate Word through Carry 9D Operation Condition Codes dst rotate_through_carry( dst, count CY ov * * * Description The concatentation of the destination operand and CY CY Set if the last rotated bit was set, cleared if the number of bits and stored flag is rotated the specified last rotated bit was zero or the rotate count was back in the destination. zero ov Cleared The rotate count is specified as signed byte data in a S Set if the MSB of the result is set, otherwise range from -128 to +127. When the rotate count is cleared positive, the destination is rotated left with the MSB Set if the result is zero, otherwise cleared rotating through the CY flag into the LSB. When the rotate count is negative, the destination is rotated right Addressing Modes and the contents of the LSB is rotated through the CY Addressing Mode count dst flag into the MSB. The destination will remain unchanged if a rotate count of zero is specified but the Rn O O flags will be updated. [Rn] O ° , [Rn+] o count > CY MSB LSB [-Rn] 4 — <« disp [ Rn/PC ] O o [ disp [ Rn/PC ] ] O o displ [ disp2 [ Rn/PC ] ] o /addr count < MSB LSB CY 1 1 1 1 » 1 1 1 [/addr] O [Rn](Rx) O disp [ Rn/PC ]( Rx ) O [ disp [ Rn/PC ] ]( Rx ) O o /addr ( Rx O If the immediate quick addressing mode is specified for [ /addr ]( Rx ) O the count operand, the immediate data is zero extended Immediate.Quick O X to byte length before its use as the rotate count. Immediate O X B6-069 To minimize the instruction execution time and interrupt latency, the rotate count is computed modulo the destination operand size. Exceptions None Instruction Format Format I, II PRELIMINARY INFORMATION 7-90 1.0 It O rr Return from Subroutine Run Syntax Instruction Opcode rsr Return from Subroutine CA Operation PC <- [SP+] Description The return address is popped from the stack and control is returned to the calling module. The RSR instruction is used to terminate subroutines entered using the JSR and BSR instructions. Condition Codes CY OV s z - - - - CY Unc hanged OV Unc hanged S Unc hanged Z Unc hanged Instruction Format Format V Exceptions None 10 7-91 PRELIMINARY INFORMATION RVBIT Reverse Bit Order RVBIT Syntax Instruction Opcode rvbit src.b.r, dst.b.w Reverse Bit Order 08 Operation Addressing Modes dst bit_reversed( src ) Addressing Mode src dst Rn Description [Rn] The individual bits of the byte data addressed by the [Rn+] source operand are reversed as follows: [-Rn] O O disp [ Rn/PC ] O 7 [ disp [ Rn/PC ] ] O O B7 B6 B5 B4 B3 B2 B1 BO displ [ disp2 [ Rn/PC ] ] O /addr O U [/addr] 7 [Rn](Rx) O O BO B1 B2 B3 B4 B5 B6 B7 disp [ Rn/PC ]( Rx ) O 86-060 [ disp [ Rn/PC ] ]( Rx ) o /addr ( Rx O The source operand is unaffected by this instruction. [ /addr ]( Rx ) o i If the immediate quick addressing mode is specified for Immediate.Quick O X the source operand, the immediate data is zero Immediate O X 86-046 extended to byte length before the bit reversal takes X Illegal Addressing Mode place. Exceptions Condition Codes None CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format I, II PRELIMINARY INFORMATION 7-92 1.0 RVBYT Reverse Byte Order RVBYT Syntax Instruction Opcode rvbyt src.w.r, dst.w.w Reverse Byte Order 2C Operation Addressing Modes dst <- byte_reversed( src Addressing Mode src dst Rn O Description [Rn] The individual bytes of the word data addressed by the [Rn+] O source operand are reversed as follows: [-Rn] o disp [ Rn/PC ] O o -n—n—r— 24 23 16 15 8 7 31 i i i i i [ disp [ Rn/PC ] ] o Byte 3 Byte 2 Bytel ByteO -i i i i i— displ [ disp2 [ Rn/PC ] ] o /addr o [/addr] o \i [Rn](Rx) o 31 i i i i i i— 24 23 -n— r- 16 15 t i i i i i 8 i 7 I I I I I I I disp [ Rn/PC ]( Rx ) o ByteO Bytel Byte 2 Byte 3 [ disp [ Rn/PC ]](Rx) o o _i ' I I I L. .j i—i i i i i o o i /addr ( Rx 06-059 [ /addr ]( Rx ) o o Imrnediate.Quick o X The byte order of 1 6-bit data can be reversed by the Immediate o X ROT instruction. X Illegal Addressing Mode 86-04 If the immediate quick addressing mode is specified for the source operand, the immediate data is zero Exceptions extended to word length before the byte reversal takes None place. This instruction is provided to simplify data transfers between machines adopting different integer notations. Condition Codes CY ov s z - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format I, II 7-93 PRELIMINARY INFORMATION 1.0 SCHOBS Search Bit String for SCHOBS Syntax Instruction Opcode schObsu bsrc.b.r, blen.b.r, dst.w.w Search Bit String for (Upward) 5B-00 schObsd bsrc.b.r, blen.b.r, dst.w.w Search Bit String for (Downward) 5B«01 Operation Addressing Modes dst bit_offset( first bit Bit Address bsrc blen dst Byte Address Rn X O Rn Description @[Rn] O - [Rn] Rn+ ] o - O [Rn+] The source bit string is scanned until a zero bit is found <3>[ found, the bit offset of @[-Rn] o - O [-Rn] or the bit string is exhausted. If the detected bit is stored in the destination operand and offset@[ Rn ] o - O disp[ Rn ] the Z flag is cleared. Otherwise, the Z flag is set and the offset@[ PC ] o - O disp[ PC ] bit offset of the next logical bit string after the searched @[ disp[ Rn ] ] o - O [disp[Rn]] bit string is stored in the destination operand. @[disp[PC]] - O [disp[PC]] offset@[ disp[ Rn ] ] o - O disp1[disp2[Rn]] To minimize the interrupt latency time, the SCHOBS offset@[ disp[ PC ] ] o - O disp1[disp2[PC]] instruction allows the service of interrupts and faults following the completion of a bus cycle. After servicing @/addr - O /addr the interrupt or correction of the fault condition, @[ /addr ] o - O [/addr] instruction execution continues from the point of Rx@[ Rn ] o - O [Rn](Rx) interruption. Rx(S>[ Rn ] o - o disp [ Rn ]( Rx ) Rx@[ PC o - o disp [ PC ]( Rx ) Register R28 is used as a work register during the ] Rx<5>[ disp[ Rn o - o disp[ Rn ] ]( Rx ) execution of this instruction, pointing to the current ] ] [ position within the bit string. After the completion of this Rx@[ disp[ PC ] ] o - o [ disp[ PC ] ]( Rx instruction, R28 will point to the byte containing the Rx@/addr o - o /addr ( Rx detected bit or the byte containing the final bit in the bit Rx@[ /addr ] o - o [ /addr ]( Rx ) string. Immediate.Quick X - X Immediate.Quick Immediate X X Immediate Condition Codes X Illegal Addressing Mode - Unavailable Addressing Mode CY OV _ — * Exceptions None CY Unchanged OV Unchanged S Unchanged z Set if a zero bit is not found, otherwise cleared Instruction Format Format Vllb PRELIMINARY INFORMATION 7-94 1.0 SCH1 BS Search Bit String fori SCH1 BS Syntax Instruction Opcode schlbsu bsrc.b.r, blen.b.r, dst.w.w Search BH String for 1 (Upward) 5B-02 schlbsd bsrc.b.r, blen.b.r, dst.w.w Search Bit String for 1 (Downward) 5B-03 Operation Addressing Modes bit_offset( first 1 bit Bit Address bsrc blen dst Byte Address dst Rn X O Rn Description @[Rn O o [Rn] @[Rn+ o o [Rn+] The source bit string is scanned until a one bit is found or the bit string is exhausted. If found, the bit offset of the @[-Rn o o [-Rn] detected bit is stored in the destination operand and the offset@[ Rn o o disp[ Rn ] Z flag is cleared. Otherwise, the Z flag is set and the bit offset@[ PC o o disp[ PC ] offset of the next logical bit string after the searched bit @[ disp[ Rn ] o o [ disp[ Rn ] ] string is stored in the destination operand. <3>[disp[PC] o o [disp[PC]] To minimize the interrupt latency time, the SCH1BS offset@[ disp[ Rn ] o o disp1[disp2[Rn]] instruction allows the service of interrupts and faults offset@[ disp[ PC ] o o disp1[disp2[PC]; following the completion of a bus cycle. After servicing @/add o o /addr the interrupt or correction of the fault condition, @[ /addr o o [/addr] instruction execution continues from the point of Rx@[Rn o o [Rn](Rx) interruption. Rx@[Rn o o disp [ Rn ]( Rx ) R28 is used as a work register during the Rx@[PC o o disp [ PC ]( Rx ) Register execution of this instruction, pointing to the current Rx<3>[ disp[ Rn ] o o [ disp[ Rn ] ]( Rx ) position within the bit string. After the completion of this Rx@[ disp[ PC ] o o [disp[PC]](Rx) instruction, R28 will point to the byte containing the Rx@/addr o o /addr ( Rx detected bit or the byte containing the final bit in the bit Rx<3>[ /addr ] o o [ /addr ]( Rx ) string. Immediate.Quick X X Immediate.Quick Immediate X X Immediate Condition Codes X Illegal Addressing Mode - Unavailable Addressing Mode CY OV _ _ — * Exceptions None CY Unchanged OV Unchanged S Unchanged z Set if a one bit is not found, otherwise cleared Instruction Format Format Vllb 7-95 PRELIMINARY INFORMATIOM 1.0 SCHC Search Character SCHC Syntax Instruction Opcode schcu.b src.b.r, slen.b.r, char.b.r Search Byte Character Upward 58-18 schcd.b src.b.r, slen.b.r, char.b.r Search Byte Character Downward 58-19 schcu.h src.h.r, slen.b.r, char.h.r Search Halfword Character Upward 5A-18 schcd.h src.h.r, slen.b.r, char.h.r Search Halfword Character Downward 5 A- 19 Operation Addressing Modes R28 search character byte address Addressing Mode src slen char R27 search character offset Rn X O O [Rn] O - Description [Rn+] O - The character string is searched for the designated [-Rn] O - character until either the character found or all is disp [ Rn/PC ] O - characters in the string have been examined. Character [ disp [ Rn/PC ] ] O - string searches are initiated from the head of the string in displ [ disp2 [ Rn/PC ] ] O - the address increment mode and from the tail in the /addr - address decrement mode. [/addr] o - This instruction is interruptable and resumable with (Rn](Rx) o - register R28 used to maintain the character address disp [ Rn/PC ]( Rx ) o - o being scanned. Following the execution of the SCHC [ disp [ Rn/PC ]](Rx) o - o instruction, R28 contains the address of the first /addr ( Rx o - character meeting the search criteria or the next [ /addr ]( Rx ) o - character after the source string if no matching character Immediate.Quick X - o was found. Register R27 contains the number of Immediate X o o characters (character offset) from the start position to the X Illegal Addressing Mode 86-055 search end position. - Unavailable Addressing Mode Condition Codes Exceptions Illegal Data Field CY OV _ _ _ * CY Unchanged OV Unchanged S Unchanged z Set if the search character is found, otherwise cleared Instruction Format Format Vllb PRELIMINARY INFORMATION 7-96 1.0 SCLF Scale Floating SCLF Syntax Instruction Opcode sclf.s count.h.r, dst.s.rw Scale Short Real 5O10 sclf.l count.h.r, dst.l.rw Scale Long Real 5E-10 Operation Addressing Modes dst dst * 2count Addressing Mode count dst Rn O O Description [Rn] O O The destination operand is scaled by the integer count [Rn+] O O and stored in the destination operand. Both the integer [-Rn] O O condition codes and the floating point condition codes disp [ Rn/PC ] O are updated to reflect the result of the operation. [ disp [ Rn/PC ] ] O O displ [ disp2 [ Rn/PC ] ] O Condition Codes /addr O O [/addr] o CY OV [Rn](Rx) O o * * * disp [ Rn/PC ]( Rx ) o [ disp [ Rn/PC ] ]( Rx ) o CY Set if the result is negative and non-zero, /addr ( Rx o otherwise cleared /addr ]( Rx ) O OV Cleared [ S Set if the mantissa sign bit of the result is set, Immediate. Quick O X otherwise cleared Immediate O X Z Set if the result is zero, otherwise cleared X Illegal Addressing Mode FIV FZD FOV FtiD FPR * — * * * Exceptions Reserved Floating Point Operand Floating Point Overflow FIV Set if an invalid operation is attempted, Floating Point Underflow otherwise unchanged Floating Point Precision FZD Unchanged FOV Set if the result is infinite, otherwise unchanged FUD Set if the result is denormal, otherwise unchanged FPR Set if a precision error occurs, otherwise unchanged Instruction Format Format II 1.0 7-97 PRELIMINARY INFORMATION SET1 Set Bit SET1 Syntax Instruction Opcode setl offset.w.r, base.w.rw Bit Test and Set 97 Operation Addressing Modes CY <- bit( base, offset Addressing Mode offset base Z <- ~bft( base, offset Rn O O b"rt( base, offset ) <- 1 [Rn] [Rn+] O Description [-Rn] O The bit located at the sum of the byte base address and disp [ Rn/PC ] O O bit offset is tested and then set. The CY and Z flags [ disp [ Rn/PC ] ] O O reflect the state of the bit prior to the execution of the displ [ disp2 [ Rn/PC ] ] O O instruction. /addr The location of the designated bit is determined by the [/addr] O O base operand. If the register addressing mode is used [Rn](Rx) O O for the base operand, the designated bit is located within disp [ Rn/PC ]( Rx ) O O a general purpose register at the specified bit offset. For [ disp [ Rn/PC ] ]( Rx ) O O any other permissible addressing mode, the designated /addr ( Rx O O bit is at the specified bit offset from the base address. An [ /addr ]( Rx ) o i IllegalData Field exception occurs if the bit offset is Immediate.Quick O X outside the range to 31 Immediate O X If the autoincrement or autodecrement addressing mode X Illegal Addressing Mode. 86-095 is specified for the base operand, the base operand is treated as word data and is incremented or decremented Exceptions by four. When the immediate quick addressing mode is Illegal Data Field specified, the immediate data is zero extended to word length and used as the bit offset. Condition Codes CY OV * — — * CY Set if the designated bit is 1 otherwise cleared , OV Unchanged S Unchanged Z Set if the designated bit is 0, otherwise cleared Instruction Format Format I, II PRELIMINARY INFORMATION 7-98 1.0 Set Flag Syntax Instruction Opcode setf cond.b.r, dst.b.w Set Flag Condition 47 Operation Condition Codes if condition ) then ( CY OV s z dst <- 01H - - - - else dst <- 00H CY Unchanged Description OV Unchanged S Unchanged If the specified condition is satisfied by the interger PSW Z Unchanged condition codes, the value 01 H (true) is stored in the destination. Otherwise, the value 00H (false) is stored in Addressing Modes the destintion. Addressing Mode cond dst The condition code field is found in the lower four bits of Rn O o the condition operand. The upper four bits are ignored [Rn] O o and have no effect on this instruction. [Rn+] o o [-Rn] o o Encodina Neme Condition OV=1 disp [ Rn/PC ] o o 0000 V 0001 NV ov-o [ disp [ Rn/PC ] ] o 001 C/L CY=1 displ [ disp2 [ Rn/PC ] ] o o 001 1 NC/NL CY-0 /addr o o 01 00 Z Z-1 01 01 NZ z=o [ /addr ] o 01 1 NH ( CY v Z ) = 1 [Rn](Rx) o o 0111 H ( CY v Z ) = 1000 S/N S=1 disp [ Rn/PC ]( Rx ) o 1 001 NS/P S-0 [ disp [ Rn/PC ] ]( Rx ) o o 1010 T Always /addr ( Rx o o 1011 F Never 1 1 00 LT ( S © OV ) = 1 [ /addr ]( Rx ) o o 1 1 01 GE ( S © OV « ) Immediate.Quick o X 1110 LE ( S © OV vZ)=1 ( ) Immediate X 1111 GT ( ( S © OV ) vZ = ) X Illegal Addressing Mode Instruction Format Exceptions Format I, II None 1.0 7-99 PRELIMINARY INFORMATION SHA Arithmetic Shift SHA Syntax Instruction Opcode sha.b count. b.r, dst.b.rw Arithmetic Shift Byte B9 sha.h count.b.r, dst.h.rw Arithmetic Shift Hatfword BB sha.w count.b.r, dst.w.rw Arithmetic Shift Word BD Operation Condition Codes dst arithmetic_shift( dst, count CY OV * * * * Description The destination operand is arithmetically shifted the CY Set if the last shifted bit was set, cleared if the specified number of bits and stored back in the last shifted bit was zero or the shift count was Integer overflow occurs if the sign of the zero destination. anytime during the execution of this OV Set if integer overflow occurs, otherwise cleared result changes at S Set if the result is negative, otherwise cleared instruction. Z Set if the result is zero, otherwise cleared The shift count is specified as signed byte data in a range from -128 to +127. When the shift count is positive, the Addressing Modes destination is shifted left with a zero bit shifted into the Addressing Mode count dst LSB. When the shift count is negative, the destination is shifted right with the MSB being shifted into itself. The Rn O o [Rn] destination will remain unchanged if a shift count of zero is specified but the flags will be updated. [Rn + ] o I [-Rn] count > CY MSB LSB disp [ Rn/PC ] o *— [ disp [ Rn/PC ] ] o displ [ disp2 [ Rn/PC ] ] o /addr o o count <0 MSB LSB CY [ /addr ] o — [Rn](Rx) & 86-133 disp [ Rn/PC ]( Rx ) [ disp [ Rn/PC ] ]( Rx ) o /addr ( Rx o o Ifthe absolute value of the shift count exceeds the [ /addr ]( Rx ) o destination operand length, zero (positive shift counts) Immediate.Quick o X or data consisting of the sign of the destination (negative Immediate ° X shift counts) is stored in the destination. 86-069 X Illegal Addressing Mode If the immediate quick addressing mode is specified for the count operand, the immediate data is zero extended Exceptions to byte length before its use as the shift count. None Instruction Format Format I, II 7-100 1.0 PRELIMINARY INFORMATION SHL Logical Shift SHL Syntax Instruction Opcode shl.b count. b.r, dst.b.rw Logical Shift Byte A9 shl.h count.b.r, dst.h.rw Logical Shift Halfword AB shl.w count.b.r, dst.w.rw Logical Shift Word AD Operation Condition Codes dst logical_shift( dst, count CY OV * * * Description The destination operand is logically shifted the specified CY Set if the last shifted bit was set, cleared if the number of bits and stored back in the destination. last shifted bit was zero or the shift count was zero The shift count is specified as signed byte data in a range OV Cleared from -128 to +127. When the shift count is positive, the s Set if the MSB of the result is set, otherwise destination is shifted left with a zero bit shifted into the cleared LSB. When the shift count is negative, the destination is Set if the result is zero, otherwise cleared shifted right with a zero bit being shifted into the MSB. The destination will remain unchanged if a shift count of Addressing Modes zero is specified but the flags will be updated. Addressing Mode count dst count > CY MSB LSB Rn O O *— [Rn] [Rn+] O O MSB [-Rn] O O count < LSB CY — disp [ Rn/PC ] O o [ disp [ Rn/PC ] ] O o 86-134 displ [ disp2 [ Rn/PC ] ] O o /addr O o If the absolute value of the shift count exceeds the [/addr] O o destination operand length, zero is stored in the [Rn](Rx) o destination. disp [ Rn/PC ]( Rx ) o [ disp [ Rn/PC ] ]( Rx ) O If the immediate quick addressing mode is specified for /addr ( Rx o the count operand, the immediate data is zero extended [ /addr ]( Rx ) O o to byte length before its use as the shift count. Immediate.Quick X Immediate X Instruction Format X illegal Addressing Mode Format I, II Exceptions None 1.0 7-101 PRELIMINARY INFORMATION SKPC Skip Character SKPC Syntax Instruction Opcode skpcu.b src.b.r, slen.b.r, char.b.r Skip Byte Character Upward 58-1 skpcd.b src.b.r, slen.b.r, char.b.r Skip Byte Character Downward 58«1B skpcu.h src.h.r, slen.b.r, char.h.r Skip Halfword Character Upward 5A-1A skpcd.h src.h.r, slen.b.r, char.h.r Skip Halfword Character Downward 5A-1B Operation Addressing Modes R28 <- skipped character byte address Addressing Mode src slen char R27 «- skipped character offset Rn X O [Rn] O - Description [Rn + ] o - O The source character string is scanned until a position [-Rn] - different from the designated character is reached or the disp [ Rn/PC ] o - string is exhausted. Character string scanning is initiated [ disp [ Rn/PC ] ] o - o from the head of the string in the address increment displ [ disp2 [ Rn/PC ] ] o - o mode and from the tail in the address decrement mode. /addr o - o This instruction is interruptable and resumable with [ /addr ] o - o register R28 used to maintain the character address [Rn](Rx) o - o being scanned. Following the execution of the SKPC disp [ Rn/PC ]( Rx ) o - instruction, R28 contains the address of the first [ disp [ Rn/PC ] ]( Rx - o character not meeeting the skip criteria or the next /addr ( Rx o - o character after the source string if the skip criteria was [/addr](Rx) o - o I continuously satisfied. Register R27 contains the Immediate.Quick X - o number of characters (offset) from the start position to Immediate X the skip end position. X Illegal Addressing Mode - Unavailable Addressing Mode Condition Codes Exceptions CY OV Illegal Data Field _ _ _ * CY Unchanged OV Unchanged S Unchanged Z Set if the skip character is found, otherwise cleared Instruction Format Format Vllb PRELIMINARY INFORMATION 7-102 1.0 STPR Store Privileged Register STPR Syntax Instruction Opcode stpr reglD.w.r, dst.w.w Store Privileged Register 02 Operation Condition Codes dst PrivilegedRegister( regID CY ov s z - - - - Description The contents of the specified privileged register are CY Unchanged copied to the destination operand. OV Unchanged S Unchanged ID Register Name z Unchanged ISP Interrupt Stack Pointer 1 LOSP Level Stack Pointer Instruction Format 2 L1SP Level 1 Stack Pointer 3 L2SP Level 2 Stack Pointer Format I, II 4 L3SP Level 3 Stack Pointer 5 SBR System Base Register 6 TR Task Register Addressing Modes 7 SYCW System Control Word Addressing Mode regID dst 8 TKCW Task Control Word 9 PIR Processor ID Register Rn O 15 PSW2 Emulation Mode Program Status Word [Rn] O 16 ATBRO Area Table Base Register [Rn+] o 17 ATLRO Area Table Length Register [-Rn] o 18 ATBR1 Area Table Base Register 1 disp [ Rn/PC ] o 19 ATLR1 Area Table Length Register 1 [ disp [ Rn/PC ] ] o o 20 ATBR2 Area Table Base Register 2 displ [ disp2 [ Rn/PC ] ] 21 ATLR2 Area Table Length Register 2 22 ATBR3 Area Table Base Register 3 /addr o 23 ATLR3 Area Table Length Register 3 [ /addr ] o 24 TRMOD Trap Mode Register [ Rn ]( Rx ) o 25 ADTRO Address Trap Register disp [ Rn/PC ]( Rx ) o 26 ADTR1 Address Trap Register 1 27 ADTRMO Address Trap Mask Register [ disp [ Rn/PC ] ]( Rx ) o 28 ADTRM1 Address Trap Mask Register 1 /addr ( Rx 86-129 [ /addr ]( Rx ) o Immediate.Quick o X An Illegal Data Field exception will occur if the register ID Immediate o X field is not in the range of to 31 Instruction execution Addressing Mode . X Illegal 86-086 results will also be unpredicatable if an undefined register ID is specified. Exceptions Privileged Instruction Illegal Data Field 1.0 7-103 PRELIMINARY INFORMATION STTASK Store Task STTASK Syntax Instruction Opcode sttask list.w.r Store Task Context FC/D Operation Condition Codes TCB TaskContext CY OV Description The current task context is copied to the Task Control CY Unchanged Block (TCB) designated by the Task Register. The task OV Unchanged context consists of S Unchanged Z Unchanged • General Purpose Registers The saving of the general purpose registers (R30- RO) is controlled by the list operand. Bits set in the Addressing Modes operand identfy which general purpose registers list Addressing Mode list are saved in the TCB. Bit 31 of the register list is Reserved for Future Use and must be zero. Rn [Rn] RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i i [Rn+] O F3222222222211111111119876543210 U098765432109876543210 [-Rn] 86-130 disp [ Rn/PC ] [ disp [ Rn/PC ] ] • Area Table Registers displ [ disp2 [ Rn/PC ] ] O In mode, the area table registers virtual /addr O (ATBR0/ATLR0-ATBR3/ATLR3) specified by the [/addr] O STCW are saved with the current task context. [Rn](Rx) • Stack Pointers (L3SP-L0SP) disp [ Rn/PC ]( Rx ) o [ disp [ Rn/PC ] ]( Rx ) o • Task Control Word (TKCW) /addr ( Rx o [ /addr ]( Rx ) o Because no valid context exists between the STTASK Immediate.Quick o instruction and a subsequent LDTASK instruction, the Immediate o ISP becomes the current stack pointer during the 86-087 execution of the STTASK instruction. Exceptions Instruction Format Privileged Instruction Format III PRELIMINARY INFORMATION 7-104 1.0 SUB Subtract SUB Instruction Opcode sub.b src.b.r, dst.b.rw Subtract Byte A8 sub.h src.h.r, dst.h.rw Subtract Halfword AA sub.w src.w.r dst.w.rw Subtract Word AC Operat on Addressing Modes dst <- dst--src Addressing Mode src dst Rn O O Description [Rn] O The source operand is subtracted from the destination [Rn+] O o operand and the result stored in the destination [-Rn] O o operand. disp [ Rn/PC ] O disp [ Rn/PC ] ] O o the immediate quick addressing mode is specified for [ If the source operand, the immediate data is zero displ [ disp2 [ Rn/PC ] ] O extended to the source operand length before /addr O o performing the operation. [/addr] O o [Rn](Rx) O o disp [ Rn/PC ]( Rx ) O o Condition Codes [ disp [ Rn/PC ] ]( Rx ) O o CY OV /addr ( Rx O o * * * * [ /addr ]( Rx ) O o Immediate.Quick O X CY Set if a borrow is generated, otherwise cleared Immediate X OV Set if integer overflow occurs, otherwise cleared X Illegal Addressing Mode S Set if the result is negative, otherwise cleared Z Set if the result is zero, otherwise cleared Exceptions Instruction Format None Format I, II 7-105 PRELIMINARY INFORMATION 1.0 SUBC Subtract with Carry (Borrow) SUBC Syntax Instruction Opcode subc.b src.b.r, dst.b rw Subtract Byte with Carry 98 subc.h src.h.r, dst.h rw Subtract Hatfword with Carry 9A subc.w src.w.r dst.w.rw Subtract Word with Carry 9C Operation Addressing Modes dst dst2 Addressing Mode dstl dst2 Rn O Description [Rn] A The contents of the first destination operand is [Rn+] A exchanged with the contents of second destination [-Rn] A operand. disp [ Rn/PC ] A In the JJ.PD70616 microprocessor, a Reserved [ disp [ Rn/PC ] ] A Addressing Mode exception will occur if the first displ [ disp2 [ Rn/PC ] ] A destination operand is not a general purpose register. /addr A [/addr] A Condition Codes [Rn](Rx) A disp [ Rn/PC ]( Rx ) A CY OV [ disp [ Rn/PC ] ]( Rx ) A /addr ( Rx A O [ /addr ]( Rx ) A CY Unchanged Immediate.Quick X X OV Unchanged Immediate X X S Unchanged 86-058 z Unchanged X Illegal Addressing Mode A Reserved Addressing Mode Instruction Format Exceptions Format I None 1.0 7-119 PRELIMINARY INFORMATION XOR Exclusive OR XOR Syntax Instruction Opcode xor.b src.b.r, dst.b.rw Exclusive OR Byte BO xor.h src.h.r, dst.h.rw Exclusive OR Halfword B2 xor.w src.w.r, dst.w.rw Exclusive OR Word B4 Operation Addressing Modes dst dst © src Addressing Mode src dst Rn O O Description [Rn] O The bit-wise exclusive OR of the source operand and the [Rn+] O O destination operand is stored in the destination operand. [-Rn] disp [ Rn/PC ] If the immediate quick addressing mode is specified for the source operand, the immediate data is zero [ disp [ Rn/PC ] ] O extended to the source operand length before displ [ disp2 [ Rn/PC ] ] O O performing the operation. /addr [/addr] O O [Rn](Rx) Condition Codes disp [ Rn/PC ]( Rx ) O CY OV [ disp [ Rn/PC ]](Rx) - * * /addr ( Rx O o [ /addr ]( Rx ) O o CY Unchanged Immediate.Quick O X OV Cleared Immediate O X S Set if the result is negative, otherwise cleared 86-046 Z Set if the result is zero, otherwise cleared X illegal Addressing Mode Instruction Format Exceptions Format I, II None PRELIMINARY INFORMATION 7-120 1.0 XORBS XOR Bit String XORBS Syntax Instruction Opcode xorbsu bsrc.b.r, blen.b.r, bdst.b.rw XOR Bit String (Upward) 5B-18 xorbsd bsrc.b.r, blen.b.r, bdst.b.rw XOR Bit String (Downward) 5B-19 Operation Addressing Modes bdst <- bsrc©bdst Addressing Mode bsrc blen bdst Rn X O X Description @[Rn] O o @[ Rn+ O o The bit-wise XOR of the source and destination bit strings is stored in the destination bit string. Specifying @[-Rn] O o the direction of the operation allows the correct result to offset@[ Rn/PC ] O O be computed when bit strings overlap. @[ disp [Rn/PC]] O o XORBS offset@[ disp [ Rn/PC ] ] o O To minimize the interrupt latency time, the @/addr O O instruction allows the service of interrupts and faults @[ /addr o o following the completion of a bus cycle. After servicing ] condition, Rx@[ Rn O O the interrupt or correction of the fault ] instruction execution continues from the point of Rx<3>[ Rn/PC ] O O interruption. Rx<3>[ disp [ Rn/PC ] ] O O Rx@/addr O O During the execution of the XORBS instruction, registers Rx@[ /addr O O R28 and R27 contain pointers to the bytes within the ] Immediate.Quick X X source and destination bit strings to be processed next. Immediate X X Following the execution of the instruction, R28 contains 86-052 the address of the byte containing the final bit of the X Illegal Addressing Mode - Unavailable Addressing Mode source bit string while R27 contains the address of the byte containing the final bit of the destination bit string. Exceptions Condition Codes None CY ov s 2 - - - - CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format Vllb 7-121 PRELIMINARY INFORMATION 1.0 XORNBS XOR Complemented Bit String XORNBS Syntax instruction Opcode xombsu bsrc.b.r, blen.b.r, bdst.b.rw XOR Complemented Bit String (Upward) 5B-1A xombsd bsrc.b.r, blen.b.r, bdst.b.rw XOR Complemented Bit String (Downward) 5B-1B Operation Addressing Modes bdst -bsrc © bdst Addressing Mode bsrc blen bdst Rn X O X Description @[Rn] O - o The bit-wise XOR of the complemented source bit string @[ Rn+ ] o - o and the destination bit string is stored in the destination @[-Rn] O - o bit string. Specifying the direction of the operation offset@[ Rn/PC ] o - o allows the correct result to be computed when bit strings @[ disp [Rn/PC]] - overlap. offset<5>[ disp [ Rn/PC ] ] O - To minimize the interrupt latency time, the XORNBS @/addr - o instruction allows the service of interrupts and faults @[/addr] O - following the completion of a bus cycle. After servicing Rx<3>[ Rn ] - o the interrupt or correction of the fault condition, Rx@[ Rn/PC ] O - o instruction execution continues from the point of Rx@[ disp Rn/PC [ ] ] - o interruption. Rx@/addr O - o During the execution of the XORNBS instruction, Rx@[ /addr ] O - o i registers R28 and R27 contain pointers to the bytes Immediate.Quick X - X within the source and destination bit strings to be Immediate X o X processed next. Following the execution of the X Illegal Addressing Mode 86-052 instruction, R28 contains the address of the byte - Unavailable Addressing Mode containing the final bit of the source bit string while R27 contains the address of the byte containing the final bit Exceptions of the destination bit string. None Condition Codes CY OV CY Unchanged OV Unchanged S Unchanged Z Unchanged Instruction Format Format Vllb PRELIMINARY INFORMATION 7-122 1.0 UPD7061 6 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Section 8 Interrupts and Exceptions This section describes the interrupt and exception handling capabilities of the U.PD70616 microprocessor. An interrupt is an event which occurs asynchronously to the operation of the U.PD70616 while an exception is an event which occurs as a direct result of program execution. When an interrupt or exception is recognized, the program is suspended and control is transferred to an interrupt or exception handler. Processing of interrupts and exceptions is similar but differ slightly in the operation of the interrupt enable flag and the stack pointer used during interrupt or exception processing. Reset is a special type of exception. When reset occurs, all processor activity is stopped and the processor is initialized to the reset state. System Base Table When an interrupt or exception is recognized, the SBT (System Base Table) is used to locate the appropriate vector. The SBT consists of 256 entries each containing a vector to an interrupt or exception handler. An SBT entry consists of a 32-bit virtual address in the virtual address mode. In the physical address mode, an SBT entry consists of a 24-bit physical address with the high order eight bits being ignored by the U.PD70616. The SBT is located in the memory address space aligned on a page (4KB) boundary by the SBR (System Base Register). The first 64 SBT entries (0-63) are reserved for use by U.PD70616 interrupts and exceptions. The remaining 192 entries (64-255) are available in user applications as maskable interrupt vectors. Figure 8-1 . System Base Table Entry -i 1 ' i 1 1 1 1 1 1 1 1 i r i r- Interrupt/Exception Handler Address The starting address of an interrupt/exception handler must be aligned on a word boundary. 1.0 8-1 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS ^PD70616 PROGRAMMER'S REFERENCE MANUAL Figure 8-2. System Base Table (SBT) vector offset 255 + 1020 Application Interrupt Vectors ; (Maskable Interrupts) 64 +256 63 Software Trap 15 +252 62 Software Trap 14 +24B 61 Software Trap 13 +244 60 Software Trap 12 +240 59 Software Trap 1 1 +236 58 Software Trap 10 +232 57 Software Trap 9 +228 56 Software Trap 8 +224 55 Software Trap 7 +220 54 Software Trap 6 +216 53 Software Trap 5 +21 52 Software Trap 4 +208 61 Software Trap 3 +204 50 Software Trap 2 +200 49 Software Trap 1 + 196 46 Software Trap + 192 47 4 188 RPJ 33 132 32 Emulation Mode Exception h 128 31 RFU < 1-124 30 RFU n1-120 29 Asynchronous Task Trap < 116 28 Asynchronous System Trap h 112 27 Change to Execution Level 3 108 26 Change to Execution Level 2 104 25 Change to Execution Level 1 100 24 Change to Execution Level 96 23 Decimal Arithmetic Exception 92 22 Floating Point Arithmetic Exception 88 21 Integer Arithmetic Exception 84 20 Illegal Data Field Exception +80 19 Mode Exception Illegal Addressing +76 18 Reserved Addressing Mode Exception +72 17 Privileged Instruction Exception +68 16 Reserved Opcode Exception +64 15 RFU +60 14 Address Trap +56 13 Instruction Breakpoint Exception +52 12 Instruction Trace Exception +48 11 Address Translation Exception +44 10 Memory Protection Exception +40 9 Page Not Present Exception +36 8 Area Not Present Exception +32 7 Stack Invalid Exception +28 6 RFU +24 5 RFU +20 4 System Fault +16 3 Serious System Fault +12 2 Non-Maskable Interrupt +8 1 Bus Freeze +4 RFU A Rystem Base Register (SBR) S •6 236 8-2 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Interrupt and Exception Processing When an interrupt or exception is recognized, the following actions are performed and control is transferred to the specified interrupt/exception handler. (i) PSW.EL«-00(Note1) (ii) PSW.IE flag modification • interrupt PSW.IE <- (maskable interrupts disabled) • exception PSW.IE unchanged (Note 2) (iii) PSWTE<-0 PSW.TP <- PSW.AE <- (iv) PSW.EM <- (native mode) (v) PSW.ASA <- 1 (Note 3) (vi) temp <- SBT[ vector ] (vii) interrupt/exception information is stored on the stack • interrupt IS (ilnterrupt stack) • exception L0SP(Note4) (viii) PC <- temp The contents of the stack following an interrupt or exception is shown in Figure 8-5. Figure 8-3. interrupt/Exception Stack Format Interrupt PSW Addresses PC SP »fr 237 Exception Exception Parameter Exception Code Parameter Count PSW PC SP The parameter count indicates the number of bytes of exception information in addition to the PC and PSW in the exception data. It is used by exception handlers to determine the number of bytes to discard from the stack following the processing of the exception. Notel It the exception is caused by the CHLVL instruction or an Asynchronous Task Trap then the specified execution level is set. Note 2 Bus error and level stack invalid exceptions will disable maskable interrupts. Note 3 If an ATT (Asynchronous Task Trap) occurs then Asynchronous System Trap is enabled. Note 4 If the previous stack was the interrupt stack then the IS is continued to be used. 1.0 8-3 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL The value of the PC placed on the stack varies depending on the type of exception as follows: • An exception during the execution of an instruction stacks the PC of the instruction causing the exception (Current PC). • An exception following the execution of an instruction stacks the PC of the instruction immediately following the instruction which caused the exception (Next PC). Interrupts Interrupts are requests for service from external devices and include the fault interrupt, non-maskable and maskable interrupt input signals. Following the acknowledgement of an interrupt, the PC and PSW are saved on the interrupt stack and program control is transferred to the predesignated or supplied vector at execution level 0. (i) Fault Interrupt The fault interrupt is used in systems employing functional redundancy monitoring (FRM). If a fault interrupt is detected, the U.PD7061 6 enters the halt state and the address and data buses are placed in the high impedance mode. Actual processing of the fault interrupt is delayed until after the fault interrupt input is negated. During the processing of a fault interrupt, non-maskable interrupts are disabled. (ii) Non-Maskable Interrupt (NMI) Non-maskable interrupts are used to signal the occurrence of catastrophic events such as a loss of power. Non-maskable interrupts cannot be masked by software. Another non-maskable interrupt will not be acknowledged until the processing of the first NMI completes and the RETIS instruction is executed. (iii) Maskable Interrupt (Ml) Maskable interrupt requests are generated by an external interrupt controller. A privileged program can control the recognition of maskable interrupts by the means of the IE (Interrupt Enable) bit in the PSW register. Following the occurrence of a maskable interrupt, further maskable interrupts will be disabled until the PSW.IE is again set. Exceptions Exceptions are divided into the following categories: • Serious System Exceptions • System Exceptions • Stack Invalid Exceptions • Memory Management Exceptions • Software Debug Exceptions • Instruction Exceptions • Arithmetic Exceptions • Change Execution Level • Asynchronous Traps • Emulation Mode Exceptions • Software Traps can be found in Table 8-1 A list of the possible U.PD70616 exceptions and their associated exception stack formats 8-4 1 ° PRELIMINARY INFORMATION U.PD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS H.PD70616 Exception Processing The complete set of exception conditions are described below. For each possible exception, a short summary of the exception and the control flow for correcting and recovering from the exception is presented. Serious System Faults Serious system faults are potentially catastrophic events such as a bus error. When a serious system fault is detected, the exception information is pushed onto the interrupt stack and control is transferred to the serious system fault exception handler. • Bus Error A bus error indicates that a memory or I/O bus cycle has failed and that external hardware is unable to correct the fault. In the case of a bus error, the exception address stored on the stack is the physical address that generated the exception. Both maskable and non-maskable interrupts are disabled during the execution of the bus error exception handler until the RETIS instruction is executed.. When a bus error involves the interrupt stack or a second bus error occurs during the processing of the initial bus error, the situation is deemed unrecoverable and the processor will halt. System Faults System faults are exceptions which occur as a result of external events. When a system fault occurs, the exception 'information is pushed on the interrupt stack and control is transferred to the system fault exception handler. • Invalid Interrupt An invalid interrupt exception occurs when an external interrupt controller supplies a system base table vector in the range of to 63. These interrupt/exception vectors are reserved for system use and attempted use will result in an exception. Stack Invalid Exceptions It is necessary to avoid additional exceptions during the processing of an exception. Exceptions involving the level stack and double exceptions are included in this category. • Level Stack Invalid A level stack invalid exception occurs when a memory management exception is generated when attempting to access the level stack. Because other exceptions normally use the level stack during exception processing, this exception must be handled differently. When a level stack invalid exception occurs, the stack is switched to the interrupt stack and the level stack invalid exception handler is entered to process the exception. • Double Exceptions When an exception occurs, the stack is switched to the level stack (or other stack in the case of an asynchronous task trap or change execution level exception) and the exception information is saved. A double exception occurs another exception is encountered while saving the exception information from if the first exception on the stack. 8-5 PRELIMINARY INFORMATION 1.0 INTERRUPTS AND EXCEPTIONS |iPD7061 6 PROGRAMMER'S REFERENCE MANUAL When a double exception occurs, the stack Is changed to the interrupt stack and the double exception information is stored together with the information from the first exception. The exception handler must then make the stack accessible and copy the first exception information from the interrupt stack to the invalid stack. The RETIS instruction will automatically transfer control to the first exception handler since the return address in exception frame contains the entry point of the first exception handler. A bus error during the exception information saving will be processed as a bus error and the first exception disregarded. Memory Management Exceptions Memory management exceptions are divided into three separate types. Not present exceptions occur when a needed address translation table is not present in memory and must be brought in from secondary storage. Protection exceptions are detected when an instruction attempts to access a location without first having established the proper permissions. Translation exceptions occur when an invalid or out of range translation table entry is referenced during the address translation process. Memory management exception handlers have the option of restarting the faulted instruction or terminating the task if the fault cannot be corrected. • Area Not Present • Page Not Present These exceptions occur the area table entry or page table entry has a cleared P (Present) bit. The exception if handler must read in the area or the page from secondary storage and restart the instruction by executing the RETIS instruction. Read Access Violation Write Access Violation Read/Write Access Violation Execute Access Violation I/O Access Violation Access violations occur when the faulted instruction does not have the proper permissions to complete the access. Read, write and execute permissions are checked at both the area and page levels and an access violation will occur if: The present execution level is less than the specified ATE access level for the access. PSW.EL > RDL, WRL, EXL { The page level permission for the access type is disabled. An I/O access violation will occur if an access crosses a page boundary and the pages are mapped in different address spaces. The exception handler processes protection faults by aborting the task or changing the access permissions and restarting the instruction. 1 -0 PRELIMINARY INFORMATION 8-6 UPD7061 6 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Invalid Section Section Length Violation Invalid Area Area Length Violation Invalid Page Invalid translation faults occur when a section, area or page is marked as not valid. In addition to the validity check, a length check is made on sections and areas to determine if the access exceeds the defined length of the section or area. The ATBR (Area Table Base Register) and the area table entries and page table entries all contain a V (Valid) bit which the memory management unit uses to determine the translation is valid. The ATLR (Area Table if Length Register) and ATE also contain a length parameter that defines the total size of the section or area. These entries are used to determine an access beyond the defined region would take place. if The exception handler must either abort the task or allocate additional memory resources and restart the instruction. Instruction Exceptions Instruction exceptions involve improper use of an instruction, operand or addressing mode. The exception handler is responsible for analyzing the cause of the fault and either aborting the task or emulating the instruction . Instruction exception are detected before the instruction executes and the exception information contains the PC of the instruction causing the fault. • Reserved Opcode Reserved opcode exceptions occur when an attempt is made to execute an opcode which is not assigned a valid instruction. These opcodes are reserved for future instruction set extensions. • Reserved Addressing Mode Reserved opcode exceptions occur when an attempt is made to use a reserved addressing mode. These addressing mode encodings are reserved for future extensions to the addressing modes. • Illegal Instruction Format If an instruction encoding cannot be decoded into one of the seven instruction formats, an illegal instruction format exception will occur. • Illegal Addressing Mode An illegal addressing mode exception occurs when a valid addressing mode is used improperly. An example of an illegal addressing mode exception is an attempt to use an immediate addressing mode as the destination operand in an instruction. • Privileged Instruction A privileged instruction exception will occur if an attempt is made to execute a privileged instruction at an execution level other than level 0. 8-7 PRELIMINARY INFORMATION 1.0 INTERRUPTS AND EXCEPTIONS U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL • Illegal Data Field An illegal data field exception occurs when an error is detected in the size of an operand. For example, the bit field data type can range in length from to 32 bits. Should a length greater than 32 bits be specified, an illegal data field exception will occur. Arithmetic Exceptions Arithmetic exceptions occur as a result of arithmetic operations. Three different classes of exceptions are supported for each of the integer, floating point and decimal data types. Integer Exceptions • Integer Zero Divide A zero divide exception occurs when a divisor of zero is used in a divide or remainder instruction. A zero divide exception sets the PSW.OV flag and leaves the destination unmodified. • Integer Overflow the Integer overflow occurs when the result of an operation cannot be expressed in the precision of destination. An integer overflow exception is caused by executing the BRKV. instruction with the PSW.OV flag set. Floating Point Exceptions • Floating Point Zero Divide A floating point zero divide exception occurs when zero is used as divisor, except in the of case of + which is an invalid floating point operation. The PSW.FZD flag will be set a zero divide takes place. if Floating point zero divide exceptions are enabled by the TKCW.FZT bit. If this bit is set, then the exception will occur immediately and the destination will remain unchanged. If zero divide exceptions are disabled, an infinite result will be placed in the destination operand and program execution will continue. • Floating Point Overflow • Floating Point Underflow operand incapable of Floating point overflow and underflow exceptions occur when the destination is representing the magnitude of a floating point result. When floating point overflow occurs, the PSW.FOV flag is set. An overflow exception will occur immediately if the TKCW.FOT bit is set or will be delayed and an infinite result will be placed in the destination operand. When floating point underflow occurs, the PSW.FUD flag is set. An underflow exception will occur placed in the destination immediately the TKCW.FUT bit is set or will be delayed and a denormal result will be if operand. PRELIMINARY INFORMATION 8-8 UPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS When exceptions are enabled, the overflow/underflow condition will result in an immediate exception. If the exception occurs as a result of a arithmetic operation, a corrected exponent is stored in the destination operand. Overflow/underflow exceptions caused by a data type conversion instruction will leave the destination operand unchanged. Short Reals Long Reals Overflow -192 -1536 Underflow +192 +1536 I -—J • Floating Point Precision A floating point precision exception occurs when the result of an arithmetic or data type conversion operation cannot be exactly expressed in the precision of the destination operand and must be rounded. When a precision exception occurs, the PSW.FPR bit is set and the exception will occur if the TKCW.FPT bit is set. The rounded result will stored in the destination operand regardless of the state of the TKCW.FPT flag. • Invalid Floating Point Operation An invalid floating operation exception will occur if one of the following operations is attempted: + normal + denormal denormal + denormal The PSW.FIV flag will be set as a result of an invalid operation. If the exception is enabled, the destination operand remains unchanged. If disabled, a QuietNaN is stored in the destination and execution continues. • Reserved Floating Point Operand A reserved floating point operand exception occurs when a NaN or infinity is used as the operand in an instruction. The destination operand is unchanged as a result of this exception. Decimal Exceptions • Decimal Format A decimal format exception occurs when the result of a decimal arithmetic operation or data type conversion is not a valid BCD representation. Software Debug Exceptions • Instruction Trace When enabled, instruction trace exceptions occur following the execution of each instruction. Because of the possibility of multiple exceptions and the subsequent restart of an instruction, the TE (Trace Enable) flag is supplemented by the TP (Trace Pending) flag. Prior to entering the exception handler, both the PSW.TE and PSW.TP fields are cleared. • Instruction Breakpoint An instruction breakpoint exception occurs when the BRK instruction is executed. 8-9 PRELIMINARY INFORMATION 1.0 INTERRUPTS AND EXCEPTIONS U.PD70616 PROGRAMMER'S REFERENCE MANUAL The PC image in the exception information contains the address of the instruction breakpoint. This allows the exception handler to restart the instruction following the removal of the breakpoint. Address Trap An address trap occurs when an access occurs that meets the trap conditions in either of the two address trap registers and address traps are enabled in the PSW. Address traps are controlled by the following registers: • TRMOD access types • ADTR trap base address • ADTMR trap address range The AE (Address Trap Enable) flag in the PSW is cleared before entering any interrupt or exception handler. The exception handler can determine which address trap occurred by examination of the address trap exception code. Figure 8-4 Exception Detection Sequence XZ Before instruction execution: • Trap if PSW.TP = 1 • PSW.TP <- PSW.TE Iz Execute the instruction \z After instruction execution: • Check for simultaneous exceptions and and nest the exception information • PSW.TP <-- if the instruction must be restarted 8-10 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Change Execution Level Exceptions ^ The change execution level exceptions are provided to allow unprivileged tasks access to system functions and devices in a controlled manner. • Change to Execution Level • Change to Execution Level 1 • Change to Execution Level 2 • Change to Execution Level 3 The stack is switched to the execution level specified in the instruction and the exception information is saved. The second operand of the instruction is zero extended to word length and used as the exception parameter. Asynchronous Traps Asynchronous traps are used to notify the system or a task of the occurrence of an important event. Asynchronous traps are important in the design of operating systems because the trap can be immediate or may be delayed until a specified execution level is reached. Two types of asynchronous traps are supported. The AST (Asynchronous System Trap) is used to inform the operating system of an event while the ATT (Asynchronous Task Trap) is used to inform a task of an event. Asynchronous traps are detected by the RETIS/RETIU instructions. During the execution of these instructions, the SYCW.AST and TKCW.ATT fields are compared with the execution level of the destination. If the new execution level is greater or equal to the AST/ATT level the asynchronous trap will occur. Asynchronous system and task traps operate similarly but differ slightly in the execution level of the trap handler. Trap Execution level after the trap AST level ATT level determined by the ATT AST/AH L ev el level AST/ATT 1 level 1 AST/ATT 1 level 2 AST/ATT 1 1 level 3 AST/ATT 1 AST/ATT disabled 1 1 AST/ATT disabled 1 1 AST/ATT disabled 1 1 1 AST/ATT disabled Asynchronous System Trap The AST (Asynchronous System Trap) is a means of informing the operating system of events. When an interrupt or exception occurs, is desirable to minimize the time that interrupts are disabled. The exception it handler need only set the AST level to the user level and exit. When control is return to the user level the AST will occur and the operating system entered. This technique simplifies the software interface between interrupt/exception handlers and the operating system. Following the detection of an AST, the execution level is changed to level and control is transferred to the AST handler. 8-11 PRELIMINARY INFORMATION 1.0 INTERRUPTS AND EXCEPTIONS UPD7061 6 PROGRAMMER'S REFERENCE MANUAL An asynchronous system trap will be disregarded while the PSW.ASA field indicates an earlier AST is being serviced. • Asynchronous Task Trap The ATT (Asynchronous Task Trap) is a means for entering user trap handlers. Because user trap handlers cannot be allowed to execute at level 0, the ATT is a means to permit task specific trap handlers to execute at non-privileged execution levels. Applications of asynchronous task traps include activation of task exception handlers or task termination processing. Following the detection of an ATT, the execution level is changed to the level specified by the TKCW.ATT field and control is transferred to the ATT handler. During context switching, the ATT is stored as part of the task context in the TCB by the STTASK instruction and loaded from the TCB by the LDTASK instruction. Asynchronous task traps are disregarded when: an AST and ATT occur simultaneously, the PSW.ASA field indicates an AST is being serviced, the PSW.ATA field indicates an ATT is being serviced. Emulation Mode Exceptions Emulation mode exceptions are exceptions which occur during the execution of emulation mode programs. Following the detection of an exception, the emulation mode PC is pushed on the stack and native mode is enabled to process the exception. The exception handler must examine the exception parameter and determine the correct method of emulation for each instance. • Emulation Mode Privileged Instruction The emulation mode system instructions listed below have been made privileged to allow operation in a protected environment: IN*, OUT*, INM, OUTM, HALT BRK, RETI, POP PSW*. El, Dl The PC stored with the exception information is the address of the byte immediately following the first byte of the instruction causing the exception. • Emulation Mode Reserved Opcode This exception occurs if a reserved but unimplemented opcode is attempted to be executed. Included in the list of reserved opcodes is the BRKEM (Break for Emulation) instruction. The PC stored with the exception information is the address of the byte immediately following the first byte of the instruction causing the exception. • Emulation Mode Zero Divide A zero divide exception has occurred in emulation mode. The PC stored with the exception information is the address of the next instruction. Conditionally trapped, see Section 10 for details. PRELIMINARY INFORMATION 8-12 10 UPD7061 6 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS • Emulation Mode Single Step Trap This exception occurs when an Instruction executes and modifies the emulation mode PSW2.BRK flag. The PSW2 BRK flag has no effect on single step and the native mode PSW.TE flag must be used to single step emulation mode programs. • Emulation Mode Overflow This exception occurs when the emulation mode BRKV instruction is executed with the PSW2.0V flag set. • Emulation Mode Index This exception occurs when the emulation mode CHKIND (Check Index) instruction is executed and the array index is found to be out of range. • Emulation Mode Coprocessor Not Present This exception occurs if an FP01 or FP02 instruction is executed and an external coprocessor is not connected. Software Traps Software traps are an implementation dependent method of implementing user traps. • Software Trap 0-15 When the condition field in a TRAP instruction and the PSW is satisfied, the specified software trap will occur. 1.0 8-13 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS UPD70616 PROGRAMMER'S REFERENCE MANUAL Interrupt/Exception Stack Formats Figure 8-5. U.PD70616 Interrupt/Exceptions (the @ symbol indicates a pointer value) Bus Freeze Interrupt .Abort. Interrupts Disabled #1 Bus Freeze Interrupt PSW PC (Current PC) Interrupt — Continue — Interrupts Disabled #2 Non-Maskable Interrupt PSW #64-255 Maskable Interrupts PC (Next PC) Serious System Faults — Abort- Interrupts Disabled #3 Bus Fault +12 Exception Address (Note : The exception address is a physical address) +8 Exception Code 8 +4 PSW PC System Exceptions — Abort /Ignore Interrupts Disabled #4 System Fault +8 Exception Code 4 Invalid Interrupt +4 PSW PC PRELIMINARY INFORMATION 8-14 1.0 LiPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Level Stack Invalid — Abort /Retry Interrupts Disabled #7 Level Stack Invalid +12 Exception Address Single Exception +8 Exception Code 8 +4 PSW PC (Current PC) Double Exception +16 First Exception Information +12 Exception Address +8 Exception Code 8 +4 PSW @ First Exception Handler Memory Management Exceptions Rerty/Abort. #8 Area Not Present Exception +12 Exception Address #9 Page Not Present Exception #1 Memory Management Exceptions +8 Exception Code 8 I/O Access Violation Read Access Violation +4 PSW Write Access Violation PC (Current PC) #1 1 Address Translation Exceptions Invalid Section Section Length Violation Invalid Area Area Length Violation Invalid Page 1.0 8-15 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS ^PD70616 PROGRAMMER'S REFERENCE MANUAL Software Debug Exceptions — Continue i #1 2 Instruction Trace Exception +8 Exception Code 4 +4 PSW PC (Next PC) #13 Instruction Breakpoint Exception +8 Exception Code 4 +4 PSW PC (Current PC) #1 4 Address Trap PC (Current PC) +12 +8 Exception Code 8 +4 PSW PC (Next PC) Instruction Exceptions — Abort Emulate / < #1 6 Reserved Opcode +8 Exception Code 4 #17 Privileged Instruction #18 Reserved Addressing Mode +4 PSW #1 9 Illegal Addressing Mode Illegal Instruction Format PC (Current PC) 86248 #20 Illegal Data Field 8-16 1.0 PRELIMINARY INFORMATION ^PD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Arithmetic Exceptions — Abort/ Continue #21 Integer Exceptions Zero Divide •12 PC (Current PC) Overflow +8 Exception Code 8 #22 Floating Point Exceptions +4 PSW Zero Divide Overflow PC (Next PC) Underflow Precision Invalid Floating Point Operation Reserved Floating Point Operand #23 Decimal Exceptions Decimal Format Change Execution Level Exceptions — Continue — #24 Change to Execution Level +12 Parameter #25 Change to Execution Level 1 #26 Change to Execution Level 2 +8 Exception Code 8 #27 Change to Execution Level 3 +4 PSW PC (Next PC) Asynchronous Traps — Continue #28 Asynchronous System Trap +8 Exception Code 4 #29 Asynchronous Task Trap +4 PSW PC (Next PC) Emulation Mode Exceptions : Abort /Continue #32 Emulation Mode Exceptions Privileged Instruction +12 PC (Current PC) Reserved Opcode +8 Exception Code 8 Zero Divide Single Step Trap +4 PSW Overflow PC (Next PC) Array Bounds CP Not Present 1.0 8-17 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS ^PD70616 PROGRAMMER'S REFERENCE MANUAL Software Traps Continue > #48-63 Software Traps +8 Exception Code 4 +4 PSW PC (Next PC) 8-18 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Exception Codes Table 8-1. uPD70616 Exception Codes Code Serious System Exceptions Code Software Debug Exceptions 0301 string data write bus error 0C00 instruction trace 0303 fixed length data write bus error 0D00 instruction breakpoint 0305 translation table write bus error 0E01 address trap 0309 string I/O write bus error 0E02 address trap 1 030B fixed length I/O write bus error 0E03 address traps and 1 0311 string data read bus error 0313 fixecflength data read bus error Instruction Exceptions 0314 system base table read bus error 0315 translation table read bus error 1000 reserved instruction 0317 instruction fetch bus error 1100 privileged instruction 0319 string I/O read bus error 1200 reserved address mode 1300 illegal addressing mode 031 fixecflength I/O read bus error 031 interrupt vector read bus error 1301 illegal instruction format 1400 illegal data field System Exceptions Arithmetic Exceptions 0400 illegal interrupt 1500 integer zero divide Stack Invalid Exceptions 1501 integer overflow 1601 floating point precision 0700 area not present — 1602 floating point underflow these exception codes can combine in the case of 0701 0702 page not present I/O access violation 1604 floating point overflow : simultaneous exceptions 1608 floating point zero divide 0703 read access violation 1610 invalid floating point operation 0704 write access violation 1680 reserved floating point operand level stack invalid 0705 read/write access violation 1780 decimal format exception 0707 invalid section 0708 section length violation Change Execution Level Exceptions 0709 invalid area 070A area length violation 1800 change to execution level 070B invalid page — 1900 change to execution level 1 0780 area not present — 1A00 1B00 change to execution level 2 change to execution level 3 0781 page not present 0782 I/O access violation Asynchronous Traps 0783 read access violation 0784 write access violation 1C00 asynchronous system trap double exception 0785 read/write access violation 1D00 asynchronous task trap 0787 invalid section 0788 section length violation Emulation Mode Exceptions 0789 invalid area 078A area length violation 2000 emulation mode privileged instruction 078B invalid page — 2001 2002 emulation mode reserved instruction emulation mode zero divide Memory Management Exceptions 2003 emulation mode single step trap 2004 emulation mode overflow 0800 area not present 2005 emulation mode index 0901 page not present 2006 emulation mode coprocessor not present 0A02 I/O access violation 0A03 read access violation Software Traps 0A04 write access violation 0A05 read/write access violation 3000 software trap 0A06 execute access violation 3100 software trap 1 3200 software trap 2 0B07 invalid section 0B08 section length violation 0B09 invalid area 0B0A area length violation 3F00 software trap 15 0B0B invalid page 1.0 8-19 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS JAPD70616 PROGRAMMER'S REFERENCE MANUAL Reset The U.PD70616 is reset when the RESET input pin is asserted. When reset occurs, internal registers and bus interface are initialized and enter the reset state. Following the negation of RESET, the U.PD7061 6 will begin program execution at address OFFFFFFFOH. Following reset, the processor is in the physical address mode using the native mode instruction set. The program execution level is set to level using the interrupt stack and maskable interrupts are disabled. The internal state following reset is shown in Figure 8-6. Figure 8-6. U.PD70616 Reset State Register Contents PC FFFFFFFOH PSW 10000000H RO - R31 Undefined LOSP - L3SP, ISP Undefined SYCW 00000070H TKCW 0000E000H SBR OOO00O00H TR Undefined ATBR0-ATBR3 Invalid ATLRO - ATLR3 Undefined ADTRO/1 ADTMRO/1 , , TRMOD Undefined PSW2 0000F002H M-2S6 8-20 1.0 PRELIMINARY INFORMATION UPD7061 6 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Interrupt/Exception Nesting Multiple interrupts and exceptions can occur simultaneously. In the event of multiple exceptions or interrupts, the P.PD7061 6 assigns each a priority and nests the exception information on the stack according to the priorities of each interrupt or exception. In general, when nesting multiple exceptions, the exception stack frames are pushed onto the stack in order of increasing priority while the processing of the exceptions will occur in order of decreasing priority. When stacking multiple exception information, the first PC pushed on the stack is a pointer to the current or next instruction. Subsequent PC images are pointers to the exception handlers to be executed in order of their priority. There are some cases which are handled slightly differently than described above: • Ifa reset, bus freeze or serious system exception occurs, all other interrupts and exceptions are ignored. Reset is the highest priority event and takes precedence over all other interrupts and exceptions. • Ifa maskable and non-maskable interrupt occur simultaneously, only the non-maskable interrupt will be recognized. The servicing of the maskable interrupt condition will delay until the completion of the non- maskable interrupt handler. • An address trap will be ignored if it occurs in conjunction with an exception that will restart instruction execution. • An instruction trace exception will be ignored occurs in conjunction with an exception that will restart if it instruction execution. The instruction trace exception frame is not stored and the PSW field in the other exception frame will have the TP (Trace Pending) bit cleared, preventing an instruction trace exception from occurring when the instruction is restarted. • Memory management exceptions are not nested with other exceptions. If a memory management exception or address trap occurs simultaneously with a maskable interrupt, it will be ignored and the instruction later restarted. Table 8-2 is a complete list of the combinations of simultaneous interrupts and exceptions. In this table, interrupts and exceptions are listed across the top and down in order of increasing priority. The action taken in the case of two or more simultaneous interrupts or exceptions can be determined by finding the first exception in the top row and reading down until the column intersects the desired interrupt/exception. For example, in the case of the instruction trace exception, an arithmetic exception, address trap, maskable and non- maskable interrupt will all be recognized and serviced in order of priority. If an instruction/memory management exception or a serious system fault, bus freeze or reset interrupt occur, the instruction trace exception will be ignored. -j 8-21 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS U.PD70616 PROGRAMMER'S REFERENCE MANUAL Table 8-2. Multiple Interrupt/Exception Processing — Increasing Priority ^v. Interrupt/Exception A I M A M N s B R R N M D I M E F E ^""s^ I S E I R R S Possible ^-s^ T T T I E E Simultaneous Interrupts/Exceptions n. H R R Z T SINGLE O • • O O O • • ARITH - - O • • INSTR - * O O • • MME * O O O • Increasing Priority AD-TR O O • • Ml • • • NMI • • SERI • BFREZ TRACE.... Instruction Trace Exception ARITH Arithmetic Exception, Change Level Exception, Asynchronous Trap, Emulation Mode Exception, Software Trap INSTR Instruction Exception, Instruction Breakpoint Exception MME Memory Management Exception AD-TR Address Trap Ml Maskable Interrupt, Illegal Interrupt NMI Non-Maskable Interrupt SERI Serious System Exception BFREZ.. ..Bus Freeze Interrupt RESET.. ..Reset O Both exceptions are recognized and are serviced in order of priority. • The higher priority interrupt/exception is serviced and the lower priority exception is ignored. - The occurrence of both exceptions is not possible. * The lower priority exception is serviced and the higher priority exception is ignored. 8-22 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Specific examples of interrupt/exception nesting are shown below: Figure 8-7 Simultaneous Instruction Trace, Arithmetic and Non-Maskable Interrupt Exception Processing exception parameter Target Program PSW(TP-1) PC (target program) M > Level Stack increasing addresses PSW (TP . 0) PC (arithmetic exception handler) Interrupt Stack This example shows the operation of the priority selection logic in servicing simultaneous interrupts and exceptions. 1 The first action taken is to push the arithmetic exception frame on the level stack. Because an instruction trace exception also occurred, the PSW image will have the TP bit set. The TE and TP fields in the PSW are then cleared during exception processing. 2. Next the stack is switched to the interrupt stack for the storage of the interrupt frame. The PC image in the interrupt frame is the entry point of the arithmetic exception handler which is scheduled to be serviced next following the completion of the maskable interrupt handler. The PSW. IE field is cleared to disable further maskable interrupts. 3. When the maskable interrupt handler terminates, the RETIS instruction pops the interrupt frame from the interrupt stack and transfers control to the arithmetic exception handler. 4. The arithmetic exception handler is now using the execution level stack. When the exception condition has been corrected, the arithmetic exception handler executes an RETIS instruction. The instruction trace handler is then entered since the PSW.TP field is set. 1.0 8-23 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS U.PD70616 PROGRAMMER'S REFERENCE MANUAL Figure 8-6 Simultaneous Instruction Trace and Page Not Present Exception Processing exception parameter Target Program PSW (TP - 0) PC (target program) r Level Stack increasing addresses This example demonstrates the restart of an instruction following a page not present exception and delay of the instruction trace exception. 1 When an exception requiring the restart of the instruction and an instruction trace exception occur simultaneously, the instruction trace exception is ignored. The memory management exception frame is pushed on the level stack with the TP field in the PSW field cleared and the PC image pointing to the first byte of the instruction. Program control is then transferred to the memory management exception handler. 2. When the page has been brought back into physical memory, the handler executes an RETIS instruction. The restored PC returns program control to the faulted instruction and because the PSW.TP flag is clear, no instruction trace exception will occur. 8-24 1.0 PRELIMINARY INFORMATION UPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Figure 8-9 Simultaneous Page Not Present and Maskable Interrupt Exception Processing exception parameter (j) Target Program PSW(TP-1) PC (target program) ^ ^ mov.w r1, [rO] Level Stack J© Maskable Interrupt Handler increasing addresses Page Not Present Handler PSW (TP - 0) PC (page not present handler) Interrupt Stack This example shows how the memory management exception is ignored if a simultaneous maskable interrupt occurs. 1. When a page not present exception and a maskable interrupt occur simultaneously, the memory management exception is ignored and only the maskable interrupt is serviced. The maskable interrupt frame is pushed on the interrupt stack with the TP field of the PSW cleared. Control is then transferred to the maskable interrupt handler with further maskable interrupts disabled. 2. The maskable interrupt handler terminates by executing a RETIS instruction, the restored PC and PSW.TP indicate to restart the instruction that originally caused the page not present exception The . re-execution of the instruction will again generate a page not present exception which will be processed as normal memory management exception. 1.0 8-25 PRELIMINARY INFORMATION INTERRUPTS AND EXCEPTIONS UPD706T6 PROGRAMMER'S REFERENCE MANUAL Figure 8-10 Simultaneous Arithmetic Exception, Maskable and Non-Maskable Interrupt Processing exception parameter Target Program PSW(TP-1) PC (target program) Level Stack increasing addresses PSW (TP - 0) PC (arithmetic exception handler) Interrupt Stack The final example demonstrates the occurrence of a simultaneous arithmetic exception with both maskable and non- maskable interrupts. 1 The exception processing begins by stacking the arithmetic exception frame on the level stack. 2. Next, when maskable and non-maskable interrupts occur simultaneously, the maskable interrupt is ignored and the non-maskable interrupt stack frame is is pushed on the interrupt stack and the NMI handler is entered. The return PC on the stack contains the entry point of the arithmetic exception handler. During the processing of the non-maskable interrupt, maskable interrupts and additional non-maskable interrupts are disable. 3. When the NMI handler terminates, an RETIS instruction is executed. However, rather than popping the exception frame from the interrupt stack and entering the arithmetic exception handler, program control is vectored immediately to the specified maskable interrupt handler. 4. When the maskable interrupt handler terminates, the restored PC transfers control to the arithmetic exception handler. Following the correction of the exception condition, control is returned to the original program. PRELIMINARY INFORMATION 8-26 1.0 LIPD70616 PROGRAMMER'S REFERENCE MANUAL INTERRUPTS AND EXCEPTIONS Interrupt/Exception Stacks The active stack is determined by the contents of the EL (Execution Level) and IS (Interrupt Stack) fields in the PSW register as shown below: EL IS Selected Stack 00 1 Interrupt Stack (ISP) 00 Level Stack (LOSP) 01 Level 1 Stack (L1SP) 10 Level 2 Stack (L2SP) 11 Level 3 Stack (L3SP) M-261 A program always sees only a single stack pointer regardless of the execution level. The PSW.EL and PSW. IS fields identify the active stack pointer (SP) and the contents of the active SP point to the top of stack (TOS) element on the active stack. The cache of five stack pointer registers (L0SP-L3SP, ISP) are independent of the user SP (R31). The user stack is switched whenever the execution level changes due to an interrupt or exception. Before changing stacks, the contents of the SP register are saved back in the contents of the corresponding stack pointer register. Because the SP is updated by any instruction affecting R31 the contents of the SP and the associated stack pointer register can , differ during the execution of a program. Notes It is possible for the active stack to become invalid due to a memory management exception, the occurrence of this condition is described below: (1) Level 1 / 2 / 3 Stacks Invalid If the level 1/2/3 stack becomes invalid, an exception is generated and the execution level changes to level and the level stack becomes the active stack. Following the correction of the exception condition the original stack is restored. If the stack invalid exception occurs during the stacking of exception information from an asynchronous task trap or change level exception, a double stack exception will occur. (2) Level Stack Invalid If the level stack is invalid, a level stack invalid exception is generated and the interrupt stack (ISP) becomes the active stack. (3) Interrupt Stack Invalid If the interrupt stack is found to be invalid, the U.PD70616 will halt until reset. For this reason, the interrupt stack must remain present. 8-27 PRELIMINARY INFORMATION 1.0 INTERRUPTS AND EXCEPTIONS J1PD7061 6 PROGRAMMER'S REFERENCE MANUAL PRELIMINARY INFORMATION 8-28 1 -° HPD7061 6 PROGRAMMER'S REFERENCE MANUAL SOFTWARE DEBUG SUPPORT Section 9 Software Debug Support This section describes the software debug facilities of the U.PD7061 6 microprocessor. The size and complexity of 32- bit systems demands that on-chip hardware contribute to the problem of debugging complex application and system software. The on-chip software debug support offered by the U.PD70616 aids in quickly identifying the errant sections of a program without spending hours over listings and real-time traces. Three separate software debug tools covering a wide range of debug strategies are supported: • instruction trace • instruction breakpoints • address traps Instruction trace is used to slowly execute a program to permit close observation of its behavior. Following the execution of each instruction, the program is interrupted and the instruction trace exception handler is entered. Because of the coupling to the U.PD70616 instruction set, instruction trace is frequently used to observe and debug programs at the assembly language level. Often millions of instructions must be executed to reach the point of interest in a program and single stepping through each instruction is obviously inadequate. Instruction breakpoints allow real-time execution up to a special instruction and then cause an exception, allowing the breakpoint handler to regain control of the system and display the program state. Both instruction trace and instruction breakpoints address the problems of debugging the instruction stream but are ho help in debugging a section of ROM code or identifying wayward data write operations that can potentially destroy programs. To aid in the debug of these situations, a new type of hardware debug support known as address trapping is required. Address traps are the most flexible debugging tool since they combine an address along with an access type, permitting the hardware to distinguish between read, write and execute accesses anywhere within the virtual address space and to trap only those accesses which meet the specified trap conditions. The level of on-chip hardware support for these three debug operations has been hitherto unavailable on any 8-, 16- or 32-bit microprocessor. This high level of software debug support allows a software debugging tool to perform many of the tasks previously relegated to expensive in-circuit emulators. The end result is a powerful, low cost means of designing complex software systems without sacrificing software reliability. 1 o 9-1 PRELIMINARY INFORMATION SOFTWARE DEBUG SUPPORT U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL Instruction Trace Instruction trace (also referred to as single stepping) is a tool used to force an exception following the execution of each instruction. Instruction trace allows a software engineer to observe the execution of a program at the instruction level to locate and correct software errors. Instruction Trace Control Instruction trace exceptions are controlled by the TE (Trace Enable) field in the PSW register. PSW.TE = instruction trace disabled PSW.TE = 1 instruction trace enabled Because this field in the upper halfword of the PSW, a privileged instruction is required to enable and disable instruction trace. Instruction Trace Operation When instruction trace exceptions are enabled, following the execution of each instruction an instruction trace exception occurs. Prior to entry into the instruction trace exception handler, the PC and PSW are pushed onto the level stack and the PSW.TE field is cleared to allow the debugger to analyze program execution. To return back to the target program, the RETIS (Return from Interrupt - System) instruction is used. Following the occurrence of an instruction trace exception, the level stack contains the following information: • PC of the next instruction • exception code (0C00H) • PSW image • parameter count Refer to section 8 for the organization of the level stack following an instruction trace exception. Instruction Trace Pending As described in section 8, the existence of an interrupt or exception condition is checked following the execution of each instruction. Because instruction trace is the lowest priority of the many exceptions that can occur, all other higher priority exceptions will be processed ahead of an instruction trace exception. The other exceptions that can occur can be classified into those which restart or resume instruction execution and those which occur after the execution of the instruction is completed. In the latter case, operation of instruction trace is as described following the correction of the higher priority exception condition. The former case presents a problem since the instruction has yet to execute and it would be incorrect to process the instruction trace exception after the higher priority exception condition was corrected and once again after the instruction completes execution. The solution to this problem is for the U.PD70616 to keep track of the exception type so to be able to restart the instruction and delay the instruction trace exception until the instruction has completed execution. This is accomplished by the TP (Trace Pending) field in the PSW register. PSW.TP = no instruction trace pending PSW.TP = 1 instruction trace pending When the PSW.TP field is cleared, an instruction trace exception is not pending and the instruction is restarted without servicing the instruction trace exception. If the PSW.TP field is set, either no other higher priority exception has occurred or the exception occurred after the execution of the instruction was completed and the instruction trace exception should be honored. PRELIMINARY INFORMATION 9-2 10 U.PD70616 PROGRAMMER'S REFERENCE MANUAL SOFTWARE DEBUG SUPPORT Consider the following examples. Suppose that a program is being debugged with the instruction trace mode enabled and a higher priority exception also occurs. Case 1 Pre-execution exception Assume that an instruction makes a memory reference to an non-existent page and causes a page fault. Because the instruction has not executed and must be restarted, the PSW.TP field is cleared prior to being pushed on the stack. After the exception information is placed on the stack, instruction trace is disabled and the memory management exception handler is entered. After the missing page has been brought into physical memory, the faulted instruction is restarted. Because the PSW.TP field is cleared, the instruction trace exception is delayed until the instruction completes execution. Case 2 Post-execution exception Assume that an integer overflow exception has occurred. Because the instruction has completed execution, the PSW.TP field is set prior to being pushed on the stack. After the exception information is placed on the When the integer stack, instruction trace is disabled and the integer overflow exception handler is entered. overflow handler is finished and executes a RETIS/RETIU instruction, the restored PSW is checked and because the PSW.TP field is set, an instruction trace exception occurs. The PSW.TP field is controlled by the U.PD70616 microprogram. When an exception occurs that requires the instruction to restarted or resumed, the TP field in the PSW image pushed onto the stack is cleared and the instruction trace exception is delayed until the instruction completes execution. UPDPSW.W Instruction Enable of instruction trace is generally by the RETIS instruction. It is also possible for the privileged UPDPSW.W instruction to modify the PSW.TE field and enable or disable instruction trace under the following circumstances: • If instruction trace is enabled and a UPDPSW.W instruction executes and clears the PSW.TE field, a final instruction trace exception will occur after the completion of the UPDPSW.W instruction. • Ifinstruction trace is disabled and the execution of a UPDPSW.W instruction sets the PSW.TE field, the instruction trace exception will not occur until after the completion of the instruction following the UPDPSW.W instruction. Instruction Trace Note A final note on instruction trace operation. If the instruction trace exception handler accidentally enables instruction trace, an endless sequence of instruction trace exceptions can occur. Exercise caution when writing instruction trace exception handlers to avoid this situation. 1 9-3 PRELIMINARY INFORMATION SOFTWARE DEBUG SUPPORT U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL Breakpoint Traps The instruction breakpoint facility is used to implement program flow debuggingt. An instruction breakpoint is set by replacing the first byte of an instruction with the one byte BRK instruction. The program then executes at full speed until the breakpoint is reached and executed causing the breakpoint trap. Following the occurrence of an breakpoint trap, the level stack contains the following information: • PC of the current instruction • exception code (0D00H) • PSW image • parameter count Refer to section 8 for the organization of the level stack following a breakpoint trap. Note that only the first byte of a multi-byte instruction needs to be replaced with the BRK instruction. Subsequent bytes may be left unmodified without causing an exception since the breakpoint trap guarantees the remaining bytes of the instruction never reach the execution unit. Also a note of caution concerning infinite breakpoint traps. The setting of an instruction breakpoint within the breakpoint exception handler will cause repeated breakpoint traps until some other exception occurs and terminates the sequence of instructions. Exercise caution to avoid this situation. instructions corresponding to each line of tru t For example, a high level language debugger can set breakpoint traps at the machine high level language source code. 9-4 1 ° PRELIMINARY INFORMATION JXPD7061 6 PROGRAMMER'S REFERENCE MANUAL SOFTWARE DEBUG SUPPORT Address Traps Address traps are a powerful debugging facility that combine the occurrence of an address (or range of addresses) with one or more access types (read, write, execute) to generate an exception. Address traps differ from instruction trace and breakpoint traps since they operate on data accesses as well as instruction accesses and can span one or more tasks in a multitasking system. Address Trap Operation The setup of a U.PD70616 address trap is performed as follows: • address assignment Specifies the base address within which address traps will occur. For example, virtual address 10000H can be used as the base address. • address mask assignment This parameter defines the range of addresses from the specified base address that address traps will * occur. To trap accesses within the virtual page at address 10000H, the range is set to 4096 bytes. • access type This parameter assigns one or more access types to the range of addresses. For instance, if traps are to occur on write access to the region, write access trapping must be specified. In the example above, the address trap would be programmed to occur when the following conditions were all satisfied: • virtual addresses 01 0000H-010FFFH • write accesses The U.PD70616 allows two independent sets (address trap and address trap 1) of address trap specifications to be defined simultaneously. Address trap specifications can be overlapped or use the same or different access types without restriction. Address Trap Registers Address traps are setup and controlled by three types of privileged registers and a field within the PSW register (refer to section 3 for detailed register specifications). • Address Trap Enable (PSW.AE) The PSW.AE flag is used as a global enable and disable for the address trap logic. PSW.AE = address traps disabled PSW.AE = 1 address traps enabled Because the AE flag resides in the privileged upper halfword of the PSW only operating system routines can control the operation of address traps. • Address Trap Registers (ADTR0/ADTR1) The two ADTR registers each contain a 32-bit base address used to define a region by the trap logic. Register ADTRO contains the base address for address trap and ADTR1 contains the base address for address trap 1 -, 9-5 PRELIMINARY INFORMATION SOFTWARE DEBUG SUPPORT HPD7061 6 PROGRAMMER'S REFERENCE MANUAL • Address Trap Mask Registers (ADTMR0/ADTMR1) The ADTMR registers are used to qualify the ADTR registers to define a range of addresses. Each of these registers contains a 32-bit mask value that identifies the corresponding bits of the ADTR registers as "don't care". ADTMRO contains the mask value for ADTRO and ADTMR1 contains the mask value for ADTR1 A limitation applies to the contents of the ADTMR registers. The low order two bits of these registers must be set in order to operate properly. Failure to heed this restriction will result in UNPREDICTABLE operation. • Trap Mode Register (TRMOD) The TRMOD register contains the access type specifiers for each set of ADTR/ADTMR registers. Fields within the TRMOD contain the following flags: • read read access to the address causes an address trap Address Trap • write write access to the address causes an address trap • execute execute access to the address causes an address trap • read read access to the address causes an address trap 1 Address Trap 1 • write write access to the address causes an address trap 1 • execute execute access to the address causes an address trap 1 Each of the above fields is independently assignable allowing trap conditions such as on read/write or read/write/execute access to a region. Address traps and 1 can be disabled by simply selecting the no access condition (i.e., all bits within an access field cleared) in the appropriate field in the TRMOD register. Address Trap Setup Setting up for address traps involves programming of the ADTR/ADTMR register pairs, the register ano TRMOD enabling address traps in the PSW register. An address trap will occur whenever all of the following conditions have been met: 1 . PSW.AE = 1 (address traps enabled) 2. any of the TRMOD R/W/E bits are set 2. any of the TRMOD R/W/E bits are set 3. a programmed access type occurs 3. a programmed access type occurs 4. an address region 'hit' occurs 4. an address region 'hit' occurs Address Trap Addr ess Tra p 1 An address 'hit' occurs when the following condition is satisfied: [ AccessAddress and not( AddressMask ) ] = [ TrapAddress and not( AddressMask ) ] For example, to trap on accesses within a 128 byte region, an ADTMR is programmed as follows: Figure 9-1 ADTMR Setup (128 byte region) 31 1 i i i i i 1 1 i i i i i i 1 1 r i 1 1 • i i • > ^^^^' 00000000000000000000000001 1 1 1 1 9-6 1 ° PRELIMINARY INFORMATION UPD7061 6 PROGRAMMER'S REFERENCE MANUAL SOFTWARE DEBUG SUPPORT Since the low order two bits of the ADTMR registers must be set, the smallest trap region is four bytes (4B) while largest trap region (all ADTMR bits set) is four gigabytes (4GB). Address Trap Generation Address traps in the U.PD70616 occur when any byte within an address trap region is accessed with a specified access type. The actual occurrence of an address trap is delayed until both the instruction and the access is completed as follows: • An execute access address trap is delayed until the instruction is executed. Instructions within the address trap region which are prefetched but not executed do not cause address traps. • A read access address trap occurs after the access to the operand has commenced and the read operation has completed. • A write access address trap occurs after the access to the operand has commenced and the write operation has completed. No priority is assigned in the event of address traps detected simultaneously by each set of address trap logic. An address trap handler can detect this condition by examining the exception code placed on the level stack by the processor. Virtual/Physical Mode Address Traps Address traps can operate in both the virtual and physical modes of the U.PD70616. Address traps in virtual mode utilize virtual addresses while address traps in physical mode utilize physical addresses. When operated in the physical mode, the trap address is regarded as a physical address and the high order 8-bits of the ADTMR registers should be set to match the addresses output on the 24-bit address bus. Failure to mask the upper 8-bits will result in UNPREDICTABLE operation. When virtual mode is enabled, the trap address is regarded as a virtual address. No capability is available for trapping of physical addresses while in the virtual mode. Address Trap Stack Contents When the conditions for an address trap are met, information is placed on the level stack and control is transferred to the address trap handler. The following information is placed on the level stack: • address of the instruction causing the trap (CurrentPC ) • address of the next instruction (NextPC) • PSW image • address trap exception code^ The CurrentPC is used by the exception handler to analyze the instruction which caused the address trap while the NextPC is used as the return address to continue program execution. After the PSW image is pushed on the stack, the AE field within the PSW is cleared to disable further address traps. The exception code contains information on which set of address trap logic detected the access as shown below: 10 9-7 PRELIMINARY INFORMATION SOFTWARE DEBUG SUPPORT UPD70616 PROGRAMMER'S REFERENCE MANUAL Figure 9-2 Address Trap Exception Code Format 31 24 23 17 16 15 i i i i i 1 1- ~i 1 r -I 1 I I I I I 1 I 1110 a number bits 0:15 number this field contains the number of bytes placed on the stack bit 1 6 a this field contains a flag which indicates if an address trap occurred a= no address trap occurred a=1 address trap occurred bit 17 b this field contains a flag which indicates if an address trap 1 occurred b= no address trap 1 occurred b= 1 address trap 1 occurred bits 18:23 reserved field with each bit cleared bits 24:31 'OE'H address trap exception code Refer to section 8 for details of the level stack contents following an address trap. Address Trap Notes The following are notes on the operation of the jiPD70616 address trap facilities. Memory Indirect Addressing Modes Address traps can occur during the effective address calculation of memory indirect addressing modes. If a memory indirect addressing mode is used and during the effective address calculation the access of the memory resident pointer is within an address trap region with read access enabled, an address trap will occur. instruction Trace Operation It is possible to use the address trap logic to implement a second form of instruction trace. By setting the entire address space as the trap region and selecting the execute access type, an address trap will occur after the execution of each instruction. Infinite Address Traps Although further address traps are automatically disabled following entry into the address trap handler, an endless series of address traps can occur if the trap handler re-enables address traps and a memory access meets the programmed trap conditions. TLBNF Accesses The address trap logic is disabled during address translation and system base table accesses. The internal uPD70616 microprogram will ignore these accesses even address traps are programmed. if PRELIMINARY INFORMATION 9-8 1.0 uPD70616 PROGRAMMER'S REFERENCE MANUAL V20/V30 EMULATION MODE Section 10 V20/V30 Emulation Mode This section describes the operation of the V20/V30 emulation mode. The V20/V30 emulation mode is included in the U.PD70616 in order to allow system designers to take advantage of the large installed base of 16-bit software while simultaneously providing an upgrade path to a high performance 32-bit architecture for new applications. V20/V30 emulation allows the design of a 32-bit system that is object code compatible with software designed for the U.PD70108/116 microprocessors yet offers higher performance. With the exception of some system level instructions which require software emulation, the entire V20/V30 instruction set is implemented. In addition to the full resources of the V20/V30 microprocessors, other enhancements of the uPD70616 such as memory management and software debug mechanisms are available for use in developing and porting 1 6-bit V20/V30 software. The software used to complete the V20/V30 architecture is called a virtual machine monitor. In addition to providing the software handlers for emulation of privileged instructions and processing of exceptions, the virtual machine monitor is used complete the emulation of the original system environment. System emulation allows programs written for a different system to execute evenif contains references to physical memory and peripheral devices. Trapping of it I/O instructions and use of the address trap facilities simplify and aid the design of system emulations. Virtual and Physical Address Modes Like uPD70616 native mode, V20/V30 emulation mode operates in either virtual mode or physical mode depending on the state of the VM flag in the System Control Word (SYCW). In the physical address mode, the 1MB emulation mode address space is mapped on to the lower 1MB of the 16MB native mode memory address space. Likewise, the V20/V30 64KB I/O address space is mapped into the lower 64K bytes of the U.PD70616 16MB I/O address space. Because there is no address translation in physical mode, the protection mechanisms are disabled and only a single emulation context can be installed at a time. mode V20/V30 emulation provides a number of advantages. With the address translation and protection Virtual mechanisms enabled, any number of native and emulation mode contexts can co-exist without interference. Virtual mode emulation mode tasks use the lower 1MB of the 4GB virtual address space but now the operating system through the address translation tables separates and protects each task and the demand paging mechanisms allow the utilization of secondary storage for complex multi-tasking systems. In virtualmode, all emulation mode tasks execute at execution level 3. An emulation mode program has all of the a similar native mode program except that the address space is restricted. In particular, this applies to facilities of mapping of virtual address on to the I/O address space. Like the native mode instruction set, all emulation mode instructions are restartable or in the case of the emulation mode block transfer instructions, are interruptable and resumable. Emulation Mode The operating mode of the uPD70616 microprocessor is controlled by the EM flag in the PSW register. During native mode operation, the EM flag is cleared and the full set of uPD70616 resources are available to programs. Setting of the EM bit changes the processor mode to V20/V30 emulation mode and allows the execution of V20/V30 programs in a demand paged, protected environment. 10 10-1 PRELIMINARY INFORMATION V20/V30 EMULATION MODE U.PD70616 PROGRAMMER'S REFERENCE MANUAL The EM flag is in a privileged field in the upper halfword of the PSW and only software running at execution level can change processor modes. Because both the flag and the instruction streams must change simultaneously, the privileged RETIS instruction is used to enter V20/V30 emulation mode. Figure 10-1. PSW Emulation Mode Specification 31 30 29 28 27 26 25 24 23 19 18 17 16 15 13 12 11 10 9 6 7 9 . ? . 1 , 9 F F F F F EL RFU RFU I Z o U P RFU V D V D R Emulation Mode EM = Native mode EM * 1 Emulation mode Prog ram Status Word (PSW2) Emulation and native mode utilize independent program status words which are switched automatically when emulation mode is entered. Separate PSW registers allows the virtual machine emulation to maintain a PSW image (such as maskable interrupt status) without having to physically mask or unmask interrupts. While the PSW2 register and V20/V30 PSW appear similar, there are minor differences in the operation of the IE and BRK flags. In emulation mode, these flags can be in either the set or cleared state but they have no affect on the operation of the system since maskable interrupts and single stepping are controlled by fields in the native mode PSW. When an instruction is executed that attempts to change the state of either flag, an exception is generated. This permits the virtual machine software to intervene and provide a proper emulation of the system function in the U.PD70616 system. Figure 10-2. Emulation Mode PSW (PSW2) 31 30 16 15 14 13 12 11 10 9 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 c D I B A c T RFU 1 1 1 1 V R S Z p 1 I R E K c Y L • Emulation mode PSW field - — I/O trapping control bit CY The CY (carry) flag indicates if a carry or borrow was generated as a result of the operation. CY = no carry (borrow) generated CY = 1 carry (borrow) was generated 10-2 1.0 PRELIMINARY INFORMATION M.PD7061 6 PROGRAMMER'S REFERENCE MANUAL V20/V30 EMULATION MODE bit 1 1 Must be set bit 2 P The P (parity) flag indicates the parity of the lower 8-bits of the result. P= odd parity p=1 even parity bit 3 Must be cleared bit 4 AC The AC (auxiliary carry) flag indicates if a carry was generated from the lower nibble to the upper nibble. AC = no carry AC = 1 carry bit 5 Must be cleared bit 6 Z The Z (zero) flag indicates if the results of the operation were zero. Z= result is non-zero Z=1 result is zero bit 7 S The S (sign) flag indicates if the results are negative (signed) or if the MSB is set (unsigned). S= result is positive or zero or MSB is S=1 result is negative or MSB is set bit 8 BRK The BRK (break) flag contains the current single step status for emulation mode programs. has no effect on single step operation and must be maintained by the It native mode virtual machine software. bit 9 IE The IE (interrupt enable) flag contains the current maskable interrupt status for emulation mode programs, it has no effect on maskable interrupts and must be maintained by the native mode virtual machine software. bit 10 DIR The DIR (direction) flag indicates determines the direction of block transfer instructions. DIR = incrementing addresses DIR = 1 decrementing addresses bit 11 V The V (overflow) flag indicates if an overflow occurred. V= no overflow V=1 overflow bits 12:15 1 Must be set bits 1 6:30 RFU Reserved for future use I o_3 PRELIMINARY INFORMATION 1.0 V20/V30 EMULATION MODE uPD70616 PROGRAMMER'S REFERENCE MANUAL bit 31 CTL The CTL (I/O control) permits selective execution of emulation mode IN and OUT instructions without generation of an exception. CTL = I/O emulation enabled CTL = 1 I/O emulation disabled Program Counter (PC) The emulation mode PC uses the low order 16-bits of the native mode program counter. Because the address space is restricted to the lower 1MB of the uPD7061 6 address space, the high order halfword must be zero. Figure 10-3. Emulation Mode Program Counter 31 16 15 1 1 1 1 1 1 1 1 1 1 i 1 i i i 0000000000000000 PC bits 0:15 PC The PC (program counter ) field contains the 1 6-bit emulation mode program counter bits 16:31 Must be zero I/O Emulation Option The I/O emulation option permits emulation mode programs to override the privileged status of IN and OLT instructions and permit selective execution of these I/O instructions without the generation of an exception. TNl option is controlled by the CTL bit in the PSW2 register as follows: • CTL = I/O emulation enabled (I/O instructions privileged) • CTL = 1 I/O emulation disabled Control of the trapping of I/O instructions is particularly useful in the design of virtual machine monitors for device drivers and other software with real-time I/O requirements. Register Allocation The emulation mode register set uses a subset of the native mode register set with the exception of the emulation mode PSW which is a physically distinct hardware resource. Since all V20/V30 registers are 16-bits in length, emulation mode registers occupy the lower halfword of each corresponding 32-bit native mode register. The emulation mode register set is mapped onto native mode registers R0 through R11. The upper halfword of registers R0-R7 are unmodified by emulation mode programs. Since the V20/V30 microprocessors use a segmentation scheme with the segment registers used in the virtual address generation, the upper halfwords of the four 16-bit segment registers (R8-R1 1) are significant and must be zero. In addition to the emulation mode register set, native mode registers R12 through R16 are used by the emulation facility as working storage and must not be modified by native mode programs. A diagram of the emulation mode register set is shown below. PRELIMINARY INFORMATION 1 0-4 1 HPD70616 PROGRAMMER'S REFERENCE MANUAL V20/V30 EMULATION MODE Figure 10-4. Emulation Mode Register Set Native Mode Emulation Mode 31 R31 (SP) Not used R30 (FP) Not used R29 (AP) Not used R28 Not used R27 Not used R26 Not used R25 Not used R24 Not used R23 Not used R22 Not used R21 Not used R20 Not used R19 Not used R18 Not used R17 Not used R16 Work register R15 Work register R14 Work register R13 Work register R12 Work register R11 DSO R10 SS R9 PS R8 DS1 R7 IY R6 IX R5 BP R4 SP R3 BW R2 DW R1 CW R0 AW 31 PSW Not used PC PC PSW2 PSW 1.0 10-5 PRELIMINARY INFORMATION V20/V30 EMULATION MODE uPD70616 PROGRAMMER'S REFERENCE MANUAL Emulation Mode Instruction Set The emulation mode instruction set includes nearly all of the V20/V30 instructions with the exception of system control instructions. The difference between the V20/V30 microprocessors and the V20/V30 emulation mode is that the system control instructions are considered to be privileged and are trapped and emulated by system software. This allows the U.PD7061 6 system software to accommodate programs containing these instructions on a program by program basis without compromising the security of the operating system. These privileged instructions include functions such as input/output, maskable interrupt control and instruction trace (single stepping). Instructions in these classes must be emulated relative to a particular system configuration in order to function properly. The one exception is for simple I/O instructions. The system programmer has the option of not trapping IN and OUT instructions and instead allowing them to execute normally. This adds flexibility by allowing programs with real-time I/O constraints to function properly albeit in a system with less than full protection. The I/O option is enabled by the CTL bit in the PSW2 register. Note that the V20/V30 U.PD8080 emulation mode is not supported. Instruction Set Summary Below is a summary of the V20/V30 instruction set. For details of the instruction and architecture, refer to the U.PD70108/116 User's Manual. The following are descriptions of the instruction and conditions which cause exceptions when executed during emulation mode. • Unconditional Instruction Exception Attempted execution of these instructions always causes an Emulation Mode Privileged Instruction exception to occur. Trap instructions BRK, BRK 3 Interrupt Processing RETI I/O Instructions INM, OUTM Processor Control Instructions HALT, El, Dl • Conditional Instruction Exceptions Conditional instructions may or may not cause an Emulation Mode Privileged Instruction exception depending on the current processor state. The V20/V30 IN and OUT instructions cause an exception the CTL bit in the PSW2 register is cleared. if The IN and OUT instructions execute normally when the CTL bit is set (I/O instruction trap enabled). I/O Instructions IN, OUT The POP PSW instruction will conditionally trap if a change of state to the IE and BRK bit positions will occur. No trap will occur H the state of these bit fields will remain unchanged. PSW Instruction POP PSW PRELIMINARY INFORMATION 10-6 10 UPD70616 PROGRAMMER'S REFERENCE MANUAL V20/V30 EMULATION MODE Table 10-1. Emulation Mode Instruction Set Instruction Class Instructions Data Transfer Instructions MOV, MOV AH, PSW, MOV PSW, AH, XCH, CVTBW, CVTWL Address Calculation Instructions LDEA Arithmetic Instructions ADD, ADDC, SUB, SUBC, INC, DEC, MULU, MUL, DIVU, DIV, NEG Comparison Instructions CMP, TEST Logical Instructions NOT, AND, OR, XOR Bit Field Instructions INS, EXT Bit Manipulation Instructions TEST1, SET1, CLR1, NOT1, SET1/CLR1/NOT1 CY, SET1/CLR1 DIR . Shift Instructions SHL, SHR, SHRA Rotate Instructions ROL, ROR, ROLC, RORC BCD Adjust Instructions ADJBA, ADJ4A, ADJBS, ADJ4S BCD Conversion Instructions CVTBD, CVTDB Decimal String Instructions ADD4S, SUB4S, CMP4S, ROL4, ROR4 Stack Instructions PUSH, POP, PUSH R, POP R, PUSH PSW, POP PSW Stack Frame Instructions PREPARE, DISPOSE Control Transfer Instructions CALL, RET.Bcc, DBcc, BCWZ Block Transfer Instructions MOVBK, CMPBK, CMPM, LDM, STM Translate Instruction TRANS Interrupt/Exception Return RETI Trap Instructions BRK, BRK 3, BRKV I/O Instructions IN, OUT, INM, OUTM Processor Control Instructions HALT, El, Dl, BUSLOCK Repeat Prefixes REPC:, REPNC:, REP:, REPE:, REPZ:, REPNE:, REPNZ: Segment Override Prefixes DSO:, DS1:, SS:„ PS: Coprocessor Instructions POLL, FP01 FP02 , Miscellaneous Instructions NOP, CHKIND Run-time Exceptions The following group of V20/V30 conditions are detected by emulation mode and cause an Emulation Mode Fault exception. - zero divide exception - single step trap - overflow exception - CHKIND instruction exception - undefined opcode Disregarded Instructions The following instructions are ignored: Processor Control Instruction BUSLOCK Coprocessor Instruction POLL 1.0 10-7 PRELIMINARY INFORMATION V20/V30 EMULATION MODE U.PD70616 PROGRAMMER'S REFERENCE MANUAL System Implementation Exceptions The following V20/V30 instructions will cause an Emulation Mode Privileged Instruction exception depending on the system implementation. Coprocessor Instructions FP01, FP02 Table 10-2. Emulation Mode Privileged Operations Instruction Class Instructions ' Reserved Instruction Exception Trap INM, OUTM, HALT, El, Dl, BRK, BRK 3, RETI, MOV PSW, AH Zero Divide Single Step Overflow Exception CHKIND Exception Undefined Opcode I/O Emulation Option IN, OUT System Dependent FP01 FP02 , Data Dependent POP PSW Disregarded BUSLOCK, POLL 1 — 66-268 Mode Transitions A transition from native mode to emulation mode occurs when the EM bit in the PSW register is set when the PSW is restored during the execution of a RETIS instruction. Transitions from emulation mode to native mode occur as a result an interrupt or exception. Native Mode -» Emulation Mode Two instances of native to emulation mode transitions exist. The initial entry into emulation mode is a four step process. 1 initialize the PS register (R9) and any other emulation mode registers 2. prepare a PSW image with EM = 1 and EL = 1 1 and push it onto the stack 3. push the initial PC of the emulation mode program on the stack 4. execute a RETIS instruction emulation The emulation mode PS register must be initialized by the native mode program since fetching of the initial mode instruction requires valid program segment register contents. Other registers can be pre-initialized in native mode or initialized by the emulation mode program. Only the lower 16-bits of the emulation mode PC is valid and the upper halfword is ignored by U.PD7061 6 emulation mode programs. the new PSW image is Emulation mode program execution can only take place at execution level 3. The EL field in will occur. checked and if an execution level other than level 3 is specified an Illegal Data Field exception 10-8 1.0 PRELIMINARY INFORMATION U.PD70616 PROGRAMMER'S REFERENCE MANUAL V20/V30 EMULATION MODE Emulation Mode -> Native Mode Return to native mode from emulation mode programs occurs as the result of an interrupt or exception. • Interrupts All interrupts on the |iPD70616 microprocessor are processed in native mode. Upon the detection of an interrupt, the emulation mode program will be suspended and native mode will be restored. • Exceptions Emulation mode exceptions occur as a result of program execution and require processing by a native mode handler to correct a fault or take some other predetermined action. In either case, the return to emulation mode after processing of the exception or interrupt is by the RETIS instruction. Termination of an emulation program is accomplished by the reserved 63H opcode. Attempted execution of this opcode will cause the Reserved Emulation Mode Opcode exception to be generated along with a specific exception code identifying the exception as a terminate operation. Memory Address Space The one megabyte (1MB) address space of the V20/V30 microprocessors is mapped into the native mode virtual address space (virtual mode) or the memory address space (physical mode). In both cases the emulation mode memory address space occupies the lower megabyte of the corresponding virtual or memory address space. Each of the four general purpose registers (R8-R11) are split into two fields. The lower 16-bit field contain the four V20/V30 segment registers in the lower halfword and the upper halfword must be must be zeroed for proper operation. Address Generation Both a segment register and an effective address are used to form the emulation mode address. The 16-bit effective address is first determined by the operand addressing mode and zero extended to 32-bit length. The 16-bit segment value in the appropriate segment register is left shifted four places and combined with the effective address to produce the 20-bit emulation mode address. This address is then zero extended to 32-bit length and either translated (virtual mode) or passed directly to the bus interface unit (physical mode). Figure 10-5. Emulation Mode Segment Registers 31 16 15 0000000000000000 DS1 R8 000000000 000000 PS R9 000000 0000000000 SS R10 0000000000000000 DS0 R11 bits 0:1 5 SEG The SEG (segment) field contains the 16-bit segment base address bits 16:31 RFU Reserved for future use 1.0 10-9 PRELIMINARY INFORMATION V20/V30 EMULATION MODE M-PD70616 PROGRAMMER'S REFERENCE MANUAL Figure 10-6. Emulation Mode Address Generation — r 16 15 t r 0000000000000000 i 1 1 1 1 1 1 1 1 1 1 1 1 1 r 1 i Segment Register — t r 000000000000 i 1 1 1 1 1 1 1 1 1 1 1 1 1 i 1 i 1 i 1 Segment Register 31 r 16 15 —-i r 0000000000000000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 i i 1 i 1 i Effective Address SZ V+ n ——————————— i i i i 20 19 —XX— ^r i 1 1 1 • 2_ 000000000000 i i i i i i i 1 1 1 1 1 1 1 1 1 1 1 i Emulation Mode Virtual Address I/O Address Space The V20/V30 emulation mode I/O address space (addresses 00000H to OFFFFH) is mapped into the lower 64KB addresses of the U.PD70616 address space the emulation mode I/O option has been selected. if An exception will occur if an I/O instruction is attempted and the I/O emulation option is enabled. Emulation Mode Notes The uPD70616 V20/V30 emulation mode offers an upgrade path to a 32-bit environment while maintaining software compatibility with the previous generation of 16-bit devices. However, some precautions must be observed to guarantee the compatibility of 16-bit software in the 32-bit environment. These precautions relate to the small subset of application software which exhibit timing dependencies or utilize non-portable programming styles. A list of the programming restrictions follows. • Instruction execution speed There is no correlation between the V20/V30 instruction execution times and the same instructions executed in V20/V30 emulation mode. There is no guarantee that programs dependent on the execution time of an instruction or sequence of instructions will execute correctly in V20/V30 emulation mode. • Self modifying code Programs that modify the instruction stream and depend on the size of the V20/V30 instruction prefetch queue may not operate correctly on the U.PD7061 6 microprocessor. 10-10 1.0 PRELIMINARY INFORMATION U.PD70616 PROGRAMMER'S REFERENCE MANUAL V20/V30 EMULATION MODE Instruction length restriction The V20/V30 microprocessors place no limit on the length of an instruction. The uPD70616 microprocessor limits the length of a single instruction to 31 bytes. This situation can only arise out the use of duplicated instruction prefixes. U.PD8080AF emulation mode The U.PD8080AF emulation mode of the V20/V30 is not supported. The attempted execution of a BRKEM instruction will cause an illegal instruction exception . Undefined opcodes Attempted execution of undefined V20/V30 opcodes will cause an illegal instruction exception except in the following cases: Second Byte First Byte MSB LSB COH, C1H, DOH, D1H, D2H, D3H X X 1 1 X X X F6H, F7H X X 1 X X X FEH, FFH X X 1 1 1 X X X In the above three cases, results of the undefined instruction execution is UNPREDICTABLE. PUSH SP instruction The contents of the stack following the execution of a PUSH SP instruction differs between the V20/V30 and the U.PD70616. The V20/V30 PUSH SP first decrements the SP register and then copies SP to the stack. The emulation mode PUSH SP instruction decrements SP by two and pushes the original value of the SP register on the stack. Address wrap-around Address wrap around occurs when a 16-bit or greater data access is made across a segment (64KB) or address space (1 MB) boundary and is not supported by V20/V30 emulation mode. In the case where the operand wraps completely around, the address computation will be correct. Restrictions only apply to accesses across a segment or address space boundary. In the V20/V30 microprocessors, a 16-bit access to data located at offset 64K-1 from the base of the segment results in the least significant byte fetched from offset 64K-1 and the most significant byte fetched from offset zero within the same segment. Emulation mode differs in that 16-bit data is located at offset 64K-1 (LSB) and at offset 64K (MSB) in the same segment. 10-11 PRELIMINARY INFORMATION 1.0 V20/V30 EMULATION MODE U.PD70616 PROGRAMMER'S REFERENCE MANUAL Instructions which potentially cause a wrap around access violation are: 1 6-bit data transfers 32-bit data transfers bit field instructions save/restore multiple registers (PUSH R/POP R) stack frame allocation (PREPARE) Segment wrap around restrictions also apply to the individual data transfers of 16-bit prefixed block transfer instructions. 64K, 1M boundary instruction fetch Instruction fetch across either a 64KB segment boundary or the 1MB memory address space boundary is prohibited. Memory allocation The memory and I/O address spaces for emulation programs is determined by the operating system. Caution should exercised in allocation of memory pages to emulation mode programs to prevent inadvertent exceptions due to improper permissions. Segment registers During emulation mode, if the upper order 16-bits of any segment register become non-zero, the results will be UNPREDICTABLE. Emulation mode single step Single stepping of emulation mode programs is possible using the U.PD7061 6 single step facility to cause a trap upon entry into the emulation mode program. The emulation mode BRK flag has no effect on single step operation and must be emulated by the native mode single step trap handler. Emulation mode interrupt processing No provisions for the processing of interrupts or exceptions by emulation mode programs is provided. The IE flag in the emulation mode PSW has no meaning and the control of maskable interrupts must be done by the native mode exception handler. PRELIMINARY INFORMATION 10-12 1 U.PD7061 6 PROGRAMMER'S REFERENCE MANUAL FUNCTIONAL REDUNDANCY MONITOR Section 11 Functional Redundancy Monitor With each passing day, an increasing number of computer systems are called upon to perform in environments where the cost of an error in economic or human terms is extremely high and failures simply cannot be tolerated. Applications such as digital flight controls, telephone switching, transaction processing and others all require the use of systems which have a MTBF (mean time between failure) measured in the thousands or millions of years or whose availability (the time which the system is available to the application) exceeds 99% over a period of several years. The U.PD7061 microprocessor is equipped with special purpose logic to aid in the design of highly reliable and fault tolerant computing systems. Fault tolerant systems can be organized in many different configurations depending on the application and the degree of fault tolerance. The U.PD70616 supports fault tolerant system design by permitting the use of multiple U.PD70616 microprocessors operating as master/checker pairs. However, the design of a fault tolerant system requires much more than redundant hardware because software failures also contribute to the overall system failure rate. The combination of hardware fault coverage, fault isolation and system reconfiguration with the powerful exception handling facilities makes the uPD70616 an optimal solution for the design of high performance, fault tolerant systems. Fault Tolerant System Configuration Prior to a general discussion of fault tolerance and the issues concerning the design of highly reliable systems, a ^definition of the term should be presented. A system is said to be fault tolerant if it can survive and function in the presence of one or more faults. A fault tolerant system can further be classified as degrading or non-degrading. A system built using the concept of graceful degradation continues to operate as faults occur but the system successively reconfigures to a lower levels of performance. A non-degrading system uses massive redundancy in a way that failures are tolerated without a change in system performance until the redundancy is exhausted and the system ultimately fails. All fault tolerant systems follow a similar path when confronted with a fault in the system. The basic sequence of steps include: • fault detection • fault isolation • fault recovery • system reconfiguration Much emphasis must be placed on fault detection because the least reliable system is one with a latent or undetected fault that can propagate and corrupt the entire system. When a fault occurs it must be allowed to propagate in order to be detected. Itthe task of a fault containment logic to detect as soon as possible the occurrence of a fault and is contain or isolate it from the remaining healthy portion of the system. Next the fault must be analyzed to determine the extent of damage to the system and finally the system must reconfigure to remove the faulty section and restore to the system to a stable, healthy state. One must also distinguish between two types of faults. The vast majority of faults that occur in a system can be characterized as transient faults. Transient faults are faults which disappear when re-tried because the disturbance which caused the fault is no longer present in the system. Because the frequency of transient faults is so much higher, a system cannot afford to degrade the system each time a fault is detected. Thus the capability of automatically re-trying the faulted operation without the intervention of the operating system is desirable. 1.0 1 1 -1 PRELIMINARY INFORMATION FUNCTIONAL REDUNDANCY MONITOR U.PD70616 PROGRAMMER'S REFERENCE MANUAL Finally, the pPD70616 functional redundancy monitor is but the first step in the design of a fault tolerant system. There is no simple, one-step solution to design in fault tolerance since a system is only as reliable as the least reliable component. Thus, similar fault tolerant design techniques must also be applied to the memory and I/O subsystems in order to improve the reliability of these subsystems to the same level of reliability as the processor. Figure 11-1 . Functional Redundancy Monitoring F ault Outp ut (W5MAT) Data Bus Address Bus SyBtem Halt (BFREZ) Functional Redundancy Monitor (FRM) The concept of FRM is demonstrated by the duplex system shown in Figure 11-1. Functional redundancy monitoring is based on identical logic running in parallel with one U.PD70616 microprocessor functioning as the master and the second uPD7061 6 configured as the checker. During operation, both the master and checker operate in lock-step on identical instruction and data streams but only the master actually drives the address, data and control buses. Instead of driving the bus outputs, the checker compares its independently computed state with the state asserted by the master |iPD70616 and outputs a signal when a discrepancy is detected. The following is a description of the FRM mode. 1 . Pin Description Four of the uPD70616 I/O pins are used for functional redundancy monitoring: Table 11-1. FRM Pin Functions Pin Name I/O Function BMODE (FRM) Input Selects the normal or FRM operating mode BLOCK (MSMAT) Output Checker output indicating a mismatch has been detected BFREZ Input Freezes processor operation RT/EP Input Continue/Interrupt selection input K-262 PRELIMINARY INFORMATION 11-2 1.0 UPD7061 6 PROGRAMMER'S REFERENCE MANUAL FUNCTIONAL REDUNDANCY MONITOR 2. Mode Selection FRM is enabled and disabled by the BUSMD/FRM input pin. Refer to the uPD70616 data sheet for the technical details of enabling the FRM logic. 3. Monitoring When enabled, the checker microprocessor continuously compares the contents of the address bus, data bus, status outputs and MRQ* and UBE* pins with the expected values. Should a discrepancy be detected, the output will indicate a mismatch and either the master or checker processor could be faulty. 4. Fault Detection When a mismatch occurs, the checker uPD70616 will assert the MSMAT* (Mismatch) output. This signal in turn informs external logic that a fault has been detected and that intervention is required. 5. Fault Isolation In response to the mismatch signal, the external fault logic must stop both processors by asserting the BFREZ (Bus Freeze) input. When BFREZ is asserted, all further bus accesses are disabled and processing is suspended. In response to the BFREZ interrupt, the master and checker U.PD70616 microprocessors will three-state the address, data and control buses. Both processors will remain isolated and disconnected from the system as long as BFREZ is asserted. 6. Fault Recovery Once the suspect devices have been isolated, the system can initiate the fault recovery procedures. Two methods of fault recovery are supported by the U.PD70616, instruction continuation and interrupt. Instruction continuation involves restarting the processors as if no fault occurred. In this mode, the processors will start by re-trying the bus cycle that failed and continuing normal execution. The power of this mode is that the new master need not be the same as the old master, i.e., a reconfiguation can occur. The other alternative is the bus freeze interrupt which causes forces an interrupt and subsequent analysis by system software. Selection of the recovery mode is via the RT/EP* input pin. When the BFREZ input is negated, each U.PD70616 checks the state of the RT/EP* pin. If RT/EP* is at a high level, then the instruction continuation mode is used. If at a low level, the bus freeze interrupt will occur and be serviced by both microprocessors. Note that fault detection can only occur when an error induced by a fault propagates to an external pin. Because of the pipelined architecture and the fact that instructions can execute which modify the internal state with no external indication (such as register to register arithmetic operations), faults may not be detected until they are observable from the external pins. Bus Freeze Interrupt The bus freeze interrupt is used by external logic to force the processor into the bus freeze interrupt handler. Following the occurrence of a bus freeze interrupt, all interrupts are disabled and the PC and PSW are saved on the interrupt stack. The bus freeze interrupt handler is then expected to perform fault analysis of the system in an attempt to isolate the faulty component. 1.0 11-3 PRELIMINARY INFORMATION FUNCTIONAL REDUNDANCY MONITOR uPD70616 PROGRAMMER'S REFERENCE MANUAL Because It may not be readily apparent which processor is faulty, the bus freeze interrupt handler in conjunction with the external voting logic will disconnect the suspect pair from the system and perform independent self tests on each processor by holding one processor in the bus freeze state while the other is tested in the normal mode. If either processor is found to be faulty, the system can be informed. Otherwise, the fault can be considered a transient fault with the processors being restarted and placed back on-line. FRM Applications The design of a fault tolerant system can take many approaches depending on the performance, reliability and fault tolerance requirements for the proposed system. Two examples of typical fault tolerant system implementations are introduced but keep in mind that each application poses its own unique set of requirements. With this in mind, a bibliography of selected works on fault tolerant system design is included at the end of this section. The descriptions of the U.PD70616 fault detection and recovery capabilities and an general understanding of the overall requirements for fault tolerant system design will aid the designer in choosing the correct fault tolerant implementation for a particular application. 1 . Duplex System A duplex system provides the basis for fault detection but provides no certain indication which unit has failed. While it is also possible under certain circumstances for a duplex system to isolate a fault to a specific unit though self test and reasonableness checks, there is no guarantee that the system will be able to survive the fault. Figure 11-2. Duplex System Implementation A V Data Bus Address Bus Master Mode Checker Mode |iPD70616 jiPD70616 Control Bus BFREZ MSMAT ~o- While limited in ability to recover from certain faults, dual systems do have varied applications. Many systems are required only to fail in a safe state. The specification of such a system would indicate what final state the system should end up in the event of a failure. The primary goal of a fail-safe system is for the state of the system not present any hazard to the user. A typical example of a fail-safe system is the common traffic signal. Because town public works departments wish to minimize their capital outlays yet not endanger the driving populace, traffic signals are specified to be fail-safe. In the event of a failure, a traffic signal should never fail in the state that all lights are green since this would pose severe liabilities for the town. Instead, the final state for a failed traffic signal will typically be one set of lights flashing red and the other set of lights flashing yellow. 11-4 1.0 PRELIMINARY INFORMATION UFD70616 PROGRAMMER'S REFERENCE MANUAL FUNCTIONAL REDUNDANCY MONITOR Because the cost of a system is directly proportional to the amount of redundancy, the duplex system is the system of choice for applications requiring to only be aware of faults in the system and are not required to recover completely from them. 2. N-Modular Redundancy N-modular redundancy is a method used to improve upon the fault coverage of the duplex system to provide the capability to survive faults. In order to provide an indication of which processor in a system has An n-modular redundant system which failed, a majority vote of all processors in the system is required. uses an odd number of processors and majority voting logic to accurately determine the failed modules. The most common implementation of an n-modular redundant system is a TMR (Triple Modular Redundant) system. The TMR approach triplicates all logic and can use a 3-way majority voter to select the correct output and identify a faulty unit. Because a TMR system can survive the occurrence of any single fault, it is said to be 1 -fault tolerant. In the event of a failure, the voting logic shuts down the failed unit, allowing the module to be repaired off- line while the system continues to function normally. After the repair has been completed, the module can be restored to the on-line condition and full fault tolerance restored. Figure 11-3. Triple Modular Redundant System Control Bus 21 Address Bus 2 21 21 2 21 w Data Bus 7y z\ V \/ \/ L V Master Mode C hecker Mode Ch ecker Mode HPD70616 HPD70616 PD70616 BFREZ BF REZ MSMAT BFF*EZ MSMAT < i i i 1 1 ' ' Majority Vote Logic Because the MTBF of a computing module is large (typically measured in months or years) and the MTTR (Mean Time To Repair) is generally 30 minutes to 1 hour, the probability of a second failure during the repair interval is low and the overall system MTBF can be on the order of hundreds of years. 1.0 11-5 PRELIMINARY INFORMATION FUNCTIONAL REDUNDANCY MONITOR uPD7061 6 PROGRAMMER'S REFERENCE MANUAL Section 11 Bibliography [1] A. Avizienis Fault Tolerant Systems IEEE Transactions on Computers, pp. 1304-1312, Vol. C-25, No. 12, December 1976 [2] D. P. Siewiorek and R. S. Swarz The Theory and Practice of Reliable System Design Digital Press, 1982 [3] G. D. Kraft and W. N. Toy Microprogrammed Control and Reliable Design of Small Computers Prentice-Hall, 1981 [4] Special Issue on Fault Tolerant Computing IEEE Computer, Vol. 17, No. 8, August 1984 [5] D. P. Siewiorek, C. G. Bell, and A. Newell Fault Tolerant Systems (Section 6 of Part 2) in Computer Structures : Principles and Examples McGraw-Hill, 1982 11-6 1 ° PRELIMINARY INFORMATION |iPD70616 PROGRAMMER'S REFERENCE MANUAL APPENDIX A Appendix A Instruction Set Summary This appendix contains a summary of the uPD70616 Definitions instruction set. The instructions are functionally grouped Identifier Description together by instruction type for ease of reference. reg Any user register, RO-R31 .B Byte integer or character (8-bit) .H Halfword integer or character (16-bit) HPD70616 Program Register Set .W Word integer (32-bit) Register Description .D Doubleword integer (64-bit) R0-R31 General purpose registers .S Short real (32-bit IEEE floating point value) PSW Program Status Word .L Long real (64-bit IEEE floating point value) PC Program Counter .BH Byte to halfword AP Argument Pointer (R29) .BW Byte to word FP Frame Pointer (R30) .HW Halfword to word SP Stack Pointer (R31) .HB Halfword to byte .WB Word to byte .WH Word to halfword HPD70616 Privileged Register Set .WS Word to short real Register Description .WL Word to long real ISP Interrupt Stack Pointer .SW Short real to word LOSP Level Stack Pointer .LW Long real to word LISP Level 1 Stack Pointer .PZ Packed to zoned decimal L2SP Level 2 Stack Pointer .ZP Zoned to packed decimal L3SP Level 3 Stack Pointer SBR System Base Register TR Task Register PSW Condition Codes SYCW System Control Word Mnemonic Flag Name TKCW Task Control Word CY Integer carry flag PIR Processor ID Register OV Integer overflow flag PSW2 Program Status Word 2 (Emulation Mode PSW) S Integer sign flag ATBRO Area Table Base Register Z Integer zero flag ATLRO Area Table Length Register FIV Floating point invalid operation flag ATBR1 Area Table Base Register 1 FZD Floating point zero divide flag ATLR1 Area Table Length Register 1 FOV Floating point overflow flag ATBR2 Area Table Base Register 2 FUD Floating point underflow flag ATLR2 Area Table Length Register 2 FPR Floating point precision flag ATBR3 Area Table Base Register 3 ATLR3 Area Table Length Register 3 TRMOD Trap Mode Register Flag Operations ADTRO Address Trap Register Identifier Description ADTMRO Address Trap Mask Register (blank) No change ADTR1 Address Trap Register 1 - No change ADTMR1 Address Trap Register 1 Cleared to 1 Set to 1 * Set or cleared according to result R Restored to previous value 1.0 A-1 PRELIMINARY INFORMATION APPENDIX A U.PD70616 PROGRAMMER'S REFERENCE MANUAL Opcode Fields Character Size Field The direction field is used by the character and bit strings Condition Code Field instructions to determine the direction of string The PSW flags are used by the conditional branch processing. The programmer has the option of instructions to determine the conditions necessary to processing character and bit strings in the upward transfer program control. These instructions include the (increasing addresses) or downward (decreasing Bcc (Branch on Condition), DBcc (Decrement and addresses) direction to allow transfer and manipulation of Branch on Condition) and TRAP instructions. overlapping strings with a single instruction. c3 c2 d cO Name Condition c Operand Size Overflow OV = 1 Byte character 1 Not overflow OV = 1 Halfword character 1 Carry/Lower CY = 1 1 1 No carry /Not lower CY = 1 Zero Z=1 Direction Field 1 1 Not zero Z= The direction field is used by the character and bit strings 1 1 Not higher (CYvZ)=1 instructions to determine the direction of string 1 1 1 Higher (CYvZ)=0 processing. The programmer has the option of 1 Sign/Negative S=1 processing character and bit strings in the upward 1 1 Not sign/Positive S= (increasing addresses) or downward (decreasing 1 1 True Always addresses) direction to allow transfer and manipulation of 1 1 1 False Never overlapping strings with a single instruction. 1 1 Less than (S©OV) = 1 1 1 Greater or equal (S©OV) = d Direction 1 (S©OV)vZ=1 Upward (increasing addresses) 1 1 1 Less or equal Greater (S©OV)vZ = 1 Downward (decreasing addresses) 1 1 1 1 Displacement Size Field Integer Size Field The integer size field specifies the integer data type for The displacement size field is found in the conditional The U.PD70616 supports both branch instructions and determines whether an 8- or 1 6- integer instructions. bit displacment field follows the opcode. signed and unsigned integers in each of the integer formats. b Displacement Size Byte (8-bit signed displacement) siz Operand Size Halfword (16-bit signed displacement) 00 Byte 01 Halfword 10 Word 11 Reserved Floating Point Size Field The floating point size field determines the operand data type for the floating point instructions. Both IEEE short and long real data types are supported by the U.PD70616 microporcessor. Operand Size Short Real (32-bit) Long Real (64-bit) A-2 1.0 PRELIMINARY INFORMATION HPD70616 PROGRAMMER'S REFERENCE MANUAL APPENDIX A Instruction Set Reference Opcode Flags Mnemonic 76543210 76543210 Format CY ov s z Exceptions Data Transfer Instructions MOV.B 00001001 I.H 1.3 MOV.H 00011011 1,11 1.3 MOV.W 00101101 1,11 1,3 MOV.D 00111111 I.H 1,3 MOVS.BH 00001010 I.H MOVS.BW 00001100 Ml MOVS.HW 00011100 1,11 MOVZ.BH 00001011 I.H MOVZ.BW 00001101 I.H MOVZ.HW 00011101 1,11 MOVT.HB 00011001 Ml - * — - MQVT.WB 00101001 1,11 - * — - MOVT.WH 00101011 1,11 - * — - XCH 1 eiz 1 I.H 1,3 MOVEA 1 siz I.H RVBYT 00101100 I.H RVBIT 00001000 I.H Integer Arithmetic Instructions ADD 10 siz 1,11 * * * * 1 ADDC 1 1 slz I.H * * * * SUB 1 1 1 siz 1,11 * * * * SUBC 1 1 1 slz Ml * * * * MUL 10 slz 1 I.H - * * * MULU 1 1 slz 1 Ml - * * * MULX 10000110 1,11 - * * * MULUX 10010110 l,H - * * * DIV 1 1 slz 1 1,11 - * * * 1,4 DIVU 1 1 1 slz 1 1,11 - * * 1,4 DIVX 10100110 1, H - * * * 1,4 DIVUX 10110110 I.H - * * * 1,4 REM 10 10 slz 1, H - * * 1.4 REMU 1 1 slz 1 1,11 - * * 1,4 INC 1 1 1 1 slz - III * * * * DEC 1 1 1 siz - III * * * * NEG 1 1 1 siz 1 1,11 * » * * * CMP 1 1 1 1 siz 1, H * * * TEST 1 1 1 1 siz Logical Instructions AND 10 10 siz I.H - OR 10 1 siz - XOR 10 110 siz 1,11 - MOT 111 siz - 1.0 A-3 PRELIMINARY INFORMATION APPENDIX A IXPD70616 PROGRAMMER'S REFERENCE MANUAL Opcode Rage Mnemonic 76543210 76543210 Formal CY OV S Exceptions Shift/Rotate Instructions SHA 10 110 siz 1 1,11 * * * * 1 SHL 10 10 siz 1 1,11 * * * 1 ROT 1 1 ill 1 1,11 * * * 1 * * ROTO 1 1 1 lit 1 1,11 * 1 Floating Point Instructions MOVF OlOlllsO 1 II * * * 1,3,7,9 ADDF 010111*0 1 1 II * * * 1,3,6,7,8,9 SUBF OlOlllsO 1 1 1 II * * * 1,3,6,7,8,9 MULF OlOlllsO 1 1 1 II * * * 1,3,6,7,8,9 DIVF OlOlllsO 1 1 1 1 II * * * 1,3,6,7,8,9,10,11 CMPF OlOlllsO II * * * * 1,3,6,7,8,9 NEGF OlOlllsO 1 1 II * * * 1,3,7,9 ABSF OlOlllsO 1 1 II * 1,3,7,9 SCLF OlOlllsO 1 II * * * 1,3,6,7,8,9 CVTF 01011111 1 II * * * 1,3,6,7,8,9 CVT.WS 01011111 II * * * 1,3,6,7,8,9 CVT.WL 01011111 1 1 II * * 1,3,6,7,8,9 CVT.SW 01011111 1 II - * * * 1,3,6,7,8,9 CVT.LW 01011111 1 1 II - * * * 1,3,6,7,8,9 TRAPFL 11001011 1,3,6,7,9 Decimal Arithmetic Instructions ADDDC 01011001 oooooooo Vile 1,5 SUBDC 01011001 00000001 Vile — — « 1,5 SUBRDC 01011001 00000010 Vile 1,5 CVTD.PZ 01011001 00010000 Vile 1,5 CVTD.2P 01011001 00011000 Vile 1,5 Bit Manipulation Instructions TEST1 10000111 I.H — — * 1,2 SET1 10010111 1,11 1,2 CLR1 10100111 • — — 1,2 NOT1 10110111 II 1,2 Bit Field Instructions EXTBFS 01011101 00001000 Vllb 1,2 EXTBFZ 01011101 00001001 Vllb 1,2 EXTBFL 01011101 00001010 Vllb 1,2 INSBFR 01011101 00011000 Vile 1,2 INSBFL 01011101 00011001 Vile 1,2 CMPBFS 01011101 oooooooo Vllb 1,2 CMPBFZ 01011101 00000001 Vllb 1,2 CMPBFL 01011101 00000010 Vllb 1.2 Bit String Instructions MOVBS 01011011 OOOOlOOd Vllb NOTBS 01011011 OOOOlOld Vllb A-4 1.0 PRELIMINARY INFORMATION HPD70616 PROGRAMMER'S REFERENCE MANUAL APPENDIX A Opcode Flags (Mnemonic 7 6543210 7 6 5 4 3 2 10 Format CY OV S Z Exceptions Bit String Instructions (cont) ANDBS 10 110 11 1 d Vllb 1 ANDNBS 10 110 11 1 Old Vllb 1 ORBS 10 110 11 1 1 d Vllb 1 ORNBS 10 110 11 1 Old Vllb 1 XORBS 10 110 11 1 1 d Vllb 1 XORNBS 10 110 11 1 Old Vllb 1 SCHOBS 10 110 11 d Vllb 1 SCH1BS 10 110 11 1 Old Vllb 1 Character Manipulation Instructions MOVC 1 1 1 c 1 d Vila 1.3 MOVCF 1 1 1 c 1 Old Vila 1,3 MOVCS 10 110 1 10 Vila 1,3 CMPC 1 1 1 c Vila — — * * 1,3 CMPCF 1 1 1 c 1 Vila — — * * 1.3 CMPCS 1 1 1 c 10 Vila — — * * 1,3 SCHC 1 1 1 c 1 1 d Vllb - - - * 1,3 SKPC 1 1 1 c 1 1 Old Vllb - - - * 1,3 Stack Manipulation Instructions PUSH 1 110 111- II 1,3 POP 1 110 11- II 1,3 ; PUSHM 1 110 110- II 1.3 POPM 1 110 10- II R R R R 1,3(Note1) PREPARE 1 10 1111- II 1,3 DISPOSE 1 10 110 V Control Transfer Instructions BC 1 1 b 1 IV BE 1 1 b 1 IV BGE 1 1 b 1 1 1 IV BGT 1 1 b 1 1 1 1 IV BH 1 1 b 1 1 1 IV BL 1 1 b 1 IV BLE 1 1 b 1 1 1 IV BLT 1 1 b 1 1 IV BN 1 1 b 1 IV BNC 1 1 b 1 1 IV BNE OllbOlOl IV BNH OllbOllO IV BNL OllbOOll IV BNV OllbOOOl IV BNZ OllbOlOl IV BP 1 1 b 1 1 IV BR 1 1 b 1 10 IV DBC 11000110 reg 1 VI DBE 11000110 reg 10 VI 1.0 A-5 PRELIMINARY INFORMATION APPENDIX A HPD70616 PROGRAMMER'S REFERENCE MANUAL Opcode Flags Mnemonic 7 6 5 4 3 2 1 7 6 5 4 3 2 1 Format CY OV S Z Exceptions Control Transfer Instructions (cent) DBGE 1 1 1 1 1 reg 1 1 VI DBGT 1 1 1 1 1 reg 1 1 1 VI DBH 1 1 1 1 1 reg 1 1 VI DBL 1 1 1 1 reg 1 VI DBLE 1 1 1 1 reg 1 1 1 VI DBLT 1 1 1 1 reg 1 1 VI DBN 1 1 1 1 reg 1 VI DBNC 1 1 1 1 1 reg 1 VI DBNE 1 1 1 1 1 reg 1 VI DBNH 1 1 1 1 reg 1 1 VI DBNL 1 1 1 1 1 reg 1 VI DBNV 1 1 1 1 1 reg VI DBNZ 1 1 1 1 1 reg 1 VI DBP 1 1 1 1 1 reg 1 VI DBR 1 1 1 1 reg 1 1 VI DBV 1 1 1 1 reg VI DBZ 1 1 1 1 reg 1 VI TB 1 1 1 1 1 reg 1 1 VI JMP 1 1 1 1 1 - III 1 BSR 1 1 IV JSR 1 1 1 1 - III 1 RSR 1 1 1 1 V CALL 1 1 1 l.ll 1 RET 1 1 1 1 - III BRK 1 1 1 V BRKV 1 1 1 1 V TRAP 1 1 1 1 - III RETIU 1 1 1 1 1 - III Miscellaneous Instructions NOP 1 1 1 1 1 V GETPSW 1 1 1 1 1 1 - III 1 UPDPSW.H 1 1 1 1,11 * * * * CHLVL 1 1 1 1 l.ll 1 CHKAR 1 1 1 1 l.ll * — * * 1 CHKAW 1 1 1 1 1,11 * — * * 1 CHKAE 1 1 1 1 1 1,11 * — * * 1 TASI 1 1 1 - III * * * * 1 CAXI 1 1 1 1 * * * * 1 SETF 1 1 1 1 1,11 1 . Privileged Instructions LDPR 1 1 1,11 2,12 STPR 1 1,11 1,2,12 CLRTLB 1 1 1 1 1 1 1 - III 12 CLRTLBA 1 V 12 PRELIMINARY INFORMATION A-6 1.0 J1PD70616 PROGRAMMER'S REFERENCE MANUAL APPENDIX A Opcode Flags Mnemonic 7 6 5 4 3 2 10 7 6 5 4 3 2 10 Format CY ov s z Exceptions Privileged Instructions (cent) GETATE 10 1 1,11 - - - * 1.12 UPDATE 1 10 1 Ml - - - * 1.12 GETPTE 10 1,11 * - - * 1.12 UPDPTE 1 10 1,11 * - - * 12 GETRA 11 i,ll * - - * 1.12 IN 1 •iz fl.ll 1,12 OUT 1 Iz 1 i.ll 1.12 LDTASK 1 1,11 12 STTASK 1 1 1 1 1 10- III 12 RETIS 1 1 1 1 1 1- III * * * * 2,12 UPDPSW.W 1 11 1,11 * * * * 12 HALT V 12 Exceptions Notes 1 Illegal Addressing Mode 1 . Flags updated if PSW is specified in the register list 2. Illegal Data Type 3. Reserved Addressing Mode 4. Integer Zero Divide 5. Illegal Decimal Format 6. Floating Point Overflow 7. Floating Point Undeflow 8. Floating Point Precision 9. Reserved Floating Point Operand 10. Invalid Floating Point Operation 1 1 Floating PointZero Divide 12. Privileged Instruction 1.0 A-7 PRELIMINARY INFORMATION HPD7061 6 PROGRAMMER'S REFERENCE MANUAL APPENDIX A A-8 1-0 PRELIMINARY INFORMATION ^PD70616 PROGRAMMER'S REFERENCE MANUAL APPENDIX B Appendix B Instruction Formats 15 14 13 12 8 7 mod m d reg op Format I 15 14 13 12 8 7 mod' mod 1 m m' subop op Format II 7 mod op Format III 23 16 15 8 7 disp8/disp16 op Format IV 7 op Format V 31 16 15 13 12 8 7 disp16 subop reg op Format VI —— 1 T 1 1 1 1 1 15 14 13 12 8 7 exf mod' ext mod 1 m m' subop op Format Vila 15 14 13 12 8 7 mod' ext mod 1 m m' subop op Format Vllb 15 14 13 8 7 -— i —————— i i i i i i 12 exf mod' mod 1 m m' subop op Format Vile i i i ' 1 1 1 1 1 1.0 B-1 PRELIMINARY INFORMATION APPENDIX B HPD70616 PROGRAMMER'S REFERENCE MANUAL Instruction Format Summary Format Fields Description Format I Opcode Fixed length data instructions using Register Field register/register and register/memory Operand Addressing Mode addressing modes Format II Opcode Fixed length data instructions using memory/memory Operand 1 Addressing Mode addressing modes and floating point instructions Operand 2 Addressing Mode Format III Opcode Single operand instructions Operand 1 Addressing Mode Format IV Opcode Conditional branch instructions PC relative displacement Format V Opcode Zero operand instructions Format VI Opcode Loop instructions Register Field PC relative displacement Format VII Opcode Variable length data instructions Operand 1 Addressing Mode (character string, bit string, decimal arithmetic) Operand 1 Length Operand 2 Addressing Mode Operand 2 Length B-2 1.0 PRELIMINARY INFORMATION HPD70616 PROGRAMMER'S REFERENCE MANUAL APPENDIX C Appendix C Addressing Mode Encodings mod Addressing Mode 71 •63- •55- 47- 39 •31 23 .15. 011*Rn Rn 001 *Rn [Rn] 100*Rn [Rn-] 101-* Rn t-Rn] 1110* valH immed.4 *— disp — 000*- Rn -i disp.8[Rn] *-disp 11110000 disp.8[PC] *— disp — 100*- Rn [ disp.8[Rn]] #— disp.— 11111000 [disp.8[PC]] 011-*- Rn- 110* Rx4 *— val — (Rn](Rx) 11110100 immed.8 001* RnH disp.16[Rn] 11110001 disp.16[PC] 101* Rn + [disp.16[Rn]] 11111001 [disp.16[PC]] 11110100 immed.16 displ disp2— 000* Rn* displ .8[ disp2.8[Rn]] displ disp2— 11111100 displ .8[ disp2.8[Rnj] disp 000* Rn< 110* Rx4" disp.8[Rn](Rx) *- disp -*• 11110000 110* Rx* disp.8[PC](Rx) disp -*> 100*Rn« 110* Rx [ disp.8[Rn]](Rx) disp 11111000 110*Rx-H [ disp.8[PC]](Rx) •disp- 001*Rn-^110*Rx- disp.16[Rn](Rx) •disp- 11110001 110*Rx- disp.16[PC](Rx) •disp- 100*Rn-«H110*Rx- (disp.16[Rn]](Rx) disp- 11111000 110*Rx- [disp.16[PC]](Rx) disp 010*Rn-i disp.32[Rn] disp 11110010 disp.32[PC] disp • 110* Rn* [disp.32[Rn]] 11111010 X disp [disp.32[PC]] displ H*- disp2- 001* Rn 4 displ .16[disp2.16[Rn]j • displ disp2- 11111101 displ .16[disp2.16[PC]] •addr- 11110011 /addr addr- 11111011 [/addr] val - 11110100 immed.32 disp - 010*Rn4 110* Rx^ disp.32[Rn](Rx) disp - 11110010 110*Rx-( disp.32[PC](Rx) disp - 110*Rn-« 110*Rxh (disp.32[Rn])(Rx) disp - 11111010 110* Rx^ [disp.32[PC]](Rx) addr- 11110011 110* Rx^ /addr(Rx) addr- 11111011 110* Rxn [/addr](Rx) displ disp2- 010* Rn* displ .32[disp2.32[Rn]] -displ disp2- 11111110 displ .32[disp2.32[PC]] 86-041 1.0 C-1 PRELIMINARY INFORMATION //PD70616 Programmer's Reference Manual HEC NEC Electronics Inc. For Literature Call Toll Free: 1-800-632-3531 1-800-632-3532 (In California) CORPORATE HEADQUARTERS No part of this document may be copied or reproduced in any form or by any means without the prior written consent of NEC Electronics Inc. The information in this document is subject to change without notice. Devices sold by NEC Electronics Inc. 401 Ellis Street are covered by the warranty and patent indemnification provisions appearing in NEC Electronics Inc. Terms and Conditions P.O. Box 7241 of Sale only. NEC Electronics Inc. makes no warranty, express, statutory, implied, or by description, regarding the information set forth herein or regarding the freedom of the described devices from patent infringement. NEC Electronics Mountain View, CA 94039 Inc. makes no warranty of merchantability or fitness for any purpose. NEC Electronics Inc. assumes no responsibility for any TEL 415-960-6000 errors that may appear in this document. NEC Electronics Inc. makes no commitment to update or to keep current the TWX 910-379-6985 information contained in this document. NECEL-000854 ©1986 NEC Electronics Inc./Printed in U.S.A. STOCK NO. 500397