3 ms·
I have an end opcode in the TXR Lisp virtual machine. It delimits blocks of code that have some sort of context attached. The opcode allows the virtual machin
by kazinator 8y ago
I have an end opcode in the TXR Lisp virtual machine. It delimits blocks of code that have some sort of context attached.
The opcode allows the virtual machine interpreter to recurse on itself; when it hits the end, the dispatch loop executes return to bail out to the higher level of recursion. Thus end is also useful for exiting the top-level invocation of the VM. It is required, in fact; if the end instruction is not present, the interpreter will keep marching through memory past the end of the routine. No wasteful check is needed whether the instruction pointer is past the code block.
my end instruction also specifies a result value (because the machine is register based; there is no top-of-stack implicit value). This becomes the return value of a procedure when the final end is executed. The block instruction also uses it. When a (block ...) is compiled, the return value of the ordinary block termination is specified in the end instruction at the end of the block. Control returns to the block instruction which receives that value.
end has something in common with the x86 ret instruction and its ilk. It's not so much an exotic "come from" as an ordinary "return".
- deleted 8y ago[deleted]