The LLAMA instruction for setting a global variable, which is used in the compilation of setq and psetq, is set-global v: the expression (which must not contain free logic variables) is copied into the general purpose memory (Memory), and its toplevel representation is stored in the address corresponding to v.
This copying is needed because the value of global variables should be stored permanently. Stack and heap are reset between queries, thus the general purpose memory is used.
If the value which is stored in the global variable is not needed afterwards, it is removed in the set-global- instruction thus avoiding a subsequent pop instruction (see section 6.3).
The counterpart to the dup instruction for local variables is push-global v in the case of global variables.