JMP

JMP

JMP - Jump

Description

JMP changes the program counter so that the next "line" is not the next one in order. It is similar to GOTO in various BASIC dialects.

Flags affected
N Z C I D V
- - - - - -
Addressing Mode Assembly OpCode No. Bytes. No. Cycles
Absolute JMP Oper 4c 3 3
Indirect JMP (Oper) 6c 3 5

Examples

JMP works much like GOTO in many BASIC languages. If you think about the memory addresses as line numbers, it is easy to understand.

$0800 : INX
$0801 : JMP $0800

First, X is incremented by one by INX. Then, JMP is executed, sending the program counter back to $0800. This code will result in an endless loop that constantly increments X.

Related Pages

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.