User guide

c. Instructions
<opcode> [<parameter>]
Instructions are the usual three letter mnemonics, with optional parameters as necessary.
Comments are introduced using the ‘;’ character. Anything following a semicolon until the end of the line is
ignored. You can include comments at the ends of command lines and instruction lines.
To reiterate: Each line is a separate entity, up to 80 characters long.
You cannot split commands across lines, nor can you put multiple commands on one line.
The 6502 (instruction set)
The 6502 processor is an 8 bit design from the late ’70s. In its day it was more popular than the Intel
8086/8088; and in many ways was more advanced than the Z80 which was its main competitor. Indeed,
objective tests (running a BBC BASIC interpreter) shows the Z80 clocking at 4MHz to be only about 12%
faster than a 6502 clocking at 2MHz. Later extensions and optimisations (such as those found in the CMOS
variants of the processor) will enhance the effective speed.
With its direct and simplified instruction set, the 6502 has even been described as a forerunner to modern
RISC microprocessors.
It offers two 8 bit ‘index’ registers, though these are fairly general purpose. They are referred to as ‘X’ and
‘Y’. The results of all mathematical operations are placed in the Accumulator, often called ‘A’. The data bus is
8 bits wide.
Instructions are between one and three bytes long.
The address bus (and ‘PC’ (Program Counter) register) is sixteen bits wide with no translation, meaning a
6502 can only directly address 64K of memory. It is possible to extend this with external fiddling. The BBC
Master 128 computer contained 128K accessed via a paging mechanism, and I dimly recall a version with
more than that!
Many popular home computers of the ’80s were built around the 6052; the BBC micro (including the Electron
and Master/Master Compact, and “Acorn Communicator” used in many a travel agent), the Apple II, the
Dragon, the Oric, Commadore’s PET...
The 6502 has three built-in branch points (IRQ, RESet, NMI) in the upper six words of memory (&FFFA to
&FFFF). These are known as the hardware vectors. The first of these is the interrupt handler (and by using the
BRK instruction, you can force an interrupt from software). The second is called when a reset condition
occurs. Finally, the last is the non-maskable interrupt. This differs from the normal IRQ in that you cannot
switch it off and it can occur while handling a normal interrupt. It is used for things that need an extremely
fast response time (in the case of the BBC micro, this was usually Econet and the floppy disc drive). The
Amélie project uses the NMI for a debounced ‘panic’ button which will halt the system regardless of whatever
else is happening (and even if interrupts are disabled).
6502asm user guide – prerelease version
page 4