Super Nintendo Development Manual Book II
Super Nintendo (Nintendo, 1990) · Developer Manual · 413 pages · 168 sections · original scan
SUPER NINTENDO
ENTERTAINMENT SYSTEM
DEVELOPMENT MANUAL
BOOK II
“Confidential” This document contains confidential and proprietary information of Nintendo and is also protected under the copyright laws of the United States and foreign countries. No part of this document may be released, distributed, transmitted or reproduced in any form or by any electronic or mechanical means, including information storage and retrieval systems, without permission in writing from Nintendo.
© 1993, 1994, 1995 Nintendo The terms Sony and Sony NEWS are registered trademarks of Sony Corporation. ® and ™ are registered trademarks of Nintendo.
TABLE of CONTENTS ]
Table of Contents
BOOK II
SUBJECT PAGE
SECTION 1 - SUPER ACCELERATOR (SA-V)......:::s:ccssssssssssssssseee 1-1- Super Accelerator System Function: Configuration of SA-1 Super Accelerator Memory Map SA-1 Internal Register Configuration . Multi-Processor Processing Character Conversion. Arithmetic Function Variable-Length Bit Processing DMA SA-1 Timer
SECTION 2 - SUPER Fx®
Introduction to Super FX........... GSU Functional Operation Memory Mapping ........ssssssecssesssesssseesseesssesssccsseessnecsuneesnecsnneessessneesseeesneesneessneess GSU Internal Register Configuration GSU Program Execution. Instruction Execution..
Data Access.
GSU Special FUnCtions ..........ccecssscssssessesssessseessssesssecsssecssecssessssecesseessuesssscssuessseeene Description of Instructions............c0escsscessssssesessssseeessnsesesstecesssiseesssursesssutssssieesesseeeee
SECTION 3 - DSP/DSP1 Introduction to DSP1
Comamand Summary ..........cscccsecssesssseesseeseessnecesneesssecssvessuscssesssseccsseecsnessssesssssseens Parameter Data Type. Use of DSP1..
Description of DSP1 Command: Math Functions and Equations.
TABLE of CONTENTS L ]
Table of Contents (Continued)
SUBJECT PAGE
SECTION 4 - ACCESSORIES The Super NES Super Scope® System Principles of the Super NES Super Scope ...........0.0c cs cceseseseeseeeseeeeeseseeseseseenenenead 4-2-1 Super NES Super Scope Functional Operation .........c..ccscesssssessssecssseeseeseessseneeseenee! 4-3-1 Super NES Super Scope Receiver Functions. Graphics Super NES Mouse Specifications Using the Standard BIOS ..0......c..cccccsesseseesecsessesesseesesseeesseseeseesesecenesssaessesnsseeseaneeees! Programming Cautions .........cccccssescsssesssseesesseeseseesssseeestesesseesesnsseessessaseseesneseeneanes MultiPlayer 5 Specifications. MultiPlayer 5 Supplied BIOS
SUPPLEMENTAL INFORMATION
Super NES Parts List Game Content Guideline: Guidelines Concerning Commercialism and Promotion of Licensee Products or Services in Nintendo Licensed Game: Super NES Video Timing Information
INDEX
BULLETINS
LIST of FIGURES [ ]
List of Figures
BOOK II
TITLE Super Accelerator System Configuration SAS Bus Image SA-1 Block Diagra: Bitmap Register Files 0~7 . Bitmap Register Files 8~F . Accelerator Mode........ Parallel Processing Mode. Mixed Processing Mode Character Conversion 1.. Character Conversion Compressed Bitmap Dat Bitmap Image Projection Bitmap Data Expansion . Memory Addresses for the Bitmap Area Character Conversion Buffers. Fixed Mode Process Flow Diagram. Auto-increment Mode Process Flow Diagram Barrel Shift Process. Normal DMA... Character Conversion DMA .. Super FX System Configuration Game Pak ROM/RAM Bus Diagrai GSU Functional Block Diagram Super NES CPU Memory Map.. Super FX Memory Map..... Example of General Register 128 Dot High BG Character Array 160 Dot High BG Character Array .. 192 Dot High BG Character Array OBJ Character Array Plot Operations Assigned by CMODE System Block Diagram (DSP})........ Super NES CPU and DSP1 Communications DSP1 Command Execution Mode 20/DSP Memory Ma) Mode 21/DSP Memory Map.. Super NES/DSP1 Memory Mapping (Mode 21) DSP! Status Register Configuration.
iii
LIST of FIGURES i}
List of Figures (Continued)
TITLE
DSP1 Operations Flow Diagram Super NES CPU/DSP1 Operational Timing Trigonometric Calculation.. Vector Calculation .... Vector Size Comparison Vector Absolute Value Calculation .. Two-Dimensional Coordinate Rotation Examples of Three-Dimensional Rotatior Assignment of Projection Parameter ... Relationship of Sight and Projected Plan Calculation of Raster Data.. BG Screen and Displayed Calculation of Projected Position of Object Projection Image of Object Calculation of Coordinates for the Indicated Point on the Screen Attack Point and Position Indicated on Screen (Side View)... Attitude Computation Object Coordinate Rotated on Y Axis. Object Coordinate Rotated on X Axis . Object Coordinate Rotated on Z Axis.. Conversion of Global to Objective Coordinates Conversion of Object to Global Coordinates Calculation of Inner Product with Forward Attitude Position of Aircraft and Vector Code ....... eee Calculation of Rotation Angle After Attitude Change Signal Flow Optical Alignment Virtual Screen Alignment Address and Bit Assignments . Picture Tube. Scanning... Area Seen by Super NES Super Scope Vertical Positioning ... Horizontal Positionin, Horizontal/Vertical Counter. Super NES Super Scope Block Diagram. Super NES Super Scope Flow Diagram .. Raster Signal.......... Definition of One Bit Output Signal Code Definitions of Codes .
LIST of FIGURES [ i}
List of Figures (Continued)
TITLE
Raster Signal Transmission Timing Receiver Block Diagram Operation Flow Diagram Receiver/Transmitter Interface Schematic. One Bit Code Detection Cursor Mode Raster Detection Cycle . Trigger Mode, Single Shot.... Trigger Mode, Multiple Shots. Noise Flag .. Null Bit Pause B: Trigger, Single Shot. Trigger, Multiple Shots Optical Color Sensitivity Chart. Valid Hyper Mouse Data String Serial Data Read Timing....... Explanation of Data Strings 2 Bits or Longe Super NES Hyper Mouse Dimensions Standard BIOS, Output Register Examples of Speed Switching Program Subroutine Call MultiPlayer 5 Device Hardware Connection: MultiPlayer 5 Read Timing Chart, SP Mode Data Read Timing for Dissimilar Devices. Valid Controller Data String..... Sample Program Display Format...........csssseseseseseeseestssseessesseesneeseee!
LIST of TABLES ]
List of Tables
BOOK II
TITLE Types of Interrupts Interrupt Identification and Clear. Interrupt Mask... Sending and Receiving a Message Situation Dependant Vectors Operating Modes and Processing Speed: Horizontal Size of VRAM (CDMA Register Number of Zero Bits in BW-RAM Character Conversion and Data Format. Arithmetic Operations Settings and Cycle: Amount of Barrel Shift Source Device Settings Destination Device Settings DMA Transmission Speed. Timer Modes and Their Ranges. Timer Interrupts .............. Registers Listed by Functional Group Instruction Set GSU General Registers GSU Status Register Flag: Screen Height. Color Gradient Dummy Interrupt Vector Addresses Dummy Data......... Functions of CMOD) DSP1 Command Summary Parameter Data Type Signal Bit Definition: MultiPlayer 5 Switch Function. MultiPlayer 5 Data Format ....
vi
SUPER ACCELERATOR SYSTEM FUNCTIONS =)
Chapter 1
Super Accelerator System Functions
The co-processor installed on the Super Accelerator System (SA-1) is an LSI developed to work with the Super NES CPU and enhance its processing speed, graphics, and arithmetic functions.
1.1. SA-1 FEATURES
1.1.1 CPU CORE The SA-1 uses a 16-bit 65C816 processor for its CPU core (SA-1 CPU). It can process the same commands as the Super NES CPU. No new architecture needs be learned and existing programs can be used without modification. Because the 65C816 is a 16-bit CPU, it efficiently processes 16-bit operations such as X and Y character coordinates. Due to the commonality of the core CPUs, evaluation of the coprocessor in the middle of game development is quite simple and program modifications are kept to a minimum.
CPU SPEED The SA-1 CPU operates at 10.74 MHz, which is four times faster than the normal operating speed of the Super NES CPU. The SA-1 CPU and the Super NES CPU operate simultaneously, which results in five times greater performance of the Super Accelerator System (SAS) over the current Super NES.
INTERNAL RAM The SA-1 has a 2 Kbyte internal work RAM (SA-1 I-RAM). This RAM can be used as the SA-1 CPU's page-zero stack, or as protected memory with a backup battery, when connected to an external battery.
COMMON MEMORY MAPPING The Super NES CPU and SA-1 CPU use the same memory mapping. SA-1 programs can be developed with the Super NES Emulator-SE. Subroutines can be shared by both CPUs, resulting in efficient use of memory.
LARGE-CAPACITY MEMORY The SAS has a total capacity of 64 Mbits of ROM and 2 Mbytes of RAM. SRAN is used for I-RAM and back-up/work RAM (BW-RAM), and can be protected with a backup battery.
C =]
1.1.6
1.1.10
1.4.11 ARITHMETIC HARDWARE The SA-1 has hardware for high-speed execution of multiplication (16 bits x 16 bits), division (16 bits x 16 bits), and cumulative arithmetic (2(16 bits x 16 bits)) operations. This results in high-speed calculation of matrix and 3D arithmetic operations.
BIT-MAP DATA OPERATIONS The SAS allows virtual bitmap VRAM to be set up in the SA-1 CPU’s RAM area. The bitmap data in virtual VRAM can be converted to Super NES PPU character format via hardware using DMA functions.
VARIABLE-LENGTH BIT DATA OPERATIONS The SA-1 has a function to read ROM data as 1~16 bit variable-length data, treating ROM data as strings of one-bit data. This allows for highspeed expansion of compressed data.
CUSTOM DMA CIRCUIT The SA-1 has a custom DMA ciruit in addition to the Super NES CPU's multi-purpose H-DMA. The DMA circuit performs data transfer between ROM, RAM and SA-1 BW-RAM. During DMA transfer, bitmap-to-character conversion, and sequential operations with the Super NES CPU multipurpose DMA can be performed.
TIMER FUNCTION The SA-1 has an HV timer synchronized to the Super NES PPU. The HV timer can be used to reference the scan line position on the screen by the SA-1 CPU or to generate HV interrupts. The timer can also be used as a linear timer.
INCREASED LEVEL OF SECURITY The SA-1 is connected between the Super NES CPU and memory . (ROM, RAM). The SA-1 ROM is also different from the standard Super NES game pak ROM. This guards against unlicensed products and FD copies.
SUPER ACCELERATOR SYSTEM FUNCTIONS J
1.2 SYSTEM CONFIGURATION
The following diagram depicts the SAS system configuration.
The SA-1 and memory (game pak ROM and BW-RAM) are installed in the game pak. When desired, data can be protectec by connecting a backup battery to BW- RAM or SA-1 I-RAM.
When external RAM is not required, the system can also be configured without BW-RAM.
Game Pak ROM Ph iat a
Address Address iG
Data b Data
SA-1
Optional
SAS
Address Data i
Super NES
Control Deck
Super NES CPU
Figure 1-1-1 Super Accelerator System Configuration
1-1-3
L
1.3 BUS IMAGE DIAGRAM
The bus image as seen by the SAS software is depicted below. The SA-1 CPU can access game pak ROM, BW-RAM and I-RAM.
The Super NES CPU can access game pak ROM, BW-RAM, I-RAM, Super NES PPU, Super NES WRAM and Super NES APU.
SA-1 CPU
(SA-1)
Super NES Super NES WRAM PPU
Figure 1-1-2 SAS Bus Image
The two MPUs (Super NES CPU and SA-1 CPU) can freely access memory (game pak ROM, BW-RAM and I-RAM). If the two MPUs try to access the same memory at the same time, one of the MPUs is automatically excluded, and any conflict is averted.
CONFIGURATION OF SA-1
Chapter 2
2.1 Configuration of SA-1
SA-1 FUNCTIONAL DESCRIPTION
The SA-1 is internally comprised of nine components. A block diagram is illustrated below.
To GPK ROM }-——>
SA-1 CPU a =) 1 To
(65C816) N ‘Arithmetic BW-RAM
uy =) Circuit R N t Character =jIconversion Circuit Cc N Variable-Length Bit Bb =} Processing Circuit fe} c I-RAM E Timer {focal i ot Circuit 16 Kbit
Kol DMA Circuit
Super NES CPU ie) i To Game Pak Connector
Figure 1-2-1 SA-1 Block Diagram
[
2.1.1 SA-1 CPU
The 65C816 serves as the CPU core. It operates at 10.74 MHz.
I-RAM
The I-RAM consists of a 16 Kbit RAM. The SA-1 CPU can access the I- RAM at 10.74 MHz in a no-wait state.
The I-RAM data can be protected by connecting RAM to an external battery.
SUPER MMC
The Super MMC performs memory control in a map mode where the ROM capacity exceeds 32 Mbits (Map Mode 22). The SA-1 has a Super MMC chip emulation circuit. The Super MMC includes a backup data protection function.
INTERNAL CONTROLLER
This controls bus access within the SA-1. It performs collision control functions between Super NES CPU and SA-1 CPU.
ARITHMETIC CIRCUIT
The arithmetic circuit hardware performs multiplication, division, and cumulative arithmetic operations.
CHARACTER CONVERSION CIRCUIT
The character conversion circuit hardware converts bitmap data to character data format.
VARIABLE-LENGTH BIT PROCESSING CIRCUIT
The variable-length bit processing circuit hardware processes data in the game pak ROM as 1~16 bit variable-length data.
TIMER CIRCUIT
The SA-1 has a HV timer which is equivalent to the Super NES PPU timer. The timer can also be used as an 18-bit linear timer.
DMA CIRCUIT
The DMA circuit transfers data between game pak ROM, BW-RAM and I- RAM.
1-2-2
CONFIGURATION OF SA-1
2.2 MEMORY ACCESS
2.2.1 GAME PAK ROM ACCESS
The Super NES CPU and SA-1 CPU share the entire game pak ROM area and can both freely access it. This is known as 2-phase access. When only the SA-1 CPU uses game pak ROM, the SA-1 CPU operates at 10.74 MHz. During this period the Super NES CPU executes its program on Super NES WRAM. When both the Super NES CPU and SA-1 CPU execute a program on game pak ROM, the SA-1 CPU runs at 5.37 MHz and the Super NES CPU runs at 2.68 MHz.
The SAS cannot utilize the Super NES CPU’s high-speed mode (3.58 MHz). It operates at a fixed speed of 2.68 MHz even when only the Super NES CPU uses game pak ROM. This timing is illustrated below for each of these conditions.
2.2.1.1 ONLY SA-1 CPU USES ROM
Sa eal C=SA-1 CPU
cic|cic}]cjc|c/c{jcjc|c}cjcjcic
SA-1 CPU
2.2.1.2 SUPER NES CPU ACCESSES ROM DURING SA-1 CPU OP- ERATIONS
C=SA-1 CPU 10.74 MHz S-CPU=Super NES CPU as +— 5.37MHz —— = C | C |S-CPUj C | C | C | C |S-CPU| C | C | S-CPU| C SA f f i CPU SA SA-1 SA-1 CPU Wait CPU Wait CPU Wait
2.2.1.3 BOTH PROCESSORS ACCESS ROM (2-PHASE ACCESS) C=SA-1 CPU 10.74 MHz ; ; S-CPU=Super NES CPU ao — — 5.37MHz
C |S-CPU} C | C | S-CPU| C | C |S-CPU| C | C |S-CPU shi | | | cpu SA4 SA-1 SA-1 SA-1 CPU Wait CPU Wait CPU Wait CPU Wait
[
2.2.2 BW-RAM ACCESS
The Super NES CPU and SA-1 CPU share all areas of BW-RAM and can freely access it (two-phase access). The SA-1 CPU accesses BW-RAM at 5.37 MHz and the Super NES CPU accesses BW-RAM at 2.68 MHz.
2.2.2.1 ONLY SA-1 CPU USES BW-RAM
- =— 5.37MHz
Read | Read Read | Write | Read No Access | No Access No Access
2.2.2.2 SUPER NES CPU ACCESSES BW-RAM DURING SA-1 CPU OPERATIONS
. . C-CPU=SA-1 CPU Access _ r— 5.37MHz S-CPU=Super NES CPU Access
C-cPU C-CPU | S-CPU C-CPU | C-CPU | S-CPU
No Access No Access
2.2.2.3 BOTH PROCESSORS ACCESS BW-RAM (2-PHASE ACCESS)
. 5 C-CPU=SA-1 CPU Access _ = 5.37MHz S-CPU=Super NES CPU Access
S-CPU | C-CPU | S-CPU | C-CPU | S-CPU S-CPU | C-CPU
No Access
CONFIGURATION OF SA-1 =]
2.2.3. SA-1 I-RAM ACCESS
The Super NES CPU and SA-1 CPU can both access all areas of SA-1 I- RAM at any time.
2.2.3.1 ONLY THE SA-1 CPU ACCESSES I-RAM
C=SA-1 CPU Access
se 10.74 MHz
cj{c c Cc Cc fo} a NIN CPU No Access NoAccess NoAccess No Access
2.2.3.2 BOTH SA-1 CPU AND SUPER NES CPU ACCESS I-RAM
Super C=SA-1 CPU Access NES CPU S=Super NES CPU Access se 10.74 MHz
ry c;cjs Cc c|s c sj;c sat ~\ \7 \Z CPU_ No Access No Access No Access
1-3-1
Super NES Memory Map (SAS, Super NES CPU)
Fd_ pd _A od 8180 __7E70 60 5 4114 2
©1@Ot FOlavo| Select
Game
BW-RAM
Image (00) ~ (1F)}
Select
Ndawe ZwwHn sacs CFE orfory Select x vj a
a (ae (OE (06)
© os — acs [id
Game Pak ROM Image [0] or
(0B 03) (oa yio2)
~S<Ow [vu — ew]
Image (00) ~ (1F) 08020100,
SA-1,-RAM SA-1 Register cpm WRAM
- Koso: A-1 |-RA\ SA-1 Register
-O@<¢s aqowetns O-+un Sax w (08)f(00) Hu FFFFH E000H ‘COOOH |AQ00H 8000H 6000H 4000H 3800H 3000H 2400H 2200H 2000H
RAM 3.1 Chapter 3 Super Accelerator Memory Map
TTT 0000H BW-RAM Image: The user can select one block from blocks 00~1F and output its image to addresses 6000H~7FFFH in banks 00~3F and
80~BF. B&&%)] Only the Super NES CPU and PPU registers have
access to these areas.
FFFFH 0000H 64M 56M 48M 40M 32M 24M 16M 8M 0
M-ROM (MAX 64M bit) MEMORY MAP FROM SUPER NES CPU PERSPECTIVE
1-3-2
Super NES Memory Map (SAS, SA-1 CPU)
64m sd ad od 818
Fo EQ Di 70 \6F
Select Select
ple Game Game
Pak Pak
ROM ROM
Image Image
[3] [2] or Bank i FX EX Data
- (0) (2) + 'G'O'|9O" @ oO BW-RAM Image(00) ~ (7F) Select One
& u
S c SA-1 I-RAM: Image: SA-1 Register [es] —-@qtqs O-+ Sct0 toue 07) 05) (04)
56M 48M 40M 32M 24M. 161 M-ROM (MAX 64M bit) 3d 20 104
Game Game Pak Pak ROM Image ROM [0] Image or [1] Bank CX C000H
Data 08 020100) : FFFFH E000H AQ00H 8000H
Image(00) ~ (7F} Select One 6000H vatatacatetetetocarecerererenenaceess ROKR KR 40004 LOY SA-1IERAM, BW-RAM Image: The user can select one block from blocks 00~7F and output its image to addresses 6000H~7FFFH in banks 00~3F and
80~BF. §83%]_ Only the Super NES CPU and PPU registers have
access to these areas. 3.2 MEMORY MAP FROM SA- 1 CPU PERSPECTIVE ] SUPER ACCELERATOR MEMORY MAP:
3.3. SUPER MMC
The Super MMC is a Super NES memory controller which can support a ROM capacity in excess of 32 Mbits. The memory map used by the Super MMC is called Map Mode 22. The SA-1 contains the Super MMC memory control function. Map Mode 22 features are described below.
3.3.1
3.3.2
3.3.3 ROM BANK SWITCHING
The entire mask ROM is divided into 8 Mbit blocks, which can be projected onto the 8 Mbit areas, OOOOH~FFFFH in banks COH~CFH, DOH~DFH, EOH~EFH, and FOH~FFH. The same 8 Mbit data can be projected onto multiple areas.
ROM IMAGE PROJECTION
The ROM data in banks CXH, DXH, EXH, and FXH, described above, is image projected onto, respectively, the 8 Mbit area 8000H~FFFFH, in banks 0OH~1FH, 20H~3FH, 80H~9FH, and AOH~BFH.
The image projection method used is different from that used in Map Mode 21 in that the ROM data is projected in successive order, as demonstrated below.
C0:0000H~CO:7FFFH — 00:8000H~00:FFFFH C0:8000H~CO:FFFFH — 01:8000H~01:FFFFH C1:0000H~C1:7FFFH —> 02:8000H~02:FFFFH
CF:8000H~CF:7FFFH —> 1F:8000H~1F:FFFFH
It is also possible to project the first 8 Mbits of data in the mask ROM (00:0000H~OF:FFFFH) onto bank 00OH~1FH, regardless of the settings for banks CXH, DXH, EXH, and FXH. In a similar manner, data in 10:0000H~1F:FFFFH, 20:0000H~2F:FFFFH, and 30:0000H~3F:FFFFH can be projected onto banks 20H~3FH, 80H~9FH, and AOH~BFH, respectively.
BACKUP RAM
Backup RAM is assigned to areas in bank 40H, justified to OOOOH, as illustrated below.
16K RAM: 40:0000H~40:07FFH 64K RAM: 40:0000H~40:1FFFH 256K RAM: 40:0000H~40:7FFFH 1M RAM: 40:0000H~41:FFFFH
SUPER ACCELERATOR MEMORY MAP ]
3.3.4
3.3.5
3.3.6 Backup RAM is image projected to the 64 Kbit areas in 6(000H~7FFFH of banks 0OH~3FH and 80H~BFH. The backup area can be divided into 64 Kbit blocks. Any of these blocks can be projected as images. The data is identical in banks OOH~3FH and 80H~BFH.
PROTECTION OF BACKUP DATA
Awrite-protect setting is available to prevent data in the backup data area (banks 40H~7DH from being damaged. This setting protects data even in case of a CPU crash.
CONTROL REGISTERS
The Super MMC control registers are assigned to 2200H~23FFH of banks 00H~3FH and 80H~BFH.
CAUTIONS
3.3.6.1 HIGH SPEED MODE
The SAS cannot use the Super NES CPU high-speed mode (3.58 MHz).
3.3.6.2 ROM AND BACKUP RAM AREA
The maximum mask ROM area is 64 Mbits. The maximum backup RAM area is 2 Mbits.
3.3.6.3 SHARED ROM MEMORY MAP
The Super NES CPU and SA-1 CPU share a common ROM memory map.
The ROM data in banks CXH, DXH, EXH, and FXH is identical (the same data is projected) for the Super NES CPU and SA-1 CPU. However, the program can be executed in different banks for each processor.
3.3.6.4 BACKUP RAM PROTECTION
The image projected to Backup RAM is specified separately.
The RAM data which is projected to the backup RAM image area in OOH~3FH and 80H~BFH can be specified separately for the Super NES CPU and SA-1 CPU.
3.3.6.5 SA-1 I-RAM PRE-ASSIGNED
SA-1 internal RAM (I-RAM) is assigned according to memory mapping.
The I-RAM is assigned to 3000H~37FFH in banks 00OH~3FH and 80H~BFH during Super NES CPU access and to 3000H~37FFH and 0000H~07FFH in banks 0OH~3FH and 80H~BFH during SA-1 CPU access.
3.4 VECTORS AND ROM-REGISTERED DATA
Set the address for the Super NES CPU vectors and ROM-registered data to 00:7FBOH~00:7FFFH. When set to this area, they are assigned to FFBOH~FFFFH in bank OOH at Super NES start-up.
SA-1 INTERNAL REGISTER CONFIGURATION, [ J
Chapter 4 SA-I Internal Register Configuration
The SA-1 internal registers are assigned to addresses 2200H~23FFH in the Super NES CPU and SA-1 CPU banks 00OH~3FH and 80H~BFH. Registers with addresses 22**H are write registers and those with addresses 23**H are read registers.
4.1 EXPLANATION OF REGISTERS
4.1.1. SA-1 CPU CONTROL (CCNT)
Access: Super NES CPU Write Address: **2200H Size: 8 bits Initial value: 20H
D7 Dé DS D4 D3 D2 D1 Do SA-1 | SA-1] SA-1 | SA-1 cpu | CPU_| cPuU CPU | SMEG3| SMEG2] SMEG1| SMEGO} 2200H IRQ_| RDY B]_RESB | _NMI
SA-1 CPU IRQ: SA-1 CPU IRQ (from Super NES CPU) 0: No Interrupt 1: Interrupt
SA-1 CPU RDY B: Ready 0: Ready 1: Wait
SA-1 CPU RESB: SA-1 CPU reset 0: Cancel 1: Reset
SA-1 CPU NMI: SA-1 CPU NMI (from Super NES CPU) 0: No Interrupt 1: Interrupt
SMEGO~SMEG3: Message from Super NES CPU to SA-1 CPU
1-4-1
4.1.2 SUPER NES CPU INT ENABLE (SIE)
Access: Super NES CPU Write Address: **2201H Size: 8 bits Initial value: OOH
D7 D6 D5 D4 03 D2 D1 bo SA-1 CPU CHDMA 2201H IRQEN 0 IRQEN (e) 0 0 0 0
SA-1 CPU IRQEN: IRQ enable/disable from the SA-1 CPU 0: Disable 1: Enable
CHDMA IRQEN: Character conversion DMA IRQ enable/disable 0: Disable 1: Enable
SUPER NES CPU INT CLEAR (SIC)
Access: Super NES CPU Write Address: **2202H Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 D2 D1 DO SA-1 CPU CHDMA 2202H IRacL| 0 | IRacL}| 0 0 0 (0) 0
SA-1 CPU IRQCL: IRQ clear from the SA-1 CPU 0: No change 1: Clear
CHDMAIRQCL: Character conversion DMA IRQ clear 0: No change 1: Clear
1-4-2
SA-1 INTERNAL REGISTER CONFIGURATION ]
4.1.4 SA-1 CPU RESET VECTOR (CRV)
Access: Super NES CPU Write Address: **2203H, **2204H Size: 16 bits Initial value: Nonspecific
D7 D6 DS D4 D3 D2 O1 DO SA-1 CPU Reset Vector CRVv7| CRV6| CRV5| CRV4| CRV3 | CRV2| CRV1 | CRVO 2203H
SA-1 CPU Reset Vector 2204H ICRV15} CRV14] CRV13| CRV12| CRV11/CRV10} CRV9 | CRV8
SA-1 CPU NMI VECTOR (CNV)
Access: Super NES CPU Write Address: **2205H, **2206H Size: 16 bits Initial value: Nonspecific
D7 D6 DS D4 D3 D2 D1 Do ga-1 CPU NMI Vector (Low) 2205H CNV7| CNV6/| CNV5 | CNV4 | CNV3 | CNV2 | CNV1 | CNVO SA-1 CPU NMI Vector (High) 2206H ICNV 15} CNV 14] CNV13] CNV12/ CNV11/CNV10} CNV9 | CNV8
SA-1 CPU IRQ VECTOR (CIV)
Access: Super NES CPU Write Address: **2207H, **2208H Size: 16 bits Initial value: Unspecified
D7. __—~+6 DS D4. __D3__—sib2 D1 Do SA-1 CPU IRQ Vector (Low) Clv7 | ClV6 | ClV5 | Clv4 | Clv3 | Clv2 | Clv1 | Clvo
SA-1 GPU IRQ Vector (High)
CIV15] ClV14] ClV13] ClV12] Clv11] Clvi0} Clv9 | ClVv8 2207H
2208H
ERE J 4.1.7, SUPER NES CPU CONTROL (SCNT)
Access: SA-1 CPU Write Address: **2209H Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 D2 D1 DO SNES | SNES SNES CPU CPU CPU 2209H IRQ IVSW. oO NVSW | CMEG3| CMEG2} CMEG1 | CMEGO!
Super NES CPU IRQ: IRQ from SA-1 CPU to Super NES CPU 0: No IRQ interrupt 1: IRQ interrupt
Super NES CPU IVSW: Super NES CPU IRQ vector selection 0: Game pak ROM 1: Super NES CPU IRQ vector register
Super NES CPU NVSW Super NES CPU NMI vector selection 0: Game pak ROM 1: Super NES CPU NMI vector register
CMEGO~CMEG3: Message from SA-1 CPU to Super NES CPU
1-4-4
SA-1 INTERNAL REGISTER CONFIGURATION =]
4.1.8 SA-1 CPU INT ENABLE (CIE)
Access: SA-1 CPU Write Address: **220AH Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 D2 D1 DO SNES SNES CPU Timer DMA CPU 220AH IRQEN | IRQEN | IRQEN | NMIEN 0 (0) 0 ie}
Super NES CPU IRQEN: IRQ control from Super NES CPU to SA-1 CPU 0: Disable 1: Enable
Timer IRQEN: IRQ control from timer to SA-1 CPU 0: Disable 1: Enable
DMA IRQEN: IRQ control to SA-1 CPU at end of SA-1 DMA 0: Disable 1: Enable
Super NES CPU NMIEN: NMI contro! from Super NES CPU to SA-1 CPU 0: Disable 1: Enable
L
SA-1 CPU INT CLEAR (CIC)
Access: SA-1 CPU Write Address: **220BH Size: 8 bits Initial value: OOH
220BH D7 D6 DS D4 D3. D2 Di DO SNES SNES CPU Timer DMA CPU IRQCL | IRQCL | IRQCL | NMICL ie} 0 0 ie}
Super NES CPU IRQCL: IRQ clear from Super NES CPU to SA-1 CPU 0: No change 1: Clear
Timer IRQCL: IRQ clear from timer to SA-1 CPU 0: No change 1: Clear
DMA IRQCL: IRQ clear to SA-1 CPU at end of SA-1 DMA 0: No change 1: Clear
Super NES CPU NMICL: NMI clear from Super NES CPU to SA-1 CPU 0: No change 1: Clear
SA-1 INTERNAL REGISTER CONFIGURATION J
4.1.10 SUPER NES CPU NMI VECTOR (SNV)
Access: SA-1 CPU Write Address: **220CH, **220DH Size: 16 bits Initial value: Nonspecific
D7 D6 D5 D4 D3 D2 D1 DO Super NES CPU NMI Vector (Low) SNV7]_ SNV6 | SNV5 | SNV4 | SNV3 | SNV2 | SNV1_}| SNVO Super NES CPU NMI Vector (High
SNV15] SNV14] SNV13] SNV12] SNV11] SNV10} SNVQ | SNV8. 220CH
220DH
4.1.11. SUPER NES CPU IRQ VECTOR (SIV)
Access: SA-1 CPU Write Address: **220EH, **220FH Size: 16 bits Initial value: Nonspecific
D7 D6 DS D4 D3 D2 D1 DO Super NES CPU IRQ Vector (Low’ SIV7_|_ SIV6 | SIV5 | S!v4 | SIV3 | SiV2 | SIV1_| SIVO
Super NES CPU IRQ Vector (High
220FH SIV15] SIVi4} SIV13] Slvi2{ Sivi1] SIV10] Siv9 | Siv8 220EH
1-4-7
[
4.1.12
4.1.13 H/V TIMER CONTROL (TMC)
Access: SA-1 CPU Write Address: **2210H Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 b2 Di bBo
2210H IHVSELB} OO 0 0 ie) 0 VEN | HEN
HVSELB: Select HV timer
0: HV Timer 1: Linear Timer
VEN, HEN: V count enable, H count enable 00: Disable both H and V 01: Enable H only: IRQ at H timer value 10: Enable V only: IRQ at V timer value 11: Enable both H and V: IRQ at H/V timer values
SA-1 CPU TIMER RESTART (CTR)
Access: SA-1 CPU Write Address: **2211H Size: 8 bits Initial value: Nonspecific
D7 D6 DS D4 D3 D2 D1 DO
2211H
Writing any value to this register restarts the timer at 0.
1-4-8
SA-1 INTERNAL REGISTER CONFIGURATION J
4.1.14
4.1.15 SET H-COUNT (HCNT)
Access: SA-1 CPU Write Address: **2212H,**2213H Size: 16 bits Initial value: Nonspecific
D7 D6 DS D4 D3 D2 Di DO H-Count (Low) 2212H H7 H6 H5 H4 H3 H2 H1 HO -Count (High) 2213H (¢} 0 ie} 0 0 ie} 0 H8
HV timer: Timer IRQ H count value (0~340) Linear timer: Lower 9 bits of the timer IRQ linear counter (0~511)
SET V COUNT (VCNT)
Access: SA-1 CPU Write Address: **2214H, **2215H Size: 16 bits Initial value: Nonspecific
D7 D6 D5 D4 D3 D2 D1 DO V-Count (Low) 2214H V7 V6 V5 V4 V3 V2 al vo -Count (High) 2215H 0 ie} ie} (e) (e) (e} ie} V8
HV timer: Timer IRQ V count value
NTSC, 0~261 PAL, 0~311
Linear timer: Upper 9 bits of the timer IRQ linear counter (0~511)
1-4-9
[
4.1.16 SET SUPER MMC BANK C (CXB)
Access: Super NES CPU Write Address: **2220H Size: 8 bits Initial value: 00H
D7 D6 DS D4 D3 D2 Di Do
2220H CBM ie} 0 0 0 CB2 | CBi | CBO
CBM: CXH Bank Image Projection
1: CXH bank data is copied into addresses 8000H~FFFFH of banks OXH~1XH (shaded). 0: The game pak ROM area © is copied to addresses 8000H~FFFFH of banks OXH~1XH.
FX_EX DX ao BX AX 9X_8X 7X 6X 5X 4X 3X 2X 1X 0X ooo
Of Y Qa)
8000H
3) 7,
0000H
TEFEFFH «= + +--+ ROM Area Selection (CBO~CB2) eS 70:0000H CB2 | CB1 | CBO | ROM Area 2 60:0000H 0 (} 0 @ 50:0000H 0 (¢) 1 @ @ | soocoon Mt 0 1 0 } ig 30:0000H (} 1 1 @ a 20:0000H 1 0 0 © ® 10:0000H =p =~ 1 0 1 © o 00:0000H t Oe 1 1 0 (0) i
1-4-10
SA-1 INTERNAL REGISTER CONFIGURATION a | 4.1.17 SET SUPER MMC BANK D (DXB)
Access: Super NES CPU Write Address: **2221H Size: 8 bits Initial value: 01H
D7 D6 DS D4 bs D2 Di DO
2221H DBM 0 0 ie} i} CB2_ | CBi CBO
DBM: DXH Bank Image Projection 1: DXH bank data is copied into addresses 8000H~FFFFH of banks 2XH~3XH (shaded). 0: The game pak ROM area @ is copied to addresses 8000H~FFFFH of banks 2XH~3XH.
FX_EX DX CX _BX AX 9X 8X 7X 6X 5X 4X 3X 2X 1X 0X FFFFH
BOG
8000H
0000H
JR-FFFFH --------- ROM Area Selection (CBO~CB2) ® | recooon CB2] CBT] CBO | ROM Area 3 60:0000H 0 0 0 ® © 50:0000H 0 0 1 @ @) “000008 84 Mbit 0 1 0 ® @ | 2000008 ie} 1 1 @ ro) 20:0000H 1 5 0 = coe. 1 1 OV enowoy t2ieeW, 1 [of 1 1 1
1-4-1]
4.1.18 SET SUPER MMC BANK E (EXB) Access: Super NES CPU Write Address: **2222H Size: 8 bits Initial value: 02H
2222H D7 D6 D5 D4 D3 D2 D1 DO
EBM 0 (e} 0 0 CB2 | CBi | CBO
EBM: EXH Bank Image Projection 1: EXH bank data is copied into addresses 8000H~FFFFH of banks 8XH~9XH (shaded). 0: The game pak ROM area @ is copied to addresses 8000H~FFFFH of banks 8XH~9XH. FX EX DX CX BX AX 9X 8X 7X 6X 5X 4X 3X 2X 1X OX FFFFH OY, WY, Y, Wy Yj Y 8000H GY Y Le Gy Y 0000H
TE:FFFFH ---++---- ROM Area Selection (CBO~CB2) a eri CB2| CBT | CBO | ROM Area @ © 60:0000H (e) 0 0 (o) 50:0000H 0 1 @ i 40:0000H 64 Mbit 0 1 0 (6) & 30:0000H 0 1 1 @ le 22.0000 1 5 ; a 10:0000H - @ J pescoo0 eee
1-4-12
SA-1 INTERNAL REGISTER CONFIGURATION ]
4.1.19 SET SUPER MMC BANK F (FXB) Access: Super NES CPU Write Address: **2223H Size: 8 bits Initial value: 03H
D7 D6 DS D4 D3 D2 Di DO
2223H FBM 0 0 0 0 CcB2 | CBi | CBO
FBM: FXH Bank Image Projection 1: FXH bank data is copied into addresses 8000H~FFFFH of banks AXH~BXH (shaded). 0: The game pak ROM area @ is copied to addresses 8000H~FFFFH of banks AXH~BXH.
FX _EX DX_CX_BX AX 9X_ 8X 7X 6X 5X 4X 3X 2X 1X 0X FFFFH
Ly @16
8000H
Z| iD]
0000H
TE-FFFFH --------- ROM Area Selection (CBO~CB2) ® | ro:c000H CB2] CBT | CBO] ROM Area 2 60:0000H 0 0 0 (0) @ | B:0000H ie) 0. 1 ® @ | 1000008 64 Mbit 0 1 0 © ro) 30:0000H ie) 1 1 @ 20:0000H 1 0 0) ® F 10:0000H =, - - 1 i] 1 © 00:0000H 4 cain 1 1 i) @ 1 1 1
1-4-13
4.1.20 SUPER NES CPU BW-RAM ADDRESS MAPPING (BMAPS)
Access: Super NES CPU Write Address: **2224H Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 D2 Di DO
2224H 0 0 0 SBM4 | SBM3{ SBM2 | SBM1 | SBMO
SBMO0~4: BW-RAM Address Image Mapping for Super NES CPU
The BW-RAM image to be mapped to addresses 6000H~7FFFH of banks OOH~3FH and 80H~BFH is user selectable from 00~1F.
FX CX BX AX 9X 8X 7X 43 42 41 40 3X 2X 1X Ox
1F]17]0F 07
1£|16]0E|06
1D|15|op|os
1c]14locloa S000
- 13/08/03 YLLA savor 1A}12]oalo2
49|11]09|01
18|10/08|00 FFFFH
0000H Select one from 00~1F mn
1-4-14
SA-1 INTERNAL REGISTER CONFIGURATION a)
4.1.21 SA-1 CPU BW-RAM ADDRESS MAPPING (BMAP)
Access: SA-1 CPU Write Address: **2225H Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 D2 Di Do
2225H SW46] CBM6]| CBM5} CBM4| CBM3| CBM2{CBM1 | CBMO
CBMO~CBM6: BW-RAM Address Image Mapping for SA-1 CPU
This selects the BW-RAM image to be mapped to the SA-1 CPU at addresses 6000H~7FFFH of banks OOH~3FH and 80H~BFH.
SW46: Specifies the BW-RAM source to be projected 0: Banks 40H~43H are displayed in 32 blocks using CBM0~CBM4. 1: Banks 60H~6FH are displayed in 128 blocks using CBM0O~CBM6.
FX CX BX AX 9X 8X 7X6F 60 43 42 41 40 3X 2X 1X 0X I7F\\ jo7|| | 1} 17|0F|07 76 l06/ |1£|16]0E}06 7D ) 05) }}1D} 15/oD] 05 7 | j04\{}1C] 14}0Clo4 nam 72 }los }/18] 13/oB/03 YL 6000H PA|| lool tal t2loaloz 79 \}o1] \j 19} 11) 09} 01
- | {00} {| 18} 10] 08) 00 FFFFH
0000H Select one from 00~7F
Xr
1-4-15
4.1.22
4.1.23 SUPER NES CPU BW-RAM WRITE ENABLE (SBWE)
Access: Super NES CPU Write Address: **2226H Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 D2 D1 DO
2226H SWEN 0 0 ie} 0 0 0 0
SWEN: Cancels BW-RAM write protection from Super NES CPU
0: Protect 1: Write enable
SA-1 CPU BW-RAM WRITE ENABLE (CBWE)
Access: SA-1 CPU Write Address: **2227H Size: 8 bits Initial value: OOH
D7 D6 D5 D4 D3 D2 D1 bo
2227H CWEN (¢) 0 ¢) (e) 0 0 0
CWEN: Cancels BW-RAM write protection from SA-1 CPU
0: Protect 1: Write enable
1-4-16
SA-1 INTERNAL REGISTER CONFIGURATION ]
4.1.24 BW-RAM WRITE-PROTECTED AREA (BWPA)
Access: Super NES CPU Write Address: **2228H Size: 8 bits Initial value: FFH
D7 D6 D5 D4 D3 D2 Di Do
0 ie) ie) ie} BWP3| BWP2 | BWP1 | BWPO 2228H
BWP0-~3: BW-RAM Write Protected Area Setting
BW-RAM Write Protected Area
BWP3 | BWP2 | BWP1 | BWPO Area Size (bits)
0 0 0 0 400000 - 4000FF 2k
0 0 1 400000 - 4001FF 4K
0 ie} 1 0 400000 - 4003FF 8K 0 0 1 1 400000 - 4007FF 16K
0 1 0 ie) 400000 - 400FFF 32K 0 1 0 1 400000 - 401FFF 64K
0 1 1 0 400000 - 403FFF 128K
0 1 1 1 400000 - 407FFF 256K
1 0 0 0 400000 - 40FFFF 512K
1 0 0 1 400000 - 41FFFF 1M
1 0 1 0 400000 - 43FFFF 2M
At start-up, all areas are write-protected.
1-4-17
4.1.25 SA-1I-RAM WRITE PROTECTION (SIWP)
Access: Super NES CPU Write Address: **2229H Size: 8 bits Initial value: OOH
D7 D6 D5 D4 D3 D2 D1 DO
2229H SIWP7| SIWP6] SIWP5] SIWP4] SIWP3| SIWP2] SIWP1 | SIWPO|
SIWPO-7: SA-1 I-RAM Write Protection Setting
0: Write disable 1: Write enable
SIWPO: Sets 3000H ~ 30FFH ore SIWP1: Sets 3100H ~ 31FFH SIWP2: Sets 3200H ~ 32FFH 3700H SIWP3: Sets 3300H ~ 33FFH @ SIWP4: Sets 3400H ~ 34FFH coor © SIWP5: Sets 3500H ~ 35FFH 3500H SIWP6: Sets 3600H ~ 36FFH © 16Kbit SIWP7: Sets 3700H ~ 37FFH 3400H @ 3300H @ 3200H o 3100H @ f 2keit 3000H ——_1.¥......1
1-4-18
SA-1 INTERNAL REGISTER CONFIGURATION
4.1.26 SA-1 I-RAM WRITE PROTECTION (CIWP)
Access: SA-1 CPU Write Address: **222AH Size: 8 bits Initial value: OOH
D7 D6 D5 D4 D3 b2 D1 Do
222AH ICIWP7] CIWP6] CIWP5| CIWP4| CIWP3| CIWP2} CIWP1} CIWPO|}
CIWPO~CIWP7: — SA-1 I-RAM write protection setting
0: Write disable 1: Write enable
CIWPO: Sets 3000H ~ 30FFH 0000H ~ OOFFH —g7FFH S7FFH:---+-+--p CIWP1: Sets 3100H ~ 31FFH Q100H ~O1FFH = 0700H 3700H CIWP2: Sets 3200H ~ 32FFH —ggooH 3600H 0200H ~ 02FFH CIWP3: Sets 3300H ~ 33FFH —-0500H 3500H 0300H ~ O3FFH —gaggy ornare 16Kbit CIWP4: Sets 3400H ~ 34FFH 0400H ~ O4FFH 0300H CIWPS5: Sets 3500H ~ 35FFH 0200H Q500H ~ O5FFH CIWP6: Sets 3600H ~ 36FFH 0100H Q600H ~ O6FFH CIWP7: Sets 3700H ~ 37FFH 0000H 0700H ~ O7FFH Q|O]/O}@]@|@/E|@
1-4-19
4.1.27 DMA CONTROL (DCNT)
Access: SA-1 CPU Write Address: **2230H Size: 8 bits Initial value: OOH
D7 D6 DS D4 D3 D2 D1 Do
2230H DMAEN} DPrio | CDEN|CDSEL| 0 DD_| SD1i | SDO
DMAEN: DMA Enable Control
0: DMA disable 1: DMA enable
DPrio: Processing priority between SA-1 CPU and DMA
0: SA-1 CPU priority 1: DMA priority DD: Destination device
0: SA-1 I-RAM 1: BW-RAM
SDO, SD1: Source Device
sD1 SDO Device
0 0 Game Pak ROM
1 BW-RAM
1 0 SA-1 I-RAM
CDEN: DMA mode selection
0: Normal DMA 1: Character conversion DMA
CDSEL: Character conversion DMA type
0: SA-1 CPU — SA-1 I-RAM write (CHR conv 2) 1: BW-RAM -> SA-1 I-RAM transfer (CHR conv 1)
1-4-20
SA-1 INTERNAL REGISTER CONFIGURATION zt]
4.1.28 CHARACTER CONVERSION DMA PARAMETERS (CDMA)
Access: SA-1 CPU/Super NES CPU Write Address: **2231H Size: 8 bits Initial value: OOH
D7 06 D5 D4 D3 D2 D1 DO
2231H ICHDEND] OO. 0 SIZE2| SIZE1| SIZEO| CB1 | CBO
CBO and CB1: Character conversion DMA color mode
CB1 | CBO | Character Format
0 8 Bit/Dot
1 4 Bit/Dot
1 0 2 Bit/Dot
1 a.
SIZE 0~2: Number of virtual VRAM horizontal characters
SIZE2 | SIZE1 | SIZEO | Number of Characters 0 0 0 1
0 0 1 2
0 1 0 4
0 1 1 8
1 0 0 16
1 0 1 32
CHDEND: End character conversion 1
When character conversion 1 is completed, CHDEND is set to “1” by the Super NES CPU.
1-4-21
4.1.29
4.1.30 DMA SOURCE DEVICE START ADDRESS (SDA)
Access: Super NES CPU/SA-1 CPU Write Address: **2232H ~ **2234H Size: 24 bits Initial value: Nonspecific 07 D6 DS D4 D3 D2 D1 DO DMA Source Device A Start Address (Cow) 4 2232! DSA7| DSA6 | DSA5 | DSA4 | DSA3 | DSA2 | DSA-1} DSAO DMA Source Device A Start Address (Middle) 2233H DSA-1§ DSA-14 DSA-13 DSA-14 DSA-11DSA-14 DSAQ | DSA8 DMA Source Device A Start Address (High) ooaaH
DSA23] DSA22} DSA21| DSA20| DSA-19 DSA-1§ DSA-14 DSA-1
DSAO-DSA23: DMA source device A start address Data should be stored to the SDA registers in the order of Low > Middle
- High.
DMA DESTINATION START ADDRESS (DDA)
Access: Super NES CPU/SA-1 CPU Write Address: **2235H ~ **2237H Size: 24 bits Initial value: Nonspecific D7 D6 DS D4 D3 D2 Di DO DMA Destination Device Start Address (Low) 2235H DDA7| DDA6 | DDAS| DDA4 | DDA3 | DDA2 | DDA1 | DDAO MA Destination Device Start Address (Middle) 2236H DDA15| DDA14| DDA13| DDA12| DDA11] DDA10| DDAQ | DDA8 DMA Destination Device Start Address (High) 2237H IDDA23] DDA22| DDA21} DDA20| DDA19] DDA18] DDA17|DDA16|
DDAO-DDA23: DMA destination device start address When transmitting to SA-1 I-RAM, DMA transfer is initiated by the write to register 2236H.
When transmitting to BW-RAM, DMA transfer is initiated by the write to register 2237H.
Data should be stored to the DDA registers in the order of Low > Middle
- High.
1-4-22
SA-1 INTERNAL REGISTER CONFIGURATION
4.1.31 DMA TERMINAL COUNTER (DTC)
Access: SA-1 CPU Write Address: **2238H, **2239H Size: 16 bits Initial value: Nonspecific
07 D6 DS D4 D3 D2 D1 bBo DMA Terminal Counter (Low) 2238H 17 T6 T5 T4 T3 T2 T1 To
DMA Terminal Counter (High)
2239H T15 T14 T13 T12 Tu T10 T9 18
TO-T15: Number of bytes (1 ~ 65535) for DMA transmission
4.1.32 BW-RAM BIT MAP FORMAT (BBF)
Access: SA-1 CPU Write Address: **223FH Size: 8 bits Initial value: OOH
D7 D6 D5 D4 D3 D2 Di Do
223FH SEL42] __ -- = -- = = = =
SEL42: BW-RAM bitmap logical space format setting from the perspective of the SA-1 CPU 0: 16 color mode (4 bits/dot) 1: 4 color mode (2 bits/dot)
1-4-23
4.1.33 BIT MAP REGISTER FILE (BRF)
Access: Address: Size: 16 bytes SA-1 CPU Write **2240H ~ **224FH
Initial value: Nonspecific
D7 D6 D5 D4 D3. D2 D1 DO Bitmap Register File 0 BMO07 | BMO6 | BMO5 | BM04 | BMO3 | BMO2 | BMO1 | BM0O Bitmap Register File 1 BM17| BM16/ BM15| BM14 | BM13 | BM12] BM11 | BM10 Bitmap Register File 2 BM27 | BM26 | BM25 | BM24 | BM23 | BM22 | BM21 | BM20 Bitmap Register File 3 BM37 | BM36 | BM35 | BM34 | BM33 | BM32 | BM31 | BM30 Bitmap Register File 4 BM47 | BM46 | BM45 | BM44 | BM43 | BM42 | BM41 | BM40 Bitmap Register File 5 BM57 | BM56 | BM55 | BM54 | BM53 | BM52 | BM51 | BM50 Bitmap Register File 6 BM67 | BM66 | BM65 | BM64 | BM63 | BM62 | BM61 | BM60
Bitmap Register File 7
BM77 | BM76 | BM75 aural BM73 | BM72 | BM71 | BM70
Figure 1-4-4 Bitmap Register Files 0 ~ 7
1-4-24 2240H
2241H
2242H
2243H
2244H
2245H
2246H
2247H
SA-1 INTERNAL REGISTER CONFIGURATION
BM87 BM86 Bitmap Register File 8
BM85. BM84 BM83. BM82 BM81 BM80
BM97 BMg6 BMg5 BMg3 Bitmap Register File 9 aurea BMg2 BMg1 BMg90
BMA7 BMA6 Bitmap Re:
BMA5 uaa BMA3 ister File A
BMA2 BMA1 BMAO
BMB7 BMB6 Bitmap Re:
BMB5 supa BMB3 ister File B
BMB2 BMB1 BMBO.
BMC7 BMC6 Bitmap Register File C
BMC5 BMC4 BMC3 BMC2 BMC1 BMCO
BMD7 BMD6 Bitmap Register File D
BMD5 BMD4 BMD3 BMD2 BMD1 BMDO.
BME7 BME6 Bitmap Re:
BMES wea BME3 ister File E
BME2 BME1 BMEO
BME7 BMF6, Bitmap Re
BMEF5, aura BMF3 ister File F
BMF2 BMF1 BMFO.
Figure 1-4-5
BRFO ~
BRF8 ~ Bitmap Register Files 8 ~ FF
BRF7:
BRFF: Buffer 1
Buffer 2
1-4-25 2248H
2249H
224AH
224BH
224CH
224DH
224EH
224FH
[
4.1.34 ARITHMETIC CONTROL (MCNT)
Access: SA-1 CPU Write Address: **2250H Size: 8 bits Initial value: OOH
D7 D6 D5 D4 D3 D2 Di DO
0 (e) 0 0 0 0 ACM M/D
Types of M/D and ACM arithmetic operations
ACM M/D TYPE OF OPERATION
0 Multiplication
1 Division
1 0 Cumulative Sum 2250H
1-4-26
SA-1 INTERNAL REGISTER CONFIGURATION
4.1.35
4.1.36 ARITHMETIC PARAMETERS: MULTIPLICAND/DIVIDEND (MA)
Access: SA-1 CPU Write Address: **2251H, **2252H Size: 16 bits Initial value: Nonspecific
D7 D6 D5 D4 D3 D2 D1 bo Arithmetic Parameters: Multiplicand/Dividend (Low) 2251H MAZ_|_MA6 | MAS | MA4 | MA3 | MA2 | MA1 | MAO rithmetic Parameters: Multiplicand/Dividend (High) MA15 | MA14} MA13 | MA12 | MA11 | MA10 | MAQ | MA8 2252H
MAO-MA15: Multiplicand/Dividend setting (signed 16-bit data)
The data contained in MAO~MA15 is saved even after it is acted upon. The register does not need to be reset, when used for multiplication. When used for division, however, the register must be reset each time.
ARITHMETIC PARAMETERS: MULTIPLIER/DIVISOR (MB)
Access: SA-1 CPU Write Address: **2253H,**2254H Size: 16 bits Initial value: Nonspecific
D7 D6 D5 D4 D3 D2 Di DO Arithmetic Parameters: Multiplier/Divisor (Low) 2253H MB7_|_MB6 | MBS | MB4 | MB3 | MB2 | MB1 | MBO Arithmetic Parameters: Multiplier/Divisor (High) 2254H MB15 | MB14 |] MB13} MB12 | MB11| MB10 | MB9 | MB8
MBO-MB15: Multiplier/divisor setting
- Signed data when used for multiplication ¢ Unsigned data when used for division
The arithmetic operation is executed following a write to register 2254H.
The multiplier/divisor must be reset each time an operation is performed.
1-4-27
[ ai)
4.1.37, VARIABLE-LENGTH BIT PROCESSING (VBD)
Access: SA-1 CPU Write Address: **2258H Size: 8 bits Initial value: Nonspecific
D7 D6 D5 D4 D3 D2 D1 pt)
HL te) te) (e} VB3_|_ VB2 | VBi | VBO 2258H
HL: Variable-length data read mode 1: Auto-increment mode
0: Fixed mode
VBO-VB3: Significant '": length of data previously stored
VB3 | VB2 | VBI | VBO | Data Length (bits)
0 0 0 0 16
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
1 0 0 0 8
1 0 0 1 9
i} 0 1 0 10
1 0 1 1 ll
1 1 0 0 12
1 1 0 1 13
1 1 1 0 14
1 1 1 1 15
1-4-28
SA-1 INTERNAL REGISTER CONFIGURATION
4.1.38 VARIABLE-LENGTH BIT GAME PAK ROM START ADDRESS (VDA)
Access: SA-1 CPU Write Address: **2259H-**225BH Size: 24 bits Initial value: Nonspecific
D7 D6 DS D4 D3 D2 D1 DO Variable-Length Bit Game Pak ROM'Start Address (Low) 2259H VA7_| VA6 | VAS VA4 | VA3 | VA2 VAI VAO Variable-Length Bit Game Pak ROM Start Address (Middle) 225AH VA15 | VA14 | VA13 | VA12 | VA11 | VA10 {|_VA9 | VA8 Varlable-Length Bit Game Pak ROM Start Address (High) 225BH VA23 | VA22 | VA21 | VA20 | VAI9 | VA18 | VA17 | VAI6
VAO-VA23: Game Pak ROM variabie-length bit area start address setting.
Variable-length bit execution begins with a write to register 225BH.
1-4-29
4.1.39 SUPER NES CPU FLAG READ (SFR)
Access: Super NES CPU Read Address: **2300H Size: 8 bits
D7 D6 DS D4 D3 D2 Di Do SA-1 CPU CHDMA 2300H IRQ IVSW. IRQ_|_ NVSW | CMEG3| CMEG2| CMEG1 | CMEGO.
SA-1 CPU IRQ: IRQ flag from SA-1 CPU 0: No IRQ 1: IRQ
IVSW: Super NES CPU IRQ vector setting 0: Game pak ROM data 1:SIV register data
CHDMA IRQ: Character conversion DMA IRQ flag 0: No IRQ 1: IRQ (character conversion 1 stand-by)
NVSW: Super NES CPU NMI vector setting 0: Game pak ROM data 1: SNV register data
CMEGO-CMEG3: Message port from SA-1 CPU: 0~15
1-4-30
SA-1 INTERNAL REGISTER CONFIGURATION
4.1.40 SA-1 CPU FLAG READ (CFR)
Access: SA-1 CPU Read Address: **2301H Size: 8 bits
D7 D6 D5 D4 D3 D2 D1 DO SNES SNES CPU Timer DMA CPU 2301H IRQ IRQ IRQ NMI__| SMEG3]| SMEG2 | SMEG1 | SMEGO
Super NES CPU IRQ: IRQ flag from Super NES CPU 0: No IRQ 1: IRQ
Timer IRQ: IRQ flag from timer. 0: No IRQ 1: IRQ
DMA IRQ: IRQ flag at the end of DMA 0: No IRQ 1: IRQ (end of DMA)
Super NES CPU NMI: NMI flag from Super NES CPU
SMEGO-SMEG3: 0: No NMI 1: NMI
Message port from Super NES CPU: 0~15
1-4-3]
[
4.1.41 H-COUNT READ (HCR)
4.1.42 Access: SA-1 CPU Read Address: **2302H, **2303H Size: 16 bits
D7 D6 DS D4 D3 D2 Di DO Timer H-Count Read (Low) 2302H HZ H6 H5 H4 H3. H2 Hi HO Timer H-Count Read (High) 2303H = - - - - ~ - H8
HO-H8: HV timer:H-count (dots,0~340) read Linear timer: Lower 9-bit count (0~511) read
All HV counter values are latched when register 2302H is read.
V-COUNT READ (VCR)
Access: SA-1 CPU Read Address: **2304H, **2305H Size: 16 bits
D7 D6 D5 D4 D3 D2 D1 DO Timer V-Count Read (Low) 2304H NZ V6 V5 V4 V3 v2 Mi Vo Timer V-Count Read (High) 2305H
VO-V8: HV timer:V-count (lines) read NTSC, 0~261 PAL, 0~311 Linear timer: Upper 9-bit counter value (0~511) read
1-4-32
SA-1 INTERNAL REGISTER CONFIGURATION
4.1.43 ARITHMETIC RESULT [PRODUCT/QUOTIENT/ACCUMULATIVE SUM] (MR)
Access: SA-1 CPU Read Address: **2306H ~ **230AH Size: 40 bits
D7 D6 DS D4 D3 D2 D1 DO Read Arithmetic Result (product/quotient/cumulative sum) WO
DZ D6 DS D4 D3 D2 D1 DO Read Arithmetic Result (product/quotient/cumulative sum) W1
D15 B14 D13 Di2 D1 D10 D9 08 Read Arithmetic Result (product/remainder/cumulative sum) W2 2306H
2307H
2308H D23 D22 D21 D20 B19 D18 D17 D16 Read Arithmetic Result (product/remainder/cumulative sum) W: 2309H D31 D30 D29 D28 D27 D26 D025 D24 Read Arithmetic Result (cumulative sum) W4 230AH D39 | D38 | D37 | D386 | D35 | D34 | D33 | D32
DO-D39: Arithmetic result Multiplication: 16 (S) x 16 (S) = 32 (S)...D0-D31 Division: 16 (S) 16 (U) = 16 (S) ...DO-D15 Remainder: 16 (U) ».D16-D31 Cumulative Sum: 2(16 (S) x 16 (S)) = 40 (S) ...D0-D39
1-4-33
4.1.44 ARITHMETIC OVERFLOW FLAG (OF)
4.1.45 230BH
230CH
230DH Access: SA-1 CPU Read Address: **230BH Size: 8 bits
D7 D6 DS D4 D3 D2 D1 bo
OF: Overflow flag 1: Overflow 0: No overflow
VARIABLE-LENGTH DATA READ PORT (VDP)
Access: SA-1 CPU Read Address: **230CH, **230DH Size: 16 bits
D7 D6 DS D4 D3 D2 D1 bBo Variable-Length Data Read Port (Low) VD7 | VD6 | VD5 | VD4 | VD3 | VD2 | VD1 VDO Variable-Length Data Read Port (High)
VD15 | VD14} VD13 | VD12 {| VD11 | VD10} VD9 | VD8
VDO-VD15: The 16-bit data resulting from barrel-shifting the values stored in the VBD register (**2258H).
1-4-34
SA-1 INTERNAL REGISTER CONFIGURATION ]
4.1.46 VERSION CODE REGISTER (VC)
230EH Access: Super NES CPU Read Address: **230EH Size: 8 bits
D7 D6 DS D4 D3 D2 D1 DO
ve7_}| vc6 | vc5 | vc4 | vc3 | VC2 | VC1 vco
VCO ~ VC7: SA-1 Device Version
1-4-35
[
Chapter 5 Multi-Processor Processing
5.1
5.2 MULTI-PROCESSOR SYSTEM
The Super Accelerator System (SAS) is a multi-processor system in which two MPUs (the Super NES CPU and the SA-1 CPU) operate in parallel. The Super NES CPU performs as the main processor, controlling execution of the SA-1 CPU. The SA-1 CPU cannot control Super NES CPU operations. This main/sub relationship is a hardware arrangement. Software can be used to manipulate flags and interrupts to use the faster SA-1 CPU as the main processor.
STARTING AND STOPPING THE SA-1 CPU
When power is applied to the Super NES control deck or its reset button is pressed, the SA-1 CPU is placed in its “stop” state. The Super NES CPU manipulates SA-1 internal registers to start and stop the SA-1 CPU as directed by software.
5.2.1 STARTING THE SA-1 CPU The Super NES CPU sets the SA-1 CPU program start address into the RV register (2203H, 2204H) and resets the SA-1 CPU RES bit of the CCNT register (2200H) to “0” to initiate SA-1 CPU processing from the address set in the RV register.
5.2.2 STOPPING THE SA-1 CPU When the Super NES CPU sets the SA-1 CPU RES bit of the CCNT register (2200H) to “1”, the SA-1 CPU stops processing and is placed in stop status.
MULTI-PROCESSOR PROCESSING
5.3 MPU HANDSHAKES
Because the Super NES CPU and SA-1 CPU collaborate in processing programs, the SAS defines the following handshakes between the two MPUs.
5.3.1 INTERRUPTS
The Super NES CPU and SA-1 CPU can each transmit interrupts such as IRQ and NMI to each other, as listed in the following table.
Interrupt Direction Register Set type
IRQ soc CCNT (2200H), SA-1 CPU IRQ bit = 1
NMI soc CCNT (2200H), SA-1 CPU NMI bit = 1
IRQ cos SCNT (2209H), Super NES CPU IRQ bit = 1
NMI cos Not possible
Table 1-5-1 Types of Interrupts
An NMI interrupt cannot be sent from the SA-1 CPU to the Super NES CPU.
The MPU being interrupted identifies the source of the interrupt and clears the interrupt when the source is the other MPU.
Interrupt Direction Interrupt Clear Register type Identification
IRQ soc CFR (2301H) CIC (220BH) Super NES CPU IRQ | Super NES CPU bit IRQCL bit=1 NMI soc CFR (2301H) CIC (220BH) Super NES CPU NMI | Super NES CPU NMI bit CL bit =1 IRQ cs SFR (2300H) SIC (2202H) SA-1 CPU IRQ bit SA-1 CPU IRQCL bit =1
Table 1-5-2 Interrupt Identification and Clear
5.3.2 To temporarily block interrupts, they can be masked in an MPU.
Interrupt Direction Mask Register
Type IRQ sc CIE (220AH), Super NES CPU IRQEN bit = 0
NMI soc CIE (220AH), Super NES CPU NMIEN bit = 0 IRQ cos SIE (2202H), SA-1 CPU IRQEN bit = 0
Table 1-5-3 Interrupt Mask
A masked interrupt becomes active after the mask is cancelled. To prevent this interrupt when the mask is cancelled, the programmer may use the interrupt identification registers, described in the table on the previous page, to identify an interrupt, then clear that interrupt before cancelling the mask.
MESSAGE
A four-bit message can be sent along with an interrupt signal between the MPUs, as described in the table below.
Interrupt Direction Register Sending Register Receiving
Type the Message the Message
IRQ s3c CCNT (2200H), SFR (2300H) SMEG0~3 CMEGO~3
NMI soc CCNT (2200H) SFR (2300H) SMEGO~3 CMEGO-~3
IRQ cs SCNT (2209H) CFR (2301H) CMEGO~3 SMEGO~3
Table 1-5-4 Sending and Receiving a Message
MULTI-PROCESSOR PROCESSING ai
5.4
5.5 SHARED MEMORY
Since SA-1 I-RAM can be accessed by both MPUs, a section of the SA-1 I-RAM can be used as a command exchange window. This window can be used in lieu of an interrupt to perform a handshake between the two MPUs. It also allows more command information to be sent than is possible with a “message”, described previously. The size of shared memory in SA-1 I-RAM can be assigned by each program. The SA-1 has a collision-control circuit for memory access, so that simultaneous read/write access by both MPUs does not cause any problems. If simultaneous access does occur, the Super NES CPU has priority access and the SA-1 CPU is put on hold.
The BW-RAM also has an area assigned to joint access and can be used as shared memory as well. However, it is generally best to use SA-1 I-RAM due to the RAM access speed (operating speed) and because BW-RAM cannot be used during character conversion DMA.
VECTOR SWITCHING
Parts of the Super NES CPU and SA-1 CPU vectors are registers in the SAS. This permits situation dependant multiple routines to be used. For example, interrupt processing can be expedited by preparing multiple IRQ routines in advance and setting the IRQ interrupt destination address in response to game situations.
Vectors which can be specified in registers include the following.
Vector Type Destination Setting Valid/Invalid Selection Bits Super NES CPU | SNV (220CH, 220DH) | SCNT Super NES CPU NMI NVSW bit Super NES CPU _ | SIV (220EH, 220FH) SCNT Super NES CPU IRQ IVSW bit
SA-1 CPU reset CRV (2203H, 2204H) | Always valid SA-1 CPU NMI CNV (2205H, 2206H) | Always valid SA-1 CPU IRQ CIV (2207H, 2208H) Always valid
Table 1-5-5 Situation Dependant Vectors
When the Super NES CPU register setting vector is set to invalid, the program jumps to the address indicated in ROM.
5.6 SA-1 CPU CORE
The SA-1 core CPU is the same 16-bit CPU (65C816) used in the Super NES CPU and can execute all the Super NES instructions. The differences between the SA-1 CPU and Super NES CPU cores are as follows:
5.6.1
5.6.2 VECTORS The reset, NMI, IRQ and other vectors registered in the M-ROM are for the Super NES CPU. The SA-1 CPU vectors must be set separately. The SA-1 CPU vectors should be set in the following registers using the Super NES CPU. Reset vector: RV (2203H, 2204H) NMI vector: CNV (2205H, 2206H) IRQ vector: CIV (2207H, 2208H) Other vectors: Same as the Super NES CPU (M-ROM data)
SA-1 CPU WAIT The SA-1 CPU operates at 10.74 MHz, but a wait cycle may be introduced when some commands and functions are executed, or when it is accessed by the Super NES CPU. This happens when:
- the following instructions are executed: RTS, RTI, RTL, JMP (a), JML (a), JMP a, JMP al, JMP (a,x), JSR (a,x), JSR a, JSL al, BRA cop
- the destination address of the following commands is odd: BPL, BMI, BVC, BVS, BRA, BCC, BCS, BNE, BEQ, BRL
- data is read from Game Pak ROM or BW-RAM.
- the SA-1 CPU, Super NES CPU or the Super NES CPU’s DMA access the same device (Game Pak ROM, BW-RAM, or SA-1 I-RAM) simultaneously.
- the BW-RAM write buffer is full when writing to BW-RAM.
- the source of the SA-1 DMA transmission is Game Pak ROM
MULTI-PROCESSOR PROCESSING [ J
5.7 OPERATION MODES
The SA-1 does not have special registers for setting the operation mode. The Super NES CPU is always in program execution state and controls the SA-1 CPU operations (start and stop).
The remainder of this chapter introduces representative relationships between the Super NES CPU and SA-1 CPU operations. They are examples and do not represent the entire SAS operation modes.
5.7.1 ACCELERATOR MODE In the accelerator mode, the SA-1 CPU is used only to handle the highload part of the program as subroutines. While the SA-1 CPU is processing, the Super NES CPU waits, in a loop, for the end of this processing. When the SA-1 CPU finishes processing, it informs the Super NES CPU by an interrupt, as illustrated below.
PREVIOUS OPERATION OPERATION W/SA-1
Super NES Super NES SA-1 CPU
Process i > — Pr roress Idle
wee eee eee > pose wibaciiet | g mail Start Ges Process . = pera B pee wet “| Process IRQ Idle . an c Process ae - Wait Start Process ; a oruremreny: Process IRQ E Process he Heese
Process E
Figure 1-5-1 Accelerator Mode
[aE
5.7.2 In the accelerator mode, the process flow is like a single-thread and it is easy to avoid programming errors. This mode is suitable for utilizing the speed of SA-1 without much complexity. On the other hand, it is not very efficient due to MPU stop and loop time.
PARALLEL PROCESSING MODE The parallel processing mode is a multi-processing mode in which both MPUs are operating simultaneously and are synchronized by handshakes. Both MPUs can freely access memory thanks to the SA-1’s automatic collision control. The handshake between MPUs is achieved by using interrupt signals and shared memory. The SA-1 CPU can process the program while the Super NES CPU is processing the multi-use DMA, as demonstrated below.
PREVIOUS OPERATION OPERATION W/SA-1 Sets ena SA-1 CPU
Progess => ao | Process Fe Process Process | Process | y ae B 5 we Process
Process 3 Cc
pease Process
cal Process E
Figure 1-5-2 Parallel Processing Mode
MULTI-PROCESSOR PROCESSING =]
In the parallel processing mode the highest processing efficiency can be achieved, as both MPUs operate without waiting for one anther. However, the process flow is complicated and more care must be taken to avoid programming errors, unsuccessful handshakes, and crashes.
5.7.3 MIXED PROCESSING MODE In the mixed processing mode, the SA-1 CPU can be used as a Super NES CPU accelerator during parallel processing in the parallel processing mode. In the SA-1, an operation mode is nothing more than program architecture, therefore, this type of processing is possible.
PREVIOUS OPERATION OPERATION W/SA-1 Super NES Super NES
‘CPU ‘SPU SA-1 CPU
Proves => a Fe oe Process Part of ee : Process ie i ical aoe Part of soxgpetegee 5 Start P ee = Wait aoe a Continue] ~* ‘Continue Process Process IRQ Process. c @ B 2 ee ne (a “ i 7 Process Process oon E seepage Process i * D : : ; q
Process E
Figure 1-5-3 Mixed Processing Mode
5.8 OPERATING MODES AND PROCESSING SPEEDS
The operating speed of the SA-1 CPU in each of the SA-1 operating modes is as follows.
SA-1 SA-1 CPU Memory SuperNES | Memory Operation Operating Used by SA- | CPU Used by Mode Speed 1 CPU Operations | Super NES CPU Accelerator | 10.74MHz Game Pak | Loop WRAM ROM program SA-1 I-RAM
10.74MHz Game Pak | Multi- Other than ROM purpose Game Pak DMA RAM Parallel A 10.74MHz SA-1 I-RAM | Multi- Other than Processing purpose SA-1 |-RAM
DMA 5.37MHz Game Pak | Multi- Game Pak ROM purpose ROM DMA
5.37MHz Game Pak | Normal Game Pak ROM operations ROM 10.74MHz SA-1 I-RAM | Normal Game Pak operations | ROM 10.74MHz Game Pak | Normal WRAM ROM operations SA-1 |-RAM
Table 1-5-6 Operating Modes and Processing Speeds
CHARACTER CONVERSION [
Chapter 6 Character Conversion
6.1
6.2 INTRODUCTION TO CHARACTER CONVERSION
The SA-1 contains a function for converting VRAM data stored in virtual bitmap format on BW-RAM and SA-1 I-RAM to Super NES PPU character format VRAM data.
Rotation, enlargement, and reduction of screen data and 3-D displays, such as polygons, are performed readily when the data is stored in bitmap format. Data compression can also be done more efficiently when the data to be compressed is stored in bitmap format.
6.1.1. BITMAP FORMAT
“Bitmap format’ refers to a data format where one address is assigned to each pixel (dot) on the screen. The SA-1 uses byte-long addresses. The effective data length is 2 bits in the 4 color mode and 4 bits in the 16 color mode. The remaining bits in the byte are ignored.
The Super NES PPU is incapable of directly processing bitmap data. The SA-1 includes a function which converts bitmap data to Super NES PPU character formatted data using DMA.
CHARACTER CONVERSION FUNCTIONS
The SA-1 has two character conversion functions for converting bitmap data to character data (Character Conversion 1 and Character Conversion 2).
6.2.1 CHARACTER CONVERSION 1
Character Conversion 1 sends bitmapped data contained on BW-RAM to the VRAM of the Super NES PPU and displays it on the screen by simultaneously performing the DMA function in the SA-1 and Super NES general purpose DMA, as demonstrated below.
ube NES Bitmap CHR formatted arpose . Purpose | CHR formatted formatted | SA-1 | ccreen data [pos screen data screen data DMA SA-11-RAM I I Sana internal butter | DMA | vram
Figure 1-6-1 Character Conversion 1
Character conversion 1 uses the buffer area in SA-1 I-RAM to convert and transmit data to the VRAM of the Super NES PPU. The buffer can be a maximum of 128 bytes (256 color mode) or 32 bytes minimum (4 color mode).
6.2.2 CHARACTER CONVERSION 2
Character conversion 2 is used when the bitmap data is in SA-1 I-RAM or game pak ROM, or when the game pak is configured without BW-RAM,
Bitmap
formatted SA-1 Buffer CHR trees
screen data}————— eg [1 screen data BW-RAM Transmitted [Registers Converted [sa pan wor area SA-1 LRAM IAW SA-1 automatically Game Pak ROM CPU ; following Instructions register write
Figure 1-6-2 Character Conversion 2
CHARACTER CONVERSION [
6.3 BITMAP ACCESS
The bitmap data storage area (virtual VRAM) is normally assigned to BW-RAM. Bitmap data is compressed (packed) and stored in BW-RAM as illustrated below.
4 Color Mode
16 Color Mode
256 Color Mode
Figure 1-6-3 Pixel Pixel Pixel Pixel
Pixel
Pixel
[_b7 | b6 | b5 | b4 | b3y b2] bi | bO | 1 Byte
Compressed Bitmap Data
6.3.1. BW-RAM IMAGE PROJECTION 4 Pixel/Byte
2 Pixel/Byte
1 Pixel/Byte
Within the SA-1, the BW-RAM image is projected into 6 x H banks in the SA-1 CPU's memory map. When BW-RAN is accessed in these 6 x H banks, it can be accessed at one pixel per byte in either the 4 color or 16 color modes.
40H
FFFFH
BW-RAM Area
Image Projection
Packed Access 0000H
Figure 1-6-4 — Bitmap Image Projection
E&
For 64 Kbit BW-RAM: BW-RAM Bitmap (16 color) Bitmap (4 color) 40:0000H~40:1FFFH = 60:0000H~60:3FFFH / 60:0000H~60:7FFFH For 256 Kbit BW-RAM: BW-RAM Bitmap (16 color) Bitmap (4 color) 40:0000H~40:7FFFH = 60:0000H~60:FFFFH / 60:0000H~61:FFFFH For 2 Mbit BW-RAM: BW-RAM Bitmap (16 color) Bitmap (4 color) 40:0000H~43:FFFFH => 60:0000H~67:FFFFH/ 60:0000H~6F:FFFFH
In the 256 color mode, the bitmap data is copied directly on the BW-RAM area.
CHARACTER CONVERSION J
6.3.2 BW-RAM DATA EXPANSION
The compressed BW-RAM data is expanded sequentially and assigned from address 60:0000H. This is demonstrated in the figure below. All areas of BW-RAM are expanded during this operation and no special register is provided for designating the expanded area. Therefore, when only a partial area of BW-RAM is used for virtual VRAM, the bitmap area corresponding to the area assigned as virtual VRAM must be accessed.
16 Color Mode b7 be bS b4 b3 b2 b1 dO
40:0000H a 60:0000H| 3] D2] D1} Do b7 b6 bS b4! b3 b2 b1 bO Ignored D7 | D6] D5] D4] D3] D2] D1] DO b7 b6 bS b4 bS b2 bt bO
D7] D6] D5} D4 a 60:0001H
Ignored
b7 b6 bS5 b4 b3 b2 bi bO
-— 60:0000H D1] DO
Ignored
4 Color Mode b7 b6 b5 b4 b3 b2 bi bd 40:0000H Peacocoull ps] p2 b7 b6 pS b4lb3 ballot bo! Ignored D7 | D6 | D5 | D4} D3] D2] D1] Do b7 b6 bS b4 b3 b2 bi bo LIL 60:0002H ee
Ignored
b7 b6 bS b4 b3 b2 b1 bO
—_—— HH —60:0003H D7] D6
Ignored
Figure 1-6-5 Bitmap Data Expansion
The color mode of the bitmap access area is set in bit SEL42 of the BBF register (223FH). SEL42 = 0: 16 color mode
SEL42 = 1: 4 color mode
1-6-5
C
The bitmap area is configured as follows.
VRAM Horizontal Size (n dots) jt >| = C—O cl x x+1 x+2 x43 xen-1 £ xen xen+t X+N+2 x4n+3 x+2n-1 a x+2n x+anHl x42n42 x+2n43 x+3n-1
El: ; j : : > ‘ q . : = e xt(m-t)n | xe(m-t)net | x+(m-1)n42 | x+(m-1)n+3 x+mn- > AT It uM. ------
Figure 1-6-6 | Memory Addresses for the Bitmap Area The variable “x” indicates the start address of the bitmap area in virtual VRAM. The variable “n” is the horizontal size (dots) of VRAM and “m” is the vertical size (dots) of VRAM. Variable “n” can be specified in bits SIZEO~2 of the CDMA register (2231H), as demonstrated below. No register is provided for specifying vertical size “m”. Vertical size can be set within the limits of BW-RAM size as a function of internal program logic. Variable “m” is processed in character units and must be a multiple of eight.
SIZEO SIZE1 SIZE2 Horizontal Character Number
0 0 0 1 (8 dots)
0 0 1 2 (16 dots) 0 1 0 4 (32 dots)
0 1 7) 8 (64 dots)
1 0 16 (128 dots) 1 0 1 32 (256 dots)
Table 1-6-1 Horizontal Size of VRAM (CDMA Register)
CHARACTER CONVERSION [ j
6.4 CHARACTER CONVERSION 1, DETAILED DESCRIPTION
Character conversion 1 is used to convert the bitmap screen data in BW-RAM to Super NES PPU character formatted VRAM data, with SA-1 DMA and Super NES general purpose DMA working in parallel. A larger volume of data can be converted at one time with character conversion 1 than with character conversion 2, due to efficient usage of both DMAs.
Character conversion 1 requires two characters of memory space in SA-1 |-RAM for use as buffers (work space). The required I-RAM size is 32 bytes in the 4 color mode, 64 bytes in the 16 color mode, and 128 bytes in the 256 color mode. Any I- RAM address can be specified by the user.
Character conversion 1 uses these two buffers to read the data from BW-RAM to VRAN in parallel. Since the processing speed is determined by the speed of the Super NES CPU’s general purpose DMA, the same amount of characters can be converted as with the Super NES, alone.
BW-RAM SA-1 -RAM VRAM
Bitmap Data mem Ca Conversion DMA
Character Character
Buffer 2 Data General Purpose DMA
After one character is completed.
BW-RAM SA-1 |-RAM VRAM
Buffer 1 Data General
Bitmap Data nd Saeracty Purpose DMA
Conversion DMA
Figure 1-6-7 Character Conversion Buffers
6.5 CHARACTER CONVERSION 1 PROGRAMMING PROCEDURE
When character conversion 1 is used, the user must carefully coordinate register settings in the Super NES CPU and SA-1 CPU. The following procedure is provided to aid the user in coordinating these settings.
STEP 1.
STEP 2. Set DCNT (2230H) using the SA-1 CPU. CDEN bit = 1 (character conversion enable) CDSEL = 1 (BW-RAM to SA-1 I-RAM transmission)
The registers indicated in the following steps are set using the Super NES CPU.
Specify the SA-1 DMA transmission source address using the Super NES CPU.
Store the transmission source address (BW-RAM) in SDA (2232H~2234H). A specific number of low bit of the address must be set to “0”, as a function of the color mode and the number of horizontal characters set in SIZEO~2 of CDMA (2231H). The specific number of “0” bits can be determined from the table below.
(Color Mode [4[4[4]4][4]4 [16161616161 Fje5e;e56|e56|e56/e56/256 Number of Horizontal (Characters ero Bits 4/5[6/7[8]/9/5/6]7/8/9|T0| 6 | 7 | 8] 9 [10] 17 2/4/8632) 1/2)4)8 1632) 1 | 2) 4 | 8 | 16/32
Table 1-6-2 Number of Zero Bits in BW-RAM
STEP 3.
STEP 4.
Specify the SA-1 I-RAM address for the buffers as the transmission destination.
Store the buffer address in DDA (2235H and 2236H).
It is not necessary to set 2237H because I-RAM is specified. The lowest 5 bits of the |-RAM address must all be “O” for 4 color mode. The lowest 6 bits of the -RAM address must be “0” for 16 color mode. And, the lowest 7 bits of the I-RAM address must be “0” for 256 color mode.
1-6-8
CHARACTER CONVERSION
STEP 5. Wait for the IRQ (CHRIRQ) generated from SA-1 to the Super NES CPU. The Super NES CPU waits for the IRQ and verifies that the CHRDMA IRQ bit of the SFR register (2300H) = 1 (character conversion 1 DMA standby). IRQ is generated for some other reason when CHRDMA IRQ = 0.
STEP 6. Transmit the character data in SA-1 I-RAM to VRAM. Character data which has been converted by the Super NES CPU's general purpose DMA is transmitted to VRAM. Set the general purpose DMA source address to the start address of the virtual VRAM in BW-RAM.
STEP 7. Use the Super NES CPU to notify the SA-1 that the conversion is complete. Set bit CHDEND of the CDMA register (2231H) to “1” to indicate that one cycle of character conversion 1 has been completed and return control of register access to the SA-1 CPU.
When necessary, use an IRQ or SA-1 I-RAM to notify the SA-1 CPU of the end of ~ character conversion.
Using the above procedure, the SA-1 internal character conversion circuit converts characters in order based upon the request from the Super NES CPU’s DMA.
The SA-1 CPU can return to program processing after STEP 1 has been performed, however, it must wait during any simultaneous access to BW-RAM or SA! |-RAM as DMA has priority.
Although CDMA, DDA, and SDA are SA-1 CPU registers, they are set by the Super NES CPU when using character conversion 1. The user should not access BW-RAM from the Super NES CPU during these operations. SA-1 I-RAM can be accessed by the user through the Super NES CPU, so flags can be changed within the SA-1 CPU.
EE
6.6 CHARACTER CONVERSION 2, DETAILED DESCRIPTION
Character conversion 2 performs character conversion by writing bitmap data to the SA-1 registers according to the SA-1 CPU’s program. Because the transmission is controlled by the SA-1 CPU’s program, the memory for bitmap data expansion can be set up more freely than when using character conversion 1. Also, when the game pak configuration does not include BW-RAM, character conversion 2 is the only means of character conversion.
The bitmap data when using character conversion 2 is one pixel/byte (unpacked). As previously described, packed data cannot be converted. Therefore, bits b7 ~ b2 of the data are invalid in the 4 color mode. Similarly, b7 ~ b4 are invalid in the 16 color mode. All bits are valid in the 256 color mode.
The table below shows the actual data in memory. When the bitmap access function is used with character conversion 1, one pixel/byte access is possible.
Bitmap Data Format
4 Color Mode 16 Color Mode
Character Conversion 1 4 Pixel/Byte 2 Pixel/Byte Character Conversion 2 1 Pixel/Byte 1 Pixel/Byte
Table 1-6-3 Character Conversion and Data Format
Character conversion 2 also requires buffers for two characters in SA-1 I-RAM, similar to character conversion 1. The bitmap data written to the SA-1 registers by the SA-1 CPU is converted as written and generated as character data in the buffer area in SA-1 I-RAM. Character conversion is performed using the two SA-1 buffers alternately. When the conversion of data contained in buffer 1 is completed, conversion begins on the data contained in buffer 2. When this conversion is completed, new data contained in buffer 1 is converted. The Super NES CPU reads the data from the buffer in the SA-1 I-RAM at the end of each conversion using its general purpose DMA.
1-6-10
CHARACTER CONVERSION J
6.7. CHARACTER CONVERSION 2 PROGRAMMING PROCEDURE
The following procedure is provided to aid the user in executing character conversion 2.
STEP 1.
STEP 2.
STEP 3.
STEP 4.
STEP 5.
STEP 6. Set DCNT (2230H) using the SA-1 CPU. DMAEN = 1 (DMA enable) CDEN = 1 (character conversion DMA) CDSEL = 0 (SA-1 CPU to SA-1 I-RAM write) No other bits need to be set.
Store the color mode in CDMA (2231H) using the SA-1 CPU. The color mode is set using bits CBO and CB1 (4, 16, or 256 color modes). Bits SIZEO~2 need not be set.
Specify the SA-1 I-RAM transmission destination address using the SA-1 CPU.
Store the I-RAM buffer address in DDA (2235H and 2236H). The lowest 5 bits of the I-RAM address must be set to all zeros for 4 color mode. The lowest 6 bits must be zero for 16 color mode. The lowest 7 bits must be zero for 256 color mode. Write the bitmap data in the conversion register using the SA-1 CPU. The data must be written 4 times in succession (64 pixels = 1 character of data) to BRF (2240H~224FH). The 4 write operations should be performed in the following order.
BRF0>1-2-... F301... ~F Character conversion DMA will begin automatically, following each 8 pixel write operation and generate the characters in I- RAM.
Notify the Super NES CPU that character conversion is complete. Notify the Super NES CPU using an interrupt or SA-1 I-RAM when a character has been completed. The Super NES CPU transmits the character data to VRAM or WRAM using general purpose DMA or a program.
Repeat STEP 4 and 5 to continue character conversion. To continue to convert characters, write 64 pixels in succession. The character data is created using DMA transmission in the other SA-1 I-RAM buffer.
1-6-1]
STEP 7. Indicate when character conversion is over.
Reset bit DMAEN of the DCNT register (2230H) to “0”. This ends one cycle of character conversion 2.
During these operations, other SA-1 DMA functions cannot be performed. The Super NES general purpose DMA may be used for other functions.
1-6-12
ARITHMETIC FUNCTION
Chapter7 Arithmetic Function
TYPES OF ARITHMETIC OPERATIONS
The SA-1 has an arithmetic circuit for high speed processing of arithmetic operations. This is in addition to the arithmentc circuit installed in the Super NES PPU. The SA-1 arithmente circuit runs faster and can run concurrently with the Super NES CPU. The SA-1 arithmetic circuit performs the following three types of arithmetic functions.
- MULTIPLICATION
Multiplicand Multiplier Result
16bits(S) X 16bits(S) = 32 bits (S)
- DIVISION
Dividend Divisor Result
16 bits(S) + 16bits(U) = 16 bits (S) 16 bits (U) Remainder
- CUMULATIVE SUM
X(16 bits (S) X 16bits(S)) = 40 bits (S)
The type of arithmetic operation is specified in the arithmetic operation control register (**2250H) using the SA-1 CPU. The user should choose between ACM (d1) for cumulative sum operations and M/D (dO) for multiplication or division operations. The required number of cycles for each operation are shown below.
Arithmetic Operation ACM | M/D | Number of Cycles Multiplication 0 0 Division 0 1 Accumulative 1 -
Table 1-7-1 Arithmetic Operations Settings and Cycles
The number of cycles is calculated based upon 10.74 MHz per cycle.
7.2 MULTIPLICATION
Multiplication operations are carried out as follows.
7.3 1. Set MCNT (2250H)
ACM=0, M/D=0
Set the arithmetic parameters.
Store the multiplicand in MA (2251H and 2252H). Store the multiplier in MB (2253H and 2254h).
Read the result after 5 cycles.
The arithmetic result is stored in WO~W3 of MR (2306H~2309H). WO is the lowest byte and W3 the highest.
The multiplicand is saved in memory following the operation, while the multiplier is not.
DIVISION
Division operations are carried out as follows.
1. Set MCNT (2250H)
ACM=0, M/D=1
Set the arithmetic parameters.
Store the dividend in MA (2251H and 2252H). Store the divisor in MB (2253H and 2254H).
Read the result after 5 cycles.
The arithmetic result is stored in WO and W1 of MR (2306H and 2307H). The remainder is stored in W2 and W3 of MR (2306H and 2307H). WO and W2 are the low bytes, while W1 and W3 are the high bytes.
Neither the dividend nor the divisor is saved in memory.
The SA-1 does not detect “divide by zero” errors. The product and remainder for division by zero will be “0”. Special attention is required to the sign of the remainder in division when using negative numbers.
ARITHMETIC FUNCTION [
7.4 CUMULATIVE SUM
Cumulative sum operations are carried out as follows.
1. Set MCNT (2250h)
ACM=1
When the ACM bit is set (1) the cumulative result is cleared to “0”.
Set the arithmetic parameters.
Store the multiplicand in MA (2251H and 2252H). Store the multiplier in MB (2253H and 2254H).
Reset the parameters after 6 cycles.
Repeat this step until the operation is completed.
Read the cumulative result.
The arithmetic result is stored in WO~W3 of MR (2306H~2309H). WO is the lowest byte and W3 the highest.
The multiplicand is saved in memory following the operation, while the multiplier is not.
The OF bit in the OF register (230BH) is set to “1” when the cumulative result exceeds 40 bits.
Chapter 8 Variable-Length Bit Processing
8.1 READING VARIABLE-LENGTH DATA
The SA-1 variable-length bit processing function consists of a barrel shift circuit which treats the entire game pak ROM as a stream (string) of bits which are sequentially read in 1 ~ 16 bit lengths. This allows the SA-1 to process data of variable lengths without having to shift the data to byte boundaries, resulting in higher processing speed.
The SA-1 variable-length bit processing function consists only of a barrel shift function. The function supports, but does not perform data compression or expansion. These processes must be performed as a part of each program. The function is configured in this way to allow the programmer to select the best compression algorithm for each piece of software, in order to achieve the optimal processing speed-compression rate combination.
The SA-1 variable-length bit processing function includes two data read modes, the Fixed Mode and the Auto-increment Mode.
The data read mode is specified in the HL bit of the VBD register (2258H).
HL=0: Fixed Mode
HL=1: Auto-increment Mode
VARIABLE-LENGTH BIT PROCESSING
8.2 FIXED MODE
In the Fixed Mode, the data stored in the variable-length data port will be read over and over until the number of bits to be barrel shifted is reached. The shift is carried out when the amount of the shift is written to the VBD register (2258H). The Fixed Mode is used to read data which is formatted so that the valid bit length is known only after the data is read. Variable-length data is processed as follows in the Fixed Mode.
Store the start address of the variable-length data.
Read data from the variable-length data port.
Yes END?
No
y Specify amount of barrel shift..
RETURN
Figure 1-8-1 Fixed Mode Process Flow Diagram
[ |
8.3 AUTO-INCREMENT MODE
In the Auto-increment Mode, the amount of the barrel shift is specified in advance. Data is shifted automatically following the data read and the next data is placed on standby.
The Auto-increment Mode is used when the valid bit length of data is known in advance or when data of the same length is to be repeated. Variable-length data is processed as follows in the Auto-increment Mode.
Store the start address of the variable-length data.
Specify the number of bits to be barrel-shifted.
Read data from the variable-length data port. !
Specify amount of barrel shift.. y RETURN
Figure 1-8-2 Auto-increment Mode Process Flow Diagram
VARIABLE-LENGTH BIT PROCESSING [ ]
8.4 VARIABLE-LENGTH DATA PROCESSING SETTINGS
Specify the number of bits to be shifted and parameters for the SA-1 variablelength data read in the following registers.
STEP 1. Set variable-length data start address. Store the start address of the variable-length bit stream in the VDA register (2259H~225BH).
STEP 2. Perform variable-length data read. Read variable-length data from the VDP register (2830CH and 230DH). An LSB-justified 16 bit block of data is read from the start of the remaining bit stream.
STEP 3. Set the amount of the barrel shift. Store the amount of the barrel shift in bits VBO~VB3 of the VBD register (2258H).
VB3 VB2 VB1 VBO Significant Bit Length (¢) 0 0 0 16 ie) 0 ie} 1 1 ie) 0 1 0 2
- 0 1 1 3 0 1 ie) 0 4 ie) 1 ie} 1 5 0 1 1 0 6
0 1 1 1 7 1 0 0 0 8 1 0 0 1 9 1 0 1 0 10 1 0 1 1 1 1 1 0 0 12 1 1 (e) 1 13 1 1 1 0 14
1 1 1 1 15
Table 1-8-1 Amount of Barrel Shift
The barrel shift is carried out from MSB to LSB and the next data is read into the vacant MSB. This flow is demonstrated in the following illustration.
MSB LSB \ | Read data from the VDP. v Set the VBD to 4. v EEEEREESEREEN aouese Next Data}; | VDP Output Data |
Figure 1-8-3 Barrel Shift Process
When specifying the amount of barrel shift, the number of bits from the word boundary is specified. For example, when 2-bit blocks of data are used;
set VB3~0 to 0010 (2) for the first shift, set VB3~0 to 0100 (4) for the second shift, and set VB3~0 to 0110 (6) for the third shift.
Chapter 9 DMA
9.1 TYPES OF DMA
The SA-1 internal DMA function transfers data between game pak ROM, BW- RAM, and SA-1 I-RAM. SA-1 internal DMA can be operated independent of the Super NES CPU’s general purpose DMA and H-DMA. Even when both DMAs access the same memory at the same time, no problems arise because memory access is exclusive.
SA-1 internal DMA has two basic operation modes. The Normal DMA Mode is used to transfer data between memories, while the Character Conversion DMA Mode is used to transmit data while converting from bitmap format to character format. This chapter describes the Normal DMA Mode. Refer to the previous chapter, “Character Conversion’, for details concerning the Character Conversion DMA Mode.
Game Pak ROM Mz) BW-RAM
Game Pak ROM DMA SA-1 FRAM
SA -RAM pus BW-RAM
BW-RAM Di SA-1 RAM
Figure 1-9-1 Normal DMA
Instruction CHR DMA [SA-1 CPU CP Conversion| Gharacter SA-1 I-RAM Conversion
DMA CHR eral “RAM ; [BWRAM | raractor Conversion] Purpose SA-1 HRAM
Conversion DMA (Super NES CPU)
Figure 1-9-2 Character Conversion DMA
1-9-1
9.2 NORMAL DMA OPERATION
All Normal DMA is started from the SA-1 CPU. The DMA-related registers (2230H~2239H) are used to start DMA, as described in the following procedure.
STEP 1.
re
The same device cannot be used for source and destination.
Vi Destination Device
SD1 | SDO | Device DD | Device 0 Game Pak ROM 0 SA-1 |-RAM
1 BW-RAM 1 BW-RAM
1 0 SA-1 I-RAM
Store the transmission mode in bit CDEN.
CDEN=0: Normal DMA
CDEN=1: Character Conversion DMA
Set DPRIO (d6) to assign priority between SA-1 CPU and DMA.
DPrio=0: SA-1 CPU priority (Instructions can be executed during transmission) DPrio=1: DMA priority (SA-1 CPU waits during DMA)
The DPrio setting is only valid during Normal DMA between BW- RAM and SA-1 I-RAM.
Set DMAEN to enable or disable DMA.
DMAEN=0: DMA disable (DMA is not used) DMAEN=1: DMA enable (Use DMA, clear parameters)
When setting the DMA parameters, first set DMAEN=1 from the SA-1 CPU and then set the other parameters. Set DMAEN>=0 after the DMA has been completed.
DMA
STEP 2. Specify the start address of the transmission source. Store the transmission source start address in the SDA register (2232H~2234H). The bit length varies according to the source device.
Source Bit Number Setting | Register Device
Game Pak 24 bits **2232H, 2233H, 2234H ROM
BW-RAM 18 bits **2232H, 2233H, 2234H
SA-1 I-RAM 11 bits **2232H, 2233H
Table 1-9-1 Source Device Settings When transmitting from game pak ROM, start from the even address. When transmitting from BW-RAM, transmit from bank 40H~43H. No transmissions can be sent from a bitmap access area.
STEP 3. Set the number of bytes for transmission. Store the number of bytes for transmission in the DTC register (2238H and 2239H). The value set in DTC is transferred to the internal counter in the DMA circuit (terminal counter). The DTC range is from 1~65535 bytes.
STEP 4. Specify the transmission destination start address. Store the transmission destination start address in the DDA register (2235H~2237h). The bit length varies according to the destination device.
Destination Bit Number | Register Start
Device Setting Trigger
BW-RAM 18 bits **2235H, 2236H, 2237H | **2237H SA-1 I-RAM 11 bits **2235H, 2236H **2236H
Table 1-9-2 Destination Device Settings When transferring data to BW-RAM, send the data to banks 40H~43H. Data cannot be sent to the bitmap access area. The DMA circuit begins the transmission after the trigger address has been written.
E |
Normal DMA transmission ends when the internal terminal counter reaches 0. After normal DMA ends, an IRQ is generated from the DMA circuit to the SA-1 CPU to set the DMAIRQ flag in the CFR register (2301H) to “1”.
9.3 DMA TRANSMISSION SPEED
The transmission speeds for Normal DMA are as follows.:
Type of DMA Frequency Game Pak ROM to SA-1 I-RAM 10.74 MHz
Game Pak ROM to BW-RAM 5.37 MHz
BW-RAM to SA-1 I-RAM 5.37 MHz
SA-1 I-RAM to BW-RAM 5.37 MHz
Table 1-9-3 DMA Transmission Speed
When the Super NES CPU's general purpose DMA or H-DMA generates an access during the SA-1’s internal DMA transmission, the SA-1 internal DMA is put in the “wait” state. Hence, the Super NES CPU's DMA has priority.
INTRODUCTION TO SUPER FX 2]
Chapter 1
Introduction to Super FX'”
The Super FX is a Graphic Support processing Unit (GSU) designed to greatly improve the Super NES graphics and mathematical functions through the use of the following special features.
1.1. FEATURES
1.4.4 RISC-LIKE INSTRUCTIONS Instructions which are utilized often consist of only one byte and are executed in one cycle in an instruction cache.
HIGH SPEED CLOCK OPERATION The current version of the Super FX operates at a clock speed of 10.74MHz. This is six times as fast as the Super NES CPU.
BUILT-IN INSTRUCTION CACHE A 512-byte cache RAM is installed in order to perform the instructions at high speed. (Refer to “Cache RAM”.)
SUPER NES CPU’S MEMORY MAY BE USED The Super FX uses game pak ROM and RAM which is currently used by the Super NES CPU. (Refer to “Memory Mapping’.)
INDEPENDENT ROM AND RAM BUSES The Super FX can access game pak ROM and RAM in parallel. Program processing speed is maximized, as buffers are provided to read from ROM and write to RAM. (Refer to “Program Execution”.)
PARALLEL OPERATIONS WITH SUPER NES CPU The Super NES CPU and Super FX may execute processing in parallel. Thus, high speed operations can be performed.
GRAPHICS FUNCTION A fast plot process can be performed by specifying a coordinate corresponding with the Super NES PPU format. (Refer to “Bitmap Emulation’, under “Super FX Special Functions”.)
PIPELINE PROCESSING Pipeline processing reduces the number of processing cycles and enables high speed operation. (Refer to “Pipeline Processing”, under “Instruction Set General Description”.)
[ |
1.2 SPECIAL CONVENTIONS
Unless otherwise specified, addresses will be written with a 2 digit hexadecimal bank number and a 4 digit hexadecimal address separated by a colon (:). The following example demonstrates this convention.
3F:0000H
In this example “3F” represents the bank number, while “0000” represents the hexadecimal address.
INTRODUCTION TO SUPER FX L ]
1.3. SYSTEM CONFIGURATION
The GSU is installed on each game pak with ROM and RAM as demonstrated below. The Super NES CPU and the GSU share game pak ROM and RAM. Additional ROM for the Super NES CPU and back-up RAM may also be installed.
MOAT ATTA EL ETAT EEE N , 4 , 4 5 SUPER NES ' Hi GAMEPAK } 4 Game Pak 5 5 4 , 4 , 4 ] 4 , é s 4 ’ 4 ‘ 4 4, é ‘ ‘
4 SUPER NES 4
5 Back-up RAM CPU ROM '
g = rE 5 4 ‘ 4 4 4 4 4 4 s s s s s s 5 y
- y —T aeeeneeee, AMEE ETE EEE
SUPER NES CONTROL DECK
SUPER NES CPU www neennnnnnnnnnnnnnnnny
Figure 2-1-1 Super FX System Configuration
2-1-3
[ —]
1.4 SYSTEM OPERATION
Although the Super NES CPU and GSU share game pak ROM and RAM, the processors can not access either simultaneously. The GSU has a flag, controlled by the Super NES CPU program, which determines whether the CPU or GSU have access to game pak ROM and/or RAM. This is demonstrated in the following figure.
(Switch) Control
SUPER NES CPU f ' i GSU ' Instruction ; ' ' ' ' ' '
j i '|W-RAM]} 1 SW Bus usage for Game Pak H 1 r Hi ROM and RAM may be BACK-UP| ; !| GAME | ; switched independently | RAM |! 1] PAK |! from one another. i + +LROM |} ' ' ' Seen | | [GAME]! ' i ‘1 PAK |i 1|_ ROM |! ‘ d a 4 ' RAM |! ‘
Figure 2-1-2 Game Pak ROM/RAM Bus Diagram
When using the GSU, the program must be written and executed with these points in mind. The following example demonstrates recommended usage of the GSU.
1.5 EXAMPLE OF USAGE
1.5.1 RESET SUPER NES
When the Super NES is reset, the GSU is also reset. In this condition the game pak ROM and RAM busses are connected to the Super NES CPU. The program stored in game pak ROM is processed by the Super NES CPU. The GSU is idle during this period.
2-1-4
INTRODUCTION TO SUPER FX
1.5.2
1.5.3
1.5.4
1.5.5
1.5.6
1.5.7 WRAM The Super NES CPU is used to move the program from game pak ROM to the work RAM (WRAM) mounted within the Super NES Control Deck. The Super NES CPU may then be operated by this WRAM program.
ACTIVATION OF GSU The GSU flag is set by the Super NES CPU. This allows the GSU to process instructions stored in game pak ROM and store results in game pak RAM.
GSU STOP COMMAND When the GSU completes the desired processing, a stop command is executed. The GSU stops processing and generates an interrupt to the Super NES CPU. This notifies the Super NES CPU that the GSU has completed its processing.
GSU DISCONNECT When the GSU stops, game pak ROM and RAM busses are again connected to the Super NES CPU. This permits the Super NES CPU to process the results of the GSU’s computations.
EXAMPLE SUMMARY This process may have been used, for example, to produce game video data. These programming steps are then repeated, as necessary, to accomplish the programmer's desired result.
CURRENT CONSUMPTION A game pak which contains the Super FX is required to have a built-in safety program to prevent it from operating in excess of the maximum current rating of the AC Adapter. For example, a game pak which contains the Super FX can not be used with Multi Player 5 because this would exceed the maximum current rating. A program must be included within the game pak which will check accessory IDs and activate the Super FX only if an acceptable accessory is connected. If an accessory ID other than those acceptable is detected, a warning message must be displayed and the Super FX must halt. Some accessories may be used, depending upon the size of ROM and RAM included in the game pak and the Super FX operating frequency. The user should contact Nintendo's Licensee Support Group for assistance, in advance, if use of an accessory other than the standard controller is desired.
[
Chapter 2 GSU FUNCTIONAL OPERATION
2.1 GSU FUNCTIONAL BLOCK DIAGRAM
The GSU is comprised of the following 6 functional blocks. These are demonstrated in the figure below.
General Registers 16 BIT X 16
s TO U GAME E GAME PA E PAK RAM INSTRUCTION RAM |, BUS : CONTROLLER Controller} is PLOT To Circuitry SUPER | iF at NES rosa ELINE Dei U DECODER BUS I A TO N GAME| u PAK E 7] GAME ROM : PAK US a ROM j=
Cc Controller
E |é 4
Figure 2-2-1 GSU Functional Block Diagram
2-2-1
GSU FUNCTIONAL OPERATION J
2.1.1 SUPER NES CPU INTERFACE The Super NES CPU Interface performs the following functions:
- Controls data transfer between the Super NES CPU, game pak ROM/RAM, and the general registers.
- Controls instruction data transfer between Super NES CPU and the cache.
- Controls activation of GSU.
- Controls interrupt to Super NES CPU.
INSTRUCTION CONTROLLER This controls fetch instructions, decode instructions, and various other blocks based upon these instructions; loaded from game pak ROM, game pak RAM, or the cache.
GAME PAK ROM CONTROLLER The game pak ROM controller performs the following functions:
- Controls data transfer between the Super NES CPU and game pak ROM.
- Loads instructions from game pak ROM to the GSU.
- Transfers data from the game pak ROM to the GSU intemal registers.
GAME PAK RAM CONTROLLER The game pak RAM controller functions as follows:
- Controls data transfer between the Super NES CPU and game pak RAM.
- Loads instructions from game pak RAM to the GSU.
- Transfers data between game pak RAM and GSU internal registers.
- Bitmap emulation.
2-2-2
2.1.5 GENERAL REGISTERS These registers are used for general operations and data transfer.
OPERATOR The Operator executes 16-bit arithmetic operations and logical operations.
2.2 REGISTERS
A list of GSU internal registers is provided in the table below.
FUNCTIONAL GROUP REGISTER NAME
7 General Register RO ~ R13) General Registers ROM Address Pointer R14.
Group Program Counter R15
Status/Flag Register SFR
Program Bank Register PBR Game Pak ROM Registers Related to Bank Register ROMBR Memory Operations Game Pak RAM Bank Register RAMBR Cache Base Register CBR
Screen Base Register SCBR Screen Mode Register SCMR Color Register COLR Plot Option Register POR Plot Related Registers
agua Register Sivan A Version Code Register R Other Registers CONFIG Register CFGR Clock Select Register CLSR
2.2.1 Table 2-2-1 Registers Listed by Functional Group
GENERAL REGISTERS 2.2.1.1 RO~R13 These registers are used to execute various instructions as GSU General Registers during GSU operation. There are special functions available for some instructions (refer to “GSU Internal Register Configuration”). These can also be accessed by the Super NES CPU when the GSU is in the idle state.
GSU FUNCTIONAL OPERATION ]
2.2.2
2.2.3 2.2.1.2
2.2.1.3
2.2.1.4 R14 This register functions as a data pointer for game pak ROM during GSU operation. Data addressed in this register is automatically stored in the ROM buffer. As with RO ~ R13, this register may be used as a GSU general register. It can also be accessed by the Super NES CPU when the GSU is in the idle state. R15 This register is the GSU Program Counter. If an address is written to this register from the Super NES CPU, while the GSU is idle, the GSU will be activated. STATUS/FLAG REGISTER (SFR) The “flags” in this register indicate GSU status and operation results. This register can be referenced by the Super NES CPU even while the GSU is operating.
REGISTERS RELATED TO MEMORY OPERATIONS 2.2.2.1
2.2.2.2
2.2.2.3
2.2.2.4 PROGRAM BANK REGISTER (PBR) This register specifies the memory bank when an instruction is read. Its value must be assigned from the Super NES CPU before the GSU is activated. This is changed during GSU operation using the LUMP instruction. GAME PAK ROM BANK REGISTER (ROMBR) This register specifies the game pak ROM bank when data are read from the game pak ROM using the ROM buffering system. Its value is changed during GSU operation using the ROMB instruction. GAME PAK RAM BANK REGISTER (RAMBR) This register specifies the game pak RAM bank when data are read/written from/to the game pak RAM. Its value is changed during GSU operation using the RAMB instruction. CACHE BASE REGISTER (CBR) This register specifies the starting address when loading data from the game pak ROM or RAM to the cache RAM. The value for CBR is updated during GSU operation whenever the CACHE instruction or LUMP instruction is executed.
PLOT RELATED REGISTERS 2.2.3.1 SCREEN BASE REGISTER (SCBR) This register is used to specify the start address in the character data storage area. Its value must be assigned from the Super NES CPU prior to activating the GSU.
[
2.2.3.2 SCREEN MODE REGISTER (SCMR) This register assigns the color and screen mode when PLOT processing is performed. Its value must be assigned from the Super NES CPU prior to activating the GSU. 2.2.3.3 COLOR REGISTER (COLR) This register specifies the color when PLOT processing is performed. Its value is changed during GSU operation using the COLOR instruction or GETC instruction. It cannot be accessed from the Super NES CPU. 2.2.3.4 PLOT OPTION REGISTER (POR) This register assigns the mode when executing the COLOR, GETC, or PLOT instructions. When these instructions are used, the value of the plot option register must be assigned before execution, using the CMODE instruction.
2.2.4 OTHER REGISTERS 2.2.4.1. B-RAM REGISTER (BRAMR) Back-up RAM enable/disable can be controlled by this register. The register’s value must be assigned from the Super NES CPU. 2.2.4.2 VERSION CODE REGISTER (VCR) This assigns the GSU version code. Its value can be read only from the Super NES CPU. 2.2.4.3 CONFIG REGISTER (CFGR) This register assigns the execution speed for GSU multiplication instructions and enables/disables the interrupt signal to the Super NES CPU. Its value must be assigned from the Super NES CPU prior to GSU activation. 2.2.4.4 CLOCK SELECT REGISTER (CLSR) This register is used to assign the operating frequency for the Super FX. Its value must be assigned from the Super NES CPU prior to activation of the Super FX.
2-2-5
GSU FUNCTIONAL OPERATION,
2.3 INSTRUCTION SET
There are 98 instructions available in the GSU. These instructions and their functions are given in the following table.
CLASSIFICATION INSTRUCTION FUNCTION
GETB Get byte from ROM buffer
om a a GETBH Get high byte from ROM buffer
buffer) to register | GETBL Get low byte from ROM buffer GETBS Get signed byte from ROM buffer Dy GETC Get byte from ROM to color register AN] grom oe LDW___(Rm) _|[Load word data from RAM i B RAM to register a Ro Load byte data from RAM _ n, (xx)| Load word data from RAM using 16 bits T i LMS Rn, (yy)| Load word data from RAM, short address iN Cc STW (Rm) __| Store word data to RAM N T] Fromregisterto |STB (Rm) __| Store byte data to RAM
s 4 game pak RAM [SM (xx), Rn] Store word data to RAM using 16 bits
F N (RAM buffer) SMS (yy), Rn| Store word data to RAM, short address RS SBK Store word data, last RAM address used From register MOVE _ Ran, Rn’ | Move word data to register MOVES Ran, Rn’ | Move word data and set flags Immediate data |TWT Rn, #xx | Load immediate word data to register IBT Rn, #pp | Load immediate byte data ADD Rn ADD #n |Add
be a Add with carry SUB Rn SUB #n Subtract
SBC Rn Subtract with carry CMP Rn Compare Arithmetic MULT Rn ; :
peste MULT #n Signed multiply
UMULT Rn . : UMULT #n Unsigned multiply FMULT Fractional signed multiply LMULT 16x16 signed multiply DIV2 Divide by 2 INC Rn Increment DEC Rn Decrement Table 2-2-2 Instruction Set (Sheet 1)
CLASSIFICATION INSTRUCTION FUNCTION
AND Rn ;
AND #n Logical AND
OR Rn 7
Logical OR #n Logical OR
ee NOT Invert all bits
von a Logical exclusive OR Ae a Bit clear mask
. ASR Arithmetic shift right
eter LSR Logical shift right
ROL Rotate left through carry ROR Rotate right through carry HIB Value of high byte of register Byte LOB Value of low byte of register pe. MERGE Merge high byte of R8 and R7 SEX Sign extend register SWAP Swap low and high byte JMP Rn Jump LJMP Rn Long jump BRA e Branch always BGE e Branch on greater than or equal to zero BLT e Branch on less than zero BNE e Branch on not equal Jump, Branch BEQ e Branch on equal PSoelIastenetions BPL e Branch on plus BMI e Branch on minus BCC e Branch on carry clear BCS e Branch on carry set BVC e Branch on overflow clear BVS e Branch on overflow set LOOP Loop LINK #n Link return address Bank Set-up ROMB Set ROM data bank Instructions RAMB Set RAM data bank CMODE Set plot mode Plot-related COLOR Set plot color Instructions PLOT Plot pixel RPIX Read pixel color
Table 2-2-2 Instruction Set (Sheet 2)
GSU FUNCTIONAL OPERATION J
CLASSIFICATION| INSTRUCTION FUNCTION
Prefix Flag ALT1 Set ALT1 mode
Instructions ALT2 Set ALT2 mode
ALT3 Set ALT3 mode : : FROM Rn Set Sreg Hee a TO Rn Set Dreg WITH — Rn Set Sreg and Dreg CACHE Set cache base register
eect NOP No operation
STOP Stop processor MOVEW Rn, (Rn’) |Load word data from RAM MOVEB Rn, (Rn’) |Load byte data from RAM MOVE Rn, (xx) {Load word data from RAM using 16 bits MOVEW (Rn’), Rn | Store word data to RAM MOVEB (Rn’), Rn | Store byte data to RAM MOVE (xx), Rn |Store word data to RAM using 16 bits a MOVE — Rn, #xx_ |Load immediate word data LEA Rn, xx Load effective address
Table 2-2-2 Instruction Set (Sheet 3)
2-2-8
[
Chapter 3
3.1
Memory Mapping
SUPER NES CPU MEMORY MAP.
The figure on the following page depicts the memory map for the Super NES CPU. Refer to this figure while reading the sub-paragraphs below.
3.1.1 GSU INTERFACE This area (A) is mapped to address 3000H ~ 32FFH in banks 00H ~ 3FH and 80H ~ BFH. (Refer to “GSU Internal Register Configuration’.)
GAME PAK ROM Game pak ROM (B) is mapped to 2 Mbytes starting from 00:8000H. Two Mbytes from 40:0000H (B’) are used for the ROM image. This image is stored in blocks of 32 Kbytes, as indicated on the memory map by circled numbers (i.e., area; ©” is the image of area ©, @” is the image of area ®, and so forth).
GAME PAK RAM Game pak RAM (C) is mapped to128 Kbytes starting from 70:0000H. Eight Kbytes from address 6000H (C’) in each of banks 00~3F and 80~BF are used for RAM image.
BACK-UP RAM Back-up RAM (D) is mapped to 128 Kbytes from 78:0000H.
SUPER NES CPU ROM Six Mbyte of ROM (E) is mapped from 80:8000H.
2-3-1
2-3-2 Figure 2-3-1 Super NES CPU Memory Map
Bank
Address \FF Co BF
SUPER NES CPU MEMORY MAP
80 7F 7E 79 78 71 70 5F 40 3F 02 0100
FFFFH
8000H 6000H 3300H 3000H 2000H
CPU ROM
(E) NSS \\ FFFFH
ROM (B)
Rowe SMO SOEs Sees Yeroro)
Le.
ZW Q 8000H
GAME PAK
RAM IMAGE (cc) od
a)
IR RAM IMAGE (c’)
fom A 6000H
MAA SSN WRAAADS A SSS GSU (A) 3800H
GSU (A) uper NES W-RAM SEReTs 2000H 0000H
0000H MEMORY MAPPING
3.2 GSU MEMORY MAPPING
The GSU memory map is depicted on the following page.
3.2.1
3.2.2 GAME PAK ROM The game pak ROM (A) is mapped to 2 Mbytes starting from 00:8000H. Two Mbytes from 40:0000H (A’) are used for the ROM image. This image is stored in blocks of 32 Kbytes, as indicated on the memory map by circled numbers (i.e., area; ©’ is the image of area , @ is the image of area @, and so forth). Other areas should not be used for this purpose.
GAME PAK RAM Game pak RAM (B) is mapped to128 Kbytes starting from 70:0000H. When the GSU accesses memory, it specifies bank addresses using three bank registers. These are; Program Bank Register (PBR), ROM Bank Register (ROMBR), and RAM Bank Register (RAMBR).
2-3-3
2-3-4 Figure 2-3-2 Super FX Memory Map
SUPER FX MEMORY MAP
Bank
Address \ FF 71 70 SF 40 3F 02 0100
FFFFH
8000H 6000H 4000H 3300H 3000H 2000H 0000H a4 | ve SW FFFH I8000H
oats Oa’
yj |6000H |4000H I3300H [3000H I2000H
[
Chapter 4
The GSU internal registers will be described in detail in this chapter. Although many of these registers may be accessed from the Super NES CPU, none can be accessed in this way during operation of the GSU, with the exception of the Status/Flag Register (SFR) and Version Code Register (VCR). In addition, when addressing the 16-bit registers from the Super NES CPU, the low byte must be accessed first. All addresses denoted with (**) can be accessed in banks 00H ~ 3FH and 80H ~ BFH.
GSU Internal Register Configuration
4.1. GENERAL REGISTERS (RO ~ R13)
Access from Super NES CPU: R/W Register Size: GSU Access Method: 16 bits Various transfer instructions (LDW (Rn)) Various Operation Instructions (ADD Rn) Other Instructions Register) Super NES | Special Functions Initial Value RO ** :3000H, 3001H |Default source/destination register Invalid
Ri ** :3002H, 3003H |PLOT instruction, X coordinate 0000H
R2 ** :3004H, 3005H |PLOT instruction, Y coordinate 0000H R3 ** :3006H, 3007H Invalid |
R4 ** :3008H, 3009H |LMULT instruction, lower 16 bits Invalid
R5 ** :300AH, 300BH Invalid
R6 ** :300CH, 300DH|FMULT and LMULT instructions, Invalid multiplication
R7 ** :300EH, 300FH |MERGE instruction, source 1 Invalid
R8 ** :3010H, 3011H |MERGE instruction, source 2 Invalid RQ ** :3012H, 3013H Invalid
R10 | ** :3014H, 3015H Invalid R11 | ** :3016H, 3017H |LINK instruction destination register Invalid R12 | ** :3018H, 3019H |LOOP instruction counter Invalid R13 | ** :301AH, 301BH |LOOP instruction branch Invalid Table 2-4-1 GSU General Registers
2-4-1
GSU INTERNAL REGISTER CONFIGURATION _]
4.2 For LINK and LOOP special functions refer to “Instruction Execution”, for other special functions refer to the instruction name in the chapter titled “Description of Instructions”.
RO
D15 D14 D13 D12 D11 D10 bg D8
D7 D6 Ds D4 D3 D2 D1 bo
Figure 2-4-1 Example of General Register
GAME PAK ROM ADDRESS POINTER (R14)
Access from Super NES CPU: Super NES CPU Addresses: Register Size: GSU Access Method: R/W ** :301CH, 3011DH 16 bits 3001H
3000H
Various transfer instructions (LDW (Rn)) Various operation instructions (ADD Rn) Other instructions
D7 D6 D5 D4 D3 D2 D1 Do GAME PAK ROM A15 A14 A13 Ai2 Alt A10 AQ A8
GAME PAK ROM A7 A6 AS A4 A3 A2 Al AO 301DH
301CH
R14 is a pointer that specifies the game pak ROM address when data are loaded from the game pak ROM to an internal register. Typically, the ROM buffering system will be used for this process.
2-4-2
4.3 PROGRAM COUNTER (R15)
Access from Super NES CPU: Super NES CPU Addresses: Register Size: Default Address: GSU Access Method: R/W ** 301EH, 3011FH 16 bits 0000H Various branching instructions (JMP Rn) Other instruction
D7 D6 D5 D4 D3 D2 D1 DO Program Counter PC15 | PC14 | PC13 | PC12 | PC11 | PC10 | PC9 PC8
Program Counter PC7 PC6 PC5 PC4 PC3 PC2 PC1 PCO 301FH
301EH
R15 is the GSU program counter. If its value is changed by a transfer instruction or operation instruction, the program jumps to the address of the new value.
GSU INTERNAL REGISTER CONFIGURATION [ ]
4.4 STATUS/FLAG REGISTER (SFR)
Access from Super NES CPU: R/W Super NES CPU Addresses: ** :3030H, 3031FH Register Size: 16 bits Default Address: 0000H
D7 D6 DS D4 D3 D2 D1 DO 3031H
Ra | + . B IH | IL | att2} acti} Status
3030H J R G Ov Ss CY Zz a Flag Portion
- This bit is O when this register is read.
Flag Description
Z Zero flag CcY Carry flag Ss Sign flag OV Overflow flag
G Go flag (set to 1 when the GSU is running)
R Set to 1 when reading ROM using Rj4 address.
ALT1 Mode set-up flag for the next instruction
ALT2 Mode set-up flag for the next instruction
IL Immediate lower 8-bit flag
JH Immediate higher 8-bit flag
B Set to 1 when the WITH instruction is executed.
IRQ Interrupt flag
Table 2-4-2 GSU Status Register Flags
The Status/Flag register indicates the status of the GSU. It may be accessed from the Super NES CPU during GSU operation to determine GSU status.
2-4-4
4.6 PROGRAM BANK REGISTER (PBR)
Access from Super NES CPU: R/W Super NES CPU Addresses: ** :3034H Register Size: 8 bits Default Address: Undefined GSU Access Method: LUMP instruction
D7 D6 DS D4 D3 D2 DI Do Program Bank a2a | azz | a2t | azo | aio | ais | ai7 | ate | 5094H
The program bank register specifies the memory bank register to be accessed when the GSU is loading the program code.
GAME PAK ROM BANK REGISTER (ROMBR)
Access from Super NES CPU: R Super NES CPU Addresses: ** :3036H Register Size: 8 bits Default Address: Undefined GSU Access Method: ROMB instruction
D7 D6 DS D4 D3 D2 DI bo ROM Data Bank azs | az2| a2t| azo] aio] ais | at7 | ate | 3036H
The game pak ROM bank register specifies the game pak ROM bank when loading data from game pak ROM using the ROM buffering system.
2-4-5
GSU INTERNAL REGISTER CONFIGURATION E ]
4.7, GAME PAK RAM BANK REGISTER (RAMBR)
Access from Super NES CPU: R Super NES CPU Addresses: ** :303CH Register Size: 1 bit Default Address: Undefined GSU Access Method: RAMB instruction
D7 D6 D5 D4 D3 D2 D1 DO RAM Data Bank
- * * * * | * * A16 303CH Bank = 70H when DO = 0 Bank = 71H when DO = 1 * This bit is O when this register is read.
The game pak RAM bank register specifies the game pak RAM bank when data are read/written between game pak RAM and the GSU internal registers. The RAMB instruction specifies bank 70H or 71H for game pak RAM access.
4.8 CACHE BASE REGISTER (CBR)
Access from Super NES CPU: R Super NES CPU Addresses: * :303EH, 303FH Register Size: 12 bits Default Address: 0000H GSU Access Method: LUMP, CACHE instructions
D7 D6 D5 D4 D3 D2 D1 DO Cache Base Address Ais | at4 | A13 | at2 | att | ato | ag | ag | S05FH Cache Base Address AZ AG AS A4 . . . * | 303EH
- This bit is 0 when this register is read.
The cache base register specifies the starting address when data are loaded from game pak ROM or RAM to the cache RAM.
[
4.9 SCREEN BASE REGISTER (SCBR)
Access from Super NES CPU: W Super NES CPU Addresses: ** :3038H Register Size: 8 bits Default Address: Undefined GSU Access Method: None
D7 D6 D5 D4 D3 D2 D1 Do Screen Base Address a7 | ate | ats | aia | aia | aie | ait | ato | 30384
The screen base register is used to specify the start address in the character data storage area.
GSU INTERNAL REGISTER CONFIGURATION Ec ]
4.10 SCREEN MODE REGISTER (SCMR)
Access from Super NES CPU: W Super NES CPU Addresses: ** :303AH Register Size: 6 bits Default Address: 00H GSU Access Method: None
D7 D6 D5 D4 D3 D2 D1 Do Screen Height Select Color Gradient
- - HT1 | RON| RAN | HTo | Mp1 | mp0} S0SAH
The screen mode register specifies the color gradient and screen height during PLOT processing and controls game pak ROM and RAM bus assignments.
4.10.1. SCREEN HEIGHT
Htl Hto Mode
0 0 128 (pixels)
0 1 160 (pixels)
1 0 192 (pixels)
1 1 OBJ mode
Table 2-4-3. Screen Height
4.10.2 COLOR GRADIENT
Mod 1 Mod 0 Mode
0 0 4-color mode
0 1 16-color mode
1 0 Not used
1 1 256-color mode
Table 2-4-4 — Color Gradient
4.10.3 ROM/RAM ENABLE FLAGS
When: RON = 0, the Super NES CPU has game pak ROM bus access. 1, the GSU has game pak ROM bus access. RAN = 0, the Super NES CPU has game pak RAM bus access. 1, the GSU has game pak RAM bus access.
2-4-8
E
4.11
4.12 COLOR REGISTER (COLR)
Access from Super NES CPU: __ Disabled Super NES CPU Addresses: Register Size: 8 bits Default Address: Undefined GSU Access Method: COLOR, GETC instructions
D7 D6 D5 D4 D3 D2 D1 Do Color Data CD7 cD6 CD5 CD4 | CD3 cD2 cD1 CDO
The color register contains data which specifies the colors to be plotted when PLOT processing is performed.
PLOT OPTION REGISTER (POR)
Access from Super NES CPU: Disabled Super NES CPU Addresses: Register Size: 5 bits Default Address: Undefined GSU Access Method: CMODE instruction
D7 D6 DS D4 D3 D2 D1 DO Freeze | High Dith ‘Trans- BY | High | Nibble | Figg | Parent
- - : Flag | Flag Flag Flag
The plot option register contains flags which specify the mode to be used when a COLOR, GETC, or PLOT instruction is executed.
2-4-9
GSU INTERNAL REGISTER CONFIGURATION
4.13
4.14 BACK-UP RAM REGISTER (BRAMR)
Access from Super NES CPU: W Super NES CPU Addresses: ** :3033H Register Size: 1 bit Default Address: 00H GSU Access Method: None
D7 D6 D5 D4 D3 D2 D1 DO
BRAM ring 3033H
When: BRAM Flag = 0, BRAM is disabled. 1, BRAM is enabled.
Data becomes “protected” when the BRAM flag is reset (“0”) after saving data to the Back-up RAM.
VERSION CODE REGISTER (VCR)
Access from Super NES CPU: R Super NES CPU Addresses: ** :303BH Register Size: 8 bit Default Address: Undefined GSU Access Method: None
D7 Dé DS D4 D3 De DI pO Version Code ve7 | vee | vos | vca| ves| voz} vor} vco| 3038H
The version code register permits the user to read the GSU version code.
2-4-10
[
4.15
4.16 CONFIG REGISTER (CFGR)
Access from Super NES CPU: W Super NES CPU Addresses: ** :3037H Register Size: 8 bit Default Address: 00H GSU Access Method: None
D7 D6 D5 D4 D3 D2 D1 DO
IRQ S MSO - - - - - 3037H
Ly Multiplier Speed Selection
0 : Standard Speed Mode 1: High Speed Mode —» IRQ Mask Flag This is equal to 1 when the GSU interrupt request is masked.
The CONFIG register selects the operating speed of the multiplier in the GSU and sets up a mask for the interrupt signal.
CLOCK SELECT REGISTER (CLSR)
Access from Super NES CPU: W Super NES CPU Addresses: **:3039H Register Size: 1 bit Default Address: 00H GSU Access Method: None
D7 D6 D5 D4 D3 D2 D1 DO
SR . : - - - 5 5 tS 3039H
When: CLSR Flag = 0, Super FX operates at 10.7 MHz = 1, Super FX operates at 21.4 MHz
This register assigns the Super FX operating frequency.
2-4-11
GSU PROGRAM EXECUTION Ez J
Chapter 5 GSU Program Execution
5.1 STARTING THE GSU
The GSU is placed in the idle state when the Super NES control deck is reset. The GSU is started by writing to its internal program counter (R15) from the Super NES. The GSU programs operate on the game pak ROM, RAM, or cache RAM, but the GSU activation method differs depending upon which memory is accessed. The various methods are described below.
5.1.1. STARTING GSU PROGRAM IN GAME PAK ROM The GSU is started by the following method when the GSU program is to operate in the game pak ROM. 5.1.1.1
5.1.1.2 BUS CONTROL In order for the Super NES CPU to pass game pak ROM bus access to the GSU, the Super NES CPU program used to start the GSU in an area other than the game pak ROM (such as WRA\W) is transferred to the GSU and the GSU jumps to that program. However, if the optional ROM for the Super NES is being used, the GSU can be started by running the start program in Super NES ROM, making the above transfer unnecessary. REGISTER ADDRESSING In the Super NES CPU program for starting the GSU, first assign the following registers.
¢ PBR (Super NES CPU Address, **:3034H) ¢ SCBR (Super NES CPU Address, **:3038H)
- SCMR (Super NES CPU Address, **:303AH)
2-5-1
C
mems Ida sta sta Ida sta Ida sta Ida ora sta mem16 rep Ida sta #clock data 3039H ;Sets operating frequency 3037H ;Sets CONFIG register #screen base . 3038H ;Sets screen base #program bank 3034H ; Sets program code bank #screen size mode 18H ; Sets RON, RAN flag, screen size, and color number 303aH
#00100000B #program address 301EH ; Sets program counter
5.1.2 STARTING GSU PROGRAM IN GAME PAK RAM
The following procedure is used to start the GSU when its program is to operate in
5.1.2.1
5.1.2.2 game pak RAM. TRANSFER GSU PROGRAM
The Super NES CPU first transfers the GSU program from the game pak ROM to game pak RAM. If the GSU will not be using game pak ROM, the Super NES CPU does not need to pass the game pak ROM bus access to the GSU. REGISTER ADDRESSING
In the Super NES CPU program for starting the GSU, first assign the following registers.
¢ PBR (Super NES CPU Address, **:3034H) ¢ SCBR (Super NES CPU Address, **:3038H) « SCMR (Super NES CPU Address, **:303AH)
- CLSR (Super NES CPU Address, **:3039H) Subsequently, when the lead address of the GSU program is written from the Super NES CPU to R15 (Super NES CPU address, **:301EH), the GSU can be started from that address.
GSU PROGRAM EXECUTION
5.1.3 STARTING GSU PROGRAM IN CACHE RAM The following procedure is used to start the GSU when its program is to operate 5.1.3.1
5.1.3.2 in cache RAM.
TRANSFER GSU PROGRAM The Super NES CPU first transfers the GSU program from the game pak ROM to cache RAM. If the GSU will not be using game pak ROM or RAM, the Super NES CPU does not need to pass the game pak ROM or RAM bus access to the GSU. REGISTER ADDRESSING In the Super NES CPU program for starting the GSU, first assign the following registers.
¢ PBR (Super NES CPU Address, **:3034H) « SCBR (Super NES CPU Address, **:3038H) ¢ SCMR (Super NES CPU Address, **:303AH)
- CFGR (Super NES CPU Address, **:3037H)
- CLSR (Super NES CPU Address, **:3039H) Subsequently, when the lead address of the GSU program is written from the Super NES CPU to R15 (Super NES CPU address, **:301EH), the GSU can be started from that address.
5.2 STOPPING THE GSU
The following two methods may be used to stop the GSU.
- GSU auto-stop using the STOP instruction
- Forced stop from the Super NES CPU using the GO flag
GSU AUTO-STOP USING STOP INSTRUCTION The STOP instruction is one of the instructions in the GSU instruction set. When the GSU reads the STOP instruction, it resets the GO flag, sends an interrupt (IRQ) to the Super NES CPU (to inform the CPU that processing is complete), and goes into the idle state. The value in R15 after the GSU has executed a STOP instruction varies depending upon the instruction that was executed immediately prior to the STOP instruction. 5.2.1
Instruction Type Value of R15 Transfer Data to R15 R15 Data +1 Jump or Branch Jump or branch destination address + 1 CACHE Instruction Address of STOP instruction + 1 Other Instruction Address of STOP instruction + 1
5.2.2 FORCED STOP FROM SUPER NES CPU USING GO FLAG The GSU can be forceably stopped by writing a “0” from the Super NES CPU to the GO flag in the status/flag register (Super NES CPU address, ** :3030H). This clears the data in the cache and resets the cache base register to OOOOH.
5.3 MEMORY ACCESS FROM SUPER NES CPU DURING GSU
OPERATION
If a “O” is written from the Super NES CPU to the RON flag in the status/flag register (Super NES CPU address, ** :303AH) during GSU operation, the GSU will shift to WAIT status when it requires game pak ROM access. This makes it temporarily possible to access game pak ROM from the Super NES CPU.
5.4 The WAIT status is subsequently canceled by writing a “1” to RON from the Super NES CPU. This causes the GSU to resume processing. In a similar manner, game pak RAM can be temporarily accessed by the Super NES CPU, using the RAN flag in the screen mode register.
INTERRUPTS
5.4.1 SUPER NES CPU INTERRUPT VECTOR Game pak ROM access from the Super NES CPU is inhibited during GSU operation and when the RON flag is “1”. If an interrupt (NMI) is generated to the Super NES CPU under these conditions, an interrupt vector from the game pak ROM will not be available for the Super NES CPU. This will cause an error. In order to avoid this problem, when a Super NES CPU interrupt vector is read, the GSU outputs a dummy vector on the data bus.The table below expresses the relationship between the Super NES CPU interrupt vector addresses and the dummy vectors. By placing interrupt routines in all the memories except the game pak ROM and encoding a jump instruction to each of the interrupt routines at WRAM addresses 00:0104H, 00:0100H, 00:0108H, and 00:010CH, interrupt processing can be executed without accessing the game pak ROM.
Interrupt Vector Address Dummy Vector 00:FFE4 00:0104 00:FFE6 00:0100 00:FFE8 00:0100 00:FFEA 00:0108 00:FFEE 00:010C Table 2-5-1 Dummy Interrupt Vector Addresses
2-5-4
GSU PROGRAM EXECUTION J
Lower 4 Bits of Address Dummy Data
OH, 2H, 6H, 8H, CH 00H
4H 04H
AH 08H
EH 0CH
Other 01H
Table 2-5-2 Dummy Data
5.4.2 INTERRUPT FROM GSU TO SUPER NES CPU The STOP instruction generates an IRQ from the GSU to the Super NES CPU. Therefore, the Super NES CPU can continue its own processing without having to periodically monitor the GSU for the end of its routine. Since there are instances in which an IRQ is generated for some other reason, the Super NES CPU must determine if the GSU was the source of the IRQ. There is an IRQ flag at bit 15 of the GSU status register. If this flag is “1”, the IRQ was generated by the completion of GSU processing. When bit 15 of this status register is read, the bit is reset to “0”. The IRQ output by the GSU can be disabled by setting bit 7 in the CONFIG register to “1”.
2-5-5
Chapter 6 Instruction Execution
6.1
6.2 READING INSTRUCTION CODE
6.1.1 EXECUTION IN GAME PAK ROM/RAM The GSU executes a program by reading the instruction codes from the game pak ROM or RAM at the addresses specified by the PBR and program counter (R15). The contents of the PBR determines whether the instruction code is to be read from game pak ROM or RAM (refer to “Memory Mapping”). The RON flag must be set (1) when an instruction code is read from game pak ROM. If the RON flag is reset (0), the GSU will be placed in the WAIT state when a game pak ROM instruction code is loaded. Likewise, the RAN flag must be set (1) when an instruction code is read from game pak RAM. If the RAN flag is reset (0), the GSU will be placed in the WAIT state when a game pak RAM instruction code is loaded.
6.1.2 EXECUTION IN CACHE RAM If the GSU's program counter (R15) is in a cache area determined by the cache base register and the data in the cache are valid, the GSU will read the instruction code from the cache RAM and execute it. When a program is being executed in the cache, even if RON or RAN is reset (0), the GSU will not stop when an instruction code is loaded. Consequently, it becomes possible to access the game pak ROM or RAM from the Super NES CPU.
PIPELINE PROCESSING
The GSU employs a “pipeline” for high-speed operation. This “pipeline” is a mechanism that, in parallel with the execution of an instruction, loads the next step and prepares it as the next instruction. The program counter (R15) indicates the next address following the instruction currently being executed.
Normally, it is not particularly necessary to be aware of this processing, but it must be considered when using instructions that change the program counter (R15), such as branch or jump instructions. When a branching process is executed, the instruction code at the next address is loaded into the pipeline. This instruction code is then executed in parallel with a load of the instruction code at the branch destination address into the pipeline. This is demonstrated in example 1 on the following page.
2-6-1
INSTRUCTION EXECUTION i}
(Example 1)
BNE FROG
INC R1
FROG: ADD R2
When the program in Example 1 is executed, the INC instruction will be executed regardless of the presence of a branch instruction, since it is loaded into the pipeline while processing the BNE instruction.
(Example 2)
BNE LOP1
BRA LOP2
LOP1: TO R1
When the program in Example 2 is executed, the program jumps to LOP1 when the Z flag is 0, but the first byte of the code “BRA LOP2” has already been loaded into the pipeline. Therefore, the code 11H at the jump destination “TO R1” will be processed as the offset value of the BRA instruction, causing “BRA ****” to be executed instead of “TO R1”.
In this situation, a NOP instruction should be inserted after the BNE instruction, as shown below.
(Example 3)
BNE LOP1
NOP
BRA LOP2
LOP1: TO R1
2-6-2
6.3
6.4 PROGRAM COUNTER
The GSU program counter is assigned to R15. When the value for R15 is changed by an instruction, the program jumps to the address indicated by that value.
(Example 4)
IWT RO,#0010H IWT R4,#0020H
IWT R15,#Address
Address: ADD R4
INC R3
In example 4, the program jumps to the specified address at the IWT instruction on the third line. Due to pipeline processing, the ADD instruction in the 7th line will be executed after the NOP instruction in the 4th line is executed. In addition, the address following the instruction currently being executed can be identified by moving the contents of R15 to another register.
FLAG PREFIXES
In the GSU, the action of the next instruction code to be executed varies depending upon the values of the status flags (ALT1, ALT2, B), set by instructions such as the ALT1 instruction.
(Example 5)
The instruction code 53H will perform the processing shown below depending upon the values for ALT1 and ALT2.
When ALT1=0, ALT2=0 Sreg+R3—>Dreg (ADD R3)
When ALT1=1, ALT2=0 Sreg+R3+CY—Dreg (ADC R3) When ALT1=0, ALT2=1 = Sreg+3—>Dreg (ADD #3) When ALT1=1, ALT2=1 Sreg+3+CY—Dreg (ADC #3)
2-6-3
INSTRUCTION EXECUTION
(Example 6)
The instruction code 11H will perform the processing shown below depending on the value of the B flag. When B=0 Set DregtoR1 (TOR1)
When B=1 Sreg—R1 (MOVE R1,Rn_ n=value for Sreg)
The ALT1 instruction is used to set the ALT1 flag to 1. Likewise, the ALT 2 instruction is used to set the ALT2 flag to 1. The ALTS instruction sets both the ALT1 flag and ALT2 flag. The WITH instruction is used to set the B flag.
Normally, the flags which were set by these instructions are cleared after the next instruction is executed. The flags are not cleared when the next instruction is a FROM, TO, WITH, ALT1, ALT2, ALTS, or a branch instruction.
For instance, since the TO and FROM instructions become MOVE and MOVES instructions, respectively; when the B flag is set, these flags will be cleared after the instructions are executed. They will also be cleared after the execution of a NOP instruction.
Since ALT1, ALT2, and ALTS instructions are used in combination with the next instruction, they do not need to be thought of as independent instructions. For instance, there is no need to be specifically aware that “if ADD R3 is executed after setting the ALT1 flag with an ALT1 instruction, the instruction becomes ADC R3”. The process can simply be seen as the two-byte instruction “ADC R3”. In the assembler, as well, it is normally unnecessary to specifically code an ALT1 instruction or to write a MOVE instruction as a WITH instruction and a TO instruction.
However, as demonstrated in the following examples, these things need to be kept in mind when accelerating program processing by effectively using the pipeline.
(Example 7)
IWT R3,#100H LOP1: ADC Ro ; ALT1+ADD RO PLOT
DEC R3 BNE LOP1 NOP
2-6-4
Due to pipeline processing, the code following a branching instruction will be executed regardless of the presence of a branch. In Example 7, the NOP instruction after the BNE instruction will always be executed, but this program can be substituted as demonstrated below.
(Example 8)
NEWLOP1: WT R3,#100H ALT1
ADD RO
PLOT
DEC R3
BNE NEWLOP1
ALT1
In this example, the branch destination “ADC RO” is divided into “ALT1” and “ADD RO”. ALT1 is placed after BNE, changing the address of the branch destination. Thus, the pipeline code at the time of the branch becomes useful.
2-6-5
INSTRUCTION EXECUTION ]
6.5 A different situation is demonstrated below.
(Example 9) IWT R3,#100H LOP2: PLOT
MOVE R4,R5 ; WITH R5+TO R4 DEC R3 BNE LOP2 NOP
This program can be substituted as shown in Example 10.
(Example 10) IWT R3,#100H LOP2: PLOT
DEC R3 WITH R5
BNE LOP2 TO R4
In example 10, “MOVE R4,R8’ is split into “WITH R5” and “TO R4”. This kind of rewrite is possible because the B flag is not changed by the branch instruction.
REGISTER PREFIXES
Most of the GSU instructions use a source register (Sreg) and destination register (Dreg). The Sreg indicates the general register used for the source of the instruction, while the Dreg indicates the general register used to store the result. The Sreg and Dreg can be assigned in the GSU using the TO, FROM and WITH register prefix instructions. The Sreg is assigned using the FROM instruction and the Dreg using the TO instruction. The Sreg and Dreg can both be assigned using the WITH instruction. The Sreg and Dreg return to the default RO when any instruction other than TO, FROM, WITH, ALT, or a branch is executed.
if
If a TO instruction or FROM instruction follows a WITH instruction, as demonstrated below, they will be executed as MOVE or MOVES instructions, causing Sreg and Dreg to return to the defaults after the instructions are executed. These registers also return to the defaults after a NOP instruction is executed.
(Example 11)
The program used to execute R3=R4-R5 is as follows.
TO R3
FROM R4 SUB R5
The operation RO=R4-R5 can be performed by executing the following program, omitting the TO instruction.
FROM R4 SUB R5
The operation RO=RO-R5 can be performed using the following program. The FROM instruction is omitted.
SUB R5
After a normal instruction has been executed, with the exception of TO, FROM, WITH, ALT, or a branch, Sreg and Dreg are both assigned the default register (RO). Consequently, in the following program, the initial SUB instruction will execute R3=R4-R5, but the second SUB instruction will execute RO=RO-R5.
TO R3 FROM R4 SUB R5 SUB R5
The WITH instruction not only assigns Sreg and Dreg, but also sets the B flag within the status/flag register. The TO and FROM instructions act as different instructions when the B flag is set.
- When a TO instruction is next, it performs a MOVE instruction (instruction to move between registers). ¢ When a FROM instruction is next, it performs a MOVES instruction (instruction to move between registers and set flags according to the data loaded).
INSTRUCTION EXECUTION [ J
6.6
6.7 LOOP
The LOOP instruction is provided for efficient loop processing in the GSU. The LOOP instruction decrements the value in R12 by 1 and, when the result is not 0, loads the address in R13 into the program counter. When the result is 0, the next instruction is executed without branching.
Consequently, when performing loop processing using the LOOP instruction, it is necessary to store the loop count number in R12 and the loop return destination address in R13.
(Example 12)
IWT R14,4DATA = ;R14=ROM Address for Read Data
IWT R12,#0100H ;R12=Loop Count Number
MOVE R13,R15 ;R13=REPEAT (Loop Back Address) REPEAT:
GETB
INC R14 LOOP }R12=R12-1. IF (R12<>0) THEN PC=R13 PLOT
SUBROUTINES
The GSU does not have any instructions for making subroutine calls. Therefore, when using a subroutine, it will be necessary to specify the return destination address in the program.
(Example 13)
A000 FB 07 AO IWT R11,#RETURN A003 FF 03 A1 IWT R15,#SUB1 ;Jump to SUB1 A006 01 NOP — ;Dummy A007 bo RETURN: INC RO ;Return Address
A103 96 SUB1: ASR A104 96 ASR A105 2B 1F MOVE R15,R11 ;Return to Main Routine A107 01 NOP ;Dummy
E ]
In Example 13, the program jumps to the subroutine after the return address in R11 has been specified. In the subroutine, the program finally returns to the main Program by loading the value for R11 to the program counter (R15).
The LINK instruction is used in the GSU for specifying the return address. LINK adds a value from 1 to 4, depending upon the operand, to the address of the instruction following LINK. The result is stored in R11.
(Example 14)
The call side of the routine in Example 13 can be rewritten as follows using the LINK instruction.
A000 94 LINK #4 3R11=A005 A001 FF 03 A1 IWT R15,#SUB1 ;Jump to SUB1 A004 01 NOP A005 DO RETURN: INC RO ;Return Address
6.8 CACHE RAM
A 512-byte instruction cache is built into the Super FX. Because instruction code is read six times as fast as reading from game pak ROM or RAM, a program in cache RAM runs at high speed. If a program is run in cache memory, access to the game pak ROM or RAM can be performed at the same time the instruction is executed. Therefore, a program can be executed at a higher speed.
6.8.1 USING CACHE INSTRUCTIONS The CACHE instruction is used to control the cache. If the CACHE instruction is executed, any subsequent instruction codes will be sequentially loaded into the cache RAM whether they are loaded from game pak ROM or game pak RAM. For instance, if the CACHE instruction is executed immediately prior to loop processing, the program can be made to operate in the cache RAM beginning with the second repetition. Program loops exceeding 512 bytes in size will not perform efficiently since the portion not handled in cache RAM will always be executed in game pak ROM or game pak RAM. Dividing the program into several loops so that the loops fit within the 512 byte limit will enable higher speed operation when the CACHE instruction is executed immediately prior to these loops.
2-6-9
INSTRUCTION EXECUTION ]
6.8.2 CACHE OPERATION When the CACHE instruction is executed, the beginning address for data to be loaded from game pak ROM or RAM to cache RAN is stored in the CBR (cache base register). The cache area will be 512 bytes beginning with the address stored in the CBR. The 512-byte cache area is further divided into 32 blocks of 16 bytes each. A “cache flag” is assigned to each of these 32 blocks.
When the program counter indicates the cache area, the cache flag that corresponds with that address is read. If the cache flag is not set, the instructions are loaded to cache RAM while the program executes in game pak ROM or RAM. The cache flag is set when the 16-byte block has been entirely loaded with instruction code. If the cache flag has already been set, the program is executed in cache RAM. The cache flags are all reset when the CACHE instruction is executed. Since the low 4 bits of the CBR are fixed at 0, the beginning address stored in the CBR after execution of a CACHE instruction will be the value of the address following the CACHE instruction with its low 4 bits set to 0 (XXXOH). If the low 4 bits of the address following the CACHE instruction are other than 0, the program jumps to the address in the CBR and loads the code from the game pak ROM or RAM into the cache RAM, after the CACHE instruction is executed. If a branch occurs before all 16 bytes of instruction code in a block can be loaded (before the cache flag is set), the program will branch after the remaining instruction code in that block has been entirely loaded. This operation is the same within the same block. If the program has branched to an address other than the block header address (XXXOH), the code between the block header address and the branch address will be loaded before the instruction at the branch address is executed. Refer to the illustration on the following page.
2-6-10
SNES DEVELOPMENT MANUAL.
XXXOH
XXXFH|
YYYOH
YYYFH| ~~ Game Pak ROM or RAM
Branch Statement
After loading into the cache, the program will
—z branch.
After loading into the cache, the program will execute the branch destination instruction..
Branch Destination <«__|
TD
Figure 2-6-1 Load to Cache RAM While Branching Since the CBR does not have any bank information, when an LUMP instruction is executed, all cache flags are cleared and the CBR is reset to a value with the low 4 bits of the jump destination address at 0 (XXXOH). This operation is the equivalent of executing another CACHE instruction. In addition, when the Super NES CPU writes a 0 to the GO flag of the GSU's status/flag register (a forced end if the GSU is operating), all of the cache flags are cleared and the CBR value is set to OOOOH. If the GSU is stopped by a STOP instruction, the contents of the CBR, cache flags and cache RAM are all saved. Consequently, when the GSU is restarted, a 0 must be written to the GO flag to reset the CBR and cache flags.
2-6-11
INSTRUCTION EXECUTION ]
6.8.3
6.8.4 CACHE RAM ACCESS FROM THE SUPER NES It is possible for the Super NES CPU to read and write to the GSU's cache RAM. The cache RAM is divided into 512-byte addresses from 3100H in any of banks OOH~3FH or 80H~BFH in the Super NES memory map. When the GSU is not operating, data can be freely read and written from/to the Super NES CPU. However, the CBR does not necessarily comply with address 3100H in the Super NES memory map. Caution should be observed when reading cache memory contents after the CACHE instruction has been executed. The address in the CBR cache RAM complies with the address indicated by the value of the low 9 bits of the CBR. Therefore, the CBR address on the Super NES is calculated as follows. CBR address on Super NES = 3100H + (CBR AND 01FFH) When cache data is loaded from the CBR complied address to 32FFH, continuous data is loaded from 3100H to the CBR complied address minus 1.
For example; when the CBR is C3A0H, Instruction Memory Address = Super NES Complied Address C3A0H~C3FFH 32A0H~32FFH C400H~C59FH 3100H~329FH When writing data from Super NES CPU to cache RAM, instructions must be written in 16-byte blocks. If data are written only part way through the 16 bytes, the flag will not be set for that block. In this case, the GSU will process as though cache data did not exist in that block. To set the cache flag, write any data to the XXXFH address of that block.
GSU EXCLUSIVE OPERATION IN CACHE RAM By activating the GSU after code has been written from the Super NES CPU to the cache RAM, it is possible to operate the program exclusively in cache RAM. The CBR value is stored from the Super NES CPU by resetting the GO flag. This causes the CBR value to become OOOOH. The program addresses in cache are normally OOOOH through 01FFH, so the GSU is activated with addresses in this range stored in the program counter.
Please be aware that, even when a STOP instruction is executed, the next code has been loaded into the pipeline. If the address of the STOP instruction is XXXFH, the GSU will try to read code from external RAM unless the cache flag for the block containing the next address (XXXOH) has been set.
2-6-12
[
Chapter 7
7A Data Access
GAME PAK ROM DATA
The GSU uses a function called the “ROM buffering system” as a method of loading data from game pak ROM during program execution. Using the ROM buffering system, register R14 is assigned as the address pointer to game pak ROM. When a value is set in register R14, the game pak ROM data at the address specified by ROMBR and register R14 are loaded to an internal buffer called the “ROM buffer’.
7.14 GSU PROGRAM RUNNING IN CACHE RAM OR GAME PAK RAM When the program is running in cache RAM or game pak RAM, game pak ROM data can be loaded in parallel with the execution of instructions. Therefore, it is most efficient to sandwich several instructions between an instruction that changes R14 and a GETB instruction. Care is required when performing the following operations while data are being loaded into the ROM buffer. ¢ If the value for R14 is updated, the initial loading process is interrupted and a new loading process is started. ¢ Ifa ROMB instruction is fetched, the program will wait until the data are loaded into the ROM buffer. The ROMBR value will be changed after data is loaded and program execution will resume.
¢ Ifa GETB or similar instruction is fetched, the program will pause while the data is loaded into the ROM buffer.
In the following examples, it is presumed that the program is being executed in cache RAM and bit 0 of the CLSR is “1” (Super FX operating frequency is 21.4 MHz). CAUTIONS If cache instructions are executed immediately after the value is set at R14, while the program is running on cache RAM, the proper value is not read to the ROM buffer. Please use caution when reading data from ROM.
- During 21.7 MHz operation, do not insert a CACHE instruction during the first 7 machine cycles after an instruction that changes the content of R14.
- During 10.7 MHz operation, do not insert a CACHE instruction during the first 4 machine cycles after an instruction that changes the content of R14.
2-7-1
DATA ACCESS
(Example 1)
Cycle Instruction Comment
2 MOVE R14,R1 ;Start Fetching 5 GETB ;Get The Byte Into RO 1 TO R1
1 FROM) R2
1 ADD R3 ;Perform R1=R2+R3 1 TO R4
1 FROM R5
1 ADD R6 ;Perform R4=R5+R6 1 ADD R8 ;RO=R0+R8 Fourteen cycles are required to execute the program in the previous example. Since RO is not used until the last instruction, the GETB instruction can be moved to the line before “ADD R8”, as demonstrated below.
(Example 2)
2 MOVE R14,R1 ;Start Fetching 1 TO Ri
1 FROM R2
1 ADD R3 ;Perform R1=R2+R3 1 TO R4
1 FROM R5
1 ADD R6 ;Perform R4=R5+R6 1 GETB ;Get The Byte Into RO 1 ADD R8 ;RO=RO+R8
Only 10 cycles are required to execute this program. Read timing for game pak ROM access is as follows.
- Operating frequency 21.4 MHz: 5 cycles
- Operating frequency 10.7 MHz: 3 cycles
GSU PROGRAM RUNNING IN GAME PAK ROM
When the GSU program is running in game pak ROM, it is necessary to use the ROM buffering system even when loading game pak ROM data. The instruction following a change in register R14 will not begin execution until the ROM buffer is loaded.
2-7-2
7.2 GAME PAK RAM DATA
The GSU uses a function called the “RAM buffering system” as a method of loading data from game pak RAM during program execution. Using the RAM buffering system, the game pak RAM address and data to be written are moved to an internal buffer. The operation of writing to RAM is started by executing a STB, STW, SM, SMS, or SBK instruction.
7.2.1 GSU PROGRAM RUNNING IN CACHE RAM OR GAME PAK ROM When the program is running in cache RAM or game pak ROM, its write data will be written to game pak RAM while the subsequent program is being executed. Therefore, it is most efficient to sandwich several instructions between STW instructions. Care is required when performing the following operations while writing to game pak RAM.
- Execution of a command that updates the register which was used as the address in a STB or STW instruction will have absolutely no effect on the write operation to game pak RAM and will not wait.
- Ifa RAMB instruction is fetched, the program will wait until the data are written to game pak RAM. The RAMBR value will be changed after the write is completed and execution of the program will resume. ¢ Ifa STW instruction is fetched, the program will wait until the data are written to game pak RAM. In the following examples, it is presumed that the program is being executed in cache RAM and bit 0 of the CLSR is “1” (Super FX operating frequency is 21.4 MHz).
(Example 3)
Cycle Instruction Comment
1 FROM R8 ;Store R8 Into (R10) 1 STW (R10) 10 STW (R11) ;Store RO Into (R11) 1 TO R1 1 FROM R2
1 ADD R3 ;Perform R1=R2+R3 1 FROM R5 1 ADD R6 ;Perform RO=R5+R6
2-7-3
DATA ACCESS ]
7.3 Seventeen cycles are required to execute the program in the previous example. Since the value for RO is not changed until the last instruction, the second STW instruction can be moved to the line immediately before that instruction. This is demonstrated on the following page.
(Example 4)
Cycle Instruction Comment
1 FROM R8 1 STW (R10) ;Store R8 Into (R10) 1 TO Ri 1 FROM R2 1 ADD R3 ;Perform R1=R2+R3 7 STW (R11) ;Store RO Into (R11) 1 FROM R5 1 ADD R6 ;Perform RO=R5+R6
Only 14 cycles are required to execute the program in Example 4. This is more efficient that Example 3, a wait period of 2 cycles is still required to write to game pak RAM.
7.2.2. GSU PROGRAM RUNNING IN GAME PAK RAM When the GSU program is running in game pak RAM, it is necessary to use the RAM buffering system described above even when writing game pak RAM data. The instruction following a STB or similar instruction is executed after completion of the write operation to game pak RAM.
BULK PROCESSING
Normally during bulk processing, data are loaded from game pak RAM, some processing is performed, and a process is executed to return the data to the same address. Waste can be avoided if the process can be completed without having to specify the address in RAM a second time.
When an instruction that performs a data transfer between the game pak RAM and an internal register is executed in the GSU, the game pak RAM address used in that instruction will be stored in memory. The SBK instruction stores the RAM address in which the register contents are stored. Since it does not require an operand, it can be executed more quickly than the SM or SMS instructions. The difference is demonstrated in the following two examples.
2-7-4
[
(Example 5)
In the following example the SBK instruction is not used. In this case, word data have been read from game pak RAM address 1234H, the register contents are incremented, and again written to 1234H.
Cycle Instruction Comment
LM —-RO,(1234H) ~~ ;RO¢-(1234H) INC RO ;RO<—RO+1 SM = (1234H),RO — ;(1234H)<—RO Nineteen cycles are required to execute the above program. If the SBK instruction is used, the following occurs.
(Example 6)
Cycle Instruction Comment
LM RO,(1234H) =; RO<-(1234H) INC RO ;RO<-RO+1 SBK ;(1234H)<-RO
In this example, only 16 cycles are required. The memory required to handle the program is also decreased.
2-7-5
GSU SPECIAL FUNCTIONS ]
Chapter 8 GSU Special Functions
The GSU performs various special functions to realize high-speed operations. These functions are described below.
8.1 BITMAP EMULATION
Since a character mapping system is used with the Super NES PPU, its CPU can not efficiently perform processing such as; placing a point, drawing a line or painting a plane (bitmap graphics). Prior to display on the screen, this data must be converted to character data. Thereby, emulating the bitmap data.
The GSU is equipped with functions that support “Plot Processing”. These functions, “place a point of a specified color at a specified coordinate position.” Consequently; after setting the screen mode (CMODE instruction), the color data (COLOR, GETC instructions), and the X,Y coordinates; the PLOT instruction is performed.
In this manner, the GSU converts plotted (bitmapped) data to character data which can be utilized by the Super NES PPU and writes them to game pak RAM. In order to be displayed on screen, character data produced in the game pak RAM must be transferred by the Super NES CPU to the V-RAM of the Super NES.
8.1.1. SET SCREEN MODE To begin GSU plot processing, screen mode assignments must be made. This is performed using the screen mode register (SCMR) and the screen base register (SCBR). The plot options are assigned using the CMODE instruction. 8.1.1.1 SCREEN MODE REGISTER (SCMR) The GSU conversion process from bitmapped data to character data requires a screen mode selection. This determines how the characters will be aligned and the bit mode to be used. This is performed by assigning a mode to the SCMR using the Super NES CPU. The GSU has 4 modes. A BG character array may be selected with screen heights of 128 dot, 160 dot and 192 dot. The fourth mode is an OBJ character array. The character data conversion processing by the GSU is performed assuming that the character array is aligned as demonstrated in the following figures for BG 128 dot, BG 160 dot, BG 192 dot, or OBJ; respectively. Consequently, when the converted data are used as BG or OBJ character data for the Super NES, it is necessary to assign the screen mode and store the screen data in the VRAM.
2-8-1
256 DOT ~—#t > 000] 010] 020 1FO 001| 011] 021 1FA 002 012] 022 1F2 128{i «| et! sie ee fe! od SC Data ee tet fel elelee oe te! ooF[oiF[oaF[ ss t—<“—*;~s*~s*s*s~*~*~™~:~:::C ‘CL Figure 2-8-1 128 Dot High BG Character Array (numbers are hexadecimal)
256 DOT = > 000] 014] 028 26C 001| 015] 029] 26D oozjoisjo2zAy we s—is—s—s «+ [26 10]; es | ei ei ee ee le DOT wi ei wtes SC Data sete le lelelee oo tc oisjo27josB) > © Ot=<“<i=<‘< ; 2]}3OW”*<‘<i‘C;étS e+ ([27F Figure 2-8-2 160 Dot High BG Character Array (numbers are hexadecimal)
256 DOT ~t _ 000] 018 2E8 001] 019 2E9 002] 01A «_|2EA) 192}; © |; oe! et ee ee . SC Data DOT; '
Figure 2-8-3 192 Dot High BG Character Array (numbers are hexadecimal)
2-8-2
GSU SPECIAL FUNCTIONS =
256 DOT ~—=t > AJ 000] 001] 002 00F| 100 10F 010] 011| o12 01F| 110 TF 020] 021] 022 02F| 120 «(ar
rot oy 1 t 1 SC Data tt ;etere tee ee pe tere ele!
1 1 ' 1 1 ase | | OFO| OF1| OF2 OFF] 1FO 1FF DOT] | 200] 201] 202 20F/300| * « «+ ([30F 210] 211] 212 21F|310 31F 220| 22i[ 222, . + + [22F[s20[. . + (82F Fe tei ei ee oe ele ee oe tet te ie; elee oe e1e eof ee ret
! A y[2Fo[2Fi[2F2| + + «+ [2FF3FO] + + «(| SF
Figure 2-8-4 OBJ Character Array (numbers are hexadecimal)
To calculate the total number of bytes of character data required, the following formula is derived from the bit mode and the screen height and width. Total number of bytes of character data = (Number of dots high/8) X (Number of dots wide/8) X (8n) Number of vertical Number of horizontal Number of characters characters bytes/char
Where n equals the number of bits per dot (2,4, or 8). 8.1.1.2 SCREEN BASE REGISTER (SCBR) The start address of the area in game pak RAM where character data will be handled must be assigned in advance from the Super NES CPU. This information is stored in the SCBR. The start address is calculated using the following formula.
(Start Address) = 70:0000H+SCBRx400H
2-8-3
8.1.2 For example, when the value 11H is stored in the SCBR, in 4bit mode, with a height of 128 dots, width of 192 dots;
(Start Address) = 70:0000H+11Hx400H = 70:4400H
(Total number of bytes of character data) = (128/8)x(192/8)x(8x4) = 3000H
game pak RAM addresses 70:4400H through 70:73FFH are used for the character data area. 8.1.1.3 CMODE INSTRUCTION The CMODE instruction must be stored in the plot option register (POR) to enable the PLOT instruction and COLOR or GETC instructions to be selected. The relationship between plot processing and the CMODE instruction is covered in more detail under “Plot Function and CMODE”, later in this chapter.
SET COLOR (COLOR, GETC) The color data used in plot processing must be stored in the GSU's color register (COLR) using the COLOR instruction or the GETC instruction. If the COLOR instruction is used, the value for the source register is stored, while the GETC instruction stores the value for the ROM buffer.
PLOT PROCESSING (PLOT) The PLOT instruction plots the color data, stored by the COLOR or GETC instruction, to the X and Y coordinates stored in general registers Ry and Ro. The X coordinate value must be in R, and the Y coordinate value in Ro. Color data plotted by the PLOT instruction are converted to character data and written to the game pak RAM. Since it would be inefficient to perform a direct write to game pak RAM for each PLOT instruction, caching is performed in an 8-bit (1 pixel) x 8-bit memory inside the GSU. This corresponds with the 1 vertical pixel x 8 horizontal pixel blocks into which the screen is divided. This memory is called the “pixel cache” and the blocks that are cached are called “character blocks”. There are two pixel cache memories in the GSU. The color data produced by the PLOT instruction is cached in the “primary pixel cache.” These data are copied to the “secondary pixel cache,” then written from the “secondary pixel cache” to game pak RAM. Each pixel cache has an 8-bit flag called the primary and secondary bit-pend flags. These indicate whether or not the color data in each pixel cache is valid.
2-8-4
GSU SPECIAL FUNCTIONS ]
When the PLOT instruction is executed, the offset address of game pak RAM where color data are written is calculated from the value in bit 7 through bit 3 of the X coordinate (R;) and the value in bit 7 through bit 0 of the Y coordinate (R2). These values are held in the GSU. When another PLOT instruction is executed, the GSU compares the new coordinate values to those stored. If the coordinates have not changed, plotting is performed to the same character block (stored in secondary cache) is written to game pak RAM. The flow of GSU plot processing will be demonstrated below using two cases. In the first description, the character block which was stored by the previous PLOT instruction is to be written. The second case demonstrates plotting to a different block. 8.1.3.1 PLOTTING TO SAME CHARACTER BLOCK Color data are written to the pixel cache and the corresponding bit-pend flag is set. When all of the bit-pend flags are set (all 8 pixels of the cache block have been written), write processing to game pak RAM is performed in the following manner. First, the contents of the primary pixel cache and the primary bit-pend flag are transferred to the secondary pixel cache and secondary bit-pend flag. If the contents of the secondary pixel cache are in the process of being written to the game pak RAM, this process is placed in WAIT status until the secondary pixel cache is empty. After transfer processing, all of the primary bit-pend flags are cleared. Then the GSU executes the instruction following the PLOT instruction. Since the primary pixel cache can be used, the next instruction could be a PLOT instruction without requiring a WAIT status. Parallel with the execution of the next instruction, the GSU converts the color data in the secondary pixel cache into character data and writes them to the game pak RAM. 8.1.3.2 PLOTTING TO A DIFFERENT CHARACTER BLOCK The contents of the primary pixel cache and the primary bitpend flag are transferred to the secondary pixel cache and secondary bit-pend flag. If the contents of the secondary pixel cache are in the process of being written to the game pak RAN, this process is placed in WAIT status until the secondary pixel cache is empty. Thereafter, color data are written to the primary pixel cache and the corresponding bit-pend flag is set. The GSU then executes the instruction following the PLOT instruction. Parallel with the execution of this instruction, the GSU converts the color data in the secondary pixel cache to character data and writes it to game pak RAM.
2-8-5
C a
The data in the corresponding character block are read from the game pak RAM and converted back, while the color data correspond with the flags which are not set in the secondary bit-pend flag are set in the secondary pixel cache. The GSU then converts the color data in the secondary pixel cache into character data and writes them to the game pak RAM. Thus, the operation of writing to game pak RAM using two pixel caches can be performed in parallel with the execution of instructions, making PLOT processing very efficient. In addition, since the PLOT instruction increments the value for R1 after processing, there is no need to specify coordinates when writing the pixels continuously toward the right.
(Example 1)
The following program is executed under the following conditions.
SCBR=O00H, Color Mode=256, and Screen Mode=BG 128 dot high
IBT R1,#0 IBT R2,#0 —_;Set the plot starting coordinate to (0,0) IBT RO,#0 CMODE ;Reset POR IBT RO,#15H COLOR sLoad 15H to the color register PLOT PLOT PLOT ;Plot (0,0) through (2,0) IBT RO,#36H COLOR ;Load 36H to the color register PLOT PLOT PLOT PLOT PLOT ;Plot (3,0) through (7,0)
GSU SPECIAL FUNCTIONS
The primary pixel cache becomes the cache RAM for the character block from coordinates (0,0) through (7,0). When the program is executed, the following values are stored in the primary pixel cache and the primary bit-pend flag.
Primary Bit-pend Flag WAVAN AV AV AV AW A GAME PAK RAM ADDRESS
- 70:0031) ema 00 (rasoCe0} Poel AY Vir (70:0021) ‘ache /0/ [0/0 //rF (70:0020) fi/ Lift \/o0 ——> (70:0011) Fe (70:0010) 1 (70:0001) EO (70:0000) 15/15/15/36/ 36/ 36/ 36/ 36,
Since all 8 pixels in a character block are set with the final PLOT instruction, they are transferred from the primary pixel cache to the secondary pixel cache and the game pak RAM write begins. This process clears the primary bit-pend flags and the primary pixel cache is released.
(Example 2)
Continuing from Example 1, the following program is executed.
IBT RO,#4AH COLOR jLoad 4AH to the color register PLOT PLOT PLOT PLOT ;Plot (8,0) through (11,0) IBT R1,#10H —;Change X coordinate to 16 PLOT ;Plot (16,0)
2-8-7
The primary pixel cache becomes the cache for the character data from coordinates (8,0) through (15,0). Immediately after the 4th PLOT instruction is executed, the primary pixel cache and primary bit-pend flags are as shown below.
Primary Bit-pend Flag 0707070
Primary land Pixel Cache AV AVA AN, [0707 o7o7
Since the last PLOT instruction writes to a different character block, RAM write processing is performed. First, a transfer is performed from the primary pixel cache and primary bit-pend flag to the secondary pixel cache and secondary bit-pend flag. Then, game pak RAM write processing is performed, but the pixels in the secondary pixel cache which have not been plotted are written after a game pak RAM read operation has been executed.
GAME PAK 1/1/1/1/1/1/1/1 RAM ADDRESS 0 070 0/0/0/0/0 . po L717 1/1/0/70/70/70 . (70:00B0) wrfofopopofsfonfes [Fo-ooB0) (70:00A1) ws var ae ae s00 —(70:00A1)
peoeoeo Ooo 0/0/0/0/0/0/ Lo (70:0090) (70:0081) _E6 re (70:0081) (70:0080) _E0_ 00 (70:0080) 4A/ 4A/ 4A/ 4A/ 10/ 12/ 12/ 10,
GSU SPECIAL FUNCTIONS
8.1.3.3 RPIX INSTRUCTION The RPIX instruction reads the character block containing the specified coordinates from game pak RAM into the pixel cache and performs processing to calculate the pixel values after the contents of the pixel cache have been written to the game pak RAM. When the screen drawing routine is complete, it is advisable to execute the RPIX instruction to insure that all of the PLOT data have been written. If consecutive RPIX instructions are executed, game pak RAM read data processing will always be performed because the instruction does not discern whether or not there are color data at the specified coordinates in the pixel cache.
Even when consecutive RPIX instructions read color data from the same character block, data will always be read from the game pak RAM.
PLOT FUNCTION AND CMODE The CMODE instruction is used to determine how the color register value will be handled by the PLOT instruction. The modes which can be specified with CMODE are shown in the table below. BIT| Flag Name | Operation Operation Related when 0 when 1 Instructions 0 | Transparent} Do not PLOT PLOT colorO | PLOT Flag color 0 1 | Dither Flag | PLOT value Alternately PLOT of low 4 PLOT high 4 bits of color bits and low register 4 bits of color register 2 | High Nibble i iene of Pewaee of COLOR, low 4 bits i its Flag in color in olor GETC register register 3 |Freeze High] Set all 8 Set only low COLOR,GETC, Nibble Flag | bits in 4 bits in PLOT color color register register with high 4 bits fixed 4 |OBJ Mode | Set mode OBJ mode PLOT,RPIX Flag with SCMR (htO,ht1)
Table 2-8-1 Functions of CMODE
The PLOT instruction is related to bit 3, but it is also used during PLOT processing for selecting the number of bits to be used (0=8 Bit, 1=4 Bit) for transparent processing. 8.1.4.1
8.1.4.2 BITO The Super NES has multiple hardware BG screens. When one BG screen is laid over another BG screen, the 0 portions of the color in the top BG screen become “transparent” and the colors of the bottom BG are displayed. The GSU uses color mode 0 to perform this function. When Bit 0=0 and all of the effective COLR bits are 0, the PLOT circuit refreshes only the X coordinate and no PLOT operation is performed. Normal PLOT operation is performed for anything other than 0. BIT1
When the number of colors that can be displayed at once is low (16 color mode), techniques can be used to apparently increase the number of colors through dither processing. The GSU is able to process this with extreme ease. The example below demonstrates the difficulties encountered when this function is not used.
(Example 3)
Routine for drawing a horizontal line of a specified length from a specified coordinate using two alternating specified colors.
R1:Start X position R2:Start Y position R3:Color 1 R4:Color 0 R12:Line length
MOVE R13,R15_— ;Set LOOP return address. ;LOOP return address
DOPLOT: FROM Ri XOR R2 AND #1 ;Execute [RO=(R1 XOR R2)And 1]. BNE DOPLOT FROM R83 ;When not zero, set R3 (color 1) to Sreg. FROM R4 ;When zero, set R4 (color 0) to Sreg. COLOR ;Set value of Sreg in COLR. PLOT LOOP NOP
2-8-10
GSU SPECIAL FUNCTIONS
Thus, if only the plotting functions are used, it takes time to determine which of the two colors to PLOT at a specified time. The bit 1 dither flag may be used to efficiently perform this type of drawing process. The dither mode is only functional in 4 color mode and 16 color mode. When dither mode is set, the PLOT circuit checks the bit 0 value of the result when an XOR operation is performed on R1 (X coordinate) and R2 (Y coordinate). If the resultant bit O=0, the low 4 bits of the COLR register are used as the color data for the PLOT instruction. However, if the resultant bit O=1, the high 4 bits of the COLR register are used. When the program in the previous example is written using the CMODE instruction, only the PLOT instruction is looped, as demonstrated below.
(Example 4)
IBT RO,#2 CMODE ;Set to transparent and dither mode. FROM R3 ADD R3 ADD RO ADD RO ADD RO ;Shift low 4 bits of COLOR] to high 4 bits. ADD R4 ;Add value of R4 (COLOR(O) to RO. COLOR ;Set COLR. MOVE R13,R15 ;LOOP return address
8.1.4.3 LOOP PLOT ;Plot pixel. Since the processing to determine whether or not a color is transparent is performed in parallel with the generation of plot data, dithering cannot be performed between a transparent color and a normal color. This mode can also be used in the 4 color mode.
BIT2
To efficiently perform rotation/enlargement/reduction of OBJ data, a system is used in which each pixel of color data is stored at one address. When displaying a 16 color OBJ, half of the memory is wasted using this method. Memory may be conserved by storing two pixels of color data together in one byte. However, this requires a method for extracting two pixels of color data from one byte of data. Bit 2 of CMODE is used by the GSU to perform this function.
2-8-1]
8.1.4.4
8.1.4.5 When the COLOR or GETC instruction is executed with bit 2 of CMODE set, the high 4 bits of the source register are written to the color register. If different OBJ data are stored in the high 4 bits and low 4 bits of the same memory area, this function permits the packed 8-bit data to be used without shift processing. This mode can also be used in 4 color mode. BIT3
If the COLOR or GETC instruction is executed in 256 color mode with bit 3 of CMODE set, only the low 4 bits of the COLR register can be written to the color register. The high 4 bits are fixed. This function enables the high 4 bits of the color register to be used in place of a palette in 256 color mode. In other words, characters of different colors can be drawn by plotting 16 color mode data while changing the value of the high 4 bits of the color register. BIT4
When bit 4 of CMODE is set, the mode which enables character data to be produced for OBJ. When this bit is 0, the mode is specified by HTO,HT1 of the SCMR. When switching the OBJ mode by changing this bit, it will be necessary to use the RPIX instruction to write the data to the game pak RAM which have already been written to the pixel caches.
2-8-12
GSU SPECIAL FUNCTIONS
COLOR Instruction [ Bit 3 | 3 GETC Instruction Pee SSS SSSeSeecr lace ' t Write inhibited ' by Bit3 PLOT instruction processing: Generates plot data COLOR - REGISTER }
2[3:4) * 10 | +——+—»|0 L_! COLOR|S:0} H SELECT| H SELECT f ' 1 4/6 Color |! ee Mode 1 '
Z is the source register for the COLOR instruction, ROM buffer value for GETC instruction.
2{[7:4] is a symbol that shows the data in bit 7 through bit 4 of Z. PLOT Instruction Processing Transparent Mode Processing Bit 0 -—>
SCMR Color Mode| |
Bit 3 -—>
COLRI7:0] In transparent mode (Bit0=0)
When COLR[1:0] are all 0 in 4 color mode When COLR{3:0] are all 0 When COLR{7:0] are all 0 When Bit 3=0 in 256 color mode When COLR{3:0] are all 0 When Bit 3=1 in 256 color mode
PLOT processing not performed PLOT Enable/Disable oo
Figure 2-8-5 Plot Operations Assigned by CMODE
2-8-13
[
8.1.5 PLOT DATA ADDRESS CALCULATION METHODS
The addresses to which plot data are written are determined using the following data.
- Xand Y coordinates are specified by the low bytes of Ry and Ro.
- The screen color mode and height mode are specified by the SCMR.
- SCBR
The following examples demonstrate the method of calculating this address. In the calculations below, “X[7:3]” indicates the value of bit 7 through 3 for the value of X. The expression “X4,” indicates the value of bit 4 for X. ‘lc Calculate the character number (CN) containing the specified coordinates. CN is the value of SC data in the character arrays previously described.
- Height, 128 Dot Mode
CN [9:0] = (X[7:3] x 10H) + Y[7:3]
X7 x6 X5 X4 X3
+ Y7 Y6 Y5 Y4 Y3
CN9_ CN8 CN7 CN6 CN5 CN4 CN3 CN2 CN1_ CNO
- Height, 164 Dot Mode
CN [9:0] = (X[7:3] x 14H) + Y[7:3]
X7 X6 X5 x4 X3 X7 X6 X5 X4 X3 + Y7 Y6 Y5 Y4 Y3 CN9 CN8 CN7 CN6 CN5 CN4 CN3 CN2 CN1_ CNO
- Height, 192 Dot Mode
CN [9:0] = (X[7:3] x 18H) + Y[7:3] X7 X6 X5 X4 X3 X7 X6 X5 x4 X3 + Y7 Y6 YS Y4 Y3 CN9 CNS CN7 CN6 CN5 CN4 CN3 CN2 CNi CNO
2-8-14
GSU SPECIAL FUNCTIONS
J
- OBJ Mode
CN [9:0] = (Y[7] x 200H) + (X[7] x100H) + (Y[6:3] x 10H) + Y[6:3]
X7 X6 X5 X4 X3
+Y7 Y6 Y5 Y4 Y3
CN9 CN8 CN7 CN6 CN5 CN4 CN3 CN2 CN1_ CNO
- The addresses to be written to are then calculated as follows.
A[19:0] = (CN[9:0] x CHAR_SIZE)
+ (SB[7:0] x 4000H) + (Y[2:0] x 2) + (PL{2] x 200H) + (PL[1] x 100H) + PL{0]
Where CHAR_SIZE is the number of bytes used for one character. This is 16 bytes for 4 color mode, 32 bytes for 16 color mode, and 64 bytes for 256 color mode. The expression “PL[2:0] indicates a plane number. The expression “SB[7:0]” indicates the value stored at the SCBR. The following examples demonstrate this calculation.
- 4 Color Mode
SB7 SB6 SB5 SB4 SB3
NO SB2 CNB SBI
CN7 SBO CN6 CN5 CN4 CN3 CN2 CN1 CNO Y2 ‘1 YO PLO
AI9: AB AI7 AI6 AIS AIS AIS
- 16 Color Mode
SB7 SB6 SB5 SB4 SB3 CNS CN8 A12
SB2 CN7 A
SBI CN6 A10 AQ AB A7 AB AS AS
SBO CN5 CN4 CN3 CN2 CN1 CNO
PLI A3
Y2 Yi AL
YO AO
PLO
AI9: AIS AI7 AIG AIS A14 AI3
- 256 Color Mode
SB7 SB6 SBS SB4 SB3 CNS CN8 CN7 Al2
SB2 CN6 AN
SB1 CNS A10 AQ AB A7 AG AS A4
SBo CN4 CN3 CN2 CN1 CNO
PL2 PL1 Y2 A2
‘1 At
YO AO
PLO
AI9: AI8 AI7 AIG AIS A14 AI A12 A A10 AQ AB A7 AB AS AG
2-8-15 AB A2 Al AO
C
8.2 MULTIPLICATION INSTRUCTIONS
The 4 multiplication instructions shown below are available in the GSU.
- MULT Signed 8 bits x Signed8bits — Signed 16 bits instruction Low 8 bits of Low 8 bits of Dreg Sreg operand
- UMULT Unsigned 8 bits x Unsigned 8 bits — Unsigned 16 bits instruction Low 8 bits of Low 8 bits of Dreg Sreg operand
° LMULT Signed 16 bits x Signed 16 bits —> Signed 32 bits instruction Sreg R6 High Dreg Low R4 ¢ FMULT Signed 16 bits x Signed 16 bits —> Signed 32 bits instruction Sreg R6 High Dreg There is an 8 bit x 8 bit multiplier built into the GSU. Since this multiplier is used only once with the MULT and UMULT instructions, these instructions can be executed at high speed. A 16 bit x 16 bit answer is calculated, for the LMULT and FMULT instructions, by performing an 8 bit x 8 bit multiplication 4 times. The execution speed of each multiplication instruction can be changed using bit 5 of the CFGR. Normally, the standard speed mode (bit 5=0) is used. When the Super FX operates at 10.7 MHz (when bit 0 of the CLSR is “O”), the high speed mode (bit 5=1) can be used.If R4 is specified as the destination register with the LMULT instruction, the high 16 bits of the operation results are stored in R4.
If R4 is specified as the destination register with the FMULT instruction, the operation results will not be stored in R4 and the results will be lost. Do not specify R4 as the destination register for the FMULT instruction.
8.2.1 INTERNAL PROCESSING OF FMULT AND LMULT For LMULT and FMULT instructions, 16 bit x 16 bit multiplication is performed by repeating an 8 bit x 8 bit multiplication circuit whose signed and unsigned numbers could both be present 4 times. The processing flow for the FMULT and LMULT instructions is explained below. The FMULT and LMULT instructions share the circuit, but notice that there are processes that can only be performed by the LMULT instruction. Initially, an 18 bit buffer used to hold the partial results during multiplication, called the partial product buffer, is cleared. The first multiplication is performed. Low 8 bits of Sreg (unsigned) x Low 8 bits of R6 (unsigned)
- 16 bit result (unsigned)
2-8-16
GSU SPECIAL FUNCTIONS
The high 8 bits of the result are stored in the low 8 bits of the partial product buffer. For LMULT, the low 8 bits of the result are stored in the low 8 bits of R4. The second multiplication is performed. High 8 bits of Sreg (signed) x Low 8 bits of R6 (unsigned)
- 16 bit result (signed) The result is expanded to 18 bits with the sign and added to the partial product buffer. The third multiplication is performed. Low 8 bits of Sreg (unsigned) x High 8 bits of R6 (signed)
- 16 bit result (signed) The result is expanded to 18 bits with the sign and added to the partial product buffer. For LMULT, the low 8 bits of the partial product buffer are further stored in the high 8 bits of R4. The fourth multiplication is performed. High 8 bits of Sreg (signed) x High 8 bits of R6 (signed)
- 16 bit result (signed) The result (16 bits) is added to the high 10 bits of the partial product buffer. For LMULT if the Dreg is R4, the value in the partial product buffer is stored in R4. If the Dreg is not R4, the value of the partial product buffer is stored in the Dreg. If R4 is specified as the destination register for the LMULT instruction when performing the above processing, the high 16 bits of the operation result will be stored in R4. However, if R4 is specified as the destination register for the FMULT instruction, the operation result will not be stored as the value for R4.
2-8-17
Chapter 9 Description of Instructions
This chapter provides a detailed description of each instruction and its function. ROM and RAM execution times listed for each instruction refer to the game pak ROM and RAM. Special indicators and symbols are used throughout this chapter. These are defined in the following 3 tables.
9.1 OPERAND DESCRIPTIONS
INDICATOR DESCRIPTION
Ro Indicates internal register Ro.
Ra A 16-bit general use register.
R,’ A 16-bit general use register.
(Rm) Indicates the value stored in the memory location specified by the contents of register Rp.
(xx) Indicates the value stored in the memory location specified by the 16-bit value xx.
(yy) Indicates the value stored in the memory location specified by the 9-bit value yy. (Osyy<510)
#n Indicates 4-bit immediate data.
#xXX Indicates 16-bit immediate data. (0<xx<65535)
#pp Indicates 8-bit immediate data. (-128<pp<127)
e 1-byte data -128<e<127, that expresses the displacement in the relative addressing mode.
9.2 FLAG DESCRIPTIONS
SYMBOL DESCRIPTION
Set Reset * Set or reset according to results. No change
2-9-1
DESCRIPTION OF INSTRUCTIONS
9.3 OPERATOR FUNCTIONS
INDICATOR DESCRIPTION
Ro Indicates internal register Ro. Rp, Rp’ | A 16-bit general use register specified by n. (Rm) Indicates a value stored in a memory location specified by the contents of register Ry. (xx) Indicates a value stored in a memory location specified by the 16-bit value xx.
(wy) Indicates a value stored in a memory location specified by the
9-bit value yy. #n Indicates 4-bit immediate data. #XX Indicates 16-bit immediate data. (0<xx<65535) #pp Indicates 8-bit immediate data. (-128<pp<127) e 1-bit data (-128<e<127), that expresses displacement in the relative addressing mode. Steg Source register Dreg Destination register |_ High-Byte | Upper byte of 16-bit data Low-Byte_| Lower byte of 16-bit data 2 Indicates direction of movement of data + Add e Subtract
- Multiply Rn, #n__|1’s compliment ALT1 _|ALTi Flag ALT2 ALT2 Flag CY Carry Flag ON Overflow Flag Z Zero Flag
Ss Sign Flag
B B Flag GO Go Flag
2-9-2
9.4 ADCR, Operation: Steg + Rn + CY Flag > Dreg (n=0~15) Description: This instruction adds the source register, the operand, and the carry flag. The result is stored in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
The operand can be any of registers Ro~Ry5-
Flags affected:
B |ALT1/ALT2} OV | S cy Z 0 0 0 * * * *
B: Reset ALT1: Reset ALT2: Reset ON: Set on signed overflow. Ss: Set if result is negative, else reset CY: Set on unsigned carry, else reset Zz: Set if result is zero. Opcode: (MSB) (LSB) ADC R, 0; Oo}; 1/ 1) 1) 17 OF 1 (3DH) Oo; 1] 0] 1 n (OH~FH) | (5nH)
Machine Cycles: ROM execution time 6 cycles
RAM execution time 6 cycles
Cache RAM execution time 2 cycles
Example: ADC R, ; RotRy+CY—Ro WITH Ro ; Set the source/destination registers to Ro ADC R3 ; RotRg+CY—Ro ADC Re ; Ro+Ro+CY—Ro
DESCRIPTION OF INSTRUCTIONS [ ]
9.5 ADC #n
Operation: Steg + #n + CY Flag > Dreg (n=0~15) Description: This instruction adds the source register, the immediate data specified by the operand #n, and the carry flag. The result is stored in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
The operand can be immediate data from 0~15.
Flags affected:
B JALT1/ALT2} OV | S cy zZ 0 0 0 * * * *
B: Reset ALT1: Reset
ALT2: Reset
ON: Set on signed overflow. Ss: Set if result is negative, else reset CY: Set on unsigned carry, else reset Zz: Set if result is zero, else reset.
Opcode: (MSB) (LSB) ADC #n o} oj; 14] 4]4] 14/4] 4 | @FH) o/ 1] o]1 n (OH~FH) | (5nH)
Machine Cycles: ROM execution time 6 cycles
RAM execution time 6 cycles
Cache RAM execution time 2 cycles
Example: ADC #9H ; Ro+0009H+CY—Ro FROM Rg ; Set the source register to Rg ADC #5H ; Rg+0005H+CY—Ro ADC #0AH ; Ro+000AH+CY—Ro,
9.6 ADDR, Operation: Steg + Rn > Dreg (n=0~15) Description: This instruction adds the source register and the register specified by the operand R,. The result is stored in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
The operand can be any of registers Ro~R45.-
Flags affected:
B |ALT1/ALT2|} OV | S cy Zz 0 0 0 * * * *
B: Reset ALT1: Reset ALT2: Reset ON: Set on signed overflow. S: Set if result is negative, else reset CY: Set on unsigned carry, else reset z: Set if result is zero.
Opcode: (MSB) (LSB) ADDR, | 0} 1] 0} 1 n (OH~FH) | (5nH)
Machine Cycles: ROM execution time 3 cycles
RAM execution time 3 cycles
Cache RAM execution time 1 cycle Example: Under the following conditions: Steg: Ro, Dreg: Ro, Ro=4283H, Ry=2438H Ro=66BBH when ADD R, is executed. ADD Ry, ; Ro+Ry—Ro TO Rs, ; Set the destination register to Rs ADD Re ; RotRe Rs ADD Rg + Ro+R3—Ro
DESCRIPTION OF INSTRUCTIONS
9.7 ADD #n
Operation:
Description: Steg t #N— Dreg (n=0~15) This instruction adds the source register to the immediate data specified by the operand #n. The result is stored in the destination register. Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro. The operand can be immediate data from 0-15.
Flags affected:
Opcode: B |ALT1/ALT2| OV | S CY Z * 0 0 0 * * *
B: Reset ALT1: Reset ALT2: Reset ON: Set on signed overflow, else reset. Ss: Set if result is negative, else reset CY: Set on unsigned carry, else reset. Z: Set on zero result, else reset.
(MSB) (LSB) ADD #n Oo; O| 1] 1] 1] 1) 14} 0 | (BER) o{ 1] o]1 n (OH~FH) (5nH)
Machine Cycles: ROM execution time 6 cycles
Example: RAM execution time 6 cycles Cache RAM execution time 2 cycles
Under the following conditions:
Steg’ Ra, Dregi Rz, Ry=3682H Rz is 368AH when ADD #8H is executed. ADD #8H ; R4+0008H>R7 WITH Ry ;Set the source and destination registers to R7 ADD #2H ; R7+0002H—>Rz ADD R, ; Ro+Ry>Ro
9.8 ALT1
FLAG PREFIX INSTRUCTION
Operation: 1 > ALT1 Flag Description: ALT1 is a prefix instruction used in combination with the instruction which follows. When ALT1 is executed, the Super FX sets the ALT1 flag in bit 8 of the status flag register (3030, 3031H).
The ALT1 flag specifies the mode for the next instruction.
Flags affected:
B |ALT1/ALT2} O/VV | S CY Zz 5 1 - - - - -
ALT1: Set
Opcode: (MSB) (LSB) ALT1 Oo; 0} 1/ 1] 1] 1] 0} 1 | (8DR)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: Execution of the ALT1 instruction sets the ALT1 flag. Various instructions can be executed, depending upon the instruction which follows the ALT1 prefix.
(Refer to, “ALT1 ($3D) +”, in the Super FX Opcode Matrix at the end of this chapter.)
2-9-7
DESCRIPTION OF INSTRUCTIONS [ a
9.9 ALT2
FLAG PREFIX INSTRUCTION
Operation: 1 > ALT2 Flag Description: ALT2 is a prefix instruction used in combination with the instruction which follows. When ALT2 is executed, the Super FX sets the ALT2 flag in bit 9 of the status flag register (3030, 3031H).
The ALT2 flag specifies the mode for the next instruction.
Flags affected: B |ALT1/ALT2} OV | S CY Z 5 5 1 5 5 5 Ao
ALT2: Set
Opcode: (MSB) (LSB) ALT2 Oo; Oo} 1/ 1] 14) 14 14] 0 | (BEH)
Machine Cycles: ROM execution time 3 cycles
RAM execution time 3 cycles
Cache RAM execution time 1 cycles
Example: Execution of the ALT2 instruction sets the ALT2 flag. Various instructions can be executed, depending upon the instruction which follows the ALT2 prefix.
(Refer to, “ALT2 ($3E) +”, in the Super FX Opcode Matrix at the end of this chapter.)
[
9.10 ALT3
FLAG PREFIX INSTRUCTION
Operation: 1 > ALT1 Flag 1 > ALT2 Flag Description: ALTS is a prefix instruction used in combination with the instruction which follows. When ALTS is executed, the Super FX sets the ALT1 and ALT2 flags in bits 8 and 9 of the status flag register (3030, 3031H).
These flags specify the mode for the next instruction.
Flags affected:
B_ |ALT1]ALT2| O/V CY Zz 5 1 1 5 cq 5
ALT1: Set
ALT2: Set
Opcode: (MSB) (LSB) ALT3 o| oo} 1/4 1] 1 | (3FH)
Machine Cycles: ROM execution time 3 cycles
RAM execution time 3 cycles
Example: Cache RAM execution time 1 cycles
Execution of the ALT3 instruction sets the ALT 1 and ALT 2 flags. Various instructions can be executed, depending upon the instruction which follows the ALTS prefix.
(Refer to, “ALT3 ($3F) +”, in the Super FX Opcode Matrix at the end of this chapter.)
2-9-9
DESCRIPTION OF INSTRUCTIONS:
9.11 AND R, Operation: Steg AND Rp» Dreg (n=1~15) Description: This instruction performs logical AND on corresponding bits of the source register and the operand R,. The result is stored in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
The operand can be any of registers Ry~Ry5.
Flags affected:
B |ALT1|/ALT2} OV | S CY Z 0 0 0 - 7 - * B: Reset
ALT1: Reset
ALT2: Reset Ss: Set if result is negative, else reset Zz: Set on zero result, else reset. Opcode: (MSB) (LSB) ADD R, 0 1/1 n (1H~FH) (7nH)
Machine Cycles: ROM execution time 3 cycles
RAM execution time 3 cycles
Example: AND
FROM TO AND Cache RAM execution time 1 cycles
Re
Rg Rio R7 ;Ro AND Rg > Ro (163AH) (OOFFH) — (003AH) ;Set the source register to Ro ;Set the destination register to Ryo ;Rg AND Ry > Rio (55AAH) (FFOOH) — (5500H)
2-9-10
‘SNES DEVELOPMENT MANUAL
9.12 AND #n
Operation: Sreg AND #n— Dreg (n=1~15) Description: This instruction performs logical AND on corresponding bits of the source register and the immediate data specified by the operand #n. The result is stored in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
The operand can be immediate data from 1~15.
Flags affected:
ALT1/ALT2| OV | S CY zZ 0 te) 0 2 * : ie : Reset ALT1: Reset ALT2: Reset S: Set if result is negative, else reset Zz: Set on zero result, else reset. (MSB) (LSB) ADD #n 0; O}; 1] 1) 1/1] 1] 0 | (EH) Oo; 1/1] 1 n(1H~FH) | (7nH) Opcode:
Machine Cycles: ROM execution time 6 cycles
RAM execution time 6 cycles
Cache RAM execution time 2 cycles Example: When register Ro is, “3E5DH (0011 1110 0101 1101B)”,
AND #6H
will result in,
Ro = “0004H (0000 0000 0000 01008)”.
2-9-11
DESCRIPTION OF INSTRUCTIONS J
9.13 ASR
Operation:
Description:
Flags affected:
Steg cy
Lite GE ee eo D15 we DO
D15 7 Do
This instruction shifts all bits in the source register one bit to the right. Bit 0 goes into the carry flag and bit 15 is unaffected. The result is stored in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
B |ALT1/ALT2} OV | S cy Zz 0 0 0 . * * * B: Reset
ALT1: Reset
ALT2: Reset
Ss: Set if result is negative, else reset CY: Set if bit 0 in the source register is “1”, else reset z: Set on zero result, else reset.
Opcode: (MSB) (LSB)
ASR 1} 0} 0} 1] O] 1] 1] 0 | (96H)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-12
E=
Example: Under the following conditions, Sreg: Rio: Dreg: Ri CY bit 15 bito [o]Ar [o]1fofo]+]1]4]4]o]1]4]1]1]0] 1] 1 | 4F7BH) When ASR is executed, the carry flag and R, are: CY bit15 bitO [+], [o]o]1]ofo]+]1]4] 1 ]o]1]4]1]1 Jo] |e7BpH)
2-9-13
DESCRIPTION OF INSTRUCTIONS ]
9.14 BCCe
Operation:
Description: If CY Flag=0 then Rys+e Ris (e= -128 ~+127) R45 identifies the next address for the BCC instruction (2 bytes)
If the carry flag is “O”, add “e” to the contents of the program counter R15 and JUMP to the address indicated by the resulting value in the program counter.
If the carry flag is “1”, do not jump.
The relative offset can be -128 to +127 bytes from the address following the code for “e”.
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
Flags affected:
B |ALT1/ALT2| OV | S CY Z
No flags affected
ee (MSB) (LSB)
0; 0} O] O| 1} 1} O] O (OCH) BCCe | 4 ¢ (OOH~FFH) ——+t® | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-14
‘SNES DEVELOPMENT MANUAL
Example: In the following example, the carry flag is zero and the program jumps forward 5 bytes from the execution address of the instruction.
BCC $+5H
The relationship between the program and the program counter is as follows:
PC ADDRESS = Object Code
51E (BCC $+5H) 51F os_]
Ba “Po before jump Execute instruction
522 at address 520 and 523 <PC after jump ~~ jump.
2-9-15
DESCRIPTION OF INSTRUCTIONS ]
9.15 BCSe
Operation:
Description:
Flags affected: If CY Flag=1 then Rys5+e>Ry5 (e= -128~+127) Rijs identifies the next address for the BCS instruction (2 bytes)
If the carry flag is “1”, add “e” to the program counter Rys5 and JUMP to the address indicated by the resulting value in the program counter.
If the carry flag is “O”, do not jump.
The relative offset can be -128 to +127 bytes from the address following the code for “e”.
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
B |ALT1/ALT2| O/VV | S cY Zz
Opcode:
Machine Cycles: No flags affected
(MSB) (LSB) 0; 0/ O} O} 1} 1} Of} 1 | (ODH) BCSe | ~<—— e(00H~FFH) ——-+» | Relative address
The number “e” (number, label, formula) which shows the jump destination is given in the assembler as an operand.
ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-16
Example: In the following example, the carry flag is set and the program jumps backward 1 byte from the execution address of the instruction.
BCS $-1H
The relationship between the program and the program counter is as follows:
PC ADDRESS Object Code
42D <PC after jump 42E OD: (BCS $-1H) 42F FD_ Execute instruction 430 <PC before jump at address 430 and 431 jump.
2-9-17
DESCRIPTION OF INSTRUCTIONS [
9.16 BEQe
Operation:
Description:
Flags affected: if ZFlag=1
then Ry5+e Ris (e= -128~+127) Ris identifies the next address for the BEQ instruction (2 bytes)
If the zero flag is “1”, add “e” to the program counter Rys and JUMP to the address indicated by the resulting value in the program counter.
If the zero flag is “0”, do not jump.
The relative offset can be -128 to +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
B |ALT1/ALT2} O/VV} S cY Zz
No flags affected
Opcode: (MSB) (LSB)
0} 0} of of 1] 0] of 14 | (o9H) BEQe |< e(00H~FFH) ——®» | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-18
LE
Example: In the following example, the zero flag is set and the program jumps ahead 5 bytes from the execution address of the instruction.
BEQ $+5H The relationship between the program and program counter is as follows:
PC ADDR!
15FD 15FE 15FF 1600 1601 1602 1603 Object Code
bg __] (BEQ $+5H) <PC before jump ——
<PC after jump <—
2-9-19 Execute instruction at address 1600 and jump.
DESCRIPTION OF INSTRUCTIONS
9.17 BGEe
Operation: If (S XOR O/V)=0 then Ry5+e R45, (e= -128~4+127) Ris identifies the next address for the BGE instruction (2 bytes) Description: If the sign flag and the overflow flag are equal, add “e” to the program counter Ry5 and JUMP to the address indicated by the resulting value in the program counter.
If the values are different, do not jump.
The relative offset can be -128 to +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
Flags affected:
B |ALT1/ALT2| O/VV | S CY Zz
No flags affected
Opcode: (MSB) (LSB)
0} 0} of of of] 1] 1] 1 | (07H) BGE e <+—— e (00H~FFH) ——~® | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-20
Example: In the following example, the sign flag and over flag are set and the program jumps backward 3 bytes from the execution address of the instruction.
BGE $-3H
The relationship between the program and program counter is as follows:
Pi DRE
22FA 22FB 22FC 22FD 22FE 22FF 2300 Object Code
<PC after jump Execute ip rea at , 7 address 2300 an FB __] (BGE $-3H) jump. <PC before jump
2-9-21
DESCRIPTION OF INSTRUCTIONS [ ]
9.18 BIC R, Operation: Seg AND Rn Dreg (n=1~15) Description: This instruction performs logical AND on corresponding bits of the source register and the 1's complement of register specified in the operand R,,. The result is stored in the destination register.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
The operand can be any of registers Ry~Ry5.
Flags affected:
B {ALT1/ALT2] OV | S CY Z 0 0 0 - * - * B : Reset ALT1 : Reset ALT2 : Reset iS) : Set if result is negative, else reset Zz : Set on zero result, else reset.
Opcode: (MSB) (LSB) OW |) yp aah) (eet) BICR n oO; 1) 144 n (1H~FH) (7nH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
Example: Under the following conditions:
Steg: Ro, Dreg: Ro
Ro=75CEH (0111 0101 1100 1110B), R,=3846H (0011 1000 0100 0110B)
Ro is 4588H (0100 0101 1000 1000B) when BIC R, is executed.
2-9-22
[ J
9.19 BIC #n
Operation: Steg AND #n— Dyeg (n=1~15) Description: This instruction performs logical AND on corresponding bits of the source register and the 1's complement of the immediate data specified in the operand #n. The result is stored in the destination register.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
The operand can be immediate data from 1~15.
Flags affected:
ALT1|/ALT2} O/VV | S | CY Z 0 0 0 a * a * B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if result is negative, else reset Z : Set on zero result, else reset.
Opcode: (MSB) (LSB) o;o}; 14/1 )4]4] 14] 41] @FH) C# Bic Folata]4 | nae-rny | cnn)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Under the following conditions: Steg: Ra, Dreg: Rs R4= 364BH (0011 0110 0100 1011B) Re is 3640H (0011 0110 0100 0000B) when BIC #F is executed.
2-9-23
DESCRIPTION OF INSTRUCTIONS [
9.20 BLTe
Operation: If (S XOR O/V)=1
then Ryste>Ri5 (e= -128~4+127) Rig identifies the next address for the BLT instruction (2 bytes) Description: If the sign flag and the overflow flag are different, add “e” to the program counter R,. and read the next instruction at the location indicated by the resulting value in the program counter.
If the values are the same, do not jump.
The relative offset can be -128 ~ +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
Flags affected:
B |ALT1|ALT2|] O/V Ss CY Zz
No flags affected
Opcode: (MSB) (LSB) 0/0] 0] of o| 1] 1] 0 | (06H) BLTe ~«+——e (00H~FFH) ——~» | Relative address
Machine Cycles: destination is given in the assembler as an operand.
ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-24
Example: In the following example, the sign flag is set and the overflow flag is reset. The program jumps forward 4 bytes from the execution address of the instruction.
BLT $+4H
The relationship between the program and program counter is as follows:
PC ADDRESS Object Code
BBD BBE BBF BCO BC1 BC2 6— (BLT $+4H) <PC before jump ——
<PC after jump ~<—
2-9-25 Execute instruction at address BCO and jump.
DESCRIPTION OF INSTRUCTIONS ]
9.21 BMle
Operation: If S Flag =1
then Ryste>Ry5 (e= -128~4+127) Rs identifies the next address for the BMI instruction (2 bytes) Description: If the sign flag is “1”, add “e” to the program counter Rys and read the next instruction at the location indicated by the resulting value in the program counter.
If the sign flag is “0”, do not jump.
The relative offset can be -128 ~ +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
Flags affected:
B |ALT1/ALT2| OV | S CY Zz
No flags affected
Opcode: (MSB) (LSB) Oo} Oo} Oo} Of 1} Of} 1] 14 | BH) BMI e ~+—— e (00H~FFH) ——» | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-26
[
Example: In the following example, the sign flag is set and the program jumps forward 5 bytes from the execution address of the instruction.
BMI $+5H
The relationship between the program and program counter is as follows:
PCADDRESS Object Code
57D 57E 0B Se 09] (BMI $+5H) 580 <—PC before jump Execute instruction 581 at address 580 582 . and jump. 583 <PC after jump ~<«—_
2-9-27
DESCRIPTION OF INSTRUCTIONS ]
9.22 BNEe
Operation: If ZFlag=0
then Ry5+e>Ry5 (e= -128~+127) R45 identifies the next address for the BNE instruction (2 bytes) Description: If the zero flag is “0”, add “e” to the program counter Ry5 and tead the next instruction at the location indicated by the resulting value in the program counter.
If the zero flag is “1”, do not jump.
The relative offset can be -128 ~ +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
Flags affected:
B |ALT1/ALT2| OV | S | CY Z
No flags affected
Opcode: (MSB) (LSB)
O/} 0} O} O} 1] OF O} O | (08H) BNE e ~+——_ e(00H~FFH) ———» | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-28
L
Example: In the following example, the zero flag is reset and the program jumps backward 2 bytes from the execution address of the instruction.
BNE $-2H
The relationship between the program and program counter is as follows: PC ADDRESS — Object Code 35FB 35FC <PC after jump Execute
eee 08 instruction at
~~] (BNE $-2H) address 3600 and 35FF FC jump 3600 <PC before jump . 3601
2-9-29
DESCRIPTION OF INSTRUCTIONS
9.23 BPLe
Operation:
Description:
Flags affected: If S Flag =0
then Ry5t+e>Ry5 (e= -128~+127) Ris identifies the next address for the BPL instruction (2 bytes)
If the sign flag is “O”, add “e” to the program counter Ry5 and read the next instruction at the location indicated by the resulting value in the program counter.
If the sign flag is “1”, do not jump.
The relative offset can be -128 ~ +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
B |ALT1}ALT2; O/VV | S | CY Z
No flags affected
Opcode: (MSB) (LSB)
0} 0/0] of] 1} 0] 1] 0 | (OAH) BPLe ~<+—_ e (00H~FFH) ———» | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-30
SNES DEVELOPMENT MANUAL. Cc
Example: In the following example, the sign flag is reset and the program jumps forward 4 bytes from the execution address of the instruction.
BPL $+4H
The relationship between the program and program counter is as follows:
PC ADDRESS
95D 95E 95F Object Code
aa (BPL $+4H) <PC before jump —— <PC after jump ~<«—
2-9-31 Execute instruction at address 960 and jump.
DESCRIPTION OF INSTRUCTIONS
9.24 BRAe
Operation:
Description:
Flags affected: RysteRy5 (e= -128~+127) Ris identifies the next address for the BRA instruction (2 bytes)
Regardless of the status of the flags, add “e” to the program counter R45 and read the next instruction at the location indicated by the resulting value in the program counter.
The relative offset can -128 ~ +127 bytes from the address following the code for “e”.
When a JUMP occurs, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
B |ALT1/ALT2| O/V | S CY Zz
Opcode:
BRA e
(MSB) (LSB) o] o] oJ oJ of 1] of 1 ] (5H) ~«——e (00H~FFH) ——» | Relative address
The number “e” (number, label, formula) which shows the jump destination is given in the assembler as an operand.
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-32
[ Z ]
Example: In the following example, the program jumps backward to the execution address of the instruction.
BRA $0H
The relationship between the program and program counter is as follows:
PC ADDRESS Object Code
BOFC BOFD BOFE 05 <PC after jump Execute BOFF FE—] (BRA $OH) _ instruction at B100 <PC before jump — address B100 B101 and jump.
2-9-33
DESCRIPTION OF INSTRUCTIONS ]
9.25 BVCe
Operation:
Description:
Flags affected: If OWN Flag=0
then Rys5te>Rys5 (e= -128~4+127) Ris identifies the next address for the BVC instruction (2 bytes)
If the overflow flag is “0”, add “e” to the program counter Rys and read the next instruction at the location indicated by the resulting value in the program counter.
If the overflow flag is “1”, do not jump.
The relative offset can be -128 ~ +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
B |ALT1/ALT2] OV | S | CY Zz
No flags affected
Opcode: (MSB) (LSB)
0; 0} O} O} 1] 1] 14] 0 | (OEH) BVCe ~<#——e (00H~FFH) -———» | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-34
Example: In the following example, the overflow flag is reset and the program jumps forward 4 bytes from the execution address of the instruction.
BVC $+4H The relationship between the program and program counter is as follows:
PC ADDRESS Object Code
288D pees GE] (eve $+4H) 2890 <PC before jump Execute instruction 2891 . at address 2890 2892 <PC after jump and jump. 2893
2-9-35
DESCRIPTION OF INSTRUCTIONS [
9.26 BVSe
Operation:
Description:
Flags affected: If OWN Flag=1
then Ry5+e>Ry5 (e= -128~+127) Rijs identifies the next address for the BVS instruction (2 bytes)
If the overflow flag is “1”, add “e” to the program counter Rys and read the next instruction at the location indicated by the resulting value in the program counter.
If the overflow flag is “0”, do not jump.
The relative offset can be -128 ~ +127 bytes from the address following the code for “e”
If the decision results in a JUMP, the next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
B |ALT1/ALT2| OVV| S | CY Z
No flags affected
Opcode: (MSB) (LSB)
0}; 0} O| O| 1} 1] 1] 1 | (OFH) BVSe ~+—— e (00H~FFH) ———» | Relative address
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
2-9-36
[ ]
Example: In the following example, the overflow flag is set and the program jumps backward 2 bytes from the execution address of the instruction.
BVS $-2H
The relationship between the program and program counter is as follows:
PC ADDRESS Object Code 68B 68C Pr j
68D PC after jump Execute instruction
68E OF y at address 690 68F FC —] (BVS $-2H) and jump. 690 <PC before jump _!
2-9-37
DESCRIPTION OF INSTRUCTIONS
9.27 CACHE
Operation: If CACHE BASE REGISTER<>(Ry5 & OFFFOH)
then (R15 & OFFFOH)—>CACHE BASE REGISTER Description: When the cache base register is equal to the address with the lower 4 bits of the program counter at 0, nothing occurs. When it is not equal to this address, reset all cache flags and set the cache base register to that value.
Flags affected:
B |ALT1/ALT2} O/V Ss CY Zz 0 0 0 - - - : B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
CACHE 0} 0}0/0/0/ 0} 1} 0} (o2hH)
Machine Cycles: ROM execution time 3~4 cycles RAM execution time 3~4 cycles Cache RAM execution time 1 cycle
2-9-38
‘SNES DEVELOPMENT MANUAL
9.28 CMODE
Operation:
Description: Steg (b4~b0) +> PLOT OPTIONS REGISTER This instruction loads the lower 5 bits of the source register into the plot options register. The instruction is used to specify the PLOT, COLOR, and GETC execution modes. Bit 0 - Transparency Flag 0 = Transparency ON If transparency is on and the color register is “O”, the plot circuit only changes the X coordinate. When transparency is on and the color register is other than “0”, the normal plotting operation is performed. 1 = Transparency OFF The normal plotting operation is performed when transparency is off. Bit 1 - Dither Flag Bit 1 is only valid in the 16-color mode. When Bit 1 is “1” and the values of bit 0 in registers R1 and R2 are the same, the lower 4 bits in the color register are plotted. When bit 0 of registers R1 and R2 are different, the upper 4 bits in the color register are plotted.
2-9-39
DESCRIPTION OF INSTRUCTIONS ]
Flags affected:
B |ALT1}ALT2|} OV | S | CY Z 0 0 0 5 5 5 5 B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB) CMODE o}o}1{1]14]1] 0] 14] (pH)
ol} 1]/o;/o]1]1] 1] 0} EH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Under the following conditions, Sreg: Ro, Ro= 0002H
the transparency and dithering modes are set when
CMODE
is executed.
2-9-40
| SNES DEVELOPMENT MANUAL
9.29 CMP R, Operation: Steg— Rn (n=0~15) Description: This instruction subtracts the operand R, from the source register and sets the flags accordingly. The result of the subtraction is not stored.
The source register is specified in advance using a FROM or WITH instruction. When not specified, the source register defaults to Ro.
The operand can be Ro~Rj5.
| Flags affected:
B |ALT1/ALT2] OV | S | CY Z 0 0 0 * * * * B : Reset ALT1 : Reset ALT2 : Reset O/vV : Set on overflow, else reset Ss : Set when the result is negative, else reset. CY : Set on unsigned borrow, else reset. Zz : Set on zero result, else reset
Opcode: (MSB) (LSB)
Oo; 0; 141 1 1| 1] 1] (SFH) CMP R " Oo; 1} 1/0 n (OH~FH) (6nH)
Machine Cycles:
Example: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
Under the following conditions,
Steg: Ry, Ry= 8000H, Rg= 2FFFH the overflow and carry flags are set and sign and zero flags are reset when
CMP Rg
is executed.
2-9-41
DESCRIPTION OF INSTRUCTIONS [ z
9.30 COLOR
Operation: Steg — Color register Description: This instruction loads the lower 8 bits of the source register into the color register as the color value.
Flags affected:
B_ JALT1/ALT2} OV | S cy Z 0 0 0 - - - : B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
COLOR 0) 1} 0}0}4] 14] 1] 0} (en)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: Under the following conditions:
Steg: Re, Re= 9830H the color register becomes 30H when
COLOR
is executed.
2-9-42
[
9.31 DEC R, Operation: R,-1>R, (n=0~14) Description: This instruction decrements the register specified in the operand R, by 1 and stores the result back in the same register. The register used can be Ro-Ry4.
Flags affected: B |ALT1/ALT2} OV | S | CY Zz 0 0 0 . * 7 *
B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. Zz : Set on zero result, else reset
Opcode: (MSB) (LSB)
DEC Ry, 1/1] 1/0 n (OH~EH) (Enh)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: Under the following conditions:
Ro= A3F7H
when the following instruction is executed
DEC Rg
Rg becomes A3F6H.
2-9-43
DESCRIPTION OF INSTRUCTIONS
9.32 DIV2
Operation:
Description:
Flags affected: If (Steg) = 1 then 0 — (Dreg) else ASR (Sjeg) — (Dreg) This instruction automatically shifts all bits in the source register right one place. The result is stored in the destination register. (Refer to ASR instruction for details.) If the source register data is FFFFH, the result stored in the destination register is OOOOH.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, these registers default to Ro.
B |ALT1/ALT2} OV | S CY Zz ofojo}-[{*]{-]* B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. cy : Set when Bit 0 of the source register is “1” and reset when “O”. Z : Set on zero result, else reset
Opcode: (usp) (LSB)
ae o}o;1}1/4]14] 0] 1) (DH)
Machine Cycles: 1/0) 0}/1 }0] 1] 1] 0] (96H)
ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
E
Example: Under the following conditions,
Sreg: Riz, Dyeg: Re cy Bitt5 Bito Ry: Lo] 1] of oT of 4] 4] of of of 1] 4] 0] 4] Of 1] (4635n)
becomes CY Bit15 Bito [4] Re:Lof of sJo] of of 4] 4] of of of 4 [7] of 4] oJ (231A)
when
Diva
is executed.
2-9-45
DESCRIPTION OF INSTRUCTIONS ]
9.33 FMULT
Operation: D15 Steg DO D15 Re Do oeceee x oe eee
D31 D16 D15 DO Upper 16 Bits Lower 16 Bits
D15 ’ DO oe CY Flag
occ ee Dreg (Dregs>Ra) Description: This instruction performs a 16 x16-bit signed multiplication with the source register and Rg. The upper 16 bits of the 32-bit result are stored in the destination register. Bit 15 of the 32-bit result becomes the carry flag.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, these registers default to Ro.
Flags affected:
ALT1/ALT2| O/VV | S CY Zz 0 0 0 . * * . B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. CY : Set when Bit 15 of the result is “1” and reset when “0”. Zz : Set if the upper 16 bits of result are zero, else reset. Opcode: (MSB) (LSB) FMULT 1/0}o}/1}/1/ 4] 4] 1] GFR
2-9-46
Machine Cycles:
Example: ROM execution time 11 or 7 cycles RAM execution time 11 or 7 cycles Cache RAM execution time 8 or 4 cycles
The number of machine cycles depends on the CFGR register.
Under the following conditions,
Steg: Rs, Deg: Reo, R= 4AAAH, Re= DAABH R2 becomes F51CH and the carry flag and sign flag are set when
FMULT
is executed.
2.9-47
DESCRIPTION OF INSTRUCTIONS ]
9.34 FROM R,
REGISTER PREFIX INSTRUCTION
Operation: IfB =0 then set Sreg to Ry (n=0~15) else Ry — Dreg Description: This instruction specifies which of the registers, Ro~Rjs, is to be used as the source register. If the B flag is set, the contents of the specified operand R,, are stored in the destination register Dreg: which is specified using the WITH instruction. (Refer to the MOVES instruction.)
Flags affected:
B |ALT1|}ALT2; O/VV| S | CY Z
No flags affected
Opcode: (MSB) (LSB)
FROMR, | 1] 0] 1] 4 n (OH~FH) (BnH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
Example: Execute
FROM Rp
to set Ro as the source register.
To perform Rot Rg= Ro, write:
FROM R2 ;Sets the source register to Ro ADD R3, Executes Ro + Rg>Ro
2-9-48
[
9.35 GETB
Operation: D7 ROM Buffer Do
00H oeceee D15 1 D8 D7 t DO
oe eee oe eee Dreg
Description: This instruction loads one byte of data stored in the ROM buffer into the lower 8 bits of the destination register and resets the upper 8 bits of the destination register. Register R14 is the ROM address pointer when data is loaded from the game pak ROM into the ROM buffer. Using the value stored at R,,4 for the game pak ROM address, data is read from game pak ROM to the ROM buffer.
Banks are specified in advance using the ROMB instruction. However, changing banks using the ROMB instruction does not in itself trigger a ROM load.
The destination register is specified in advance using a WITH or TO instruction. When not specified, this register defaults to Ro.
Flags affected:
B |ALT1/ALT2] O/VV| S | CY Zz 0 0 0 - : : : B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB) GETB 1} 4] 4)0 71] 1) 1) 17) (EFH)
Machine Cycles: ROM execution time 3~8 cycles RAM execution time 3~9 cycles Cache RAM execution time 1~6 cycles
2-9-49
DESCRIPTION OF INSTRUCTIONS
Example: Under the following conditions,
ROM butfer=0075H, Dreg:Ro
Ro becomes 0075H when
GETB
is executed.
2-9-50
ESE ae)
9.36 GETBH
Operation: Steg D7_ROMBuffer Do D15 Ds D7 DO LJ +++. - 7] [] UpperByte 7 |[ [ LowerByte | | D15 | D8 D7 { Do Upper Byte Lower Byte Dreg Description: This instruction loads the data contained in the ROM buffer to the high byte of the destination register and the low byte of the source register to the low byte of the destination register.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
Flags affected:
B |ALT1/ALT2| OV | S cy Z 0 0 0 - : : :
B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
ean 0} o}4}1/4] 14] 0} 1] (pn)
1} 1; 1/0)1 1} 14] (EFH)
Machine Cycles: ROM execution time 6~10 cycles RAM execution time 6~9 cycles Cache RAM execution time 2~6 cycles
2-9-5]
DESCRIPTION OF INSTRUCTIONS ]
Example: Under the following conditions,
(ROM buffer) = 75H, Steg: Re Dreg: Re, Ro= 4ABDH
Rg becomes 75BDH when
GETBH
is executed.
2-9-52
r
9.37 GETBL
Operation: Steg D15 D8D7 Do D7 _ROMBuffer Do [_] Upper Byte [J [ LowerByte [] [|] ----~ | ] D15 D8 D7 | DO Upper Byte Lower Byte
Dreg
Description: This instruction loads the data contained in the ROM buffer to the low byte of the destination register and the high byte of the source register to the high byte of the destination register.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
Flags affected:
B |ALT1/ALT2| OV | S CY Zz 0 0 0 - - a :
B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) GETBL Oo; Oo; 1/1 1 | 1} 1] 0] (3EH)
- 4}, 4;O}4]7 4} 4] 1 (EFH)
Machine Cycles: ROM execution time 6~10 cycles RAM execution time 6~9 cycles Cache RAM execution time 2~6 cycles
2-9-53,
DESCRIPTION OF INSTRUCTIONS ]
Example: Under the following conditions,
(ROM buffer) = 75H, Sreg: Ro, Dreg: Re, Ro= 4ABDH
Rg is 4A75H when
GETBL
is executed.
2-9-54
[
9.38 GETBS
Operation: D7 D6 DO ROM Buffer
reyyvyyery reg D15 D8 D7 D6 Do
Description: This instruction loads the data contained in the ROM buffer to the low byte of the destination register and the data contained in Bit 7 of the ROM buffer to Bits 8~15 of the destination register.
The destination register is specified in advance using a WITH or TO instruction. When not specified, this register defaults to Ro.
Flags affected:
B_ {ALT1/ALT2| O/V Ss CY Zz 0 ) 0 : 5 - -
B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB)
GETBS Oo; o; 14/1 1 1 1] 1 (3FH)
1/1/4707 14) 4) 1) 14) (EFH)
Machine Cycles: ROM execution time 6~10 cycles RAM execution time 6~9 cycles Cache RAM execution time 2~6 cycles
2-9-55
DESCRIPTION OF INSTRUCTIONS ]
Example: Under the following conditions,
(ROM buffer) = 85H, Dreg: Rg
Rg becomes FF85H when
GETBS
is executed.
2-9-56
9.39 GETC
Operation: (ROM buffer) > (COLOR register) Description: This instruction loads the data contained in the ROM buffer into the color register as color data.
Flags affected: B JALT1;/ALT2} OV} S | CY Z 0 0 0 - - - :
B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) GETC 1} 1/0/}1 1 1} 1] 1) (DFH)
Machine Cycles: ROM execution time 3~10 cycles RAM execution time 3~9 cycles Cache RAM execution time 1~6 cycles
Example: Under the following conditions, (ROM buffer) = 4BH
4BH is loaded to the color register when
GETC
is executed.
2-9-57
DESCRIPTION OF INSTRUCTIONS
9.40 HIB
Operation:
D15 Steg D8 D7 Do Upper Byte Lower Byte 00H D15 \ D8 D7 { DO Upper Byte Lower Byte Dieg
Description: This instruction loads the high byte of the source register into the low byte of the destination register. The high byte of the destination register is loaded with OOH.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, these registers default to Ro.
Flags affected:
B |ALT1/ALT2| OV | S | CY 4 0 0 0 - if : * B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if a negative number is loaded to the low byte of the destination register, else reset. Zz : Set if zero is loaded to low byte of the destination register, else reset.
Opeode: (MSB) (LSB)
HIB 1} 1) 0}0 ]0j] 0] 0} 0} (Con)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-58
C
Example: Under the following conditions,
Steg’ R11, Dreg=Ry, Ry1= 8A43H
R, becomes O08AH and the sign flag is set when
HIB
is executed.
2-9-59
DESCRIPTION OF INSTRUCTIONS [ J
9.41 IBTR,, #pp
Operation: D7 D6 DBO immediate data pp:
veyvryery Pri (n=0~15) Dis D8 D7 Dé DO (pp= -128 ~+127)
Description: This instruction loads one byte of immediate data (hexadecimal) into the low byte of register R,,. Bit 7 of the immediate data is loaded into bits 8 through 15 of R,.
Flags affected:
B |ALT1/ALT2} OV | S cy Zz 0 0 0 - - = 5
B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) IBT Rn, #PP 1/0} 1/0 n (OH~FH) (AnH) -<——— pp (OOH~ FFH) ————>| (ppH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Since hexadecimal numbers are handled in the assembler as intergers, without signs, a hexadecimal number of 80H or greater that is entered as an operand is processed as a number greater than +128, exceeding the range -128~+127. When this occurs, the assembler will specify the low byte as the immediate data of the IBT instruction.
IBT Rg, #4 -. 0004H — Rg IBT Rg, #128 ... FF80H > Rg IBT Rg, #0A4H_ ... FFA4H > Rg
2-9-60
9.42 INC R, Operation: Ry+1—> Rp (n = 0~14) Description: This instruction increments the contents of the register specified in the operand R,, by one and stores the result back into the same register.
The operand can be Ro~Ry4.
Flags affected:
B_ |ALT1/ALT2} OV | S | CY Zz 0 0 0 - * 7
B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if result is negative, else reset. Z : Set on zero result, else reset. Opcode: (MSB) (LSB) INC Ry 1} oO; 4]4 n(OH~EH) | (DnH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: When register Ry» is 65B1H, Ry becomes 65B2H when
INC Ryo
is executed.
2-9-61
DESCRIPTION OF INSTRUCTIONS [ ]
9.43 IWT Rp, #xx Operation: #xx (2-byte hexadecimal immediate data) > R, (n = 0~15, #xx=0~65535)
Description: This instruction loads two bytes of immediate data, #xx (hexadecimal), to the register specified in the operand, Rp.
Flags affected:
B |ALT1}ALT2] OV | S | CY Z 0 0 0 - - - -
B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) ITWR,, fx LAL ttt n(OH~FH) — | (FnH) X (OOH~FFH) (Lower Byte)
x (00OH~FFH) (Upper Byte)
The two-byte immediate data in the op code is loaded low byte first, followed by the high byte.
Machine Cycles: ROM execution time 9 cycles RAM execution time 9 cycles Cache RAM execution time 3 cycles
Example: Register Ro becomes 4583H when
IWT Ro, #4583H
is executed.
2-9-62
c
9.44 JMP R, Operation: Ry Ris (PC) (n=8~13) Description: This instruction loads the contents of the register specified in the operand R,, to Rys (program counter) and initiates a program fetch from the resulting location specified by the program counter.
The next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
The operand can be register Rg~Ry3.
Flags affected:
ALT1/ALT2} O/VV | S | CY Zz 0 0 0 - - - 2
B : Reset ALT1 : Reset ALT2 : Reset ae (MSB) (LSB) JMP R, 1} 0/0/14 n (8H~DH) (9nH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: When register Ryo is 0555H and the following program is executed,
PC Opcode
0444H ~~ JMP Rig 0445H INC Rig
the jump destination is 0555H.
2-9-63
DESCRIPTION OF INSTRUCTIONS [ ]
9.45 LDB (Rn) Operation: (Rm) > Dreg (Low Byte) (m=0~11)
00H —> Drag (High Byte) Description: This instruction loads one byte of data located at the game pak RAM address contained in the register specified in the operand Rm and stores this data in the destination register. The upper byte of the destination register is loaded with OOH.
Use the RAMB instruction to set the RAM bank. (Refer to RAMB.)
The destination register is specified in advance using a WITH or TO instruction. When not specified, this register defaults to Ro.
Flags affected:
B |ALT1/ALT2} O/V| S | CY Zz 0 0 0 - - -
B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) Oo; 0; 14/1 1 1] 0] 1] (3DH) LDB (R, ®m) Folsfolol m (OH~BH) (4mH)
Machine Cycles: ROM execution time 11 cycles RAM execution time 13 cycles Cache RAM execution time 6 cycles
SNES DEVELOPMENT MANUAL.
Example: Under the following conditions,
Dreg=R7, Ry= 3482H, (70:3482H)= 51H RAMBR:70H
and when the following program is executed,
LDB (Ry)
R7 becomes 0051H.
2-9-65
DESCRIPTION OF INSTRUCTIONS J
9.46 LDW (R,,) Operation: (Rim) — Dreg (Low Byte) (m=0~11) (Rmt1) > Dreg (High Byte) When the contents of R,, is: even, (Rmt+1) odd, (Rm-1) is loaded to the high byte. Description: The word data located in the game pak RAM address that equals the contents of register R,, are stored in the destination register. The game pak RAM address bank is specified using the RAMB instruction (refer to RAMB).
The destination register is specified in advance using a WITH or TO instruction. When not specified, this register defaults to Ro.
Flags affected:
B |ALT1/ALT2} O/VV | S | CY Zz 0 (0) 0 - - - : B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MsB) (LSB)
LDW (Rn) | Of 1} 0] 0 m (OH~BH) (4mH)
Machine Cycles: ROM execution time 10 cycles RAM execution time 12 cycles Cache RAM execution time 7 cycles
Dreg:Rs, Rg=6480H, (70:6480H)=COH, RAMBR=70H and when the following program is executed,
LDW (Rg)
the register R; becomes CO2EH.
2-9-66
[
9.47 LEA R,, xx (Refer to IWT R,, #xx) Operation: Ra xx (n=0~15, xx=0~65535) Description: This instruction loads two bytes of immediate data, #xx (hexadecimal), to the register specified in the operand Rp.
Flags affected:
B |ALT1/ALT2| OV | S | CY Zz 0 0 ie) = - 5 - B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) LEA Ry XX 1} 4) 144 n (OH~FH) (FnH) x (OOH~FFH) (Lower Byte)
x (OOH~FFH) (Upper Byte)
The two-byte immediate data in the op code is loaded low byte first, followed by the high byte.
Machine Cycles: ROM execution time 9 cycles RAM execution time 9 cycles Cache RAM execution time 3 cycles Example: Register Rg becomes 4853H when
LEA Rg, #4853H
is executed.
2-9-67
DESCRIPTION OF INSTRUCTIONS [ ee]
9.48 LINK #n
Operation: Rig t+ #n > Ry (n=1~4) Ry5 contains address following LINK instruction Description: This instruction adds the operand #n to the value contained in register Ry5 (program counter) and stores the result in register R11. Operand #n can be a number from 1~4. This instruction can be used to specify a return address in register R,, when jumping to a subroutine.
Flags affected:
B {ALT1/ALT2| OV | S cY Zz 0 0 0 - - - -
B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
LINK #n 1/0]o0]14 n (1H~4H) (9nH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
Example: Under the following conditions,
R45: 4368H
and when the following program is executed,
4368 LINK #4 4369 IWT Ris, #74FFH 436C NOP 436B IBT Ry, #12H
register Ry, becomes 4369H + 2=436BH
2-9-68
9.49 LUMP R,
Operation:
Description:
Flags affected: Rn > Rys (PC) (n=8~13)
Steg — Program Bank Register (PBR) This instruction loads the register specified as operand, Rp, into the program counter, Rys and loads the lower byte of the source register to the program bank register. This allows the program to jump to addresses in different banks.
The next instruction to be executed will already be in the instruction pipeline of the processor. For this reason one byte from the pipeline will be executed before the instruction at the branch destination is executed. (The execution time for this instruction is not included in the machine cycles listed below.)
The operand can be any of registers Rg~Ry3.
ALT1|ALT2| O/V | S | CY Z
Opcode:
LUMP R, B : Reset ALT1 : Reset ALT2 : Reset
(MSB) (LSB) Oo} o}1}1]14 414] 0] 1] (DH) 1; 0/ 0/1 n (8H~DH) (9nH)
Machine Cycles: ROM execution time 6 cycles
Example: RAM execution time 6 cycles Cache RAM execution time 2 cycles
Under the following conditions, Ry:0001H the program jumps from 00:8006H to 01:0002H when the following program is executed. Bank :Address Syntax 00 :8000H IWT Rj, #0002H 00 =:8003H FROM R, 00 :8004H LJMP Rig 00 :8006H NOP
2-9-69
DESCRIPTION OF INSTRUCTIONS ]
9.50 LM R,, (xx) Operation: RAM (xx) — Ry (low byte) (n=0~15, xx=0~65535) RAM (xx+1) — R,, (high byte) When the value of xx is: even, (xx+1) odd, (xx-1) is loaded to the high byte. Description: This instruction loads the data contained in the game pak RAM address specified in the second operand xx and stores the data in the register specified in the first operand R,. The RAMB instruction is used to specify the bank of the RAM address.
Flags affected:
B |ALT1}ALT2| OV | S | CY Z 0 0 0 5 5 5 5
B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB) o}o}1}1{4]14] 0] 1] eon) LMR, ox) LAL 1] 111 n(OH~FH) | (FnH) X (OOH~FFH) (ADRS Lower Byte)
x (OOH~FFH) (ADRS Upper Byte)
Machine Cycles: ROM execution time 20 cycles RAM execution time 21 cycles Cache RAM execution time 11 cycles
Example: Under the following conditions,
(70:BACCH) = 28H, (70:BACDH) = 96H, RAMBR=70H
register Rg becomes 9628H when the following program is executed:
LM Rg, (OBACCH)
2-9-70
9.51 LMS R,, (yy) Operation: RAM (yy) > R,, (low byte) (n=0~15, yy=0~510*) RAM (yy+1) — R,, (high byte)
“Note: Selectable RAM address (yy) must be an even number. Description: This instruction uses a short address method to perform the LM instruction. The address is shortened by reducing the number of bytes in the instruction opcode. The instruction loads data from the game pak RAM address equal to the immediate number yy and stores the data in register R,. The selectable game pak RAM address may be an even number of 0~510. The RAMB instruction is used to specify the bank of the RAM address.
Flags affected:
B |ALT1/ALT2| OV | S | CY Z 0 0 0 Z - - -
B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
o}o}1{1}1] 4] 0] 1] @pH) 1Jo}1]o n(OH~FH) | (AnH) kk (OOH~FFH) (Address) LMS Rp, (yy)
[Short address method] This method is used by LMS, SMS, and other instructions to reduce the number of bytes in the instruction opcode. Only one byte is used. The actual game pak RAM address is twice that of the address code. The relationship between yy in the above syntax and kk in the opcode is:
yy =kkx2
Machine Cycles: ROM execution time 17 cycles RAM execution time 17 cycles Cache RAM execution time 10 cycles
2-9-71
DESCRIPTION OF INSTRUCTIONS
Example: Under the following conditions, (70:1AAH) = 32H, (70:1ABH) = 92H, RAMBR:70H
register Rg becomes 9232H when the following program is executed:
Syntax Opcode
LMS Rg, (1AAH) 3D A3 D5
2-9-72
9.52 LMULT
Operation: D15 Steg Do D15 Re Do oe eee xX oe eee
D31 D16 D15 DO Upper Word Lower Word Dis y DO p15 \ DO oe eee
Dreg CY Flag Ra
Description: This instruction performs 16 x 16-bit signed multiplication using
Flags affected:
Opcode: the source register and register Rg. The upper 16 bits of the result are stored in the destination register, and the lower 16 bits are stored in Ry. If Bit 15 of Re is set, the carry flag is also set to a4,
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro. If Ry is specified as the destination register, the result will be invalid.
B |ALT1/ALT2/ OV | S | CY Z 0 0 0 ~ * * *
B : Reset ALT1 : Reset ALT2 : Reset iS} : Set if the result is negative, else reset CY : Set if Bit 15 of Re is 1”, reset if “Oo” Z : Set if the destination register result is zero, else reset.
(MSB) (LSB) LMULT 0} oO} 1}f1 {4} 14] 0) 1] (DH) 1; 0/ 0/1 1] 1] 1) 11) (QFH)
2-9-73
DESCRIPTION OF INSTRUCTIONS ]
Machine Cycles: ROM execution time 10 or14 cycles RAM execution time 10 or14 cycles Cache RAM execution time 5 or 9 cycles
the register Rg becomes OAE3H and R, 5C72H when
LMULT
is executed.
2-9-74
E 5
9.53 LOB
Operation:
D15 Steg D8 D7 DO Upper Byte Lower Byte 00H D15 | D8 D7 { Do Upper Byte Lower Byte Dreg
Description: This instruction loads the lower byte of the source register to the low byte of the destination register. The high byte of the destination register is loaded with OOH.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro.
Flags affected:
B |ALT1/ALT2} O/VV | S CY Zz 0 0 (0) - * - * B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if the low byte of the source register is negative, else reset. Zz : Set if low byte of the source register is zero, else reset. Opcode: (MSB) (LSB) LOB 1] 0; 0}1}4/ 14] 14] 0] @EH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-75
DESCRIPTION OF INSTRUCTIONS ]
Example: Under the following conditions,
Steg: Rio: Drag: Riz, Rio= FB23H
the register Ry> becomes 0023H when
LOB
is executed.
2-9-76
9.54 LOOP
Operation:
Description:
Flags affected: Ry2- 1 Rio If Z Flag=0 then Ry3— Rys (PC)
This instruction decrements Rj by 1. If the result does not set the zero flag, the contents of Ry3 are loaded into Rys and the Program is fetched from the resulting location specified by the Program counter.
If the zero flag is set, the program counter is incremented and the next instruction is executed.
The instruction at the address following the LOOP instruction is already loaded into the pipeline. The branch is taken after this instruction is executed.
B |ALT1/ALT2} O/VV | S | CY Zz 0 0 0 - * - *
B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if the register Ryo is negative, else reset. Z : Set if the register Ryo is zero, else reset.
Opcode: (MSB) (LSB)
LOOP Oo; Oo; 1/]1 1 1] 0} 0} (3CH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: In the following program, 00:8014 INC R, 00:8015 INC Re 00:8016 LOOP 00:8017 NOP 00:8018 ADDR, if Ry3 is 8014H and Ryo is other than 0001H, the Program jumps to 00:8014H after the NOP instruction is executed. If Ryo is 0001H, the jump does not happen and the instruction ADD is executed.
2-9-77
DESCRIPTION OF INSTRUCTIONS [ a
9.55 LSR
Operation:
D15 Steg Do CY
D15 Y DO Dreg
Description: This instruction shifts all bits in the source register one bit to the right and stores the result in the destination register. Bit 15 becomes “0” and the value of Bit 0 is stored in the carry flag.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro.
Flags affected:
B |ALT1/ALT2} OV | S CY Zz 0 0 0 - 0 * * B : Reset ALT1 : Reset ALT2 : Reset cS) : Reset CY : Set if Bit 0 in source register is “1”, else reset Zz : Set on zero result, else reset. Opcode: (MSB) (LSB) LSR 0} 0}0/0]0] 0] 1] 14 (03H)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: Under the following conditions,
Steg: Re; Dreg: Ro bit 15 bitO Rg: |1]0}1}1/0}1)0)1)0}0/ 1] 14] 1] 1] 1} 1} (B53FH) LSR execution results in:
bit15 bito CY Ro: [0]1[o]1]1 Jo] [o[+fofo]1]1]1] 1] 1] asrH) [7 |
2-9-78
9.56 MERGE
Operation: D15 bBo D8 D7 Do D15 D8 D7 R7LL Upper Byte Lower Byte ReL_[ Upper Byte | ]| | Lower Byte | | D15 Y
Descripti D8 D7 Do UpperByte | [| | LowerByte | |
ion: This instruction stores the high byte of Rz in the high byte of the destination register and the high byte of Rg in the low byte of the destination register.
The destination register is specified in advance using a WITH or TO instruction. When not specified, the register defaults to Ro.
Flags affected:
Opcode:
Machine Cycles: B |ALT1/ALT2| O/V Ss CY Z 0 0 0 * * * * B : Reset ALT1 : Reset ALT2 : Reset ON : Set if the result of (B6 or B7 or B14 or B15) is “4”, and reset if “O”. Ss : Set if the result of (B7 or B15) is “1”, and reset if “0”. CY : Set if the result of (B5 or B6 or B7 or B13 or B14 or B15) is “1”, reset if “0”. Z : Set if the result of (B4 or BS or B6 or B7 or B1Z or B13 or B14 or B15) is “1”, reset if “O” (MSB) (LSB) MERGE 0; 1] 1}1]0] 0] 0} Of (on)
ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-79
DESCRIPTION OF INSTRUCTIONS ]
Example: Under the following conditions:
Drag: Rg, R7=05AAH, Rg=FC33H
Rg becomes 05FCH and the sign, over flow, carry and zero flags are set when
MERGE
is executed.
2-9-80
9.57 MOVE R,, R,’ Operation: Rn’ > Ry (n, n’ = 0~15) Description: This instruction loads the contents of register R,’, specified in the second operand, to register R,, specified in the first operand.
Flags affected:
B |ALT1/ALT2} OV} S | CY Zz 0 0 0 - - : -
B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) : ~ 2n’H MOVE Rp, Br’ Oo} oOo} 1]}0 n’ (OH~FH) (2n’H) 0}; 0; 0}1 n (OH~FH) (1nH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Under the following conditions,
Ry 4= 4983H, Rg= 9264H
the register Rg becomes 4983H when
MOVE Rg, Ry4
is executed.
2-9-81
DESCRIPTION OF INSTRUCTIONS L a]
9.58 MOVE R,, #xx
MACRO INSTRUCTION
Operation: #xx > R, (n = 0~15, #xx=-32768~65535) (if unsigned, #xx=0~65535) Conditions: IF (-128<xx<127): (if unsigned, (Osxx<127) or then, use an IBT instruction (65408<xx<65535))
Description:
Example: else, use an IWT instruction.
This instruction directly loads hexadecimal immediate data into register R,, specified in the first operand. This is a macro instruction and is stored in memory as “IWT R,,, #xx” or “IBT R, #pp.” The assembler automatically recognizes whether this should be replaced with an IBT instruction or IWT instruction, depending upon the value of immediate data.
If immediate data is -128 ~ 127 (unsigned, 0~127 or 65408~65535), it is replaced with an IBT instruction. Otherwise, it is replaced with an IWT instruction. Refer to “IBT R,, #pp” or “IWT R,, #xx” for machine cycles, flags affected, and opcode.
MOVE Rg, #070H ;0070H—Rg_—(IBT Rg, #070H) MOVE Rg, #0A4H; O0A4H—>Rg _—(IWT Reg, #0A4H) MOVE Re, #-128; | FF80—Rg (IBT Re, #-128)
2-9-82
i!
9.59 MOVE R,, (xx)
MACRO INSTRUCTION
Operation:
Conditions:
Description:
Example: (xx) > Rp (low byte) (n=0~15, xx=0~FFFFH) (xxt1) — R,, (high byte)
If (QOOOHsxx<01FFH) and xx is even: then, use an LMS instruction else, use an LM instruction.
This instruction loads hexadecimal data contained in the game pak RAM address specified in the second operand and stores the data in register R,, specified in the first operand.. The RAMB instruction is used to specify the bank of the game pak RAM address (refer to RAMB).
This is a macro instruction and is stored in memory as “LM R,, (xx)” or “LMS R,, (yy).” The assembler automatically recognizes whether it should be replaced with an LM instruction or an LMS instruction, depending upon the value of the game pak RAM address specified.
When the game pak RAM address is an even number of 0~1FFH, it is replaced with an LMS instruction. Otherwise, it is replaced with an LM instruction. Refer to “LM Rp, (xx)” or “LMS R,, (yy)” for machine cycles, flags affected, and opcode.
Under the following conditions,
(70:BACCH) = 28H, (70:BACDH) = 96H, RAMBR=70H
the register Rg becomes 9628H when the following program is executed: MOVE Rg, (OBACCH) _;(70:BACCH)—>Re(Low Byte) (LM Ro, (OBACCH)) ;(70:BACDH)—>R,(High Byte)
2-9-83
DESCRIPTION OF INSTRUCTIONS e|
Also, under the following conditions,
(71:01AAH) = 32H, (71:01ABH) = 92H, RAMBR=71H
the register Rg becomes 9232H when the following program is executed:
MOVE Rg, (1AAH) 3(71:01AAH)—>R,(Low Byte) (LMS Rs, (01AAH)) 3(71:01ABH)—R,(High Byte)
2-9-84
9.60 MOVE (xx), R n
MACRO INSTRUCTION
Operation:
Conditions:
Description:
Example: R, (low byte) — (xx) (n=0~15, xx=0~FFFFH) R,, (high byte) —> (xxt1)
If (QOOOHSxx<01FFH) and xx is even: then, use an SMS instruction, else, use an SM instruction.
This instruction stores the contents (hexadecimal data) of register R, specified in the second operand in the game pak RAM address specified in the first operand. The RAMB instruction is used to specify the bank of the game pak RAM address (refer to “RAMB").
This macro instruction is stored in memory as “SM (xx), R,” or “SMS (yy), Rp.” The assembler automatically recognizes whether it should be replaced with an SM instruction or an SMS instruction, depending upon the value of the game pak RAM address specified.
When the game pak RAM address is an even number of 0~1FFH, it is replaced with an SMS instruction. Otherwise, it is replaced with an SM instruction. Refer to “SM (xx), R,” and “SMS (yy), R,” for machine cycles, flags affected, and opcode.
Under the following conditions,
Rg: BACDH, and RAMBR=71H when the following program is executed, MOVE (9CDEH),Ry —_—_;Rg (Low Byte)—3(71:9CDEH) (SM (9CDEH), Re) 3Rg (High Byte)—(71:9CDFH) the result is (71:9CDEH)=CDH, (71:9CDFH)=BAH
2-9-85
DESCRIPTION OF INSTRUCTIONS i | Also, under the following conditions,
Ro: 3248H, and RAMBR=70H when the following program is executed, MOVE = (136H), Ro ;Ro (Low Byte)—(70:0136H) (SMS (136H), Re) Ro (High Byte)—(70:0137H) the result is (70:0136H)=48H, (70:0137H)=32H
2-9-86
9.61 MOVEB R,, (R,’)
MACRO INSTRUCTION
Operation:
Conditions:
Description:
Example: (Rp’) > Rp (Low Byte) (n=0~15, n’=0~11) 00H —R, (High Byte)
If n=0: then, use only LDB instruction, else, use TO instruction and LDB instruction.
This instruction loads one byte of data located at the game pak RAM address equal to the contents of register R,’, specified by the second operand and stores this data in the register specified in the first operand. The high byte of the destination register is loaded with OOH. The register identified in the second operand is selectable from Ro~R,;. The RAMB instruction is used to specify the game pak RAM bank (refer to “RAMB”).
This macro instruction is stored in memory as “LDB (Rj,)” or “TO R,.” + “LDB (R,,).” The assembler automatically recognizes whether or not the TO instruction is required. When n does not equal 0, the TO instruction is added. Refer to “LDB (Rm)” and “TO R,,.” for machine cycles, flags affected, and opcode.
Under the following conditions,
R,=3482H, (70:3482H)=51H, RAMBR=70H
when the following program is executed,
MOVEB R7, (Ry) —_;(R1)—9R (Low Byte) (TO R7+LDB (R;)) ;00H—>R; (High Byte)
register R7 becomes 0051H.
Also, under the following conditions,
Rg=3581H, (70:3581H)=9AH, RAMBR=70H
when the following program is executed,
MOVEB Rp, (Rg) _;(Rg)—>Rp (Low Byte) (LDB (Rg)) ;00H—Ro (High Byte)
register Rp becomes O09AH.
2-9-87
DESCRIPTION OF INSTRUCTIONS [ J
9.62 MOVEB (R,’), Ry
MACRO INSTRUCTION
Operation: Rp (low byte) > (R,’) (n=1~15, n’=0~11) Conditions: If n=0: then, use only STB instruction, else, use FROM instruction and STB instruction.
Description: This instruction stores the contents of the low byte of register R,
Example: specified in the second operand at the game pak RAM address equal to the contents of register R,,’, specified in the first operand. The register identified in the first operand is selectable from Ro~R,1. The RAMB instruction is used to specify the game pak RAM bank (refer to “RAMB”).
This macro instruction is stored in memory as “STB (Rm)” or “FROM Rn” + “STB (R,,).” The assembler automatically recognizes whether or not the FROM instruction is required. When n does not equal 0, the FROM instruction is added. Refer to “STB (Rm) and “FROM Rn’” for machine cycles, flags affected, and opcode.
Under the following conditions,
R5=3843H, Ry4=94F1H, RAMBR=71H
when the following program is executed,
MOVEB (Ry), R5_ ;Rs (Low Byte)>(Ry,) (FROM Rs+STB (Ry4))
the result is (71:94F 1H)=43H.
Also, under the following conditions,
Ro=89E0H, R3=438BH, RAMBR=70H
when the following program is executed, MOVEB (Rz3),Ro Ro (Low Byte) (Rg) (STB (Rg)) the result is (70:438BH)=43H.
2-9-88
9.63 MOVES R,, R,’ Operation: Ry’ > Ra (n, n’ = 0~15) Description: This instruction loads the contents of register R,’, specified in the second operand, to register Rp, specified in the first operand. Flags are set according to the data loaded. (Refer to MOVE R,, R,’.)
Flags affected:
B {ALT1/ALT2} OV | S | CY Z 0 0 0 * * Z * B : Reset ALT1 : Reset ALT2 : Reset ON : Set if Bit 7 is “1”, else reset Ss : Set if Bit 15 is “1”, else reset Zz : Set when data is zero, else reset Opcode: (MSB) (LSB) 7 ~ 2n’H MOVES Ro, Pe’ Oo} o;1]0 n’ (OH~FH) ( ) 1]}o}14]4 n (OH~FH) (BnH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: When R; is 4983H and
MOVES Rio, Ry
is executed, the register Rig becomes 4983H and the overflow flag is set.
2-9-89
DESCRIPTION OF INSTRUCTIONS [ J
9.64 MOVEW R,, (R,’)
MACRO INSTRUCTION
Operation: (Rn’) > Rp, (Low Byte) (n=0~15, n’=0~11) (R,’t1) > R, (High Byte)
Description: This instruction loads hexadecimal data from the game pak RAM address equal to the contents of register R,,’ specified in the second operand and stores it into register R,, specified by the first operand. The game pak RAM address bank is specified using the RAMB instruction (refer to RAMB). This macro instruction is stored in memory as “LDW (R,,)” or ‘TO R,,” + “LDW (R,,).” The assembler automatically recognizes whether or not the TO instruction is required. When n is not equal to 0, the TO instruction is added. Refer to “LDW (R,,)” and “TO R,,” for machine cycles, flags affected, and opcode. Example: Under the following conditions, Rg=6480H, (71:6480H)=2EH, (71:6481H)=COH, RAMBR=71H and when the following program is executed,
MOVEW Rs, (Rg) ;(Rg)—>Re(Low Byte) (TO Rs + LDB (Rg)) :(Rg+1)—Rs(High Byte)
register R5 becomes CO2EH.
Also, under the following conditions,
Re=0822H, (70:0822H)=43H, (70:0823H)=96H, RAMBR=70H and when the following program is executed,
MOVEW Ro, (Re) 3(Re)—>Ro(Low Byte) (LDB (Reg)) 3(Rg+1)—Ro(High Byte)
register Rp becomes 9643H.
2-9-90
9.65 MOVEW (R,’), Ry
MACRO INSTRUCTION
Operation:
Conditions:
Description:
Example: Rp, (low byte) — (R,’) (n=0~15, n’=0~11) R, (high byte) —> (R," +1)
If n=0: then, use only STW instruction, else, use FROM instruction and STW instruction.
This instruction stores the contents (hexadecimal data) of register R, specified in the second operand into the game pak RAM address which is equal to the value of register R,,’ specified in the first operand. The game pak RAM address bank is specified using the RAMB instruction (refer to RAMB). The operand n’ can be a register from Ro~Ry4.
This macro instruction is stored in memory as “STW (Rm)” or “FROM R,,” + “STW (Rp).” The assembler automatically recognizes whether or not the FROM instruction is required. When n is not equal to 0, the FROM instruction is added. Refer to “STW (Rm) and “FROM R,” for machine cycles, flags affected, and opcode.
Under the following conditions,
Rg=BFAS3H, Ry9=4444H, RAMBR=71H
and when the following program is executed, MOVEW (Rio), Rg -Re(Low Byte)—»(Rjo) (FROM Ro+STW (Rjo)) 3Rg(High Byte)—>(Rj9+1) the result is (71:4444H)=A3H, (71:4445H)=BFH.
2-9-9]
DESCRIPTION OF INSTRUCTIONS
Also, under the following conditions,
Ro=3151H, Re=92A0H, RAMBR=71H
and when the following program is executed, MOVEW (Re), Ro —_-Ro (Low Byte)>(Rg) (STW (Re)) 3Ro (High Byte)—>(Rg+1)
the result is (71:92A0H)=51H, (71:92A1H)=31H.
2-9-92
Cc
9.66 MULT R, Operation: Steg (low byte) * Rp (low byte) > Dreg (n=0~15) Description: This instruction performs 8 x 8-bit signed multiplication using the low byte of the source register and the low byte of register Rp. The result is stored in the destination register.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, the source and destination registers default to Ro. The operand can be a register Ro~Ry5. Flags affected:
B |ALT1/ALT2] OVV |] S CY Z 0 0 0 - * : *
B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. Zz : Set on zero result, else reset. Opcode: ps (MSB) (LSB) MULT R, 1/0] 0/0 n (OH~FH) (8nH)
Machine Cycles: ROM execution time 3 or 5 cycles RAM execution time 3 or 5 cycles Cache RAM execution time 1 or 2 cycles
the register Rp becomes 0961H when
MULT R,
is executed.
2-9-93
DESCRIPTION OF INSTRUCTIONS [ J
9.67 MULT #n
Operation: Sreg (low byte) * #n Dieg (n=0~15) Description: This instruction performs 8 x 8-bit signed multiplication using the low byte of the source register and the immediate data specified in the operand #n. The result is stored in the destination register.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, the source and destination registers default to Ro.
The operand can be immediate data from 0~15.
Flags affected:
B_ |ALT1/ALT2} O/V Ss cY Zz 0 0 0 - * - * B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. Zz : Set on zero result, else reset.
Opcode: (MSB) (LSB)
0; 0} 1/1441] 14] 1] 0} (3EH) MULT #1 UT# TT Pofolo | m(OH-FH) | (nk)
Machine Cycles: ROM execution time 6 or 8 cycles RAM execution time 6 or 8 cycles Cache RAM execution time 2 or 3 cycles
Steg: Ra; Dreg:R4, Rg= 95C6H the register R, becomes FDF6H when
MULT #9
is executed.
2-9-94
[
9.68 NOP
Operation: PC <— PC+1 Description: This instruction causes the processor to idle for one cycle and increment the program counter by one.
Flags affected:
B |ALT1/ALT2| OV | S | CY Zz 0 0 (0) - cS B 2 B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
NOP 0; 0} 0/0 }|0/] 0} 0} 1] (O1H)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-95
DESCRIPTION OF INSTRUCTIONS [ J
9.69 NOT
Operation:
Description: Sreg — Dreg
This instruction calculates the 1’s complement of the source register and stores the result in the destination register.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, the source and destination registers default to Ro.
Flags affected:
B |ALT1/ALT2} OV | S cy Zz 0 0 0 5 * 5 * B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. Zz : Set on zero result, else reset.
Opcode: (MsB) (LSB)
NOT Oo; 1; 0;0/1 1} 1] 1} (4FH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
Example: Under the following conditions,
Steg: Ro: Dreg: Rig Bitt5 Bito Ro: [1] of 1[ 1] oO] 1] 1] 1] of 1] 1[ 0] 0] 4] o] o| (B764n)
the execution of
NOT
results in:
BitiS BitO Ry3:_O[ 1] of 0[ 1] of of of 1] of of 1] 1] Of 4] 1] (489BH)
2-9-96
‘SNES DEVELOPMENT MANUAL [
9.70 OR Rn
Operation: Steg OR Rn > Dreg (n=1~15) Description: This instruction performs logical bit-wise OR on corresponding bits of the source register and the register specified in the operand R,,. The result is stored in the destination register.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, the source and destination registers default to Ro. The operand can be a register Ry~R45. Flags affected:
B |ALT1/ALT2| OV] S | CY Zz 0 0 0 : * 5 7 B : Reset ALT1 : Reset ALT2 : Reset Sy : Set when the result is negative, else reset. Zz : Set on zero result, else reset.
Opcode: (MSB) (LSB) OR R, 1/1/ 0]0 n (1H~FH) (Cn)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-97
DESCRIPTION OF INSTRUCTIONS:
Example: Under the following conditions, Steg: Ra, Dreg: Rs Biti5 Bito R,:O[ 1] 1[0] of of 1] 4] Of 4] 1] 0] 1] of of 0] (6368h) Bitt5 Bito Ro: [0] of of 1] of 1] 1] of 1] of of 0] 1] 4] Of o| (168CH)
the register R; becomes: Bit15 Bito Rs: Oo] 1] 1[ 1] of 1] 4] 4] 4] 1] 1J 0] 1] 4] Of 0] (77ECH)
when
OR Re
is executed.
2-9-98
EE
9.71 OR #n
Operation:
Description:
Flags affected: Sreg OR #n > Dreg (n=1~15)
This instruction performs logical bit-wise OR on corresponding bits of the source register and the immediate data specified in the operand #n. The result is stored in the destination register.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, the source and destination registers default to Ro.
B |ALT1}ALT2} OV] S CY Zz 0 0 0 - * : * B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. Z : Set on zero result, else reset.
Opcode: (MSB) (LSB) 0} 0; 1}1}4] 14] 1] 0] (@EH) R # onan 114} 0/0] n(iH-FH) (CnH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Under the following conditions, Steg: Rz, Dreg: Rs Bit15 BitO R7:Lol 1] of 1] 4] 4] 1] 1] 1] 0] 1] 0] Of Of 4] o| (sFAzH) the register R5 becomes:
Bit15 Bito
Rs:Lol [of [4] 4] a] a] a] of s [oT of 4] 4] 1] Graze)
when
OR #5H is executed.
2-9-99
DESCRIPTION OF INSTRUCTIONS [
9.72 PLOT
Description: This instruction plots the color code specified by the COLOR or GETC instruction to locations X and Y specified by R, and Ro. After plotting, R, will be incremented.
Flags affected:
B |ALT1/ALT2} OV | S CY Z 0 ie) 0 - - - - B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) PLOT 0} 1/0}0}111] 0] 0} (4cH)
Machine Cycles: ROM execution time 3~48 cycles RAM execution time 3~51 cycles Cache RAM execution time 1~48 cycles
2-9-100
‘SNES DEVELOPMENT MANUAL
9.73 RAMB
Operation:
Description:
Flags affected: Steg > RAMBR This instruction moves the low byte of the source register into the game pak RAM bank register in order to specify the game pak RAM bank when transferring data between game pak RAM and multi-purpose registers. Note that the SCBR is used with the RAMBR to specify the bank for plotting. The game pak RAM bank register can only be changed with the RAMB instruction. The initial value of this register is invalid.
The source register is specified in advance using a FROM or WITH instruction. When not specified, the register defaults to Ro.
B |ALT1;/ALT2} OV] S | CY Zz
Opcode:
RAMB
Machine Cycles:
Example: B : Reset ALT1 : Reset ALT2 : Reset
(MSB) (LSB)
o}o}i1]i1}4]4] 4] 0} Ben
th1foft]a} 4] 4] 4] orH
ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles
Under the following conditions,
Steg: Rg, Rg= 0170H the RAM bank register becomes 70H when
RAMB
is executed.
2-9-101
DESCRIPTION OF INSTRUCTIONS ]
9.74 ROL
Operation:
cy D15 Steg Do
jnf+y SH
D1i5 Deg Do
eee
Description: This instruction shifts all bits in the source register one bit to the left. Bit 15 is shifted to the carry flag and the carry flag is shifted to Bit 0. The result is stored in the destination register.
The source and destination registers are specified in advance usi ing a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro.
Flags affected:
B |ALT1]ALT2] O/VV Ss CY Zz 0 0 0 . * * * B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if result is negative, else reset. CY : Set if Bit 15 in source register is “1”, else reset. Zz : Set on zero result, else reset. Opcode: (MSB) (LSB)
ROL 0} 0/0}/0]0]} 1] 0} Of (o4n)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-102
Example: Under the following conditions,
Steg: Re, Dreg: Ra CY biti5S bito Rg: |9}0/0);1)1/1}0]14 171] (1D4BH)
executing ROL results in: CY bit15 bit [o] rg: [ofo[s}1]t]o]1]o = = (3A97H)
2-9-103
DESCRIPTION OF INSTRUCTIONS EE |
9.75 ROMB
Operation: Steg > ROMBR Description: This instruction moves the low byte of the source register into the game pak ROM bank register in order to specify the game pak ROM bank when loading data from game pak ROM. The game pak ROM bank register can only be changed with the ROMB instruction, but the contents can not be read. The initial value of this register is invalid.
The source register is specified in advance using a FROM or WITH instruction. When not specified, the source register defaults to Ro.
Flags affected:
B |ALT1/ALT2} OV | S CY Zz 0 te) 0 - - - : B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB) ROMB oj} o}1}1}1}4] 14) 4] GH 1} a} o}1]4] 4} 1] 14) (FH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Under the following conditions, Sreg: Rs, Rg= 0046H the ROMBR becomes 46H when
ROMB
is executed.
2-9-104
9.76 ROR
Operation:
D15 Steg bo CY +p... at]
D15 Dreg Do
eee
Description: This instruction shifts all bits in the source register one bit to the right. Bit 0 is shifted to the carry flag and the carry flag is shifted to Bit 15. The re
The source and sult is stored in the destination register.
destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and dest
Flags affected: ination registers default to Ro.
B |ALT1/ALT2] OV | S | CY Zz CMs SEs Ea=
B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if result is negative, else reset. cy : Set if Bit 0 in source register is “1”, else reset. Zz : Set on zero result, else reset.
Opeode: (MSB) (LSB)
ROR 1,0] 0/1 /0/ 1/1) 1} @7H)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-105
DESCRIPTION OF INSTRUCTIONS om
Example: Under the following conditions, Sreg: Ryo, Dreg: Ryo
CY bits bito [1] ro:0Jo]o]4]+]+ [0] 4 Jo] + [ofo]i]ols = (1D4BH)
executing ROR results in:
cy bits bito Ryo 1/0 ]o]o]1]1]1]o]1]0]1]/o]o]1]o (8EASH)
2-9-106
9.77 RPIX
Operation: PIXEL COLOR from game pak RAM Dreg Description: This instruction loads the color data stored in game pak RAM and stores it in the destination register. Because data in game pak RAM is in the PPU format, it is first read to the color matrix and subsequently stored in the destination register. The data is then read from game pak RAM to the color matrix.
Flags affected:
B_ |ALT1/ALT2| O/V Ss CY Z 0 0 0 - a : B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. Zz : Set on zero result, else reset. Opcode: (MSB) (LSB) Oo} of 141] 1] 14) 0} 1] (3DH) Oo} 1); 0/0] 1 1] 0} 0] (4CH) *
RPIX
Machine Cycles: ROM execution time 24~80 cycles RAM execution time 24~78 cycles Cache RAM execution time 20~74 cycles
2-9-107
DESCRIPTION OF INSTRUCTIONS J
9.78 SBCR,
Operation:
Description:
Flags affected: Steg — Rn - CY Flag— Dreg (n=0~15) This instruction subtracts the contents of the register specified in the operand and the carry flag from the source register and stores the result in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro.
B |ALT1/ALT2| OV | S | CY Zz * 0 0 0 * * * B : Reset ALT1 : Reset ALT2 : Reset ON : Set on signed overflow, else reset Ss : Set when the result is negative, else reset. cY : Set on unsigned overflow, else reset Zz : Set on zero result, else reset
Opcode: (MSB) (LSB)
o}o/1]1/]4]14] 0] 1] (DH) SCBR, w o}1]1]o n (OH~FH) (6nH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Under the following conditions: Steg: R4, Dreg: Rg, R4=5682H, R5=3609H, CY Flag=1 register Rg becomes 2079H and the carry flag is reset when
SBC Rs
is executed.
2-9-108
9.79 SBK
Operation:
Description:
Flags affected: Sieg — (Last game pak RAM address used) The game pak RAM address accessed when data is transferred between game pak RAM and a multi-purpose register, for example the LD and ST instructions, is buffered internally. When data is to be stored to the last accessed game pak RAM address, this buffer is used so that the address does not have to be specified again in the op code. This is called “bulk processing”.
This instruction uses bulk processing to store the word data contained in the source register to RAM.
The source register is specified in advance using a WITH or FROM instruction. When not specified, the register defaults to Ro.
B JALT1;ALT2} OV} S cY Zz 0 0 0 - - : : B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB) SBK | 1} 0/0}]1]0j]0/ 0} 0} (0H)
Machine Cycles:
Example: ROM execution time 3~8 cycles RAM execution time 7~11 cycles Cache RAM execution time 1~6 cycles
Under the following conditions,
(70:3230H)=51H, (70:3231H)=49H, RAMBR=70H
executing,
LM Rj, (3230H) INC R, SBK
will result in Ry=4952H, (70:3230H)=52H, and (70:3231H)=49H.
2-9-109
DESCRIPTION OF INSTRUCTIONS
9.80 SEX
Operation: D15 D8 D7 D6 DO Steg Upper Byte Lower Byte
reg Lower Byte D15 D8 D7 D6 Do
Description: This instruction performs signed expansion of the low byte of the
Flags affected: source register, converts it to word data and stores it in the destination register.
This means that Bit 7 of the source register is stored in Bits 8 ~ 15 of the destination register. The low byte is loaded directly from the source register to the destination register.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro.
B |ALT1/ALT2| O/V Ss CY Z 0 0 0 = * : *
B : Reset ALT1 : Reset ALT2 : Reset Ss : Set if the result is negative, else reset. Zz : Set on zero result, else reset.
Opcode: (MSB) (LSB)
SEX | 1/0] 0/1
Machine Cycles: 1] 0] 1] @5H)
ROM execution time RAM execution time Cache RAM execution time 1 cycles
2-9-110 3 cycles 3 cycles
LE
Example: Under the following conditions,
Steg: Rs, Dreg:R1, Re= 9284H
the register R, becomes FF84H when
SEX
is executed.
2-9-111
DESCRIPTION OF INSTRUCTIONS J
9.81 SM (xx), Ry Operation: R,, (low byte) — (xx) (n=0~15, xx=0~65535) Rp (high byte) — (xx+1) When the contents of R, are even, the high byte is stored at address (R,+1); When the contents of R, are odd, the high byte is stored at address (R,-1). Description: This instruction stores the contents of register R,, specified in the second operand, to the game pak RAM address which equals the value of (xx), the first operand. The RAM bank must be specified with the RAMB instruction. (Refer to RAMB.)
Flags affected:
ALT1/ALT2} OV | S cy Zz 0 0 0 a 5 S 5
B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB) o}o}4])1]4] 4] 14] 0} en) SM (x), Ry LAL tT 114 n(OH~FH) | (FnH) x (OOH~FFH) (ADRS Lower Byte)
x (OOH~FFH) (ADRS Upper Byte)
Machine Cycles: ROM execution time 12~17 cycles RAM execution time 16~20 cycles Cache RAM execution time 4~9 cycles
2-9-112
9.82 SMS (yy), R,
Operation:
Description:
Flags affected: Rp, (low byte) > (yy) (n=0~15, yy=0~510*) R,, (high byte) > (yy+1)
*Note: Selectable RAM address (yy) must be an even number.
Similar to SM, this instruction loads word data from register R,, specified in the second operand, and stores it in the game pak RAM address equal to the value specified in the first operand, yy. The selectable address is an even number 0~510. The bank is specified with the RAMB instruction. This instruction uses the short address method to reduce the number of bytes in the instruction code.
B |ALT1/ALT2| OV | S | CY Zz
Opcode:
SMS (yy), Ry B : Reset ALT1 : Reset ALT2 : Reset (MSB) (LSB) ojo} 1}1]4]4] 1] 0] ger tfatata n(OH~FH) | (AnH) kk (OOH~FFH) (Address)
[Short address method]
Machine Cycles:
yy =kkx2
ROM execution time 9~14 cycles RAM execution time 13~17 cycles Cache RAM execution time 3~8 cycles
Because this instruction uses the RAM buffer, the number of machine cycles varies depending upon the program.
2-9-113
DESCRIPTION OF INSTRUCTIONS
Example: Under the following conditions,
Register R,;= ABCDH, RAMBR=71H
the following program is execution,
Syntax Opcode
SMS (194H), Ry4 3E ABCA
will result in (71:0194H) = CDH, (71:0195H) = ABH. The relationship between syntax and opcode is as shown above.
2-9-114
9.83 STB (Rm) Operation: Steg (low byte) — (Rm) (m=0~11) Description: This instruction stores the low byte of the source register in the game pak RAM address equal to the value in the register specified in the operand. The operand can be a register Ro~Ry1. The game pak RAM bank must be specified with the RAMB instruction.
The source register is specified in advance using a WITH or FROM instruction. When not specified, the register defaults to Ro.
Flags affected:
B |ALT1/ALT2} OV | S | CY Z 0 0 0 - : : -
B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
o}o;}1]1}41] 4] 0} 1] (3DH) STB (R, (Fm) Fotos t+ | m(OH-BH) | (mx)
Machine Cycles: ROM execution time 6~9 cycles RAM execution time 8~14 cycles Cache RAM execution time 2~5 cycles
Sreg:R5, Rg=216CH, Re=9A34H, RAMBR=70H and when the following program is executed,
STB (Re)
the result is (70:9A34H)=6CH.
2-9-115
DESCRIPTION OF INSTRUCTIONS ]
9.84 STOP
Operation: 0 > Go flag Description: This instruction resets the GSU GO flag and stops the processor. When this instruction is executed and the GSU stops, the Super NES IRQ signal is initiated.
Flags affected:
B |ALT1/ALT2|] OV | S | CY Zz 0 0 0 : 5 : 5 B : Reset ALT1 : Reset ALT2 : Reset Opcode: (MSB) (LSB) STOP 0} 0]/o0};o]o 0} 0] (OOH)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
2-9-116
9.85 STW (Rm) Operation: Sieg (low byte) —> (Rm) (m=0~11) Steg (high byte) — (Rm +1) When the contents of Rp, are even, the high byte is stored at address (Rm+1); When the contents of Ry, are odd, the high byte is stored at address (R,,-1). Description: This instruction stores the contents of the source register into the game pak RAM address specified in the operand, Ry. The RAM bank must be specified with the RAMB instruction. The operand can be a register from Ro~Rj4. The source register is specified in advance using WITH or FROM. When not specified, the register defaults to Ro.
Flags affected:
B |ALT1/ALT2} OV | S CY Zz 0 0 0 - - - - B : Reset ALT1 : Reset ALT2 : Reset
Opcode: (MSB) (LSB)
STW (Rm) o;o}1]1 m (OH~BH) (3mH)
Machine Cycles: ROM execution time 3~8 cycles RAM execution time 7~11 cycles Cache RAM execution time 1~6 cycles
2-9-117
DESCRIPTION OF INSTRUCTIONS
9.86 SUB R,
Operation:
Description:
Flags affected: Steg — Rn Dreg (n=0~15) This instruction subtracts the contents of the register specified in the operand from the source register and stores the result in the destination register.
Source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro.
The operand can be any of registers Ro~Ry5.
ALT1}ALT2| O/VV | S | CY Z 0 0 0 * * * *
Opcode:
SUBR,
Machine Cycles:
Example: B : Reset ALT1 : Reset ALT2 : Reset ON : Set on signed overflow, else reset. Ss : Set if the result is negative, else reset CY : Set on unsigned overflow, else reset (Set on adder overflow.) Zz : Set if result is zero.
(MSB) (LSB) o} 1} 1]0 n (OH~FH) (6nH)
ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles
Under the following conditions:
Sieg: Rs, Deg: Rg, Rg=735AH, Rg=426BH the register Ry becomes 30EFH when
SUB Rg
is executed.
2-9-118
9.87 SUB #n
Operation: Steg — #n — Dreg (n=0~15) Description: This instruction subtracts the immediate data specified in the operand from the contents of the source register and stores the result in the destination register.
The source and destination registers are specified in advance using a WITH, FROM, or TO instruction. When not specified, the source and destination registers default to Ro.
The operand can be immediate data from 0-15.
Flags affected:
B |ALT1/ALT2| OV | S | CY Zz 0 0 0 * + rs * B : Reset ALT1 : Reset ALT2 : Reset ON : Set on signed overflow, else reset. Ss : Set if the result is negative, else reset CY : Set on unsigned borrow, else reset Z : Set if resultts zero.
Opcode: (MSB) (LSB) Oo} o}1{]1}14]4] 14] 0] (@EH) B #n oO Oo; 1) 1/0 n (OH~FH) (6nH)
Machine Cycles: ROM execution time 6 cycles RAM execution time 6 cycles Cache RAM execution time 2 cycles Example: Under the following conditions:
Steg: Ro, Dreg: Ro, Ro=329BH the register Ro becomes 3291H when
SUB #10
is executed.
2-9-119
DESCRIPTION OF INSTRUCTIONS f J
9.88 SWAP
Operation: Steg (low byte) > Dreg (high byte) Sreg (high byte) > Dreg (low byte) Description: This instruction swaps the low byte and high byte of the source register and stores the result in the destination register.
The source and destination registers are specified in advance using a FROM, WITH, or TO instruction. When not specified, the source and destination registers default to Ro.
Flags affected:
B {ALT1/ALT2) OV | S | CY Zz 0 0 0 5 c E B : Reset ALT1 : Reset ALT2 : Reset Ss : Set when the result is negative, else reset. Zz : Set on zero result, else reset. Opcode: (MSB) (LSB) SWAP. Oo; 1;/0;0/1 1} 0] 1} (4DH) *
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: Under the following conditions: Sreg: Rg; Dreg: Rig, Rg=48D0H the register R,3 becomes D048H when
SWAP.
is executed.
2-9-120
9.89 TOR,
REGISTER PREFIX INSTRUCTION
Operation: If B Flag = 0 then set Dyeg to Ry, else Steg > Ry (n=0~15) Description: This instruction specifies register R, as the destination register. The destination register can be any of registers Ro ~ Ris.
If the B flag has been set (i.e., if a WITH instruction was executed immediately prior to this instruction) the contents of the source register are loaded to R,, (refer to MOVE R,, Ry’).
Flags affected:
B_ JALT1/ALT2} O/V Ss CY Zz
No flags affected
Opcode: (MSB) (LSB) TOR, 0; o}o0]1 n (OH~FH) (in)
Machine Cycles: ROM execution time 3 cycles RAM execution time 3 cycles Cache RAM execution time 1 cycles Example: Under the following conditions: Re= 7106H, Ry=0028H
the register Rg becomes 712EH when the following program is executed.
FROM Re TO Ry ADD Rg
2-9-121
The last 135 pages are left out of this plain copy. The reader at this address has every page; it needs JavaScript.