Skip to content

Memory Opcodes ​

This section documents the memory operations instructions available in CandleVM.

For operand encodings, see the executable format reference.

Values, modules, globals and resources ​

Opcode byteOpcodeOperand bytesBehavior
9LoadConstdestination: register, value: tagged valueLoads an immediate Value using the encoding rules and stores it.
10Movdestination: register, source: registerCopies a runtime value from one register to another.
11LoadModuledestination: register, name: stringLooks up the exact module name and stores a ModuleRef; unknown names raise ModuleName.
12LoadFunctiondestination: register, module: register, name: stringRequires a ModuleRef; another value type raises ValueTypeMismatch. It looks up the exact function name and stores a FunctionRef. An invalid module ID raises InvalidModuleRef, and a missing function raises FunctionName.
13LoadGlobaldestination: register, name: stringLoads the named global. A missing global reads as Null.
14StoreGlobalname: string, source: registerStores a global. Storing Null removes it. A write to an existing read-only global raises ReadOnlyGlobal.
15LoadResourcedestination: register, id: stringLooks up an embedded resource by exact ID, allocates a new buffer containing a copy, and stores its ObjectRef. Missing IDs raise ResourceNotFound.
16Typedestination: register, source: registerStores the source value's type discriminator as a byte.
17ObjectTypedestination: register, object: registerRequires a valid ObjectRef and stores its object type discriminator as a byte.

At VM startup, read-only globals include API_VERSION, VM_VERSION, DEBUG, TYPE_NULL, TYPE_BYTE, TYPE_NUMBER, TYPE_BOOL, TYPE_CHAR, TYPE_MODULE_REF, TYPE_FUNCTION_REF, TYPE_OBJECT_REF, and OBJECT_TYPE_ARRAY, OBJECT_TYPE_MAP, OBJECT_TYPE_STRING, OBJECT_TYPE_ERROR, OBJECT_TYPE_BUFFER, OBJECT_TYPE_NATIVE.

Built for the Candle ecosystem · Powered by VitePress.