Changes

Jump to: navigation, search

6502 Jumps, Branches, and Procedures

618 bytes added, 16:21, 23 September 2021
Branches
Where $FB represents -5 in [[Signed#Two.27s_Compliment|two's compliment]] notation, since the processor needs to branch back 5 bytes from the current PC location (which is the byte after the end of the BNE instruction).
 
Because branches are always relative, code that uses only branches is called Position Independent Code (PIC) and can be easily relocated in memory. Therefore, some programmers prefer to use a forced branch instead of a jump, using an approach like this:
 
CLC ; clear the carry flag
BCC SOMEWHERE ; branch if carry clear (which will always be the case) - this is unconditional
 
Although not included in the basic/original 6502, some newer variants of this processor (such as the [https://en.wikipedia.org/wiki/WDC_65C02 65C02]) have a BRanch Always (BRA) instruction which performs an unconditional relative branch.
== Procedures ==

Navigation menu