LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

caller(x, y) returns x + callee(x, y), where callee(u, v) returns u * v. Follow the values through the registers. Why is x still available after the call?

caller copies x, y into a10, a11 and calls; callee sees them as a2, a3, writes x*y into its a2 and returns. The product is now in caller's a10, and x is untouched in a2 because the window hid it during the call.

The compiled code (GCC at -O3):

callee:
    entry   sp, 32
    mull    a2, a2, a3      # a2 <- a2 * a3
    retw.n                  # return

caller:
    entry   sp, 32
    mov.n   a11, a3         # a11 <- y
    mov.n   a10, a2         # a10 <- x
    call8   callee          # window shifts by 8
    add.n   a2, a10, a2     # a2 <- (x*y) + x
    retw.n
Moment caller's a2 a3 a10 a11
On entry x y – –
After the two mov.n x y x y
Inside callee (seen as its a2, a3) hidden hidden x → x*y y
After return x y x*y y
After add.n x + x*y y x*y y

Two things to take from it. First, callee's result arrives in the caller's a10, the same register the first argument went out in, because the callee's a2 is that register. Second, no load or store appears anywhere: the stack is never touched. On a processor without register windows, caller would have to save x to the stack or a callee-saved register before the call, because callee could overwrite it.

Go deeper:

  • tool Compiler Explorer — pick an Xtensa ESP32 GCC and watch C turn into this assembly as you type.

From Quiz: SIOT / Xtensa LX6 Registers, Calls and Branches in Assembly | Updated: Dec 01, 2026