General information | |
---|---|
Launched | 1983 |
Common manufacturer(s) | |
Performance | |
Max. CPU clock rate | 1 MHz to 14 MHz |
History | |
Predecessor(s) | MOS Technology 6502 |
The Western Design Center (WDC) 65C02 microprocessor is an enhanced CMOS version of the popular nMOS-based 8-bit MOS Technology 6502. It uses less power than the original 6502, fixes several problems, and adds new instructions. The power usage is on the order of 10 to 20 times less than the original 6502 running at the same speed; [1] its reduced power consumption has made it useful in portable computer roles and industrial microcontroller systems. The 65C02 has also been used in some home computers, as well as in embedded applications, including medical-grade implanted devices.
Development of the WDC 65C02 began in 1981 [lower-alpha 1] with samples released in early 1983. [lower-alpha 2] The 65C02 was officially released sometime shortly after. [2] WDC licensed the design to Synertek, NCR, GTE Microcircuits, and Rockwell Semiconductor. Rockwell's primary interest was in the embedded market and asked for several new commands to be added to aid in this role. These were later copied back into the baseline version, at which point WDC added two new commands of their own to create the W65C02. Sanyo later licensed the design as well, and Seiko Epson produced a further modified version as the HuC6280.
Early versions used 40-pin DIP packaging, and were available in 1, 2 and 4 MHz versions, matching the speeds of the original nMOS versions. Later versions were produced in PLCC and QFP packages, as well as PDIP, and with much higher clock speed ratings. The current version from WDC, the W65C02S-14 has a fully static core and officially runs at speeds up to 14 MHz when powered at 5 volts.
The 65C02 is a low cost, general-purpose 8-bit microprocessor (8-bit registers and data bus) with a 16-bit program counter and address bus. The register set is small, with a single 8-bit accumulator (A), two 8-bit index registers (X and Y), an 8-bit status register (P), and a 16-bit program counter (PC). In addition to the single accumulator, the first 256 bytes of RAM, the "zero page" ($0000
to $00FF
), allow faster access through addressing modes that use an 8-bit memory address instead of a 16-bit address. The stack lies in the next 256 bytes, page one ($0100 to $01FF), and cannot be moved or extended. The stack grows backwards with the stack pointer (S) starting at $01FF and decrementing as the stack grows. [3] It has a variable-length instruction set, varying between one and three bytes per instruction. [1]
The basic architecture of the 65C02 is identical to the original 6502, and can be considered a low-power implementation of that design. At 1 MHz, the most popular speed for the original 6502, the 65C02 requires only 20 mW, while the original uses 450 mW, a reduction of over twenty times. [4] The manually optimized core and low power use is intended to make the 65C02 well suited for low power system-on-chip (SoC) designs. [1]
A Verilog hardware description model is available for designing the W65C02S core into an application-specific integrated circuit (ASIC) or a field-programmable gate array (FPGA). [5] As is common in the semiconductor industry, WDC offers a development system, which includes a developer board, an in-circuit emulator (ICE) and a software development system. [6]
The W65C02S–14 is the production version as of 2023 [update] , and is available in PDIP, PLCC and QFP packages. The maximum officially supported Ø2 (primary) clock speed is 14 MHz when operated at 5 volts, indicated by the –14 part number suffix (hobbyists have developed 65C02 homebrew systems that run faster than the official rating). The "S" designation indicates that the part has a fully static core, a feature that allows Ø2 to be slowed down or fully stopped in either the high or low state with no loss of data. [7] Typical microprocessors not implemented in CMOS have dynamic cores and will lose their internal register contents (and thus crash) if they are not continuously clocked at a rate between some minimum and maximum specified values.
|
VPB
) output indicates when interrupt vectors are being addressedMLB
) output indicates to other bus masters when a read-modify-write instruction is being processedWAI
) and SToP (STP
) instructions reduce power consumption, decrease interrupt latency and enable synchronization with external eventsThe W65C02S may be operated at any convenient supply voltage (VDD) between 1.8 and 5 volts (±5%). The data sheet AC characteristics table lists operational characteristics at 5 V at 14 MHz, 3.3 V or 3 V at 8 MHz, 2.5 V at 4 MHz, and 1.8 V at 2 MHz. This information may be an artifact of an earlier data sheet, as a graph indicates that typical devices are capable of operation at higher speeds than suggested by the AC characteristics table, and that reliable operation at 20 MHz should be readily attainable with VDD at 5 volts, assuming the supporting hardware will allow it.
The W65C02S support for arbitrary clock rates allows it to use a clock that runs at a rate ideal for some other part of the system, such as 13.5 MHz (digital SDTV luma sampling rate), 14.31818 MHz (NTSC colour carrier frequency × 4), 14.75 MHz (PAL square pixels), 14.7456 (baud rate crystal), etc., as long as VDD is sufficient to support the frequency. Designer Bill Mensch has pointed out that FMAX is affected by off-chip factors, such as the capacitive load on the microprocessor's pins. Minimizing load by using short signal tracks and fewest devices helps raise FMAX. The PLCC and QFP packages have less pin-to-pin capacitance than the PDIP package, and are more economical in the use of printed circuit board space.
WDC has reported that FPGA realizations of the W65C02S have been successfully operated at 200 MHz.[ citation needed ]
Although the 65C02 can mostly be thought of as a low-power 6502, it also fixes several bugs found in the original and adds new instructions, addressing modes and features that can assist the programmer in writing smaller and faster-executing programs. It is estimated that the average 6502 assembly language program can be made 10 to 15 percent smaller on the 65C02 and see a similar improvement in performance, largely through avoided memory accesses through the use of fewer instructions to accomplish a given task. [1]
The original 6502 has 56 instructions, which, when combined with different addressing modes, produce a total of 151 opcodes of the possible 256 8-bit opcode patterns. The remaining 105 unused opcodes are undefined, with the set of codes with low-order 4-bits with 3, 7, B or F left entirely unused, the code with low-order 2 having only a single opcode. [8]
On the 6502, some of these leftover codes actually perform computation. Due to the way the 6502's instruction decoder works, simply setting certain bits in the opcode cause parts of the instruction processing to take place. Some of these opcodes immediately crash the processor, while other perform useful functions and were even given unofficial assembler mnemonics by some programmers. [9]
The 65C02 adds new opcodes that use some of these previously undocumented instruction slots. For example, $FF is used for the new BBS
instruction. Those which remain truly unused are equivalent to NOP
s. 6502 programs using those opcodes will not work on the 65C02. [1]
The original 6502 had several errata when initially launched. Early versions of the processor had no ROR
(rotate right) instruction and MOS Technology manuals did not document it either. ROR
was implemented very early in the production run and the vast majority of machines using the processor support this instruction. [10]
A bug that is present in all NMOS variants of the 6502 involves the jump instruction when using indirect addressing. In this addressing mode, the target address of the JMP
instruction is fetched from memory, the jump vector, rather than being an operand to the JMP
instruction. For example, JMP ($1234)
would fetch the value in memory locations $1234 (least significant byte) and $1235 (most significant byte) and load those values into the program counter, which would then cause the processor to continue execution at the address stored in the vector.
The bug appears when the vector address ends in $FF, which is the boundary of a memory page. In this case, JMP
will fetch the most significant byte of the target address from $00 of the original page rather than $00 of the new page. Hence JMP ($12FF)
would get the least significant byte of the target address at $12FF and the most significant byte of the target address from $1200 rather than $1300. The 65C02 corrected this issue. [1]
More of an oversight than a bug, the state of the (D)ecimal flag in the NMOS 6502's status register is undefined after a reset or interrupt. This means programmers have to set the flag to a known value in order to avoid any bugs related to arithmetic operations. As a result, one finds a CLD
instruction (CLear Decimal) in almost all 6502 interrupt handlers, as well as early in the reset code. The 65C02 automatically clears this flag after pushing the status register onto the stack in response any interrupt or in response to a hardware reset, thus placing the processor back into binary arithmetic mode. [11]
During decimal mode arithmetic, the NMOS 6502 will update the (N)egative, o(V)erflow and (Z)ero flags to reflect the result of underlying binary arithmetic, that is, the flags are reflecting a result computed prior to the processor performing decimal correction. In contrast, the 65C02 sets these flags according to the result of decimal arithmetic, at the cost of an extra clock cycle per arithmetic instruction. [11]
When executing a read-modify-write (R-M-W) instruction, such as INC addr
, all NMOS variants will do a double write on addr, first rewriting the current value found at addr and then writing the modified value. This behavior can result in difficult-to-resolve bugs if addr is a hardware register. This may occur if the hardware is watching for changes to the value in the register and then performs an action, in this case, it will perform two actions, one with the original value and then again with the new value. The 65C02 instead performs a double read of addr, followed by a single write.
When performing indexed addressing, if indexing crosses a page boundary all NMOS variants will read from an invalid address before accessing the correct address. As with a R-M-W instruction, this behavior can cause problems when accessing hardware registers via indexing. The 65C02 fixed this problem by performing a dummy read of the instruction opcode when indexing crosses a page boundary. However, this fix introduced a new bug[ citation needed ] that occurs when the base address is on an even page boundary (which means indexing will never cross into the next page). With the new bug, a dummy read is performed on the base address prior to indexing, such that LDA $1200,X
will do a dummy read on $1200 prior to the value of X being added to $1200. Again, if indexing on hardware register addresses, this bug can result in undefined behavior.
If an NMOS 6502 is fetching a BRK (software interrupt) opcode at the same time a hardware interrupt occurs, the BRK will be ignored as the processor reacts to the hardware interrupt. The 65C02 correctly handles this situation by servicing the interrupt and then executing BRK.
The 6502 has two indirect addressing modes which dereference through 16-bit addresses stored in page zero:
LDA ($10,X)
, adds the X register to the given page zero address before reading the 16-bit vector. In this example, if X is 5, it reads the 16-bit address from location $15/$16. This is useful when there is an array of pointers in page zero.LDA ($10),Y
adds the Y register to the 16-bit vector read from the given page zero address. For instance, if Y is 5, and $10/$11 contains the vector $1000, This reads the value from $1005. This performs pointer-offset addressing.A downside of this model is that if indexing is not needed but the address is in the zero page, one of the index registers must still be set to zero and used in one of these instructions. The 65C02 added a non-indexed indirect addressing mode LDA ($10)
to all instructions that used indexed indirect and indirect indexed modes, freeing up the index registers. [12]
The 6502's JMP
instruction had a unique (among 6502 instructions) addressing mode known as "absolute indirect" that read a 16-bit value from a given memory address and then jumped to the address in that 16-bit value. For instance, if memory location $A000 holds $34 and $A001 holds $12, JMP ($A000)
would read those two bytes, construct the value $1234, and then jump to that location.
One common use for indirect addressing is to build branch tables, a list of entry points for subroutines that can be accessed using an index. For instance, a device driver might list the entry points for OPEN
, CLOSE
, READ
, etc in a table at $A000. READ
is the third entry, zero indexed, and each address requires 16-bits, so to call READ
one would use something similar to JMP ($A004)
. If the driver is updated and the subroutine code moves in memory, any existing code will still work as long as the table of pointers remains at $A000.
The 65C02 added the new "indexed absolute indirect" mode which eased the use of branch tables. This mode added the value of the X register to the absolute address and took the 16-bit address from the resulting location. For instance, to access the READ
function from the table above, one would store 4 in X, then JMP ($A000,X)
. This style of access makes accessing branch tables simpler as a single base address is used in conjunction with an 8-bit offset. [12] The same could be achieved in the NMOS version using indexed indirect mode, but only if the table was in the zero page, a limited resource. Allowing these to be constructed outside zero page not only lessened the demand for this resource, but also allowed the tables to be constructed in ROM.
In addition to the new addressing modes, the "base model" 65C02 also added a set of new instructions. [13]
INC
and DEC
with no parameters now increment or decrement the accumulator. This was an odd oversight in the original instruction set, which only included INX
/DEX
,INY
/DEY
and INC addr
/DEC addr
. Some assemblers use the alternate forms INA
/DEA
or INC A
/DEC A
. [13] STZ addr
, STore Zero in addr. Replaces the need to LDA #0;STA addr
and doesn't require changing the value of the accumulator. As this task is common in most programs, using STZ
can reduce code size, both by eliminating the LDA
as well as any code needed to save the value of the accumulator, typically a PHA
PLA
pair. [14] PHX
,PLX
,PHY
,PLY
, push and pull the X and Y registers to/from the stack. Previously, only the accumulator and status register had push and pull instructions. X and Y could only be stacked by moving them to the accumulator first with TXA
or TYA
, thereby changing the accumulator contents, then using PHA
. [15] BRA
, branch always. Operates like a JMP
but uses a 1-byte relative address like other branches, saving a byte. The speed is often the same as the 3 cycle absolute JMP
unless a page is crossed which would make the BRA
version 1 cycle longer (4 cycles). [16] As the address is relative, it is also useful when writing relocatable code, [14] a common task in the era before memory management units.Both WDC and Rockwell contributed improvements to the bit testing and manipulation functions in the 65C02. WDC added new addressing modes to the BIT instruction that was present in the 6502, as well two new instructions for convenient manipulation of bit fields, a common activity in device drivers.
BIT
in the 65C02 adds immediate mode, zero page indexed by X and absolute indexed by X addressing. [13] Immediate mode addressing is particularly convenient in that it is completely non-destructive. For example:
LDA $1234
BIT #%00010000
may be used in place of:
LDA $1234
AND #%00010000
The AND
operation changes the value in the accumulator, so the original value loaded from $1234 is lost. Using BIT
leaves the value in the accumulator unchanged, so subsequent code can make additional tests against the original value, avoiding having to re-load the value from memory.
In addition to the enhancements of the BIT
instruction, WDC added two instructions designed to conveniently manipulate bit fields:
TSB addr
and TRB addr
, Test and Set Bits and Test and Reset Bits..A
) is logically ANDed with memory at addr, which location may be zero page or absolute. The Z flag in the status register is conditioned according to the result of the logical AND—no other status register flags are affected. Furthermore, bits in addr are set (TSB) or cleared (TRB) according to the mask in .A
. Succinctly, TSB performs a logical OR
after the logical AND
and stores the result of the logical OR
at addr, whereas TRB stores the results of the logical AND
at addr. In both cases, the Z flag in the status register indicates the result of .A AND addr
before the content of addr is changed. TRB and TSB thus replace a sequence of instructions, essentially combining the BIT
instruction with additional steps to save the computational changes, but in a way that reports the status of the affected value before it is changed. [1] Rockwell's changes added more bit manipulation instructions for directly setting and testing any bit, and combining the test, clear and branch into a single opcode. The new instructions were available from the start in Rockwell's R65C00 family, [17] but was not part of the original 65C02 specification and not found in versions made by WDC or its other licensees. These were later copied back into the baseline design, and were available in later WDC versions.
Rockwell-specific instructions are:
SMBbit#zp
and RMBbit#zp
. Set or Reset (clear) bit number bit# in zero page byte zp.SMB1 $12
which sets bit 1 in zero-page address $12. Some assemblers treat bit# as part of the instruction's operand, e.g., SMB 1,$12
, which has the advantage of allowing it to be replaced by a variable name or calculated number. [14] BBSbit#zp,addr
and BBRbit#zp,addr
. Branch on Bit Set/Reset.BBS1 $12,addr
which branches to the address label addr if bit 1 of the byte at zero-page address $12 is set. Some assemblers treat bit# as part of the instruction's operand, e.g., BBS 1,$12,addr
, which has the advantage of allowing it to be replaced by a variable name or calculated number. As is the case with RMB and SMB, BBR and BBS replace a sequence of three instructions. [14] In addition to the new commands above, WDC also added the STP
and WAI
instructions for supporting low-power modes.
STP
, STop the Processor, halted all processing until a hardware reset was issued. This could be used to put a system to "sleep" and then rapidly wake it with a reset. Normally this would require some external system to maintain main memory, and it was not widely used.
WAI
t had a similar effect, entering low-power mode, but this instruction woke the processor up again on the reception of an interrupt. Previously, handling an interrupt generally involved running a loop to check if an interrupt has been received, sometimes known as "spinning", checking the type when one is received, and then jumping to the processing code. This meant the processor was running during the entire process, even when no interrupts were occurring.
In contrast, in the 65C02, interrupt code could be written by having a WAI
followed immediately by a JSR
or JMP
to the handler. When the WAI
was encountered, processing stopped and the processor went into low-power mode. When the interrupt was received, it immediately processed the JSR
and handled the request.
This had the added advantage of slightly improving performance. In the spinning case, the interrupt might arrive in the middle of one of the loop's instructions, and to allow it to restart after returning from the handler, the processor spends one cycle to save its location. With WAI
, the processor enters the low-power state in a known location where all instructions are guaranteed to be complete, so when the interrupt arrives it cannot possibly interrupt an instruction and the processor can safely continue without spending a cycle saving state.
The 65SC02 is a variant of the WDC 65C02 without bit instructions. [18] [19]
The Data General Nova is a series of 16-bit minicomputers released by the American company Data General. The Nova family was very popular in the 1970s and ultimately sold tens of thousands of units.
The 6309 is Hitachi's CMOS version of the Motorola 6809 microprocessor, released in late 1982. It was initially marketed as a low-power version of the 6809, without reference to its many internal improvements.
The MOS Technology 6502 is an 8-bit microprocessor that was designed by a small team led by Chuck Peddle for MOS Technology. The design team had formerly worked at Motorola on the Motorola 6800 project; the 6502 is essentially a simplified, less expensive and faster version of that design.
The Motorola 6809 ("sixty-eight-oh-nine") is an 8-bit microprocessor with some 16-bit features. It was designed by Motorola's Terry Ritter and Joel Boney and introduced in 1978. Although source compatible with the earlier Motorola 6800, the 6809 offered significant improvements over it and 8-bit contemporaries like the MOS Technology 6502, including a hardware multiplication instruction, 16-bit arithmetic, system and user stack registers allowing re-entrant code, improved interrupts, position-independent code and an orthogonal instruction set architecture with a comprehensive set of addressing modes.
The Z80 is an 8-bit microprocessor introduced by Zilog as the startup company's first product. The Z80 was conceived by Federico Faggin in late 1974 and developed by him and his 11 employees starting in early 1975, before going on sale in July 1976. The processor is software-compatible with the Intel 8080 but with several enhancements and at a lower price. Like the 8080, the Z80 was mainly aimed at embedded systems, but it became one of the most widely used CPUs in home computers of the late 1970s and early 1980s. The Zilog Z80 was also common in military applications, musical equipment, and coin-operated arcade games of the era, including Pac-Man.
The Intel MCS-51 is a single chip microcontroller (MCU) series developed by Intel in 1980 for use in embedded systems. The architect of the Intel MCS-51 instruction set was John H. Wharton. Intel's original versions were popular in the 1980s and early 1990s, and enhanced binary compatible derivatives remain popular today. It is a complex instruction set computer, but also has some of the features of RISC architectures, such as a large register set and register windows, and has separate memory spaces for program instructions and data.
The Intel 8085 ("eighty-eighty-five") is an 8-bit microprocessor produced by Intel and introduced in March 1976. It is the last 8-bit microprocessor developed by Intel.
The COSMAC is an 8-bit microprocessor family introduced by RCA. It is historically notable as the first CMOS microprocessor. The first production model was the two-chip CDP1801R and CDP1801U, which were later combined into the single-chip CDP1802. The 1802 represented the majority of COSMAC production, and today the entire line is known simply as the RCA 1802.
Addressing modes are an aspect of the instruction set architecture in most central processing unit (CPU) designs. The various addressing modes that are defined in a given instruction set architecture define how the machine language instructions in that architecture identify the operand(s) of each instruction. An addressing mode specifies how to calculate the effective memory address of an operand by using information held in registers and/or constants contained within a machine instruction or elsewhere.
The zero page or base page is the block of memory at the very beginning of a computer's address space; that is, the page whose starting address is zero. The size of a page depends on the context, and the significance of zero page memory versus higher addressed memory is highly dependent on machine architecture. For example, the Motorola 6800 and MOS Technology 6502 processor families treat the first 256 bytes of memory specially, whereas many other processors do not.
National Semiconductor's SC/MP for Simple Cost-effective Micro Processor, is an early 8-bit microprocessor which became available in April 1976. It was designed to allow systems to be implemented with the minimum number of additional support chips. SC/MP included a daisy-chained control pin that allowed up to three SC/MP's share a single main memory to produce a multiprocessor system, or to act as controllers in a system with another main central processing unit (CPU). Three versions were released over its lifetime, SCMP-1 through 3, the latter two also known as INS8060 and INS8070.
The Signetics 2650 was an 8-bit microprocessor introduced in July 1975. According to Adam Osborne's book An Introduction to Microprocessors Vol 2: Some Real Products, it was "the most minicomputer-like" of the microprocessors available at the time. A combination of missing features and odd memory access limited its appeal, and the system saw little use in the market.
The HuC6280 8-bit microprocessor is Japanese company Hudson Soft's improved version of the WDC 65C02 CPU, an upgraded CMOS version of the popular NMOS-based MOS Technology 6502 8-bit CPU, manufactured for Hudson by Seiko Epson and NEC. The most notable product using the HuC6280 is NEC's TurboGrafx-16 video game console.
The CSG 65CE02 is an 8/16-bit microprocessor developed by Commodore Semiconductor Group in 1988. It is a member of the MOS Technology 6502 family, developed from the CMOS WDC 65C02 released by the Western Design Center in 1983.
The 65xx family of microprocessors, consisting of the MOS Technology 6502 and its derivatives, the WDC 65C02, WDC 65C802 and WDC 65C816, and CSG 65CE02, all handle interrupts in a similar fashion. There are three hardware interrupt signals common to all 65xx processors and one software interrupt, the BRK instruction. The WDC 65C816 adds a fourth hardware interrupt—ABORT, useful for implementing virtual memory architectures—and the COP software interrupt instruction, intended for use in a system with a coprocessor of some type.
The Mitsubishi 740, also known as MELPS 740, is a series of 8-bit CMOS microcontrollers and microprocessors with an enhanced MOS Technology 6502 compatible core based on the expanded WDC 65C02. The ICs were manufactured by Mitsubishi Electric during the 1980s and 1990s.
National Semiconductor's IPC-16A PACE, short for "Processing and Control Element", was the first commercial single-chip 16-bit microprocessor, announced in late 1974. It was a single-chip implementation of their early 1973 five-chip IMP-16 architecture, which in turn had been inspired by the Data General Nova minicomputer. To the basic IMP-16, PACE added a new operational mode, "byte mode", which was useful for working with 8-bit data like ASCII text.
The ST6 and ST7 are 8-bit microcontroller product lines from STMicroelectronics. They are commonly used in small embedded applications like washing machines.
The W65C816S is a 16-bit microprocessor (MPU) developed and sold by the Western Design Center (WDC). Introduced in 1983, 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 65C816 is the CPU for the Apple IIGS and, in modified form, the Super Nintendo Entertainment System.
The Mostek MK5065 was an 8-bit microprocessor introduced by Mostek in early 1974. The design was originally developed by Motorola for use in an Olivetti electronic calculator, and was licensed to Mostek for use in non-calculator roles. It featured three sets of processor registers, allowing it to switch to an interrupt handler in a single cycle, and a wait-for-data mode that aided direct memory access.
N, V, and Z flags were incorrect after decimal operation (but C was ok).