6502 and 65816
This is a processor with a very dramatic fate, no other processor can compare with it. Its appearance and introduction were accompanied by very large events in scope and consequences. I will list some of them:
- the weakening of the giant Motorola company, which for some time exceeded the capabilities of Intel;
- the destruction of the independent company MOS Technology;
- the cessation of the 6502 development and its stagnant production with little or no modernization.
It all started with the fact that Motorola for unknown reasons refused to support the initiative of young engineers, who offered to improve the overall rather mediocre processor 6800. They had to leave Motorola and continue their work in a small but promising MOS Technology company, where they soon prepared two processors, the 6501 and 6502, both of them (like almost all processors of that time) were fabricated using NMOS technology. The first one was pin-compatible with the 6800, but in other details they were identical. The 6501/6502 team was able to successfully introduce a new chip production technology, which radically reduced the cost of new processors. In 1975, MOS Technology could offer the 6502 for $25, while the starting price for the Intel 8080 and Motorola 6800 was $360 in 1974. In 1975, Motorola and Intel lowered prices, but they were still close to $100. MOS Technology specialists claimed that their processor was up to 4 times faster than the 6800. I find this questionable: the 6502 can work much faster with memory, but the 6800's second accumulator greatly accelerated many calculations. I can assume on estimation that the 6502 was on average no more than 2 times faster. Motorola launched a lawsuit against its former employees – they allegedly used many of the company's technological secrets. During the trial it was possible to establish that one of the engineers who had left Motorola took some confidential documents on the 6800, acting contrary to the attitudes of his colleagues. Whether it was his own act or there were still some guiding forces behind him is still unknown. For this and other unclear reasons, Motorola indirectly won the case and MOS Technology whose financial capabilities were very small, was forced to pay a substantial amount of $200,000 and to abandon production of the 6501. Intel in a similar situation with Zilog acted quite differently. Although it must be admitted that MOS Technology was sometimes too risky when trying to use the big money that Motorola spent on promoting the 6800 for its own purposes.
Further, the legendary Commodore company and its no less legendary founder Jack Tramiel appeared in the 6502 story, in the shadows of whom was the figure of the chief financier of the company determining its policy – a man named Irving Gould. Jack got a loan from Irving and with this money, using a few to put it mildly unscrupulous tactics, forced MOS Technology to become a part of Commodore. After that and possibly against the wishes of Tramiel, who was forced to give in to Gould, the development of the 6502 almost stopped, despite the fact that even in 1976 it was possible to produce prototypes of the 6502 with operating frequencies up to 10 MHz. Although the message about this appeared only many years later from a man named Bill Mensch, who was with the team that left Motorola and sometimes made loud but by and large empty statements and played a rather ambiguous role in the fate of the 6502. The main developer of the 6502 Chuck Peddle was forever removed from the development of processors. The 6502 continued to be produced not only at Commodore but also at Western Design Center (WDC) created by Bill Mensch. It is fascinating that none of the former 6502 team worked with him in the future.
The continuing drama around the 6502 was not over. In 1980, a short anonymous article appeared in Rockwell's AIM65 Interactive magazine stating that all 6502's carry a dangerous bug called the JMP (xxFF). The tone of the article suggests something completely out of the ordinary. Subsequently this attitude moved to Apple regarding the issue and became a kind of mainstream. Although a "bug" strictly speaking it was not. Of course for a specialist accustomed to the comfortable processors of large systems of those years one of the features that is quite relevant and even useful among microprocessors, could seem something annoying, a bug. But in fact this behavior of hurting someone's feelings was described in the official documentation from 1976, and in the textbooks on programming published before the appearance of the mentioned article. The "bug" was eliminated by Bill Mensch, who made the 65С02 (CMOS 6502) supposedly by 1983, i.e. after the official release of the 65816. While Intel, Motorola and others had already made 16-bit processors of new generations, the 6502 was only microscopically improved and made artificially partially incompatible with itself. In addition to eliminating the "bug", a number of changes were made, which in particular led to a change in the course of executing several instructions. These instructions became slower in a cycle, but at the same time they became more correct in some far-fetched academic sense. But it must be admitted that several new instructions turned out to be expected and useful. On the other hand, the absolute majority of the new instructions only occupied the code space, adding almost nothing to the capabilities of the 6502, which left fewer new codes for possible further upgrades. Commodore and Japanese Ricoh (manufacturer of the very popular game consoles NES) did not accept these changes. The author of this material himself has encountered several times the problem of this “bug”, although knowing nothing about it, he was writing programs for the Commodores. There was an incompatibility, he had to change the codes, to do a conditional assembly. The code for the 65C02 turned out to be more cumbersome and slower. Then I raised this question on the forum 6502.org, where some participants had familiarity with the Apple ][ computers. I asked if anyone could give an example when the aforementioned "bug" crashed the program. I received only emotional and general comments, a specific example was never offered.
The 65C02 was licensed to many companies, in particular NCR, GTE, Rockwell, Synertek, and Sanyo. The 6512 was a 65C02 variant which was used in later BBC Micro models. Atari used the NMOS 6502. Synertek and Rockwell companies in addition to the CMOS 6502, also produced the NMOS 6502. By the way the NMOS 6502 has its own set of undocumented instructions, the nature of which is completely different from the secret commands of the 8085. In the 6502 these instructions appeared as a side effect of the technology used, so most of them are rather useless. But several instructions for example, loading or unloading two registers with one command at once, and some others can make the code faster and more compact.
There were other attempts to modernize the 6502. In 1979, an article appeared that for the Atari computers, the 6509 processor was being prepared for production (not to be confused with the later Commodore's processor with the same name), in which command execution acceleration by 25% and many new instructions were expected. For unknown reasons the production of this processor never took place. Commodore conducted only microscopic upgrades. There, in particular they switched to HMOS technology and the manufacture of static cores, which allowed slowing down of the processors. From the point of view of programming, the most interesting was the processor 6509 which, albeit in a very primitive form, with the help of only two instructions specially allocated for this purpose allows addressing up to 1 MB of memory. In the super-popular Commodore 64 and 128, there were the 6510/8510 processors, and in the less successful 264 series – the 7501/8501. These processors had 6 and 7 embedded I/O bit-ports respectively, while the 7501/8501 did not support non-masked interrupts. Rockwell produced a version of the 65C02 extended by their own 32 operations for one-bit values (similar to the z80's bit instructions). However, as far as I know such processors were not used in computers, and these bit instructions themselves were more likely to be used only in embedded systems. This extension was made by Bill Mensch.
The last scene of the drama with the participation of the 6502 was featured in the prevention of computers based on the 6502 with a frequency of 2 MHz on the US market in the first half of the 80's. This affected the English BBC Micro, their manufacturing company Acorn made a large batch of computers for the United States, but as it turned out, in vain. Some kind of lock was triggered and the computers had to be urgently redone to European standards. Almost American, but formally Canadian computers Commodore CBM II (1982), despite some problems (in particular, compliance with the standards for electrical equipment), were nevertheless admitted. Perhaps it was due to a fact that they did not have graphic modes and even color text which made them little threat to American market mainstreams and even the stylish Porsche design could not compensate for this. The latest in the list of losers was the 100% American Apple III (1980) – it is known that Steve Jobs like Apple's management in general did a lot to prevent this computer from being successful. Steve demanded obviously impracticable specifications and the management asked for unrealistic deadlines. Will we ever know their motives? It became possible to eliminate the flaws of the Apple III in the Apple III Plus (1983), but the Apple’s management quietly closed the project in 1984 because of their reluctance to have a competition with the Macintosh computer. Only in 1985, when the era of 8-bit technology began to go away, did the Commodore 128 appear which could use in one of its modes the 6502 at 2 MHz clock. But even here it turned out to be more of a joke since this mode was practically not supported and there are practically no programs for it. Only in the second half of the 80's in the United States there began production of accelerators for the Apple II and since 1988 the Apple IIc+ model with a 4 MHz processor. Why did it happen that way? Perhaps because the 6502 at 2 or 3 MHz (and these were already produced at the very beginning of the 80's) could successfully compete with systems based on the Intel 8088 or Motorola 68000 in a number of tasks and especially games. In 1991, the willful decision of Commodore closed an interesting albeit belated project, the C65 based on the 4510 processor with a frequency of 3.54 MHz. The 4510 is the fastest 6502, made only in 1988, it finally carried out the previously mentioned optimization of cycles which gave a 25% increase in speed. Thus, the processor in the C65 is close in speed to the 6502 systems at 4.5 MHz. Surprisingly, this fastest 6502 with an extended set of instructions (in some detail this extension turned out to be more convenient than in the 65816) has never been used anywhere else.
The Commodore C128 and Apple III Plus had a MMU that allowed them to use several stacks and zero pages, to address more than 64 KB of memory, etc. The C128's MMU was artificially trimmed to work with only 128KB of memory. For the BBC Micro computers the second processor boards were produced with the 6502 at 3 MHz (1984) and 4 MHz (1986).
|Anti-advertising – multiple Porsche PETs in the apartment of the villain of The Jewel of the Nile – The Apple only era in Hollywood had not yet come|
Now a few words about the instruction system of the 6502. The main feature of this processor is that it was made almost as fast as possible, with almost no extra clock cycles which are especially numerous in the 8080/8085/z80/8088/68000 processors. In fact, it was the main concept of RISC-architecture processors that appeared later under the direct influence of the 6502. The same concept dominates starting with the 80486, and among Intel processors. In addition, the 6502 responded very quickly to interrupts, which made it very useful in some embedded systems. The 6502 has one accumulator and two index registers, in addition, the first 256 bytes of memory can be used in dedicated commands either as faster memory or as a set of 16-bit registers (which are almost identical in their functionality to the BC and DE registers in the 8080/z80) for pretty powerful ways to address memory locations. Some arithmetic commands (shifts, rotation, increment, and decrement) can be used with memory directly, without using registers. There are no 16-bit instructions – this is a 100% 8-bit processor. It supports all the basic flags but the parity flag which is typical only for the Intel's architecture. There is one more special flag of the low-useful decimal mode. Intel and Motorola processors use special corrective instructions for working with decimal numbers, and the 6502 can switch to decimal mode which makes its speed advantage with decimal numbers even more significant than with binary ones. Very impressive for the 6502 is the presence of a table multiplication of 8-bit operands with a 16-bit result in less than 30 cycles, with an auxiliary table size of 2048 bytes. One of the slowest 6502's operations is a block memory copy, it can take more than 14 cycles per byte.
The 6502 can work in parallel with another device, for example another 6502. As far as I know, such dual-processor systems have never been produced, instead of the second processor a video controller was usually used, which shared memory with the 6502.
The 65816 was released by WDC in 1983. Interesting is the fact that some specifications of the new processor Bill Mensch received from Apple. Of course, this was a big step forward, but clearly belated and with large architectural flaws. The 65816 was not considered by anyone as a competitor for the main processors of Intel or Motorola – it was already a minor outsider, which was already somehow programmed to be set to further lose its positions. The 65816 had two important advantages – it was relatively cheap and almost compatible with the still very popular 6502. In subsequent years, Bill Mensch didn’t even try to somehow improve his brainchild, do cycle optimization, replace the zero page addressing by extended one using the Z register (this was done in the 4510), add at least multiplication, etc. WDC only increased the limiting clock speeds, reaching 14 MHz by the mid-90's (this processor was used in the popular accelerator for the C64, the SuperCPU at a frequency of 20 MHz). However, even now (2019!) WDC for some reason, offers the 65816 only at the same 14 MHz. The 65816 can use up to 16 MB of memory, but the addressing methods used for this look far from optimal. For example: index registers can be only 8 or 16 bit, the stack can be placed only in the first 64 KB of memory, only there you can use the convenient short addressing of the direct page (the generalization of zero page addressing), working with memory above 64 KB is comparatively awkward, etc. The 65816 has a 16-bit ALU but an 8-bit data bus, so it is only about 50% faster than the 6502 with arithmetic operations. Nevertheless, the 65816 was released in more than a billion units. Indeed, some instructions of the 65816 clearly fill the gaps in the 6502 architecture, for example, the commands for block copying of memory in 7 clock cycles per byte. I can also add that the 65816 uses almost all instruction codes, 255 out of 256. The last unused code is for future long instructions that have not yet appeared.
The Apple IIx in the development of which Steve Wozniak was actively involved had to use the 65816. However, it was possible to start mass production of this processor only in 1984 and the first batches of it were defective, which caused excessive delays and eventually the closure of the entire project.
The 65802 is another version of the 65816, which uses a 16-bit address bus and a pin layout compatible with the 6502. An upgrade for the Apple II based on this processor was offered, but slight acceleration with such an upgrade can only be obtained with specially written programs.
The 6502 was used in a large number of computer systems, the most popular of which were the 8-bit Commodore, Atari, Apple, and NES. It is interesting that the 6502 was also used in the keyboard controller of the Commodore Amiga, and two 6502's at 10 MHz were used in the high-performance Apple Macintosh IIfx. Here it is impossible not to mention the Atari game consoles, produced from 1977 to 1996 – about 35 million of them were sold! The 65816 was used in the rather popular Apple IIgs computer, in the Super NES gaming console, and also in the rare Acorn Communicator computer.
In 1984, an article in Byte magazine about a bad copy of the Apple ][ computer, the Agat, made in the USSR appeared in the background of pictures with red banners, Lenin and marching soldiers. This article cited a curious price for this computer of $17,000 (it was an absurd amount, the real price was about 4000 rubles) and ironically indicated that Soviet manufacturers would have to dramatically lower the price if they wanted to sell their product in the West. The Agat was used mainly in school education. The older Agat models were almost 100% compatible with the Apple ][ and had some pretty useful extensions.
One can only try to fantasize about what would have happened if the 6502 had developed at the same pace as its competitors. It seems to me that the gradual moving of zero-page memory to registers, and the gradual expansion of the command system with simultaneous optimization of cycles would allow The Terminator 6502 to remain in the lead in terms of performance until the early 90's. Introducing 16-bit mode and then 32-bit, would allow more memory and faster commands to be used. Would its competitors have been able to oppose this?
I would like to finish with some general philosophical arguments. Why the 6502 was slowed down in its development and deprived of a much brighter future? Maybe due to the fact that this development really could very much press large firms and create a completely new reality. Was the 6502 team set up for this? In my humble opinion, rather no, they just wanted to make a better processor.
Edited by Richard BN and Dr Jefyll