Function f(x, y) calls g(u, v) with call8. In which registers does f put u and v, and where does g find them?
f puts u and v in its own a10 and a11. After the window shifts by 8, those same physical registers are g's a2 and a3, exactly where any function expects its first two arguments.
* One set of physical registers, two sets of names. *
A shift of 8 means every register name in the callee is 8 lower than the caller's name for the same physical register: the caller's a8 is the callee's a0, a9 is a1, a10 is a2, and so on up to a15 = a7.
Step by step:
- In
f,xandyare ina2anda3,f's return address is ina0and its stack pointer ina1. fplaces the arguments two registers above the shift amount:uintoa10,vintoa11.call8 gstores the return address intof'sa8and jumps tog.gruns with the window moved by 8. Itsa0(the olda8) is its return address, itsa1(the olda9) gets its stack pointer, and itsa2/a3(the olda10/a11) areuandv.
Meanwhile f's a0–a7, including x and y, are behind the window. g has no name for them and cannot disturb them, so f doesn't have to save x or y anywhere before the call.
The rule generalises: with callN, arguments go in the caller's a(N+2) onwards. That is a6 for call4, a10 for call8 and a14 for call12.
Go deeper:
Xtensa ISA Reference Manual, CALL8 (§6, PDF) — "the caller's a8..a15 are the same registers as the callee's a0..a7".