6502#

The MOS 6502 is an 8-bit microprocessor that was first introduced in 1975. It was used in a wide range of home computers and game consoles during the late 1970s and early 1980s. The 6502 was a popular choice for designers due to its low cost, simplicity, and power efficiency. It was used in many popular systems, including:

The MOS 6502 family includes a number of related microprocessors, including the 6507, 6510, 6509, 6502C, 6510, and Ricoh 2A03. These processors are similar to the 6502, but often include additional features, such as extra I/O ports, expanded addressing modes, and integrated sound and video hardware.

The 6502 and its variants were known for their speed, reliability, and ease of programming, and were instrumental in the development of the home computer and game console markets. They remain popular among hobbyists and retro computing enthusiasts today.

Registers#

The 6502 has three primary 8-bit registers – A, X, and Y. All three registers can read or write memory, albeit with different combinations of addressing modes.

The A register (the “Accumulator”) can store the result of consecutive addition, subtraction, comparison, logical (bitwise), shift, and rotate operations.

The X and Y registers are limited to load, store, compare, and transfer. Howver they can be used as an offset in indexed addressing modes. They are also often used as loop counters since they have single-byte increment and decrement operations.

Register

Load/Store

Add/Sub

Logical

Shift/Rotate

Compare

Inc/Dec

Addr. Offset

A

*

*

*

*

*

X

*

*

*

*

Y

*

*

*

*

In addition to these primary registers, the processor has a number of special purpose registers, including:

Register

Name

Description

PC

Program counter

(16-bit) Holds the address of the next byte to be fetched.

S

Stack pointer

Holds the low byte of the address of the next byte to be pushed.

P

Status register

Processor flags. Each instruction modifies zero or more flags.

Processor Flags#

The available condition flags are:

  • N (Negative) – Set if the result of the previous arithmetic or logical operation has the most significant bit set (i.e., is negative); otherwise, it is cleared.

  • Z (Zero) – Set if the result of the previous arithmetic or logical operation is zero; otherwise, it is cleared.

  • C (Carry) – Set if the previous arithmetic or shift operation produced a carry or borrow out of the most significant bit; otherwise, it is cleared.

  • V (Overflow) – Set if the previous arithmetic operation resulted in a two’s complement overflow; otherwise, it is cleared.

There are additional flags for setting interrupt disable and decimal (BCD) modes.

See Also#

Comments