Difference between revisions of "6502"

From SEGGER Wiki
Jump to: navigation, search
m
m
 
(4 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
For those really interested in hardware design of a CPU, the Javascript simulator might be interesting http://www.visual6502.org/JSSim/index.html
 
For those really interested in hardware design of a CPU, the Javascript simulator might be interesting http://www.visual6502.org/JSSim/index.html
 +
Another really interesting site is Monster 6502: They build a complete, working transistor-scale replica of the classic MOS 6502 microprocessor. https://monster6502.com/
 +
The main designer was Chuck Peddle, https://en.wikipedia.org/wiki/Chuck_Peddle
 +
== What is so great about the 6502? ==
 +
The 6502 was the first affordable microprocessor. Developed in 1976, it was sold at a fraction of the price of the Intel 8080, helping to create and make "home" computers such as the Apple ][ affordable.
 +
Despite its simple design, it achieved an astonishing performance, with a 1MHz 6502 achieving similar performance as a 4 MHz Z80.
 +
All of that has been achieved with just about 3200 transistors.
 +
== Programming ==
 +
The 6502 is a real 8-bit machine, with very few registers.
 +
=== Registers ===
 +
* PC - 16 bit Program counter
 +
* S - 8 bit stack pointer. Stack is always located in the first page, so from 0x100 to 0x1FF
 +
* ACC - 8 bit accumulator
 +
* X - 8 bit index register
 +
* Y - 8 bit index register
 +
* Flags - 8 bit Flag register
 +
 +
=== Sweet 16 ===
 +
Some programs have been using [[Sweet 16]], a pseudo processor implemented originally by Steve Wozniak https://en.wikipedia.org/wiki/Steve_Wozniak
 +
Sweet 16 was a pseudo 16-bit processor, with 16 16-bit registers. It required 32-bytes in the Zero page of the 6502, to hold the values of these registers
 +
and needed less instructions than the 6502 for most programs. Typical programs written in SWEET-16 needed about half the size and 5 to 10 times as much time
 +
as pure 6502 assembly code. The Sweet 16 executer was implemented in the ROM of the original Apple ][.  6502 assembler and Sweet 16 could be mixed easily:
 +
Sweet 16 code was inlined and simply preceeded by a function call to the executer, which was located at a known address (0xF689 or in Apple speech $F689)
 +
could easily be started by a subroutine call.
 +
Despite its simplicity, Sweet 16 achieved an amazing code density, which is still hard to beat today.
 +
For more information on SWEET-16, see http://www.6502.org/source/interpreters/sweet16.htm

Latest revision as of 18:38, 8 September 2019

The 6502 CPU is an 8-bit processor designed in the mid 70s. It has been used in various home computers and consoles at the time, amongst them the Apple II. The core (or a variation of it) is still in use in some Microcontrollers.

An excellent article exists on Wikipedia: https://en.wikipedia.org/wiki/MOS_Technology_6502

For those really interested in hardware design of a CPU, the Javascript simulator might be interesting http://www.visual6502.org/JSSim/index.html Another really interesting site is Monster 6502: They build a complete, working transistor-scale replica of the classic MOS 6502 microprocessor. https://monster6502.com/ The main designer was Chuck Peddle, https://en.wikipedia.org/wiki/Chuck_Peddle

What is so great about the 6502?

The 6502 was the first affordable microprocessor. Developed in 1976, it was sold at a fraction of the price of the Intel 8080, helping to create and make "home" computers such as the Apple ][ affordable. Despite its simple design, it achieved an astonishing performance, with a 1MHz 6502 achieving similar performance as a 4 MHz Z80. All of that has been achieved with just about 3200 transistors.

Programming

The 6502 is a real 8-bit machine, with very few registers.

Registers

  • PC - 16 bit Program counter
  • S - 8 bit stack pointer. Stack is always located in the first page, so from 0x100 to 0x1FF
  • ACC - 8 bit accumulator
  • X - 8 bit index register
  • Y - 8 bit index register
  • Flags - 8 bit Flag register

Sweet 16

Some programs have been using Sweet 16, a pseudo processor implemented originally by Steve Wozniak https://en.wikipedia.org/wiki/Steve_Wozniak Sweet 16 was a pseudo 16-bit processor, with 16 16-bit registers. It required 32-bytes in the Zero page of the 6502, to hold the values of these registers and needed less instructions than the 6502 for most programs. Typical programs written in SWEET-16 needed about half the size and 5 to 10 times as much time as pure 6502 assembly code. The Sweet 16 executer was implemented in the ROM of the original Apple ][. 6502 assembler and Sweet 16 could be mixed easily: Sweet 16 code was inlined and simply preceeded by a function call to the executer, which was located at a known address (0xF689 or in Apple speech $F689) could easily be started by a subroutine call. Despite its simplicity, Sweet 16 achieved an amazing code density, which is still hard to beat today. For more information on SWEET-16, see http://www.6502.org/source/interpreters/sweet16.htm