9.3.7.3 Shuffling Instructions

These instructions are used to move around values on the stack.

Instruction: mov s12:dst s12:src
Instruction: long-mov s24:dst x8:_ s24:src

Copy a value from one local slot to another.

As discussed previously, procedure arguments and local variables are allocated to local slots. Guile’s compiler tries to avoid shuffling variables around to different slots, which often makes mov instructions redundant. However there are some cases in which shuffling is necessary, and in those cases, mov is the thing to use.

Instruction: long-fmov f24:dst x8:_ f24:src

Copy a value from one local slot to another, but addressing slots relative to the fp instead of the sp. This is used when shuffling values into place after multiple-value returns.

Instruction: push s24:src

Bump the stack pointer by one word, and fill it with the value from slot src. The offset to src is calculated before the stack pointer is adjusted.

The push instruction is used when another instruction is unable to address an operand because the operand is encoded with fewer than 24 bits. In that case, Guile’s assembler will transparently emit code that temporarily pushes any needed operands onto the stack, emits the original instruction to address those now-near variables, then shuffles the result (if any) back into place.

Instruction: pop s24:dst

Pop the stack pointer, storing the value that was there in slot dst. The offset to dst is calculated after the stack pointer is adjusted.

Instruction: drop c24:count

Pop the stack pointer by count words, discarding any values that were stored there.

Instruction: shuffle-down f12:from f12:to

Shuffle down values from from to to, reducing the frame size by FROM-TO slots. Part of the internal implementation of call-with-values, values, and apply.

Instruction: expand-apply-argument x24:_

Take the last local in a frame and expand it out onto the stack, as for the last argument to apply.