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
- JSR - Jump to Subroutine.
- program counter
page revision: 7, last edited: 15 Jul 2012 05:15