Control Flow Instructions

Branch instruction may change the next instruction to be executed, depending on a test. For example:
BRBC1111 01kk kkkk ksssPC = PC + k + 1 if !STATUS_REGISTER[s]
BRBS1111 00kk kkkk ksssPC = PC + k + 1 if STATUS_REGISTER[s]
Note, -64 <= k <= 63.

Branch instruction can only transfer control to a limited range of nearby addresses. This may be sufficient for small if/while/for statements. Otherwise a jump instruction must be used, e.g
JMP k1001 010k kkkk 110k
kkkk kkkk kkkk kkkk
PC = k
IJMP1001 0101 0000 1001PC = R31:R30
Note, JMP is a 32 bit instruction. This allows a 22-bit address to be formed.

Note, the use of r30 and r31 to form a 16-bit value for IJMP. This is sufficient to allow execution to be transfered to any instruction in the ATmega64's 64k of program memory.

Index