Open main menu

The W65C816S (also 65C816 or 65816) is an 8/16-bit microprocessor (MPU) developed and sold by the Western Design Center (WDC). Introduced in 1983,[1] the W65C816S is an enhanced version of the WDC 65C02 8-bit MPU, itself a CMOS enhancement of the venerable MOS Technology 6502 NMOS MPU. The 65816 was the CPU for the Apple IIGS and Super Nintendo Entertainment System.

WDC 65C816
W65C816S8PG-14 lg.jpg
W65C816S in PDIP40 package
ProducedFrom 1983 to today
Common manufacturer(s)
Max. CPU clock rate1 MHz to 14 MHz
Instruction set6502
Package(s)
  • 40-pin DIP, others

The 65 in the part's designation comes from its 65C02 compatibility mode, and the 816 signifies that the MPU has selectable 8– and 16–bit register sizes. In addition to the availability of 16 bit registers, the W65C816S features extended memory addressing to 24-bits, supporting up to 16 megabytes of random-access memory, an enhanced instruction set, and a 16 bit stack pointer, as well as several new electrical signals for improved system hardware management.

At reset, the W65C816S starts in "emulation mode," meaning it substantially behaves as a 65C02. Thereafter, the W65C816S may be switched to "native mode" with a two instruction sequence, causing it to enable all enhanced features, yet still maintain a substantial degree of backward compatibility with most 65C02 software. However, unlike the PDIP40 version of the 65C02, which is a pin-compatible replacement for its NMOS ancestor, the PDIP40 W65C816S is not pin-compatible with any other 6502 family MPU.

Related to the W65C816S is the W65C802, which had the same internal structure and 16-bit support, but used a 40-pin layout compatible with the original 6502. This allowed it to be used as a drop-in replacement in certain roles, but its lack of new address pins limited it to 64 kB of memory. It did not see extensive use and is no longer produced.

HistoryEdit

 
PLCC-44 version of W65C816S microprocessor, shown mounted on a single-board computer.

In 1981, Bill Mensch, founder and CEO of WDC, began development of the 65C02 with his production partners, primarily Rockwell Semiconductor and Synertek. The primary goal of the 65C02 effort was to move from the original 6502's NMOS process to the 65C02's CMOS, which would allow it to run at much lower power levels, somewhere between ​110 and ​120 when running at the same clock speeds. A number of new opcodes and bug fixes were also worked into the design.[2]

Development of the W65C816S commenced in 1982 after Mensch consulted with Apple Computer on a new version of the Apple II series of personal computers that would, among other things, have improved graphics and sound. Apple wanted an MPU that would be software compatible with the 6502 then in use in the Apple II but with the ability to address more memory, and to load and store 16 bit words. The result was the 65C816, finished in March 1984, with samples provided to both Apple and Atari in the second half of the year and full release in 1985.[3] Mensch was aided during the design process by his sister Kathryn, who was responsible for part of the device's layout.

The same process also led to the 65C802, which was identical inside to the 65C816. Both were produced on the same fabrication lines and diverged only during the last metalization stages when the chip was being connected to the external pins. In the 65C802, those pins had the same layout as the original 6502, which allowed it to be used as a drop-in replacement while still allowing the 16-bit processing of the CPU to be used. However, as it used the original pinout it had only 16 addressing pins, and could therefore only access 64 kB of external memory.[4] Typically, when hardware manufacturers designed a project from the ground up, they used the 65C816 rather than the 65C802, resulting in the latter being withdrawn from production.

Apple subsequently integrated the 65C816 into the Apple IIGS computer. The basic 65C816 design was second-sourced by GTE, Sanyo and others from the mid-to-late 1980s to the early 1990s.

In the 1990s, both the 65C816 and 65C02 were converted to a fully static core, which made it possible to completely stop the processor clock without losing data in any of the registers. This feature, along with the use of asynchronous static RAM, made it possible to produce designs that used minimal power when in a standby state.

