MOS Technology 6502/650x/651x architecture

Memory

Program, data and stack memories occupy the same memory space. The total addressable memory size is:

  • 64 KB for 6502 and 6512.
  • 8 KB for 6504, 6507 and 6514.
  • 4 KB for 6503, 6505, 6506, 6513 and 6515.

Program memory - program can be located anywhere in memory. Jump and subroutine call instructions can be used to jump anywhere in memory. Conditional branches are limited to 256 bytes (-127 - +128 bytes from current location).

Data memory - data can be anywhere in memory space. 16-bit data pointers are stored as the low-order byte first, then the high-order byte.

Stack memory is limited to 256 bytes. Stack is always located at addresses 100h - 1FFh.

Reserved memory locations:

  • 0000h - 00FFh (zero page): reserved for zero-page pointers. These pointers are used by zero-page addressing modes.
  • 0100h - 01FFh: 256-byte stack.
  • FFFAh - FFFBh: Pointer to NMI interrupt-processing routine.
  • FFFCh - FFFDh: Pointer to a program handling Reset signal.
  • FFFEh - FFFFh: Pointer to IRQ interrupt-processing routine.
  • Some memory addresses may be reserved for memory mapped I/O as the processor doesn't have hardware I/O capability.

Interrupts

IRQ - maskable interrupt. When the interrupt occurs the program counter and processor status are stored in the stack, the further interrupts are disabled and the processor jumps to memory location address of which is stored in memory FFFEh - FFFFh. To return from the interrupt the processing routine should use RTI instruction. This interrupt can be enabled/disabled using CLI/SEI instructions. This interrupt type is not available on 6507 processor.

NMI - non-maskable interrupt. When the interrupt occurs the program counter and processor status are stored in the stack, the further interrupts are disabled and the processor jumps to memory location address of which is stored in memory FFFAh - FFFBh. To return from the interrupt the processing routine should use RTI instruction. This interrupt can not be disabled. This interrupt type is not available on 6504, 6505, 6507, 6514 and 6515 processors.

I/O ports

None.

Registers

Accumulator is an 8-bit register used for arithmetic and logic operations.

X index is an 8-bit register usually used as an index in different types of index addressing modes.

Y index is an 8-bit register usually used as an index in different types of index addressing modes.

Program counter is a 16-bit register.

Stack pointer is an 8-bit register. The processor assumes that the higher 8-bits of the stack pointer are always set to 01h thus limiting stack to memory range 100h - 1FFh.

Processor Status register contains the following flags:

  • Negative (N) - set if the most significant bit of the result is set.
  • Overflow (V)
  • Break command (B)
  • Decimal mode (D) - set if the processor is in decimal mode.
  • IRQ disable (I) - set if the IRQ interrupt is disabled.
  • Zero (Z) - set if the result is zero.
  • Carry (C) - set if there was a carry from or borrow to during last result calculation.

Instruction Set

6502/650x instruction set consists of 56 instructions:

  • Data moving instructions.
  • Arithmetic - add (always with carry), subtract (always with carry), increment, decrement and compare.
  • Logic - AND, OR, exclusive OR and shift/rotate.
  • Control transfer - conditional, unconditional, call subroutine and return from subroutine.
  • Other - clear/set processor flags, bit test, stack operations.

Addressing modes

Implied - the data value/data address is implicitly associated with the instruction.

Accumulator - the instruction implies that the data is in the accumulator.

Immediate - 8-bit data is provided as the second byte in the instruction.

Absolute (direct) - the second and the third bytes of the instruction specify the memory address where data is located.

Zero page - the second byte in the instruction points to location in page zero (0000h - 00FFh) where data is located.

Indexed zero page - the contents of the X or Y register is added to the second byte of the instruction (carry is ignored), and the resulting byte is a memory offset in page zero (0000h - 00FFh) where data is located. This form of addressing is written as "addr8, X" or "addr8, Y", where addr8 is an 8-bit value.

Indexed absolute - the contents of the X or Y register is added to the 16-bit pointer specified in the second and third bytes of the instruction, and the resulting 16-bit value is a pointer to memory where data is located. This form of addressing is written as "addr16, X" or "addr16, Y", where addr16 is a 16-bit value.

Relative - one byte offset is added to the contents of the program counter register. The offset is a signed number in the range -127 - +128.

Indexed indirect - the contents of the X register is added to the second byte provided in the instruction (carry is ignored), the resulting byte is a memory offset in page zero where a 16-bit pointer is stored. The 16-pointer points to data. This type of addressing is written as "(addr8, X)", where addr8 is an 8-bit value. This addressing is useful for addressing an array of data pointers.

Indirect indexed - the second byte in the instruction points to memory in page zero where 16-bit data pointer is stored. This pointer is added to the contents of the Y register, the resulting 16-bit value is an offset to memory where data is located. This type of addressing is written as "(addr8), Y", where addr8 is an 8-bit value.

Absolute indirect - The second and third bytes in the instruction specify the memory address containing 16-bit data, which is loaded into the program counter. This type of addressing is written as "(addr16)", where addr16 is a 16-bit value.

Comments

Last modified: 15 Oct 2013
Terms and Conditions · Privacy Policy · Contact Us (c) Copyright 2003 - 2010 Gennadiy Shvets

Search CPU-World

Search site contents:

Identify part

Identify CPU, FPU or MCU:

Quick Links

Jump to CPU / Family

Type in partial CPU manufacturer, family, model and/or number.