Skip to content
Astrolune

ALVM ISA v1

skeleton

A frame with the open questions fixed in writing. It records what existing code already constrains and what is genuinely undecided — it does not invent a specification to look finished.

Status: implemented. Opcode values are permanent consensus identifiers. All immediates are little-endian.

ByteMnemonicImmediateStack effectDefault compute
00STOP-() -> ()1
01PUSH64u64() -> (x)1
02ADD-(a,b) -> (a+b)3
03SUB-(a,b) -> (a-b)3
04MUL-(a,b) -> (a*b)3
05DIV-(a,b) -> (a/b)3
06EQ-(a,b) -> (a==b)3
07LT-(a,b) -> (a<b)3
08DUP-(a) -> (a,a)1
09DROP-(a) -> ()1
0aJUMPu32 offset() -> ()2
0bJUMPIu32 offset(condition) -> ()2
0cLOAD8-(offset) -> (value)5
0dSTORE8-(value,offset) -> ()5
0eRETURN-(offset,length) -> ()1
0fREVERT-(offset,length) -> ()1
10MOD-(a,b) -> (a%b)3
11AND-(a,b) -> (a&b)3
12OR-(a,b) -> (a|b)3
13XOR-(a,b) -> (a^b)3
14NOT-(a) -> (~a)3
15SHL-(value,count) -> (value&lt;<count)3
16SHR-(value,count) -> (value>>count)3
17GT-(a,b) -> (a>b)3
18LE-(a,b) -> (a&lt;=b)3
19GE-(a,b) -> (a>=b)3
1aSWAP-(a,b) -> (b,a)1
1bLOAD64-(offset) -> (u64-le)5
1cSTORE64-(value,offset) -> ()5
1dCALLDATA_SIZE-() -> (length)1
1eCALLDATA_COPY-(source,destination,length) -> ()5
1fCALLu16 functionparams -> results2
20RET-results -> caller1
21HOSTu16 host IDhost-specific2 plus host
22ISZERO-(a) -> (a==0)1
23BYTE-(position,value) -> (byte)3
24SIGNEXTEND-(bytes,value) -> (sign-extended)3
25SHA3-(offset,length) -> (hash) writes 32-byte hash at memory[offset]30
26MLOAD-(offset) -> (u64) load 8 bytes LE from memory[offset]5
27MSTORE-(value,offset) -> () store 8 bytes LE to memory[offset]5
28SLOAD-(key_off,key_len) -> (val_len) read from contract storage50
29SSTORE-(key_off,key_len,val_off,val_len) -> () write to contract storage200
2aADDRESS-(offset) -> () write current contract address (32 bytes) to memory[offset]2
2bCALLER-(offset) -> () write transaction sender address (32 bytes) to memory[offset]2
2cCALLVALUE-() -> (value) push transaction call value2
2dCODESIZE-() -> (size) push execution code length2
2eCODECOPY-(dest_off,src_off,len) -> () copy len bytes from execution code[src_off] to memory[dest_off]5

Arithmetic and control flow

ADD, SUB and MUL trap on unsigned overflow. DIV and MOD trap on zero. Shift counts at least 64 produce zero. Memory accesses are bounds checked before any read or write. Jumps are static offsets into the current function; dynamic jumps and cross-function jumps do not exist.

Byte extraction and sign extension

BYTE extracts the byte at position p (0 = most significant) from a 64-bit value. For positions outside 0..7 the result is zero.

SIGNEXTEND treats the first argument as the number of bytes (0..7) to sign-extend. For b < 8 the sign bit is at position b*8 + 7. All upper bits are set if the sign bit is set, cleared otherwise. For b >= 8 the value passes through unchanged.

Memory and storage

MLOAD and MSTORE are 8-byte (u64) loads and stores, little-endian, using the same linear memory as LOAD8 and STORE8. SLOAD and SSTORE access the per-contract key-value store through the state transaction. Keys and values are arbitrary-length byte slices referenced by (offset, length) pairs in memory.

Execution context

ADDRESS writes the 32-byte current contract address to memory at the given offset. CALLER writes the 32-byte transaction sender address. CALLVALUE pushes the transaction call value as a u64 onto the stack. CODESIZE pushes the length of the execution code. CODECOPY copies a range of the execution code into memory.

RETURN and REVERT

RETURN and REVERT unwind the whole machine, so they are legal only where nothing above them needs resuming: in function zero, and in non-zero functions that nothing CALLs - those serve as data-returning transaction entrypoints (zero parameters). Everything reachable through CALL ends with RET. The validator enforces this split statically.

Schedule

The table is the default development schedule. Genesis carries every opcode and host cost, and validation rejects zero or UINT64_MAX costs. A schedule change is a chain-identity change, not a local tuning option.

Edit on GitHubSource: 03-vm/bytecode-isa.md