Tutorials and Primers  Projects  Code  Resources  Tools  Forum
 Here you will find lessons on various aspects of the 6502 and its programming, along with handy reference material.
Please submit contributions for "Tutorials and Primers" to us via .

**  Tutorials and Primers

  • NMOS 6502 Opcodes by John Pickens, Updated by Bruce Clark
      An alphabetical listing of the complete set of NMOS 6502 opcodes including addressing modes, standard syntax, execution times.

  • CMOS 65C02 Opcodes by Bruce Clark
      The 65C02 has many similarities to the NMOS 6502, but the 65C02 has additional instructions and addressing modes available. In addition, there are instructions with functional differences and different cycle counts. These differences are documented in this article.

  • Compare Instructions from 6502 Software Design, Updated by Bruce Clark
      Describes the 6502's compare instructions, how they affect the processor status flags, and demonstrates how to implement them for making decisions on different conditions.

  • Beyond 8-bit Unsigned Comparisons by Bruce Clark
      The 6502 has several options available for comparing numbers. Each option, naturally, has its pros and cons in terms of speed and size. There are also some infrequently used options that occasionally come in handy. Finally, and unfortunately, some misconceptions abound about signed (two's complement) numbers and the correct way to compare them. All of these topics are covered in this article.

  • Decimal Mode by Bruce Clark
      BCD (Binary Coded Decimal) numbers can be directly added or subracted on the 6502 by using decimal mode. The basics of decimal mode are easily understood, but the specifics of its operation and use aren't always well documented. This tutorial is intended to provide those specifics.

  • The Overflow (V) Flag Explained by Bruce Clark
      One of the more mysterious topics of the 6502 is the overflow (V) flag. This tutorial is intended to fill these voids by providing a detailed description of the overflow flag, its purposes, and its uses.

  • Investigating Interrupts by Garth Wilson
      This is an extensive tutorial on interrupt programming. It introduces the concept of interrupts, demonstrates how to code interrupt handlers, explains special interrupt types (NMI, BRK, WAI), provides three sample projects that make good use of interrupts, and discusses performance considerations.

  • Zero-Overhead Forth Interrupts by Garth Wilson
      Servicing interrupts in high-level Forth is rather easy to do in an indirect-threaded Forth system. This article shows what is needed to do it on a 6502. It should be easy to adapt it for other simple processors as well.

  • Register Preservation Using The Stack (and a BRK handler) by Bruce Clark
      Learn the common methods for preserving registers on the stack for both the 6502 and 65C02. This tutorial also demonstrates how to properly distinguish whether an interrupt was caused by IRQ or the BRK instruction.