This the multi-page printable view of this section.Click here to print.

Return to the regular view of this page.

Jump to location

Transfer control to the address specified by the operand field.

Table of Contents

The branch instructions sets the Program Counter to a new value from which the next instruction will be taken.

JMP - Jump to location

The program counter is loaded with the target address. If a long JMP is executed the bank is loaded from the third byte of the address.

Some assemblers accept JML as an alternate mnemonic for JMP long.

BRA - Branch Always

A branch is always taken, no test is performed. It is equivalent to a JMP instruction, except that as it uses a signed displacement it is only 2 bytes in length instead of 3 for JMP. In addition, because it uses displacements, code using BRA is relocatable.

The 1-byte signed displacement in the second byte of the instruction is sign-extended to 16-bits and added to the Program Counter. If the branch is not taken then the instruction immediately following the 2-byte instruction is executed.

The allowable range of the displacement is -128 to +127 from the instruction immediately following the branch.

BRA was introduced with the 65C02 processor.

BRL - Branch Always Long

A branch is always taken, no test is performed. It is equivalent to a BRA instruction, except that BRL is a 3 byte instruction. The two bytes after the opcode form a 16-bit signed displacement from the Program Counter.

The allowable range of the displacement is anywhere within the current 64K program bank.

The advantage of BRL is that it makes code relocatable, although it is 1 cycle slower than the absolute JMP instruction.

BRL was introduced with the 65802 processor.

Flags Affected
None.
Instructions
SyntaxOpcode Available on: # of # of Addressing Mode
(hex) 6502 65C02 65816 bytes cycles
BRA nearlabel80 x x 2 33 Program Counter Relative
BRL label82 x 3 4 Program Counter Relative Long
JMP addr4C x x x 3 3 Absolute
JMP (addr)6C x x x 3 51, 2 Absolute Indirect
JMP (addr,X)7C x x 3 6 Absolute Indexed Indirect
JMP long5C x 4 4 Absolute Long
JMP [addr]DC x 3 6 Absolute Indirect Long

Notes:

  1. Add 1 cycle if 65C02
  2. 6502: If low byte of address is 0xFF yields incorrect result
  3. Add 1 more cycle if branch taken crosses page boundary on a 6502, 65C02 or a 65816 in 6502 emulation mode (e=1)