Fixed native word-RAM van Emde Boas code #
The same thirty-two-register structured program dispatches insertion, membership and strict successor. It uses only standard unsigned integer operations, comparisons, loads and stores. The split size and child span are read from the represented memory; no code is generated from the depth, key or word width.
The minimum is stored outside recursive clusters, following Demaine's exposition. The lecture notes credit Michael Bender. The five-word contiguous records and explicit four-word successor return stack are engineering choices, distinguished from the original stratified representation of van Emde Boas, Kaas and Zijlstra.
These definitions alone establish no operation's correctness, execution bound, initialization or space use. Each certified operation must supply actual execution and representation proofs. In particular, a fitting query word may exceed the tree universe; membership rejects queries above the cached maximum before computing a descendant address.
Main definitions #
tag,arg,out,found,root,stackBase,depth,tableBase,zero,one,two,three,four,five,p,x,q,t,high,low,child,addr,present,mn,mx,tmp,sp,runFlag,kind,payload,frameQ,frameT: the thirty-two named registers of the van Emde Boas machine program.setup,coordinates,finishMin,finishMax,finishNone,pushFrame,descendCluster,descendSummary,popFrame: register setup, coordinate splitting, termination, and return-stack frame subroutines.program: one fixed dispatch over native instructions.memberBody,memberLoop: membership descent with a cached-maximum rejection.insertTail,insertBody,insertLoop: native insertion descent.successorDescentBody,successorDescent,successorUnwindBody,successorUnwind,successorPhase: native strict-successor descent and return-stack unwinding.
Main results #
program_size: the fixed dispatch has 212 instructions before halt.program_not_readsWidth: no instruction reads the selected word width.
References #
Caller-supplied operation tag: insertion = 0, membership = 1, successor = 2.
Caller-supplied key or query word.
Returned key or Boolean membership word.
Presence flag distinguishing a successor from absence.
Persistent base address of the represented tree.
Persistent base address of the reserved return stack.
Reserved register for initialization depth; the dispatch program does not read it.
Reserved register for initialization metadata; the dispatch program does not read it.
Register holding zero after setup.
Register holding one after setup.
Register holding two after setup.
Register holding three after setup.
Register holding four after setup.
Register holding the five-word header size after setup.
Current subtree address.
Current local query or inserted key.
Current node's stored split size.
Current node's stored child span.
High part of the current key.
Low part of the current key.
Computed child address.
Scratch address for indexed memory operations.
Cached presence flag read from the current record.
Cached minimum read from a record.
Cached maximum read from a record.
Scratch arithmetic register.
Return-stack cursor.
Whether the descent loop continues.
Return-frame tag: cluster = 0, summary = 1.
Return-frame payload: cluster offset or parent address.
Split size loaded from a return frame.
Child span loaded from a return frame.
Initialize constants, traversal, result and stack registers in twelve instructions.
Split the key and compute its cluster address using six arithmetic instructions.
Return the cached minimum and stop descent.
Return the cached maximum and stop descent.
Return absence and stop descent.
Continuation of insertBody after updating the local header's extrema and setting x to the
displaced key: stop at depth zero, install into an empty destination cluster, or descend.
One native insertion iteration. Empty records and empty destination clusters install their first key directly in the three-word bounds area.
Native insertion descent.
One native membership iteration. The maximum check rejects large queries before descent.
Native membership descent, with one depth decrease for each continuing iteration.
Push four words: continuation kind, payload, split and child span.
Save a cluster-return continuation and descend into the selected cluster.
Save a summary-return continuation and descend into the summary.
One native successor-descent iteration. The cached maximum chooses between early termination, cluster descent and summary descent.
Native successor descent.
Pop the four-word return frame.
One native successor-unwind iteration.
Reconstruct the answer through cluster and summary return frames.
Two-phase native strict-successor routine: descend with saved return frames, then unwind.
One fixed dispatch program, independent of the universe, query, state and word width.
The fixed dispatch has 212 instructions before the final compiled halt.
The dispatch never reads the selected word width.