91. RCALL – Relative Call to Subroutine
91.1. Description
Relative call to an address within PC - 2K + 1 and PC + 2K (words). The return address (the instruction
after the RCALL) is stored onto the Stack. See also CALL. For AVR microcontrollers with Program
memory not exceeding 4K words (8KB) this instruction can address the entire memory from every
address location. The Stack Pointer uses a post-decrement scheme during RCALL.
Operation: Comment:
(i) PC ← PC + k + 1 Devices with 16-bit PC, 128KB Program memory maximum.
(ii) PC ← PC + k + 1 Devices with 22-bit PC, 8MB Program memory maximum.
Syntax: Operands: Program Counter: Stack:
(i) RCALL k -2K ≤ k < 2K PC ← PC + k + 1 STACK ← PC + 1
SP ← SP - 2 (2 bytes,
16 bits)
(ii) RCALL k -2K ≤ k < 2K PC ← PC + k + 1 STACK ← PC + 1
SP ← SP - 3 (3 bytes,
22 bits)
16-bit Opcode:
1101 kkkk kkkk kkkk
91.2. Status Register (SREG) and Boolean Formula
I T H S V N Z C
– – – – – – – –
Example:
rcall routine ; Call subroutine
...
routine: push r14 ; Save r14 on the Stack
...
pop r14 ; Restore r14
ret ; Return from subroutine
Words 1 (2 bytes)
Cycles 3 devices with 16-bit PC
4 devices with 22-bit PC
Cycles XMEGA 2 devices with 16-bit PC
3 devices with 22-bit PC
Atmel AVR Instruction Set Manual [OTHER]
Atmel-0856L-AVR-Instruction-Set-Manual_Other-11/2016
137