As of 2019, the W65C816S is available from WDC in a 40 pin PDIP or PLCC44 package, as well as a core for ASIC integration (for example Winbond's W55V9x series of TV Edutainment ICs). WDC, itself a fabless semiconductor company, works with various foundries to produce the W65C816S, as well as other compatible products. Discrete processors are available through a number of electronics distributors. For designers who wish to include W65C816S functionality into a custom ASIC, WDC offers RTL (register-transfer level) code in Verilog.

 
W65C802P

FeaturesEdit

WDC 65816 features:

WDC 65816 registers
23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 (bit position)
Main registers
B A Accumulators
Index registers
X X index
Y Y index
DP 0 0 0 0 0 0 0 0 Direct Page register
0 0 0 0 0 0 0 0 SP Stack Pointer
DB 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Data Bank register
Program counter
PB PC Program Counter
Status register
N V m x D I Z C SR Status register
  • Fully static CMOS design for low power consumption (300µA at 1MHz) and increased noise immunity.
  • Wide operating voltage range: 1.8V to 5.0V ± 5%.
  • Wide operating frequency range, up to 14 MHz, using a single-phase clock source.
  • Emulation mode allows software compatibility with the 65C02, excepting undocumented opcodes (which in 65C02 act as NOPs).
  • 24-bit memory addressing provides access to 16MB of memory space.
  • 16-bit ALU, accumulator (A), stack pointer (SP), and index registers (X and Y).
  • 16-bit Direct Page register (D).
  • 8-bit Data Bank (DB) and Program Bank (PB) registers, generating bits 16-23 of 24-bit data and code addresses.
  • Valid Data Address (VDA) and Valid Program Address (VPA) outputs for dual cache and cycle steal DMA implementation.
  • Vector Pull (VPB) output to indicate when an interrupt vector is being addressed.
  • Abort (ABORTB) input and associated vector supports processor repairs of bus error conditions, such as page faults and memory access violations.
  • Separate program and data bank registers allow program segmentation or 16MB linear addressing (data only).
  • Direct register and stack relative addressing provides capability for reentrant, recursive and re-locatable programming.
  • 24 addressing modes—13 original 6502 modes with 92 instructions using 256 op codes, including most new opcodes implemented in the 65C02.
  • Block-copy instructions, allowing rapid copying of data structures from one area of RAM to another with minimal code.
  • Wait-for-Interrupt (WAI) and Stop-the-Clock (STP) instructions further reduce power consumption, decrease interrupt latency and allows synchronization with external events.
  • Co-Processor (COP) instruction with associated vector supports co-processor configurations, e.g., floating point processors
  • Reserved "escape" (WDM) instruction for future two-byte opcodes and a link to future designs. (WDM is the initials of W65C816S designer William D. Mensch.)

Comparison with earlier modelsEdit

Two modesEdit

The 65C816 had two modes, "emulation mode" in which the 16-bit operations and registers were invisible and the chip appeared to be an original 6502, down to the same cycle timings for the opcodes, and "native mode" which made all of the additional features visible. The CPU automatically returned to emulation mode when it was powered on or reset, which allowed it to replace a 6502 assuming one made the required changes for the different pin layout.[2]

16-bit registersEdit

The most obvious change to the 65C816 when running in 16-bit mode is the expansion of the various registers from 8-bit to 16-bit values. This affects the accumulator (A), the X and Y index registers, and the stack pointer (SP). It does not affect the program counter (P), which was always 16-bit.[5]

When running in native mode, two bits in the status register change their meaning. In the original 6502, bits 4 and 5 were not used, although bit 4 was sometimes referred to as the B(reak) flag. In native mode, bit 4 becomes the x flag and bit 5 becomes the m flag. These bits control whether or not the index registers (x) and/or accumulator/memory (m) are 8-bit or 16-bit values. Zeros in these bits indicate 16-bit values, ones indicate 8-bit values. These bits are normally not present when the chip is started up, but are switched on and set to one when switched to native mode.[5]

It might not be immediately obvious why one would want to use the now 16-bit registers in 8-bit mode; however, switching to 8-bit mode using the new SEP (SEt bit in Processor status) and REP (REset) instructions means that all subsequent instructions accessing those registers will only read a single byte instead of two. For instance, if the m bit is set to 1, when an LDA $1234 instruction is issued, only a single byte at address $1234 will be read, thereby reducing the number of cycles needed to execute the instruction.[6] This is particularly useful when dealing with 8-bit character data, for instance.[7]

When running in 16-bit mode, operations on the registers effect all 16-bits. For instance, doing a left shift (ASL) will shift all 16 bits.[8]

24-bit addressingEdit

The other major change to the system while running in native mode is that the memory model is expanded to a 24-bit format from the original 16-bit format of the 6502. This is handled using 8-bit offset registers, the Data Bank Register (DBR) and the Program Bank Register (PBR). Addresses in the code remain in the original 16-bit format, but the values in the DBR and PBR are prepended to form a 24-bit address in main memory. This means that instructions can access data within the 64 kB page (or bank as they referred to it), and if data outside that page needs to be accessed, the DBR has to change. Likewise, instructions can lie anywhere in memory by using the PBR, but they can only branch or jump to instructions within their bank.[5]

A further addition to the register set is the Direct Page Register (D), which set the base address for what was formerly called the zero page, but now referred to as the direct page. The direct page offers a special addressing mode that requires only one byte, which can offer significantly improved performance when used wisely. In the 6502 the direct page was always the first 256 bytes of memory, thus "zero page", whereas the 16-bit D register offset that to any location in a 24-bit memory.[9]

Switching between modesEdit

The current mode of operation is stored in the emulation bit. There were not enough bits left in the status register to hold the new mode bit, so a unique solution was used. The mode bit was left "invisible", unable to be directly accessed. The new XCE (eXchange Carry with Emulation) exchanges the value of the emulation bit with the C(arry) bit, bit 0, in the status register. For instance, if one wants to enter native mode after the processor has started up, one would use CLC to CLear the Carry bit, and then XCE to write it to the emulation bit.[10] Returning to 6502 mode uses SEC;XCE.[7]

When the CPU switches to native mode, the upper 8-bits of the registers are initially set to zero. These can be read and written as complete 16-bit values from that point (assuming the x and m are in 16-bit mode). When the system switches back to 8-bit mode, any value in the upper 8-bits is maintained and will "return" when the system switches back to native.[11]

ApplicationsEdit

Systems based on 65816 variants:

It is also used in the C-One and SuperCPU enhancements for the Commodore 64.

See alsoEdit

ReferencesEdit

CitationsEdit

BibliographyEdit

  • Eyes, David; Lichty, Ron (1986). Programming the 65816 - including the 6502, 65C02, 65802. Prentice Hall. ISBN 978-0893037895.

Further readingEdit

External linksEdit

This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.