I'm new on AVR. I have an "Relative branch out of reach" error for the "brne round_loop" line while debugging. Is anyone to help me? Thank you so much for your helps.
; Test if round counter has reached 14
mov t4, rc
subi t4, 14
brne round_loop
round_loop:
round_loop:
; XOR state and key
eor s0, k0
eor s1, k1
eor s2, k2
eor s3, k3
The AVR BRNE
instruction is a 16 bit op-code, 7 bits of which are the branch offset. This 7 bit signed operand can have a value k in the range -64 ≤ k ≤ +63. The PC is modified by k +1 (i.e. -63 to +64). If the jump is further then that, a relative branch is unsuitable.
You either need to locate the target closer to the branch, or use an unconditional branch to an unconditional jump (JMP) with a 22bit range, or a relative jump (RJMP) with a 12 bit range.
mov t4, rc
subi t4, 14
brne round_loop_longjmp
rjmp no_round_jmp
round_loop_longjmp:
rjmp round_loop
no_round_jmp:
...