aboutsummaryrefslogtreecommitdiff
path: root/docs/implementation
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-10-13 22:57:02 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-10-13 22:57:02 -0400
commit8371572563799b08aee171707017474db9e5e496 (patch)
tree167129c88a8016b60f473c7d570bd07de5b164b7 /docs/implementation
parent7583529c468fcbbc5b99eca6fd36785305c51114 (diff)
Fix reference to LEBv (now LEB) in vm.md
Diffstat (limited to 'docs/implementation')
-rw-r--r--docs/implementation/vm.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/implementation/vm.html b/docs/implementation/vm.html
index eef49106..b6f563a1 100644
--- a/docs/implementation/vm.html
+++ b/docs/implementation/vm.html
@@ -28,7 +28,7 @@
<p>Compilation separates blocks so that they are not nested in bytecode. All compiled code is contained in some block. The self-hosted compiler compiles the entire program into an immediate block, and the program is run by evaluating this block. Blocks are terminated with the RETN instruction.</p>
<p>The starting index refers to the position where execution starts in order to evaluate the block. When the block is evaluated depends on its type and immediateness. An immediate block (0,1) is evaluated as soon as it is pushed; a function (0,0) is evaluated when called on arguments, an immediate modifier (1 or 2, 1) is evaluated when called on operands, and a deferred modifier (1 or 2, 0) creates a derived function when called on operands and is evaluated when this derived function is called on arguments.</p>
<h3 id="leb128">LEB128</h3>
-<p>Arguments for BQN bytecode are always natural numbers, encoded as a sequence of bytes using the unsigned <a href="https://en.wikipedia.org/wiki/LEB128">LEB128</a> format. The environment only needs to decode this format and not encode it (encoding is done by <code><span class='Function'>LEBv</span></code> in the compiler).</p>
+<p>Arguments for BQN bytecode are always natural numbers, encoded as a sequence of bytes using the unsigned <a href="https://en.wikipedia.org/wiki/LEB128">LEB128</a> format. The environment only needs to decode this format and not encode it (encoding is done by <code><span class='Function'>LEB</span></code> in the compiler).</p>
<p>To read a number from the byte stream, read (unsigned) bytes from the stream in sequence, stopping when a byte less than 128 is found. Each byte contributes its lowest 7 bits to the number: the byte's value if it is less than 128, and its value minus 128 otherwise. Values are accumulated starting at the lowest-order bits. To accomplish this, begin with a multiplier of 1 (shift of 0). At each step, add the 7 bits read, times the multiplier, to a running total that starts at 0, then multiply the multiplier by 128 (or add 7 to the shift).</p>
<p>Because most encoded numbers will be less than 128, for higher performance it's best to add a special case for the first byte, which simply returns the byte if it's less than 128.</p>
<h3 id="instructions">Instructions</h3>