đŸ Archived View for dcreager.net âș swanson âș s0-bytecode.gmi captured on 2024-05-12 at 15:39:53. Gemini links have been rewritten to link to archived content
âŹ ïž Previous capture (2023-11-14)
-=-=-=-=-=-=-
Each Sâ instruction will be encoded into a 1-byte opcode. Some opcodes will have a variable amount of data following the opcode, as described below.
There will be four working stacks, so the top two bits of each opcode identify which stack the instruction operates on (the âtarget stackâ).
Instructions needed:
Opcode: tt000000 Semantics: âŠnilâ⧠Οâ â Οââ []
The ânilâ instruction pushes an empty stack value onto the target stack.
Opcode: tt000001 Semantics: âŠunpackâ⧠Οââ [Ο] â Οââ Ο
The âunpackâ instruction pops a stack value from the target stack, and pushes the contents of the stack value onto the target stack.
Opcode: tt000010 Semantics: âŠpackâ⧠Οââ v â Οââ [v]
The âpackâ instruction pops a value (âelementâ) from the target stack, and pushes a new stack value containing âelementâ onto the target stack.
Opcode: tt000011 Semantics: âŠcatâ⧠Οââ [Οâ]â [Οâ] â Οââ [Οââ Οâ]
The âcatâ instruction pops two stack values from the target stack, and pushes a new stack value containing the concatenation of their contents onto the target stack.
Opcode: tt0001tt Semantics: âŠswapâ⧠Οââ vââ vâ â Οââ vââ vâ
The âswapâ instruction pops two values from the target stack, and pushes them back onto the target stack in reverse order.
Opcode: tt0001ss Semantics: âŠâtoâ⧠Οââ v Οâ â Οâ Οââ v
The âtoâ instruction pops a value from the source stack, and pushes it onto the target stack.
Opcode: tt001000 Semantics: âŠnewtagâ⧠Οâ â Οââ α
The ânewtagâ instruction pushes a new tag onto the target stack.
Opcode: tt001001 Semantics: âŠdroptagâ⧠Οââ α â Οâ
The âdroptagâ instruction pops a tag from the target stack.
Opcode: tt001010 Semantics: âŠlockâ⧠Οââ αâ v â Οââ αâ âŠv/αâŠ
The âlockâ instruction pops a value and a tag from the target stack, locks the value using the tag, and pushes the locked value and tag onto the target stack.
Opcode: tt001011 Semantics: âŠunlockâ⧠Οââ αâ âŠv/α⊠â Οââ αâ v
The âunlockâ instruction pops a locked value and a matching tag from the target stack, unlocks the value, and pushes the unlocked value and tag onto the target stack.
Opcode: tt11nnnn âšbranchâ© (1) tt111111 nnnnnnnn âšbranchâ© (2) Semantics: âŠapplyâ⧠Οââ {branch} â âŠbranch⧠Οâ
The âapplyâ instruction pops a quotation from the target stack, and invokes the quotation's named branch.
Opcode variant (1) is used for a branch name with 15 or fewer bytes.
Opcode variant (2) is used for a branch name with 15 or more bytes.
Opcode: tt01iiii âšinstructionsâ© (1) tt011111 iiiiiiii iiiiiiii âšinstructionsâ© (2) tt10bbbb (branches*) (3) tt100000 bbbbbbbb (branches*) (4) Semantics: hard to describe in math at the moment
The âquotationâ instruction (which includes the definition of a quotation) pops a value from the target stack, and pushes the quotation closed over that value onto the target stack.
Opcode variant (1) is used for a âbranchlessâ quotation with fewer than 15 instructions.
Opcode variant (2) is used for a âbranchlessâ quotation with 15 or more instructions.
Opcode variant (3) is used for a quotation with 1 to 15 branches, at least one of which has a name.
Opcode variant (4) is used for all other quotations.
Opcode: tt0011dd (1) tt001111 dddddddd (2) Semantics: hard to describe in math at the moment
The âupquoteâ instruction finds the d-th closest syntactically enclosing quotation, pops a value from the target stack, and pushes the quotation closed over that value onto the target stack.
Opcode variant (1) is used for a depth of less than 3.
Opcode variant (2) is used for all other depths.
Just for target stack 0:
00 nilâ 01 unpackâ 02 packâ 03 catâ 04 swapâ 05 âtoâ 06 âtoâ 07 âtoâ 08 newtagâ 09 droptagâ 0a lockâ 0b unlockâ 0c upquoteâ 0 0d upquoteâ 1 0e upquoteâ 2 0f upquoteâ â„3 10 quotationâ, branchless, 0 instructions 11 quotationâ, branchless, 1 instructions 12 quotationâ, branchless, 2 instructions 13 quotationâ, branchless, 3 instructions 14 quotationâ, branchless, 4 instructions 15 quotationâ, branchless, 5 instructions 16 quotationâ, branchless, 6 instructions 17 quotationâ, branchless, 7 instructions 18 quotationâ, branchless, 8 instructions 19 quotationâ, branchless, 9 instructions 1a quotationâ, branchless, 10 instructions 1b quotationâ, branchless, 11 instructions 1c quotationâ, branchless, 12 instructions 1d quotationâ, branchless, 13 instructions 1e quotationâ, branchless, 14 instructions 1f quotationâ, branchless, â„15 instructions 20 quotationâ, â„16 branches 21 quotationâ, 1 branch 22 quotationâ, 2 branches 23 quotationâ, 3 branches 24 quotationâ, 4 branches 25 quotationâ, 5 branches 26 quotationâ, 6 branches 27 quotationâ, 7 branches 28 quotationâ, 8 branches 29 quotationâ, 9 branches 2a quotationâ, 10 branches 2b quotationâ, 11 branches 2c quotationâ, 12 branches 2d quotationâ, 13 branches 2e quotationâ, 14 branches 2f quotationâ, 15 branches 30 apply, nameless branch 31 apply, 1-byte branch 32 apply, 2-byte branch 33 apply, 3-byte branch 34 apply, 4-byte branch 35 apply, 5-byte branch 36 apply, 6-byte branch 37 apply, 7-byte branch 38 apply, 8-byte branch 39 apply, 9-byte branch 3a apply, 10-byte branch 3b apply, 11-byte branch 3c apply, 12-byte branch 3d apply, 13-byte branch 3e apply, 14-byte branch 3f apply, â„15-byte branch