diff --git a/package-lock.json b/package-lock.json index 037d2c6..146a589 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,8 +24,8 @@ "@reduxjs/toolkit": "^2.2.8", "@tanstack/react-virtual": "^3.10.9", "@typeberry/block": "^0.0.1-1a02906", - "@typeberry/pvm-debugger-adapter": "0.0.1-3eb6bed", - "@typeberry/spectool-wasm": "^0.13.0", + "@typeberry/pvm-debugger-adapter": "0.1.0-dc28f3f", + "@typeberry/spectool-wasm": "0.18.0", "@uiw/react-codemirror": "^4.23.6", "class-variance-authority": "^0.7.0", "classnames": "^2.5.1", @@ -2805,15 +2805,15 @@ "license": "MPL-2.0" }, "node_modules/@typeberry/pvm-debugger-adapter": { - "version": "0.0.1-3eb6bed", - "resolved": "https://registry.npmjs.org/@typeberry/pvm-debugger-adapter/-/pvm-debugger-adapter-0.0.1-3eb6bed.tgz", - "integrity": "sha512-tnb1XhjuSy3YZit/gYGCHB/cG3ivuv3+d+UMncEjhrZWFzAnv2l91Ykgtt1AbewgSOT3NQ9LhYpKep8r66GL+g==", + "version": "0.1.0-dc28f3f", + "resolved": "https://registry.npmjs.org/@typeberry/pvm-debugger-adapter/-/pvm-debugger-adapter-0.1.0-dc28f3f.tgz", + "integrity": "sha512-9URPw+vy88ni2hRuimyGoY91iSWh6VwoqzqcT65xJ0qV0uQpXaekxI+ujiBzw233zjpZhWzmUPaNqRxOzlsDeg==", "license": "MPL-2.0" }, "node_modules/@typeberry/spectool-wasm": { - "version": "0.13.0", - "resolved": "https://registry.npmjs.org/@typeberry/spectool-wasm/-/spectool-wasm-0.13.0.tgz", - "integrity": "sha512-Apmi5IJCpSa7L5g4gEA6G0jE9O8uFNcvNaS1cTtFg2Q8jUix8g/Tl3BNDzkyKfJeLjScKg1/fBwKlh/ZDOLy+w==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@typeberry/spectool-wasm/-/spectool-wasm-0.18.0.tgz", + "integrity": "sha512-HGXuk4upkGwabHtyHrA3Kyr9FnxSSkcxPQkiPpgyEx8RLOb4bvlxXaSNM7BagP/76JLbaHdYpc7DCItvJCPwVA==", "license": "MIT/Apache-2.0" }, "node_modules/@types/babel__core": { diff --git a/package.json b/package.json index 5201779..a3be5b7 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,8 @@ "@reduxjs/toolkit": "^2.2.8", "@tanstack/react-virtual": "^3.10.9", "@typeberry/block": "^0.0.1-1a02906", - "@typeberry/pvm-debugger-adapter": "0.0.1-3eb6bed", - "@typeberry/spectool-wasm": "^0.13.0", + "@typeberry/pvm-debugger-adapter": "0.1.0-dc28f3f", + "@typeberry/spectool-wasm": "0.18.0", "@uiw/react-codemirror": "^4.23.6", "class-variance-authority": "^0.7.0", "classnames": "^2.5.1", diff --git a/src/components/Instructions/utils.tsx b/src/components/Instructions/utils.tsx index 07ef3de..68c99f7 100644 --- a/src/components/Instructions/utils.tsx +++ b/src/components/Instructions/utils.tsx @@ -8,7 +8,7 @@ export const valueToNumeralSystem = ( withPrefix: boolean = true, ): string => { const stringValue = - typeof value === "bigint" ? BigInt.asUintN(32, value).toString(16) : ((value ?? 0) >>> 0).toString(16); + typeof value === "bigint" ? BigInt.asUintN(64, value).toString(16) : ((value ?? 0) >>> 0).toString(16); return numeralSystem === NumeralSystem.HEXADECIMAL ? `${withPrefix ? "0x" : ""}${stringValue.padStart(padStartVal, "0")}` diff --git a/src/components/KnowledgeBase/index.tsx b/src/components/KnowledgeBase/index.tsx index ce22c6f..0b50424 100644 --- a/src/components/KnowledgeBase/index.tsx +++ b/src/components/KnowledgeBase/index.tsx @@ -63,14 +63,16 @@ export const KnowledgeBase = ({ currentInstruction }: { currentInstruction: Curr

{currentInstructionFromKnowledgeBase?.description}

- + {currentInstructionFromKnowledgeBase?.linkInGrayPaperReader && ( + + )}
); diff --git a/src/components/NumeralSystemSwitch/index.tsx b/src/components/NumeralSystemSwitch/index.tsx index 6f86f37..499c65a 100644 --- a/src/components/NumeralSystemSwitch/index.tsx +++ b/src/components/NumeralSystemSwitch/index.tsx @@ -5,13 +5,14 @@ import { NumeralSystemContext } from "@/context/NumeralSystemContext"; import { NumeralSystem } from "@/context/NumeralSystem"; export const NumeralSystemSwitch = ({ className }: { className: string }) => { - const { setNumeralSystem } = useContext(NumeralSystemContext); + const { setNumeralSystem, numeralSystem } = useContext(NumeralSystemContext); return (
setNumeralSystem(checked ? NumeralSystem.HEXADECIMAL : NumeralSystem.DECIMAL)} /> diff --git a/src/components/ProgramLoader/Assembly.tsx b/src/components/ProgramLoader/Assembly.tsx index 0166f1f..a7f93d0 100644 --- a/src/components/ProgramLoader/Assembly.tsx +++ b/src/components/ProgramLoader/Assembly.tsx @@ -37,6 +37,7 @@ function assemblyFromInputProgram(initialState: InitialState, program: number[]) if (program.length === 0) { return DEFAULT_ASSEMBLY; } + try { const raw = disassemble(new Uint8Array(program)); const lines = raw.split("\n"); @@ -71,7 +72,7 @@ function assemblyFromInputProgram(initialState: InitialState, program: number[]) // now append initial registers const registers: string[] = []; for (const [idx, reg] of (initialState.regs ?? []).entries()) { - if (reg !== 0) { + if (BigInt(reg) !== 0n) { registers.push(`pre: r${idx} = ${reg}`); } } @@ -131,7 +132,9 @@ export const Assembly = ({ } // we want to keep all of the old stuff to avoid re-rendering. output.initial = newInitialState; - onProgramLoad(output); + // TODO [ToDr] Assembly for 64-bit is temporarily broken, so we don't trigger + // the `onProgramLoad` here. + // onProgramLoad(output); setError(undefined); } catch (e) { if (e instanceof Error) { @@ -149,8 +152,7 @@ export const Assembly = ({ setError(`${e}`); } }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [onProgramLoad, program], + [onProgramLoad, program, initialState], ); const [error, setError] = useState(); @@ -193,8 +195,10 @@ export const Assembly = ({ className="h-full" height="100%" placeholder="Try writing some PolkaVM assembly code." + /* TODO [ToDr] Marking as readonly since the 64-bit assembly is not working correctly yet */ + readOnly value={assembly} - onChange={(value) => compile(value)} + onChange={compile} />
diff --git a/src/components/ProgramLoader/Examples.tsx b/src/components/ProgramLoader/Examples.tsx index ade2f0b..6e78f23 100644 --- a/src/components/ProgramLoader/Examples.tsx +++ b/src/components/ProgramLoader/Examples.tsx @@ -1,3 +1,4 @@ +import { RegistersArray } from "@/types/pvm"; import { ProgramUploadFileOutput } from "./types"; import { Button } from "@/components/ui/button.tsx"; @@ -15,8 +16,8 @@ const programs: { fibonacci: { name: "Fibonacci sequence", program: [ - 0, 0, 33, 4, 8, 1, 4, 9, 1, 5, 3, 0, 2, 119, 255, 7, 7, 12, 82, 138, 8, 152, 8, 82, 169, 5, 243, 82, 135, 4, 8, 4, - 9, 17, 19, 0, 73, 147, 82, 213, 0, + 0, 0, 33, 51, 8, 1, 51, 9, 1, 40, 3, 0, 121, 119, 255, 81, 7, 12, 100, 138, 170, 152, 8, 100, 169, 40, 243, 100, + 135, 51, 8, 51, 9, 1, 50, 0, 73, 147, 82, 213, 0, ], regs: [4294901760, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0], pc: 0, @@ -27,16 +28,17 @@ const programs: { gameOfLife: { name: "Conway's Game of Life", program: [ - 0, 0, 129, 23, 62, 1, 3, 255, 0, 62, 1, 11, 255, 0, 62, 1, 19, 255, 0, 62, 1, 18, 255, 0, 62, 1, 9, 255, 0, 5, - 233, 0, 4, 1, 255, 17, 2, 17, 1, 7, 17, 8, 223, 0, 4, 2, 255, 17, 2, 34, 1, 7, 18, 8, 241, 35, 19, 8, 8, 35, 3, 5, - 47, 2, 51, 128, 0, 11, 52, 18, 68, 1, 15, 20, 1, 14, 44, 21, 2, 25, 50, 21, 3, 21, 5, 8, 7, 21, 3, 6, 5, 11, 2, - 51, 128, 26, 3, 255, 0, 5, 205, 2, 51, 128, 26, 3, 5, 198, 4, 5, 82, 52, 4, 8, 64, 2, 68, 255, 73, 132, 7, 2, 119, - 128, 0, 11, 118, 18, 102, 1, 8, 101, 5, 2, 68, 2, 73, 132, 7, 2, 119, 128, 0, 11, 118, 18, 102, 1, 8, 101, 5, 2, - 68, 247, 73, 132, 7, 2, 119, 128, 0, 11, 118, 18, 102, 1, 8, 101, 5, 2, 68, 16, 73, 132, 7, 2, 119, 128, 0, 11, - 118, 18, 102, 1, 8, 101, 5, 2, 68, 1, 73, 132, 7, 2, 119, 128, 0, 11, 118, 18, 102, 1, 8, 101, 5, 2, 68, 254, 73, - 132, 7, 2, 119, 128, 0, 11, 118, 18, 102, 1, 8, 101, 5, 2, 68, 240, 73, 132, 7, 2, 119, 128, 0, 11, 118, 18, 102, - 1, 8, 101, 5, 2, 68, 2, 73, 132, 7, 2, 119, 128, 0, 11, 118, 18, 102, 1, 8, 101, 5, 5, 60, 255, 4, 1, 17, 2, 19, - 128, 0, 1, 18, 3, 50, 2, 17, 4, 7, 17, 64, 12, 255, 5, 240, 33, 132, 16, 146, 9, 153, 72, 138, 18, 17, 69, 137, + 0, 0, 129, 23, 30, 1, 3, 255, 0, 30, 1, 11, 255, 0, 30, 1, 19, 255, 0, 30, 1, 18, 255, 0, 30, 1, 9, 255, 0, 40, + 233, 0, 51, 1, 255, 1, 139, 17, 1, 81, 17, 8, 223, 0, 51, 2, 255, 1, 139, 34, 1, 81, 18, 8, 241, 140, 19, 8, 180, + 35, 3, 40, 47, 139, 51, 128, 0, 114, 52, 122, 68, 1, 82, 20, 1, 14, 83, 21, 2, 25, 86, 21, 3, 21, 40, 8, 81, 21, + 3, 6, 40, 11, 139, 51, 128, 70, 3, 255, 0, 40, 205, 139, 51, 128, 70, 3, 40, 198, 51, 5, 100, 52, 51, 8, 64, 139, + 68, 255, 185, 132, 7, 139, 119, 128, 0, 114, 118, 122, 102, 1, 180, 101, 5, 139, 68, 2, 185, 132, 7, 139, 119, + 128, 0, 114, 118, 122, 102, 1, 180, 101, 5, 139, 68, 247, 185, 132, 7, 139, 119, 128, 0, 114, 118, 122, 102, 1, + 180, 101, 5, 139, 68, 16, 185, 132, 7, 139, 119, 128, 0, 114, 118, 122, 102, 1, 180, 101, 5, 139, 68, 1, 185, 132, + 7, 139, 119, 128, 0, 114, 118, 122, 102, 1, 180, 101, 5, 139, 68, 254, 185, 132, 7, 139, 119, 128, 0, 114, 118, + 122, 102, 1, 180, 101, 5, 139, 68, 240, 185, 132, 7, 139, 119, 128, 0, 114, 118, 122, 102, 1, 180, 101, 5, 139, + 68, 2, 185, 132, 7, 139, 119, 128, 0, 114, 118, 122, 102, 1, 180, 101, 5, 40, 60, 255, 51, 1, 1, 139, 19, 128, 0, + 118, 18, 112, 50, 139, 17, 4, 81, 17, 64, 12, 255, 40, 240, 33, 132, 16, 146, 9, 153, 72, 138, 18, 17, 69, 137, 82, 149, 36, 74, 146, 40, 73, 162, 36, 137, 146, 36, 74, 146, 40, 73, 162, 36, 137, 146, 52, 42, 33, ], regs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], @@ -53,7 +55,7 @@ const programs: { }, branch: { name: "Branch instruction", - program: [0, 0, 16, 4, 7, 210, 4, 7, 39, 210, 4, 6, 0, 4, 7, 239, 190, 173, 222, 17, 6], + program: [0, 0, 16, 51, 7, 210, 4, 81, 39, 210, 4, 6, 0, 51, 7, 239, 190, 173, 222, 17, 6], regs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], pc: 0, pageMap: [], @@ -62,7 +64,7 @@ const programs: { }, add: { name: "ADD instruction", - program: [0, 0, 3, 8, 135, 9, 1], + program: [0, 0, 3, 121, 121, 2, 1], regs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], pc: 0, pageMap: [], @@ -71,7 +73,7 @@ const programs: { }, storeU16: { name: "Store U16 instruction", - program: [0, 0, 5, 69, 7, 0, 0, 2, 1], + program: [0, 0, 7, 31, 3, 0, 0, 2, 52, 18, 1], regs: [0, 0, 0, 0, 0, 0, 0, 305419896, 0, 0, 0, 0, 0], pc: 0, pageMap: [ @@ -87,21 +89,7 @@ const programs: { empty: { name: "Empty", program: [0, 0, 0], - regs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] as [ - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - number, - ], + regs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], pc: 0, pageMap: [], memory: [], @@ -125,7 +113,7 @@ export const Examples = ({ onProgramLoad }: { onProgramLoad: (val: ProgramUpload onClick={() => { onProgramLoad({ initial: { - regs: programs[key].regs, + regs: programs[key].regs.map((x) => BigInt(x)) as RegistersArray, pc: programs[key].pc, pageMap: programs[key].pageMap, memory: programs[key].memory, diff --git a/src/components/ProgramLoader/ProgramFileUpload.tsx b/src/components/ProgramLoader/ProgramFileUpload.tsx index d759230..fdc840b 100644 --- a/src/components/ProgramLoader/ProgramFileUpload.tsx +++ b/src/components/ProgramLoader/ProgramFileUpload.tsx @@ -93,7 +93,7 @@ export const ProgramFileUpload = ({ program: Array.from(code), name: "custom", initial: { - regs: Array.from(registers) as RegistersArray, + regs: Array.from(registers).map((x) => BigInt(x as number | bigint)) as RegistersArray, pc: 0, pageMap: [], // TODO: map memory properly diff --git a/src/components/ProgramLoader/utils.ts b/src/components/ProgramLoader/utils.ts index bd86937..3b55ec0 100644 --- a/src/components/ProgramLoader/utils.ts +++ b/src/components/ProgramLoader/utils.ts @@ -1,5 +1,6 @@ import { mapKeys, camelCase, pickBy } from "lodash"; import { ProgramUploadFileInput, ProgramUploadFileOutput } from "./types"; +import { RegistersArray } from "@/types/pvm"; export function mapUploadFileInputToOutput(data: ProgramUploadFileInput): ProgramUploadFileOutput { const camelCasedData = mapKeys(data, (_value: unknown, key: string) => camelCase(key)); @@ -20,5 +21,6 @@ export function mapUploadFileInputToOutput(data: ProgramUploadFileInput): Progra // expected: mapKeys(expected, (_value: unknown, key) => camelCase(key.replace("expected", ""))) as unknown as ProgramUploadFileOutput["expected"], }; + result.initial.regs = result.initial.regs?.map((x) => BigInt(x as number | bigint)) as RegistersArray; return result; } diff --git a/src/components/PvmSelect/index.tsx b/src/components/PvmSelect/index.tsx index 0642510..6b09e69 100644 --- a/src/components/PvmSelect/index.tsx +++ b/src/components/PvmSelect/index.tsx @@ -171,7 +171,7 @@ export const PvmSelect = () => { id: value, type: PvmTypes.WASM_URL, params: { - url: path.join(url, "../", metadata.wasmBlobUrl32 || metadata.wasmBlobUrl), + url: path.join(url, "../", metadata.wasmBlobUrl), lang, }, }, diff --git a/src/components/Registers/index.tsx b/src/components/Registers/index.tsx index fdbea50..790b820 100644 --- a/src/components/Registers/index.tsx +++ b/src/components/Registers/index.tsx @@ -1,6 +1,5 @@ import { ExpectedState, InitialState, RegistersArray, Status } from "@/types/pvm"; import { ReactNode, useContext } from "react"; -import { NumeralSystem } from "@/context/NumeralSystem"; import { NumeralSystemContext } from "@/context/NumeralSystemContext"; import { valueToNumeralSystem } from "@/components/Instructions/utils.tsx"; import classNames from "classnames"; @@ -131,7 +130,7 @@ export const Registers = ({
-
+

PC

{allowEditingPc ? ( @@ -140,13 +139,10 @@ export const Registers = ({ className="w-20 h-6 m-0 py-0 px-[4px] text-md border-white hover:border-input" onChange={(e) => { const value = e.target?.value; - const valueInDecimal = - numeralSystem === NumeralSystem.HEXADECIMAL ? `${parseInt(value, 16)}` : value; - const pcValue = - valueInDecimal && !Number.isNaN(parseInt(valueInDecimal)) ? parseInt(valueInDecimal) : 0; + const newValue = stringToNumber(value, Number); onCurrentStateChange({ ...currentState, - pc: pcValue, + pc: newValue, }); }} onKeyUp={(e) => { @@ -205,14 +201,11 @@ export const Registers = ({ className="w-20 h-6 m-0 p-0" onChange={(e) => { const value = e.target?.value; - const valueInDecimal = - numeralSystem === NumeralSystem.HEXADECIMAL ? `${parseInt(value, 16)}` : value; - const regValue = - valueInDecimal && !Number.isNaN(parseInt(valueInDecimal)) ? parseInt(valueInDecimal) : ""; + const newValue = stringToNumber(value, BigInt); onCurrentStateChange({ ...currentState, - regs: currentState.regs?.map((val: number, index: number) => - index === regNo ? regValue : val, + regs: currentState.regs?.map((val: bigint, index: number) => + index === regNo ? newValue : val, ) as InitialState["regs"], }); }} @@ -231,7 +224,7 @@ export const Registers = ({ propName="regs" propNameIndex={regNo} workers={workers} - padStartVal={numeralSystem ? 8 : 0} + padStartVal={numeralSystem ? 16 : 0} /> )}
@@ -242,3 +235,11 @@ export const Registers = ({
); }; + +function stringToNumber(value: string, cb: (x: string) => T): T { + try { + return cb(value); + } catch (_e) { + return cb("0"); + } +} diff --git a/src/context/NumeralSystemProvider.tsx b/src/context/NumeralSystemProvider.tsx index 37ede88..b89bdc2 100644 --- a/src/context/NumeralSystemProvider.tsx +++ b/src/context/NumeralSystemProvider.tsx @@ -3,7 +3,7 @@ import { NumeralSystem } from "./NumeralSystem"; import { NumeralSystemContext } from "./NumeralSystemContext"; export const NumeralSystemProvider = ({ children }: { children: ReactNode }) => { - const [numeralSystem, setNumeralSystem] = useState(NumeralSystem.DECIMAL); + const [numeralSystem, setNumeralSystem] = useState(NumeralSystem.HEXADECIMAL); return ( diff --git a/src/packages/pvm/pvm/assemblify.ts b/src/packages/pvm/pvm/assemblify.ts index f83ca4e..1825fb1 100644 --- a/src/packages/pvm/pvm/assemblify.ts +++ b/src/packages/pvm/pvm/assemblify.ts @@ -12,10 +12,13 @@ const instructionsWithoutArgs: InstructionTuple[] = [ const instructionsWithOneImmediate: InstructionTuple[] = [[Instruction.ECALLI, 1]]; +const instructionsWithOneRegisterAndOneExtendedWidthImmediate: InstructionTuple[] = [[Instruction.LOAD_IMM_64, 1]]; + const instructionsWithTwoImmediates: InstructionTuple[] = [ [Instruction.STORE_IMM_U8, 1], [Instruction.STORE_IMM_U16, 1], [Instruction.STORE_IMM_U32, 1], + [Instruction.STORE_IMM_U64, 1], ]; const instructionsWithOneOffset: InstructionTuple[] = [[Instruction.JUMP, 1]]; @@ -28,15 +31,19 @@ const instructionsWithOneRegisterAndOneImmediate: InstructionTuple[] = [ [Instruction.LOAD_U16, 1], [Instruction.LOAD_I16, 1], [Instruction.LOAD_U32, 1], + [Instruction.LOAD_I32, 1], + [Instruction.LOAD_U64, 1], [Instruction.STORE_U8, 1], [Instruction.STORE_U16, 1], [Instruction.STORE_U32, 1], + [Instruction.STORE_U64, 1], ]; const instructionsWithOneRegisterAndTwoImmediate: InstructionTuple[] = [ [Instruction.STORE_IMM_IND_U8, 1], [Instruction.STORE_IMM_IND_U16, 1], [Instruction.STORE_IMM_IND_U32, 1], + [Instruction.STORE_IMM_IND_U64, 1], ]; const instructionsWithOneRegisterOneImmediateAndOneOffset: InstructionTuple[] = [ @@ -62,31 +69,41 @@ const instructionsWithTwoRegistersAndOneImmediate: InstructionTuple[] = [ [Instruction.STORE_IND_U8, 1], [Instruction.STORE_IND_U16, 1], [Instruction.STORE_IND_U32, 1], + [Instruction.STORE_IND_U64, 1], [Instruction.LOAD_IND_U8, 1], [Instruction.LOAD_IND_I8, 1], [Instruction.LOAD_IND_U16, 1], [Instruction.LOAD_IND_I16, 1], [Instruction.LOAD_IND_U32, 1], - [Instruction.ADD_IMM, 1], + [Instruction.LOAD_IND_I32, 1], + [Instruction.LOAD_IND_U64, 1], + [Instruction.ADD_IMM_32, 1], [Instruction.AND_IMM, 1], [Instruction.XOR_IMM, 1], [Instruction.OR_IMM, 1], - [Instruction.MUL_IMM, 1], - [Instruction.MUL_UPPER_S_S_IMM, 1], - [Instruction.MUL_UPPER_U_U_IMM, 1], + [Instruction.MUL_IMM_32, 1], [Instruction.SET_LT_U_IMM, 1], [Instruction.SET_LT_S_IMM, 1], - [Instruction.SHLO_L_IMM, 1], - [Instruction.SHLO_R_IMM, 1], - [Instruction.SHAR_R_IMM, 1], - [Instruction.NEG_ADD_IMM, 1], + [Instruction.SHLO_L_IMM_32, 1], + [Instruction.SHLO_R_IMM_32, 1], + [Instruction.SHAR_R_IMM_32, 1], + [Instruction.NEG_ADD_IMM_32, 1], [Instruction.SET_GT_U_IMM, 1], [Instruction.SET_GT_S_IMM, 1], - [Instruction.SHLO_L_IMM_ALT, 1], - [Instruction.SHLO_R_IMM_ALT, 1], - [Instruction.SHAR_R_IMM_ALT, 1], + [Instruction.SHLO_L_IMM_ALT_32, 1], + [Instruction.SHLO_R_IMM_ALT_32, 1], + [Instruction.SHAR_R_IMM_ALT_32, 1], [Instruction.CMOV_IZ_IMM, 1], [Instruction.CMOV_NZ_IMM, 1], + [Instruction.ADD_IMM_64, 1], + [Instruction.MUL_IMM_64, 1], + [Instruction.SHLO_L_IMM_64, 1], + [Instruction.SHLO_R_IMM_64, 1], + [Instruction.SHAR_R_IMM_64, 1], + [Instruction.NEG_ADD_IMM_64, 1], + [Instruction.SHLO_L_IMM_ALT_64, 1], + [Instruction.SHLO_R_IMM_ALT_64, 1], + [Instruction.SHAR_R_IMM_ALT_64, 1], ]; const instructionsWithTwoRegistersAndOneOffset: InstructionTuple[] = [ @@ -101,24 +118,34 @@ const instructionsWithTwoRegistersAndOneOffset: InstructionTuple[] = [ const instructionWithTwoRegistersAndTwoImmediates: InstructionTuple[] = [[Instruction.LOAD_IMM_JUMP_IND, 1]]; const instructionsWithThreeRegisters: InstructionTuple[] = [ - [Instruction.ADD, 1], - [Instruction.SUB, 1], + [Instruction.ADD_32, 1], + [Instruction.SUB_32, 1], + [Instruction.MUL_32, 1], + [Instruction.DIV_U_32, 1], + [Instruction.DIV_S_32, 1], + [Instruction.REM_U_32, 1], + [Instruction.REM_S_32, 1], + [Instruction.SHLO_L_32, 1], + [Instruction.SHLO_R_32, 1], + [Instruction.SHAR_R_32, 1], + [Instruction.ADD_64, 1], + [Instruction.SUB_64, 1], + [Instruction.MUL_64, 1], + [Instruction.DIV_U_64, 1], + [Instruction.DIV_S_64, 1], + [Instruction.REM_U_64, 1], + [Instruction.REM_S_64, 1], + [Instruction.SHLO_L_64, 1], + [Instruction.SHLO_R_64, 1], + [Instruction.SHAR_R_64, 1], [Instruction.AND, 1], [Instruction.XOR, 1], [Instruction.OR, 1], - [Instruction.MUL, 1], [Instruction.MUL_UPPER_S_S, 1], [Instruction.MUL_UPPER_U_U, 1], [Instruction.MUL_UPPER_S_U, 1], - [Instruction.DIV_U, 1], - [Instruction.DIV_S, 1], - [Instruction.REM_U, 1], - [Instruction.REM_S, 1], [Instruction.SET_LT_U, 1], [Instruction.SET_LT_S, 1], - [Instruction.SHLO_L, 1], - [Instruction.SHLO_R, 1], - [Instruction.SHAR_R, 1], [Instruction.CMOV_IZ, 1], [Instruction.CMOV_NZ, 1], ]; @@ -136,6 +163,7 @@ const instructions: InstructionTuple[] = [ ...instructionsWithTwoRegistersAndOneOffset, ...instructionWithTwoRegistersAndTwoImmediates, ...instructionsWithThreeRegisters, + ...instructionsWithOneRegisterAndOneExtendedWidthImmediate, ]; type OpCode = { diff --git a/src/packages/pvm/pvm/instruction.ts b/src/packages/pvm/pvm/instruction.ts index f3b543d..4053db9 100644 --- a/src/packages/pvm/pvm/instruction.ts +++ b/src/packages/pvm/pvm/instruction.ts @@ -1,92 +1,118 @@ export enum Instruction { TRAP = 0, - FALLTHROUGH = 17, - JUMP = 5, - JUMP_IND = 19, - LOAD_IMM = 4, - LOAD_U8 = 60, - LOAD_I8 = 74, - LOAD_U16 = 76, - LOAD_I16 = 66, - LOAD_U32 = 10, - STORE_U8 = 71, - STORE_U16 = 69, - STORE_U32 = 22, - STORE_IMM_IND_U8 = 26, - STORE_IMM_IND_U16 = 54, - STORE_IMM_IND_U32 = 13, - LOAD_IMM_JUMP = 6, - BRANCH_EQ_IMM = 7, - BRANCH_NE_IMM = 15, - BRANCH_LT_U_IMM = 44, - BRANCH_LE_U_IMM = 59, - BRANCH_GE_U_IMM = 52, - BRANCH_GT_U_IMM = 50, - BRANCH_LT_S_IMM = 32, - BRANCH_LE_S_IMM = 46, - BRANCH_GE_S_IMM = 45, - BRANCH_GT_S_IMM = 53, - MOVE_REG = 82, - SBRK = 87, - STORE_IND_U8 = 16, - STORE_IND_U16 = 29, - STORE_IND_U32 = 3, - LOAD_IND_U8 = 11, - LOAD_IND_I8 = 21, - LOAD_IND_U16 = 37, - LOAD_IND_I16 = 33, - LOAD_IND_U32 = 1, - ADD_IMM = 2, - AND_IMM = 18, - XOR_IMM = 31, - OR_IMM = 49, - MUL_IMM = 35, - MUL_UPPER_S_S_IMM = 65, - MUL_UPPER_U_U_IMM = 63, - SET_LT_U_IMM = 27, - SET_LT_S_IMM = 56, - SHLO_L_IMM = 9, - SHLO_R_IMM = 14, - SHAR_R_IMM = 25, - NEG_ADD_IMM = 40, - SET_GT_U_IMM = 39, - SET_GT_S_IMM = 61, - SHLO_L_IMM_ALT = 75, - SHLO_R_IMM_ALT = 72, - SHAR_R_IMM_ALT = 80, - CMOV_IZ_IMM = 85, - CMOV_NZ_IMM = 86, - BRANCH_EQ = 24, - BRANCH_NE = 30, - BRANCH_LT_U = 47, - BRANCH_LT_S = 48, - BRANCH_GE_U = 41, - BRANCH_GE_S = 43, - LOAD_IMM_JUMP_IND = 42, - ADD = 8, - SUB = 20, - AND = 23, - XOR = 28, - OR = 12, - MUL = 34, - MUL_UPPER_S_S = 67, - MUL_UPPER_U_U = 57, - MUL_UPPER_S_U = 81, - DIV_U = 68, - DIV_S = 64, - REM_U = 73, - REM_S = 70, - SET_LT_U = 36, - SET_LT_S = 58, - SHLO_L = 55, - SHLO_R = 51, - SHAR_R = 77, - CMOV_IZ = 83, - CMOV_NZ = 84, - ECALLI = 78, - STORE_IMM_U8 = 62, - STORE_IMM_U16 = 79, - STORE_IMM_U32 = 38, + FALLTHROUGH = 1, + ECALLI = 10, + LOAD_IMM_64 = 20, + STORE_IMM_U8 = 30, + STORE_IMM_U16 = 31, + STORE_IMM_U32 = 32, + STORE_IMM_U64 = 33, + JUMP = 40, + JUMP_IND = 50, + LOAD_IMM = 51, + LOAD_U8 = 52, + LOAD_I8 = 53, + LOAD_U16 = 54, + LOAD_I16 = 55, + LOAD_U32 = 56, + LOAD_I32 = 57, + LOAD_U64 = 58, + STORE_U8 = 59, + STORE_U16 = 60, + STORE_U32 = 61, + STORE_U64 = 62, + STORE_IMM_IND_U8 = 70, + STORE_IMM_IND_U16 = 71, + STORE_IMM_IND_U32 = 72, + STORE_IMM_IND_U64 = 73, + LOAD_IMM_JUMP = 80, + BRANCH_EQ_IMM = 81, + BRANCH_NE_IMM = 82, + BRANCH_LT_U_IMM = 83, + BRANCH_LE_U_IMM = 84, + BRANCH_GE_U_IMM = 85, + BRANCH_GT_U_IMM = 86, + BRANCH_LT_S_IMM = 87, + BRANCH_LE_S_IMM = 88, + BRANCH_GE_S_IMM = 89, + BRANCH_GT_S_IMM = 90, + MOVE_REG = 100, + SBRK = 101, + STORE_IND_U8 = 110, + STORE_IND_U16 = 111, + STORE_IND_U32 = 112, + STORE_IND_U64 = 113, + LOAD_IND_U8 = 114, + LOAD_IND_I8 = 115, + LOAD_IND_U16 = 116, + LOAD_IND_I16 = 117, + LOAD_IND_U32 = 118, + LOAD_IND_I32 = 119, + LOAD_IND_U64 = 120, + ADD_IMM_32 = 121, + AND_IMM = 122, + XOR_IMM = 123, + OR_IMM = 124, + MUL_IMM_32 = 125, + SET_LT_U_IMM = 126, + SET_LT_S_IMM = 127, + SHLO_L_IMM_32 = 128, + SHLO_R_IMM_32 = 129, + SHAR_R_IMM_32 = 130, + NEG_ADD_IMM_32 = 131, + SET_GT_U_IMM = 132, + SET_GT_S_IMM = 133, + SHLO_L_IMM_ALT_32 = 134, + SHLO_R_IMM_ALT_32 = 135, + SHAR_R_IMM_ALT_32 = 136, + CMOV_IZ_IMM = 137, + CMOV_NZ_IMM = 138, + ADD_IMM_64 = 139, + MUL_IMM_64 = 140, + SHLO_L_IMM_64 = 141, + SHLO_R_IMM_64 = 142, + SHAR_R_IMM_64 = 143, + NEG_ADD_IMM_64 = 144, + SHLO_L_IMM_ALT_64 = 145, + SHLO_R_IMM_ALT_64 = 146, + SHAR_R_IMM_ALT_64 = 147, + BRANCH_EQ = 150, + BRANCH_NE = 151, + BRANCH_LT_U = 152, + BRANCH_LT_S = 153, + BRANCH_GE_U = 154, + BRANCH_GE_S = 155, + LOAD_IMM_JUMP_IND = 160, + ADD_32 = 170, + SUB_32 = 171, + MUL_32 = 172, + DIV_U_32 = 173, + DIV_S_32 = 174, + REM_U_32 = 175, + REM_S_32 = 176, + SHLO_L_32 = 177, + SHLO_R_32 = 178, + SHAR_R_32 = 179, + ADD_64 = 180, + SUB_64 = 181, + MUL_64 = 182, + DIV_U_64 = 183, + DIV_S_64 = 184, + REM_U_64 = 185, + REM_S_64 = 186, + SHLO_L_64 = 187, + SHLO_R_64 = 188, + SHAR_R_64 = 189, + AND = 190, + XOR = 191, + OR = 192, + MUL_UPPER_S_S = 193, + MUL_UPPER_U_U = 194, + MUL_UPPER_S_U = 195, + SET_LT_U = 196, + SET_LT_S = 197, + CMOV_IZ = 198, + CMOV_NZ = 199, } export const HIGHEST_INSTRUCTION_NUMBER = Instruction.SBRK; diff --git a/src/packages/web-worker/command-handlers/step.ts b/src/packages/web-worker/command-handlers/step.ts index 1508e53..19003bd 100644 --- a/src/packages/web-worker/command-handlers/step.ts +++ b/src/packages/web-worker/command-handlers/step.ts @@ -17,7 +17,7 @@ const step = ({ pvm, program, stepsToPerform }: StepParams) => { throw new Error("PVM is uninitialized."); } - const isFinished = stepsToPerform > 1 ? !pvm.run(stepsToPerform) : !pvm.nextStep(); + const isFinished = stepsToPerform > 1 ? !pvm.nSteps(stepsToPerform) : !pvm.nextStep(); const state = getState(pvm); const result = nextInstruction(state.pc ?? 0, program) as unknown as CurrentInstruction; diff --git a/src/packages/web-worker/index.ts b/src/packages/web-worker/index.ts deleted file mode 100644 index d92a799..0000000 --- a/src/packages/web-worker/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// import MyWorker from "./worker?worker&inline"; -// const worker = new MyWorker(); -// -// export { worker }; diff --git a/src/packages/web-worker/pvm.ts b/src/packages/web-worker/pvm.ts index 43ecd57..4993a7e 100644 --- a/src/packages/web-worker/pvm.ts +++ b/src/packages/web-worker/pvm.ts @@ -4,6 +4,7 @@ import { instructionArgumentTypeMap, ProgramDecoder, tryAsMemoryIndex, + tryAsSbrkIndex, } from "@typeberry/pvm-debugger-adapter"; import { ArgsDecoder, Registers } from "@typeberry/pvm-debugger-adapter"; import { byteToOpCodeMap } from "../../packages/pvm/pvm/assemblify"; @@ -19,9 +20,9 @@ export const initPvm = (pvm: InternalPvmInstance, program: Uint8Array, initialSt const isWriteable = page["is-writable"]; if (isWriteable) { - memoryBuilder.setWriteable(startPageIndex, endPageIndex, new Uint8Array(page.length)); + memoryBuilder.setWriteablePages(startPageIndex, endPageIndex, new Uint8Array(page.length)); } else { - memoryBuilder.setReadable(startPageIndex, endPageIndex, new Uint8Array(page.length)); + memoryBuilder.setReadablePages(startPageIndex, endPageIndex, new Uint8Array(page.length)); } } @@ -30,17 +31,16 @@ export const initPvm = (pvm: InternalPvmInstance, program: Uint8Array, initialSt memoryBuilder.setData(idx, new Uint8Array(memoryChunk.contents)); } - //const HEAP_START_PAGE = 4 * 2 ** 16; - const HEAP_END_PAGE = tryAsMemoryIndex(2 ** 32 - 2 * 2 ** 16 - 2 ** 24); + const pageSize = 2 ** 12; + const maxAddressFromPageMap = Math.max(0, ...pageMap.map((page) => page.address)); + const hasMemoryLayout = maxAddressFromPageMap > 0; + const heapStartIndex = tryAsSbrkIndex(hasMemoryLayout ? maxAddressFromPageMap + pageSize : 0); + const heapEndIndex = tryAsSbrkIndex(2 ** 32 - 2 * 2 ** 16 - 2 ** 24); - // TODO [ToDr] [#216] Since we don't have examples yet of the - // PVM program allocating more memory, we disallow expanding - // the memory completely by setting `sbrkIndex` to the same value - // as the end page. - const memory = memoryBuilder.finalize(HEAP_END_PAGE, HEAP_END_PAGE); + const memory = memoryBuilder.finalize(heapStartIndex, heapEndIndex); const registers = new Registers(); - registers.copyFrom(new Uint32Array(initialState.regs!)); + registers.copyFrom(new BigUint64Array(initialState.regs!.map((x) => BigInt(x)))); pvm.reset(new Uint8Array(program), initialState.pc ?? 0, initialState.gas ?? 0n, registers, memory); }; diff --git a/src/packages/web-worker/utils.ts b/src/packages/web-worker/utils.ts index ddbba77..010ca1a 100644 --- a/src/packages/web-worker/utils.ts +++ b/src/packages/web-worker/utils.ts @@ -28,14 +28,14 @@ export function getState(pvm: PvmApiInterface): ExpectedState { } export function regsAsUint8(regs?: RegistersArray): Uint8Array { - const arr = new Uint8Array(13 * 4); + const arr = new Uint8Array(13 * 8); if (!regs) { return arr; } let i = 0; for (const reg of regs) { - const bytes = u32_le_bytes(reg); + const bytes = u64_le_bytes(reg); for (let a = 0; a < bytes.length; a += 1) { arr[i] = bytes[a]; i += 1; @@ -44,7 +44,7 @@ export function regsAsUint8(regs?: RegistersArray): Uint8Array { return arr; } -export function u32_le_bytes(val: number) { +function u32_le_bytes(val: number) { const out = new Uint8Array(4); out[0] = val & 0xff; out[1] = (val >> 8) & 0xff; @@ -53,11 +53,25 @@ export function u32_le_bytes(val: number) { return out; } +export function u64_le_bytes(val: bigint) { + const out = new Uint8Array(8); + out[0] = Number(val & 0xffn); + out[1] = Number((val >> 8n) & 0xffn); + out[2] = Number((val >> 16n) & 0xffn); + out[3] = Number((val >> 24n) & 0xffn); + out[4] = Number((val >> 32n) & 0xffn); + out[5] = Number((val >> 40n) & 0xffn); + out[6] = Number((val >> 48n) & 0xffn); + out[7] = Number((val >> 56n) & 0xffn); + return out; +} + export function uint8asRegs(arr: Uint8Array): RegistersArray { - const regs: RegistersArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - const u32Regs = new Uint32Array(arr.buffer); + const regs: RegistersArray = [0n, 1n, 2n, 3n, 4n, 5n, 6n, 7n, 8n, 9n, 10n, 11n, 12n]; + const u64Regs = new BigUint64Array(arr.buffer); for (const regIdx of regs) { - regs[regIdx] = u32Regs[regIdx]; + const idx = Number(regIdx); + regs[idx] = u64Regs[idx]; } return regs; } diff --git a/src/packages/web-worker/wasmAsShell.ts b/src/packages/web-worker/wasmAsShell.ts index ddc3a50..d61af88 100644 --- a/src/packages/web-worker/wasmAsShell.ts +++ b/src/packages/web-worker/wasmAsShell.ts @@ -14,7 +14,7 @@ export async function createAssemblyScriptWasmPvmShell(module: WebAssembly.Modul resetGeneric, resetGenericWithMemory, nextStep, - run, + nSteps, getProgramCounter, setNextProgramCounter, getStatus, @@ -32,7 +32,7 @@ export async function createAssemblyScriptWasmPvmShell(module: WebAssembly.Modul resetGeneric, resetGenericWithMemory, nextStep, - run, + nSteps, getProgramCounter, setNextProgramCounter, setGasLeft, diff --git a/src/packages/web-worker/wasmBindgenInit.ts b/src/packages/web-worker/wasmBindgenInit.ts index d8afaee..05bfbd8 100644 --- a/src/packages/web-worker/wasmBindgenInit.ts +++ b/src/packages/web-worker/wasmBindgenInit.ts @@ -92,8 +92,8 @@ export function nextStep() { * @param {number} steps * @returns {boolean} */ -export function run(steps) { - const ret = wasm.run(steps); +export function nSteps(steps) { + const ret = wasm.nSteps(steps); return ret !== 0; } diff --git a/src/packages/web-worker/wasmBindgenShell.ts b/src/packages/web-worker/wasmBindgenShell.ts index 77e2f20..257b4a8 100644 --- a/src/packages/web-worker/wasmBindgenShell.ts +++ b/src/packages/web-worker/wasmBindgenShell.ts @@ -16,7 +16,7 @@ export interface WasmPvmShellInterface { gas: bigint, ): void; nextStep(): boolean; - run(steps: number): boolean; + nSteps(steps: number): boolean; getExitArg(): number; getStatus(): Status; getRegisters(): Uint8Array; @@ -31,7 +31,7 @@ export function createWasmPvmShell(): WasmPvmShellInterface { resetGeneric, resetGenericWithMemory, nextStep, - run, + nSteps, getProgramCounter, setNextProgramCounter, getExitArg, @@ -48,7 +48,7 @@ export function createWasmPvmShell(): WasmPvmShellInterface { resetGeneric, resetGenericWithMemory, nextStep, - run, + nSteps, getProgramCounter, setNextProgramCounter, getStatus, diff --git a/src/packages/web-worker/wasmGoShell.ts b/src/packages/web-worker/wasmGoShell.ts index da52a0c..d04487c 100644 --- a/src/packages/web-worker/wasmGoShell.ts +++ b/src/packages/web-worker/wasmGoShell.ts @@ -9,7 +9,7 @@ export function createGoWasmPvmShell(): WasmPvmShellInterface { __wbg_set_wasm, resetGeneric: reset, nextStep, - run: (steps: number) => { + nSteps: (steps: number) => { for (let i = 0; i < steps; i++) { if (!nextStep()) { return false; diff --git a/src/pages/ProgramLoader.tsx b/src/pages/ProgramLoader.tsx index 7bb9765..3dd5db4 100644 --- a/src/pages/ProgramLoader.tsx +++ b/src/pages/ProgramLoader.tsx @@ -32,7 +32,7 @@ const ProgramLoader = () => { program: Array.from(code), name: "custom", initial: { - regs: Array.from(registers) as RegistersArray, + regs: Array.from(registers).map((x) => BigInt(x as number | bigint)) as RegistersArray, pc: 0, pageMap: [], // TODO: map memory properly diff --git a/src/store/debugger/debuggerSlice.ts b/src/store/debugger/debuggerSlice.ts index a12dcab..33db13f 100644 --- a/src/store/debugger/debuggerSlice.ts +++ b/src/store/debugger/debuggerSlice.ts @@ -22,7 +22,7 @@ export interface DebuggerState { const initialState: DebuggerState = { program: [], initialState: { - regs: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + regs: [0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n, 0n], pc: 0, pageMap: [], memory: [], diff --git a/src/types/pvm.ts b/src/types/pvm.ts index f24d641..3b3f2fe 100644 --- a/src/types/pvm.ts +++ b/src/types/pvm.ts @@ -4,7 +4,7 @@ export { Pvm } from "@typeberry/pvm-debugger-adapter"; type GrowToSize = A["length"] extends N ? A : GrowToSize; type FixedArray = GrowToSize; -export type RegistersArray = FixedArray; +export type RegistersArray = FixedArray; export type InitialState = { regs?: RegistersArray; diff --git a/src/utils/instructionsKnowledgeBase.ts b/src/utils/instructionsKnowledgeBase.ts index 0f4c151..5190bf3 100644 --- a/src/utils/instructionsKnowledgeBase.ts +++ b/src/utils/instructionsKnowledgeBase.ts @@ -11,651 +11,774 @@ export const instructionsKnowledgeBase: InstructionKnowledgeBaseEntry[] = [ name: "trap", opcode: 0, description: "Trigger a trap, setting the error state.", - latex: "\\varepsilon = \\text{⚡}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/233a02233a02", + latex: "\\varepsilon = \\text{☇}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/243b02243b02", }, { name: "fallthrough", - opcode: 17, + opcode: 1, description: "Proceed with the next instruction without any modifications.", latex: "", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/233a02233a02", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/243b02243b02", }, { name: "ecalli", - opcode: 78, - description: "Execute a call with an external operation, setting the error state based on the result.", - latex: "\\varepsilon = \\hbar \\times \\nu_X", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/245c00245c00", + opcode: 10, + description: "Perform a host environment call using an immediate value.", + latex: "\\varepsilon = \\text{h} \\times \\nu_X", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255d00255d00", + }, + + { + name: "load_imm_64", + opcode: 20, + description: "Load a 64-bit immediate value into a register.", + latex: "\\omega'_A = \\nu_X", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/25ba0025ba00", }, { name: "store_imm_u8", - opcode: 62, - description: "Store the immediate value νY into memory at the address νX modulo 2^8.", - latex: "\\mu'_{\\nu_X} = \\nu_Y \\mod 2^8", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24b90024b900", + opcode: 30, + description: "Store an 8-bit immediate value to memory.", + latex: "\\mu'\\nu_X = \\nu_Y \\mod 2^8", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/251701251701", }, { name: "store_imm_u16", - opcode: 79, - description: "Store the immediate value νY into memory at the address νX as a 16-bit value.", - latex: "\\mu'_{\\nu_X...+2} = \\mathcal{E}_2(\\nu_Y \\mod 2^{16})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24b90024b900", + opcode: 31, + description: "Store a 16-bit immediate value to memory.", + latex: "\\mu'\\nu_X+2 = \\mathcal{E}_2(\\nu_Y \\mod 2^{16})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/251701251701", }, { name: "store_imm_u32", - opcode: 38, - description: "Store the immediate value νY into memory at the address νX as a 32-bit value.", - latex: "\\mu'_{\\nu_X...+4} = \\mathcal{E}_4(\\nu_Y)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24b90024b900", + opcode: 32, + description: "Store a 32-bit immediate value to memory.", + latex: "\\mu'\\nu_X+4 = \\mathcal{E}_4(\\nu_Y \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/251701251701", + }, + { + name: "store_imm_u64", + opcode: 33, + description: "Store a 64-bit immediate value to memory.", + latex: "\\mu'\\nu_X+8 = \\mathcal{E}_8(\\nu_Y)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/251701251701", }, { name: "jump", - opcode: 5, - description: "Perform a jump to the address specified by νX.", - latex: "branch(\\nu_X, \\top)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/248101248101", + opcode: 40, + description: "Unconditionally jump to a computed address.", + latex: "\\text{branch}(\\nu_X, \\top)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/25fa0125fa01", }, { name: "jump_ind", - opcode: 19, - description: "Indirect jump to the address calculated as (ωA + νX) modulo 2^32.", - latex: "djump((\\omega_A + \\nu_X) \\mod 2^{32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 50, + description: "Dynamically jump to an address computed from a register and offset.", + latex: "\\text{djump}((\\omega_A + \\nu_X) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "load_imm", - opcode: 4, - description: "Load the immediate value νX into register ω'A.", + opcode: 51, + description: "Load an immediate value into a register.", latex: "\\omega'_A = \\nu_X", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "load_u8", - opcode: 60, - description: "Load an 8-bit unsigned value from memory at address μνX into register ω'A.", - latex: "\\omega'_A = \\mu_{\\nu_X}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 52, + description: "Load an 8-bit value from memory into a register.", + latex: "\\omega'_A = \\mu_X", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "load_i8", - opcode: 74, - description: "Load an 8-bit signed value from memory at address μνX into register ω'A.", - latex: "\\omega'_A = \\mathbb{Z}_4^{-1}(\\mathbb{Z}_1(\\mu_{\\nu_X}))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 53, + description: "Load an 8-bit signed value from memory into a register.", + latex: "\\omega'_A = \\mathcal{H}_1(\\mu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "load_u16", - opcode: 76, - description: "Load a 16-bit unsigned value from memory at address μνX into register ω'A.", - latex: "\\omega'_A = \\mathcal{E}_2^{-1}(\\mu_{\\nu_X...+2})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 54, + description: "Load a 16-bit unsigned value from memory into a register.", + latex: "\\omega'_A = \\mathcal{E}_2^{-1}(\\mu_{X+2})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "load_i16", - opcode: 66, - description: "Load a 16-bit signed value from memory at address μνX into register ω'A.", - latex: "\\omega'_A = \\mathbb{Z}_4^{-1}(\\mathbb{Z}_2(\\mathcal{E}_2^{-1}(\\mu_{\\nu_X...+2})))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 55, + description: "Load a 16-bit signed value from memory into a register.", + latex: "\\omega'_A = \\mathcal{K}_2(\\mathcal{E}_2^{-1}(\\mu_{X+2}))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "load_u32", - opcode: 10, - description: "Load a 32-bit unsigned value from memory at address μνX into register ω'A.", - latex: "\\omega'_A = \\mathcal{E}_4^{-1}(\\mu_{\\nu_X...+4})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 56, + description: "Load a 32-bit unsigned value from memory into a register.", + latex: "\\omega'_A = \\mathcal{E}_4^{-1}(\\mu_{X+4})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", + }, + { + name: "load_i32", + opcode: 57, + description: "Load a 32-bit signed value from memory into a register.", + latex: "\\omega'_A = \\mathcal{K}_4(\\mathcal{E}_4^{-1}(\\mu_{X+4}))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", + }, + { + name: "load_u64", + opcode: 58, + description: "Load a 64-bit unsigned value from memory into a register.", + latex: "\\omega'_A = \\mathcal{E}_8^{-1}(\\mu_{X+8})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "store_u8", - opcode: 71, - description: "Store an 8-bit unsigned value from register ωA into memory at address μνX.", - latex: "\\mu'_{\\nu_X} = \\omega_A \\mod 2^8", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 59, + description: "Store an 8-bit value from a register into memory.", + latex: "\\mu'\\nu_X = \\omega_A \\mod 2^8", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "store_u16", - opcode: 69, - description: "Store a 16-bit unsigned value from register ωA into memory at address μνX.", - latex: "\\mu'_{\\nu_X...+2} = \\mathcal{E}_2(\\omega_A \\mod 2^{16})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 60, + description: "Store a 16-bit value from a register into memory.", + latex: "\\mu'\\nu_X+2 = \\mathcal{E}_2(\\omega_A \\mod 2^{16})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "store_u32", - opcode: 22, - description: "Store a 32-bit unsigned value from register ωA into memory at address μνX.", - latex: "\\mu'_{\\nu_X...+4} = \\mathcal{E}_4(\\omega_A)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/24dd0124dd01", + opcode: 61, + description: "Store a 32-bit value from a register into memory.", + latex: "\\mu'\\nu_X+4 = \\mathcal{E}_4(\\omega_A \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", + }, + { + name: "store_u64", + opcode: 62, + description: "Store a 64-bit value from a register into memory.", + latex: "\\mu'\\nu_X+8 = \\mathcal{E}_8(\\omega_A)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/255602255602", }, { name: "store_imm_ind_u8", - opcode: 26, - description: "Store the immediate value νY into memory at the address (ωA + νX) modulo 2^8.", - latex: "\\mu'_{\\omega_A + \\nu_X} = \\nu_Y \\mod 2^8", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/251000251000", + opcode: 70, + description: "Store an 8-bit immediate value indirectly into memory.", + latex: "\\mu'\\omega_A+\\nu_X = \\nu_Y \\mod 2^8", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26c00026c000", }, { name: "store_imm_ind_u16", - opcode: 54, - description: "Store the immediate value νY into memory at the address (ωA + νX) as a 16-bit value.", - latex: "\\mu'_{\\omega_A + \\nu_X...+2} = \\mathcal{E}_2(\\nu_Y \\mod 2^{16})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/251000251000", + opcode: 71, + description: "Store a 16-bit immediate value indirectly into memory.", + latex: "\\mu'\\omega_A+\\nu_X+2 = \\mathcal{E}_2(\\nu_Y \\mod 2^{16})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26c00026c000", }, { name: "store_imm_ind_u32", - opcode: 13, - description: "Store the immediate value νY into memory at the address (ωA + νX) as a 32-bit value.", - latex: "\\mu'_{\\omega_A + \\nu_X...+4} = \\mathcal{E}_4(\\nu_Y)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/251000251000", + opcode: 72, + description: "Store a 32-bit immediate value indirectly into memory.", + latex: "\\mu'\\omega_A+\\nu_X+4 = \\mathcal{E}_4(\\nu_Y \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26c00026c000", + }, + { + name: "store_imm_ind_u64", + opcode: 73, + description: "Store a 64-bit immediate value indirectly into memory.", + latex: "\\mu'\\omega_A+\\nu_X+8 = \\mathcal{E}_8(\\nu_Y)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26c00026c000", }, { name: "load_imm_jump", - opcode: 6, - description: "Load immediate value νX into register ω'A and perform a branch to address νY.", - latex: "branch(\\nu_Y, \\top), \\omega'_A = \\nu_X", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 80, + description: "Load an immediate jump address and branch to it.", + latex: "\\text{branch}(\\nu_Y, \\top), \\omega'_A = \\nu_X", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_eq_imm", - opcode: 7, - description: "Branch to νY if ωA equals νX.", - latex: "branch(\\nu_Y, \\omega_A = \\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 81, + description: "Branch if the register equals an immediate value.", + latex: "\\text{branch}(\\nu_Y, \\omega_A = \\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_ne_imm", - opcode: 15, - description: "Branch to νY if ωA does not equal νX.", - latex: "branch(\\nu_Y, \\omega_A \\neq \\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 82, + description: "Branch if the register is not equal to an immediate value.", + latex: "\\text{branch}(\\nu_Y, \\omega_A \\neq \\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_lt_u_imm", - opcode: 44, - description: "Branch to νY if ωA is less than νX (unsigned comparison).", - latex: "branch(\\nu_Y, \\omega_A < \\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 83, + description: "Branch if the register is less than an immediate value (unsigned).", + latex: "\\text{branch}(\\nu_Y, \\omega_A < \\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_le_u_imm", - opcode: 59, - description: "Branch to νY if ωA is less than or equal to νX (unsigned comparison).", - latex: "branch(\\nu_Y, \\omega_A \\leq \\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 84, + description: "Branch if the register is less than or equal to an immediate value (unsigned).", + latex: "\\text{branch}(\\nu_Y, \\omega_A \\leq \\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_ge_u_imm", - opcode: 52, - description: "Branch to νY if ωA is greater than or equal to νX (unsigned comparison).", - latex: "branch(\\nu_Y, \\omega_A \\geq \\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 85, + description: "Branch if the register is greater than or equal to an immediate value (unsigned).", + latex: "\\text{branch}(\\nu_Y, \\omega_A \\geq \\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_gt_u_imm", - opcode: 50, - description: "Branch to νY if ωA is greater than νX (unsigned comparison).", - latex: "branch(\\nu_Y, \\omega_A > \\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 86, + description: "Branch if the register is greater than an immediate value (unsigned).", + latex: "\\text{branch}(\\nu_Y, \\omega_A > \\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_lt_s_imm", - opcode: 32, - description: "Branch to νY if ωA is less than νX (signed comparison).", - latex: "branch(\\nu_Y, \\mathbb{Z}_4(\\omega_A) < \\mathbb{Z}_4(\\nu_X))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 87, + description: "Branch if the register is less than an immediate value (signed).", + latex: "\\text{branch}(\\nu_Y, Z_8(\\omega_A) < Z_8(\\nu_X))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_le_s_imm", - opcode: 46, - description: "Branch to νY if ωA is less than or equal to νX (signed comparison).", - latex: "branch(\\nu_Y, \\mathbb{Z}_4(\\omega_A) \\leq \\mathbb{Z}_4(\\nu_X))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 88, + description: "Branch if the register is less than or equal to an immediate value (signed).", + latex: "\\text{branch}(\\nu_Y, Z_8(\\omega_A) \\leq Z_8(\\nu_X))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_ge_s_imm", - opcode: 45, - description: "Branch to νY if ωA is greater than or equal to νX (signed comparison).", - latex: "branch(\\nu_Y, \\mathbb{Z}_4(\\omega_A) \\geq \\mathbb{Z}_4(\\nu_X))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 89, + description: "Branch if the register is greater than or equal to an immediate value (signed).", + latex: "\\text{branch}(\\nu_Y, Z_8(\\omega_A) \\geq Z_8(\\nu_X))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "branch_gt_s_imm", - opcode: 53, - description: "Branch to νY if ωA is greater than νX (signed comparison).", - latex: "branch(\\nu_Y, \\mathbb{Z}_4(\\omega_A) > \\mathbb{Z}_4(\\nu_X))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/250401250401", + opcode: 90, + description: "Branch if the register is greater than an immediate value (signed).", + latex: "\\text{branch}(\\nu_Y, Z_8(\\omega_A) > Z_8(\\nu_X))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/26d00126d001", }, { name: "move_reg", - opcode: 82, - description: - "Move the value from register ωA to register ω'D. Optionally, set ω'D to the minimum value in the set of natural numbers NR that is greater than or equal to h.", - latex: "\\omega'_D = \\omega_A \\text{ or } \\omega'_D \\equiv \\min(x \\in \\mathbb{N}_R) : x \\geq h", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/259902259902", + opcode: 100, + description: "Move the value of one register into another.", + latex: "\\omega'_D = \\omega_A", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/266503266503", }, { name: "sbrk", - opcode: 87, - description: "Adjust the program's data space by moving the break value.", + opcode: 101, + description: "Advance the program break (heap) to allocate memory.", latex: - "\\mathbb{N}_{x...+\\omega_A} \\notin \\mathbb{V}_\\mu \\text{ or } \\mathbb{N}_{x...+\\omega_A} \\in \\mathbb{V}^*_{\\mu'}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/259902259902", + "\\omega'_D = \\min(x \\in \\mathbb{N}_R : x \\geq h \\land \\mathbb{N}_{\\omega_R \\nearrow} \\notin \\mathbb{V}_h \\land \\mathbb{N}_{\\omega_R \\nearrow} \\subseteq \\mathbb{V}_{\\mu})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/266503266503", }, { name: "store_ind_u8", - opcode: 16, - description: "Store an 8-bit unsigned value from register ωA into memory at the address (ωB + νX).", - latex: "\\mu'_{\\omega_B + \\nu_X} = \\omega_A \\mod 2^8", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 110, + description: "Store an 8-bit value indirectly into memory.", + latex: "\\mu'{\\omega_B+\\nu_X} = \\omega_A \\mod 2^8", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "store_ind_u16", - opcode: 29, - description: "Store a 16-bit unsigned value from register ωA into memory at the address (ωB + νX).", - latex: "\\mu'_{\\omega_B + \\nu_X...+2} = \\mathcal{E}_2(\\omega_A \\mod 2^{16})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 111, + description: "Store a 16-bit value indirectly into memory.", + latex: "\\mu'{\\omega_B+\\nu_X+2} = \\mathcal{E}_2(\\omega_A \\mod 2^{16})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "store_ind_u32", - opcode: 3, - description: "Store a 32-bit unsigned value from register ωA into memory at the address (ωB + νX).", - latex: "\\mu'_{\\omega_B + \\nu_X...+4} = \\mathcal{E}_4(\\omega_A)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 112, + description: "Store a 32-bit value indirectly into memory.", + latex: "\\mu'{\\omega_B+\\nu_X+4} = \\mathcal{E}_4(\\omega_A \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", + }, + { + name: "store_ind_u64", + opcode: 113, + description: "Store a 64-bit value indirectly into memory.", + latex: "\\mu'{\\omega_B+\\nu_X+8} = \\mathcal{E}_8(\\omega_A)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "load_ind_u8", - opcode: 11, - description: "Load an 8-bit unsigned value from memory at the address (ωB + νX) into register ω'A.", - latex: "\\omega'_A = \\mu_{\\omega_B + \\nu_X}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 114, + description: "Load an 8-bit value indirectly from memory.", + latex: "\\omega'_A = \\mu_{\\omega_B+\\nu_X}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "load_ind_i8", - opcode: 21, - description: "Load an 8-bit signed value from memory at the address (ωB + νX) into register ω'A.", - latex: "\\omega'_A = \\mathbb{Z}_4^{-1}(\\mathbb{Z}_1(\\mu_{\\omega_B + \\nu_X}))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 115, + description: "Load an 8-bit signed value indirectly from memory.", + latex: "\\omega'_A = Z_8(\\mathcal{Z}_1(\\mu_{\\omega_B+\\nu_X}))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "load_ind_u16", - opcode: 37, - description: "Load a 16-bit unsigned value from memory at the address (ωB + νX) into register ω'A.", - latex: "\\omega'_A = \\mathcal{E}_2^{-1}(\\mu_{\\omega_B + \\nu_X...+2})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 116, + description: "Load a 16-bit unsigned value indirectly from memory.", + latex: "\\omega'_A = \\mathcal{E}_2^{-1}(\\mu_{\\omega_B+\\nu_X+2})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "load_ind_i16", - opcode: 33, - description: "Load a 16-bit signed value from memory at the address (ωB + νX) into register ω'A.", - latex: "\\omega'_A = \\mathbb{Z}_4^{-1}(\\mathbb{Z}_2(\\mathcal{E}_2^{-1}(\\mu_{\\omega_B + \\nu_X...+2})))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 117, + description: "Load a 16-bit signed value indirectly from memory.", + latex: "\\omega'_A = Z_8(\\mathcal{Z}_2(\\mathcal{E}_2^{-1}(\\mu_{\\omega_B+\\nu_X})))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "load_ind_u32", - opcode: 1, - description: "Load a 32-bit unsigned value from memory at the address (ωB + νX) into register ω'A.", - latex: "\\omega'_A = \\mathcal{E}_4^{-1}(\\mu_{\\omega_B + \\nu_X...+4})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 118, + description: "Load a 32-bit unsigned value indirectly from memory.", + latex: "\\omega'_A = \\mathcal{E}_4^{-1}(\\mu_{\\omega_B+\\nu_X+4})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "add_imm", - opcode: 2, - description: "Add immediate value νX to ωA and store the result in ω'B modulo 2^32.", - latex: "\\omega'_B = (\\omega_A + \\nu_X) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "load_ind_i32", + opcode: 119, + description: "Load a 32-bit signed value indirectly from memory.", + latex: "\\omega'_A = Z_8(\\mathcal{Z}_4(\\mathcal{E}_4^{-1}(\\mu_{\\omega_B+\\nu_X})))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", + }, + { + name: "load_ind_u64", + opcode: 120, + description: "Load a 64-bit unsigned value indirectly from memory.", + latex: "\\omega'_A = \\mathcal{E}_8^{-1}(\\mu_{\\omega_B+\\nu_X+8})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", + }, + { + name: "add_imm_32", + opcode: 121, + description: "Add an immediate value to a register.", + latex: "\\omega'_A = \\mathcal{X}_4((\\omega_B + \\nu_X) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "and_imm", - opcode: 31, - description: "Perform a bitwise AND between ωA and νX and store the result in ω'B.", - latex: - "\\forall i \\in \\mathbb{N}_{32}: \\mathbb{B}_4(\\omega'_B)_i = \\mathbb{B}_4(\\omega_A)_i \\land \\mathbb{B}_4(\\nu_X)_i", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 122, + description: "Bitwise AND a register value with an immediate.", + latex: "\\forall i \\in \\mathbb{N}_4 : B_8(\\omega'_A) = B_8(\\omega_B) \\land B_8(\\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "xor_imm", - opcode: 30, - description: "Perform a bitwise XOR between ωA and νX and store the result in ω'B.", - latex: - "\\forall i \\in \\mathbb{N}_{32}: \\mathbb{B}_4(\\omega'_B)_i = \\mathbb{B}_4(\\omega_A)_i \\oplus \\mathbb{B}_4(\\nu_X)_i", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 123, + description: "Bitwise XOR a register value with an immediate.", + latex: "\\forall i \\in \\mathbb{N}_4 : B_8(\\omega'_A) = B_8(\\omega_B) \\oplus B_8(\\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "or_imm", - opcode: 49, - description: "Perform a bitwise OR between ωA and νX and store the result in ω'B.", - latex: - "\\forall i \\in \\mathbb{N}_{32}: \\mathbb{B}_4(\\omega'_B)_i = \\mathbb{B}_4(\\omega_A)_i \\lor \\mathbb{B}_4(\\nu_X)_i", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + opcode: 124, + description: "Bitwise OR a register value with an immediate.", + latex: "\\forall i \\in \\mathbb{N}_4 : B_8(\\omega'_A) = B_8(\\omega_B) \\lor B_8(\\nu_X)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "mul_imm", - opcode: 35, - description: "Multiply ωA by νX and store the result in ω'B modulo 2^32.", - latex: "\\omega'_B = (\\omega_A \\times \\nu_X) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "mul_imm_32", + opcode: 125, + description: "Multiply a register value with an immediate value (32-bit).", + latex: "\\omega'_A = \\mathcal{X}_4((\\omega_B \\times \\nu_X) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "mul_upper_s_s_imm", - opcode: 65, - description: - "Multiply the signed value of ωA by the signed value of νX and store the upper half of the result in ω'B.", - latex: "\\omega'_B = \\mathbb{Z}_4^{-1}((\\mathbb{Z}_4(\\omega_A) \\times \\mathbb{Z}_4(\\nu_X)) + 2^{32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "set_lt_u_imm", + opcode: 126, + description: "Set if less than (unsigned comparison) with immediate.", + latex: "\\omega'_A = \\omega_B < \\nu_X", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "mul_upper_u_u_imm", - opcode: 63, - description: - "Multiply the unsigned value of ωA by the unsigned value of νX and store the upper half of the result in ω'B.", - latex: "\\omega'_B = ((\\omega_A \\times \\nu_X) + 2^{32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shlo_imm_32", + opcode: 128, + description: "Shift left logical by immediate (32-bit).", + latex: "\\omega'_A = \\mathcal{X}_4((\\omega_B \\cdot 2^{\\nu_X} \\mod 2^{32}) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "set_lt_u_imm", - opcode: 27, - description: "Set ω'B to 1 if ωA is less than νX (unsigned comparison); otherwise, set it to 0.", - latex: "\\omega'_B = \\omega_A < \\nu_X", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shlo_imm_alt_32", + opcode: 135, + description: "Alternative shift left logical by immediate (32-bit).", + latex: "\\omega'_A = \\mathcal{X}_4((\\omega_B \\cdot 2^{\\nu_X} \\mod 2^{32}) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "set_lt_s_imm", - opcode: 56, - description: "Set ω'B to 1 if ωA is less than νX (signed comparison); otherwise, set it to 0.", - latex: "\\omega'_B = \\mathbb{Z}_4(\\omega_A) < \\mathbb{Z}_4(\\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shar_imm_32", + opcode: 136, + description: "Arithmetic shift right by immediate (32-bit).", + latex: "\\omega'_A = Z_8(\\lfloor Z_4(\\omega_B) \\div 2^{\\nu_X} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "shlo_l_imm", - opcode: 9, - description: "Shift ωA left by a value of (2 * νX) modulo 32 and store the result in ω'B.", - latex: "\\omega'_B = (\\omega_A \\times 2^{\\nu_X} \\mod 32) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "cmov_iz_imm", + opcode: 137, + description: "Conditional move if zero; otherwise keep register value.", + latex: + "\\omega'_A = \\begin{cases} \\nu_X & \\text{if } \\omega_B = 0 \\\\ \\omega_A & \\text{otherwise} \\end{cases}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "shlo_r_imm", - opcode: 14, - description: "Shift ωA right by a value of (2 * νX) modulo 32 and store the result in ω'B.", - latex: "\\omega'_B = (\\omega_A \\div 2^{\\nu_X} \\mod 32) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "cmov_nz_imm", + opcode: 138, + description: "Conditional move if not zero; otherwise keep register value.", + latex: + "\\omega'_A = \\begin{cases} \\nu_X & \\text{if } \\omega_B \\neq 0 \\\\ \\omega_A & \\text{otherwise} \\end{cases}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "shar_r_imm", - opcode: 25, - description: "Arithmetic shift right of ωA by νX and store the result in ω'B.", - latex: "\\omega'_B = \\mathbb{Z}_4^{-1}(\\mathbb{Z}_4(\\omega_A) \\div 2^{\\nu_X \\mod 32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "add_imm_64", + opcode: 139, + description: "Add an immediate value to a 64-bit register.", + latex: "\\omega'_A = (\\omega_B + \\nu_X) \\mod 2^{64}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "neg_add_imm", - opcode: 40, - description: "Add the two's complement of νX to ωA and store the result in ω'B modulo 2^32.", - latex: "\\omega'_B = (\\nu_X + 2^{32} - \\omega_A) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "mul_imm_64", + opcode: 140, + description: "Multiply an immediate value with a 64-bit register.", + latex: "\\omega'_A = (\\omega_B \\times \\nu_X) \\mod 2^{64}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "set_gt_u_imm", - opcode: 39, - description: "Set ω'B to 1 if ωA is greater than νX (unsigned comparison); otherwise, set it to 0.", - latex: "\\omega'_B = \\omega_A > \\nu_X", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shlo_imm_64", + opcode: 141, + description: "Shift left logical by immediate value (64-bit).", + latex: "\\omega'_A = \\mathcal{X}_8((\\omega_B \\cdot 2^{\\nu_X} \\mod 2^{64}))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "set_gt_s_imm", - opcode: 61, - description: "Set ω'B to 1 if ωA is greater than νX (signed comparison); otherwise, set it to 0.", - latex: "\\omega'_B = \\mathbb{Z}_4(\\omega_A) > \\mathbb{Z}_4(\\nu_X)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shro_r_imm_64", + opcode: 142, + description: "Logical shift right by immediate value (64-bit).", + latex: "\\omega'_A = \\mathcal{X}_8(\\lfloor \\omega_B \\div 2^{\\nu_X} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "shlo_l_imm_alt", - opcode: 75, - description: "Alternative left shift of νX by 24 modulo 32 and store the result in ω'B.", - latex: "\\omega'_B = (\\nu_X \\times 2^{24} \\mod 32) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shar_r_imm_64", + opcode: 143, + description: "Arithmetic shift right by immediate value (64-bit).", + latex: "\\omega'_A = Z_8(\\lfloor Z_8(\\omega_B) \\div 2^{\\nu_X} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "shlo_r_imm_alt", - opcode: 72, - description: "Alternative right shift of νX by 24 modulo 32 and store the result in ω'B.", - latex: "\\omega'_B = (\\nu_X \\div 2^{24} \\mod 32) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "neg_add_imm_64", + opcode: 144, + description: "Add the negated immediate value to a 64-bit register.", + latex: "\\omega'_A = (\\nu_X + 2^{64} - \\omega_B) \\mod 2^{64}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "shar_r_imm_alt", - opcode: 28, - description: "Alternative arithmetic right shift of ωA by (νX mod 32) and store the result in ω'B.", - latex: "\\omega'_B = \\mathbb{Z}_4^{-1}(\\mathbb{Z}_4(\\omega_A) \\div 2^{\\nu_X \\mod 32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shlo_1_imm_alt_64", + opcode: 145, + description: "Alternative shift left logical by immediate value (64-bit).", + latex: "\\omega'_A = (\\nu_X \\cdot 2^{\\omega_B} \\mod 2^{64})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "cmov_iz_imm", - opcode: 85, - description: "Move νX to ω'A if ωB equals 0; otherwise, move ωA to ω'A.", - latex: - "\\omega'_A = \\begin{cases} \\nu_X & \\text{if } \\omega_B = 0 \\\\ \\omega_A & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shlo_r_imm_alt_64", + opcode: 146, + description: "Alternative shift right logical by immediate value (64-bit).", + latex: "\\omega'_A = \\lfloor \\nu_X \\div 2^{\\omega_B} \\rfloor", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { - name: "cmov_nz_imm", - opcode: 86, - description: "Move νX to ω'A if ωB does not equal 0; otherwise, move ωA to ω'A.", - latex: - "\\omega'_A = \\begin{cases} \\nu_X & \\text{if } \\omega_B \\neq 0 \\\\ \\omega_A & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/261000261000", + name: "shar_r_imm_alt_64", + opcode: 147, + description: "Alternative arithmetic shift right by immediate value (64-bit).", + latex: "\\omega'_A = Z_8(\\lfloor Z_8(\\nu_X) \\div 2^{\\omega_B} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/278d00278d00", }, { name: "branch_eq", - opcode: 24, - description: "Branch to νX if ωA equals ωB.", - latex: "branch(\\nu_X, \\omega_A = \\omega_B)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/26b00326b003", + opcode: 150, + description: "Branch if two register values are equal.", + latex: "\\text{branch}(\\nu_X, \\omega_A = \\omega_B)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288301288301", }, { name: "branch_ne", - opcode: 30, - description: "Branch to νX if ωA does not equal ωB.", - latex: "branch(\\nu_X, \\omega_A \\neq \\omega_B)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/26b00326b003", + opcode: 151, + description: "Branch if two register values are not equal.", + latex: "\\text{branch}(\\nu_X, \\omega_A \\neq \\omega_B)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288301288301", }, { name: "branch_lt_u", - opcode: 47, - description: "Branch to νX if ωA is less than ωB (unsigned comparison).", - latex: "branch(\\nu_X, \\omega_A < \\omega_B)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/26b00326b003", + opcode: 152, + description: "Branch if the first register is less than the second (unsigned).", + latex: "\\text{branch}(\\nu_X, \\omega_A < \\omega_B)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288301288301", }, { name: "branch_lt_s", - opcode: 48, - description: "Branch to νX if ωA is less than ωB (signed comparison).", - latex: "branch(\\nu_X, \\mathbb{Z}_4(\\omega_A) < \\mathbb{Z}_4(\\omega_B))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/26b00326b003", + opcode: 153, + description: "Branch if the first register is less than the second (signed).", + latex: "\\text{branch}(\\nu_X, Z_8(\\omega_A) < Z_8(\\omega_B))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288301288301", }, { name: "branch_ge_u", - opcode: 41, - description: "Branch to νX if ωA is greater than or equal to ωB (unsigned comparison).", - latex: "branch(\\nu_X, \\omega_A \\geq \\omega_B)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/26b00326b003", + opcode: 154, + description: "Branch if the first register is greater than or equal to the second (unsigned).", + latex: "\\text{branch}(\\nu_X, \\omega_A \\geq \\omega_B)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288301288301", }, { name: "branch_ge_s", - opcode: 43, - description: "Branch to νX if ωA is greater than or equal to ωB (signed comparison).", - latex: "branch(\\nu_X, \\mathbb{Z}_4(\\omega_A) \\geq \\mathbb{Z}_4(\\omega_B))", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/26b00326b003", + opcode: 155, + description: "Branch if the first register is greater than or equal to the second (signed).", + latex: "\\text{branch}(\\nu_X, Z_8(\\omega_A) \\geq Z_8(\\omega_B))", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288301288301", }, { name: "load_imm_jump_ind", - opcode: 42, - description: - "Perform an indirect jump to the address calculated as (ωB + νY) modulo 2^32 and load the immediate value νX into register ω'A.", - latex: "djump((\\omega_B + \\nu_Y) \\mod 2^{32}), \\omega'_A = \\nu_X", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/27be0027be00", + opcode: 160, + description: "Load an immediate jump address indirectly and branch.", + latex: "\\text{djump}((\\omega_B + \\nu_Y) \\mod 2^{32}), \\omega'_A = \\nu_X", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/28a60228a602", }, { - name: "add", - opcode: 6, - description: "Add ωA and ωB and store the result in ω'D modulo 2^32.", - latex: "\\omega'_D = (\\omega_A + \\omega_B) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "add_32", + opcode: 170, + description: "Add two register values (32-bit).", + latex: "\\omega'_D = \\mathcal{X}_4((\\omega_A + \\omega_B) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "sub", - opcode: 20, - description: "Subtract ωB from ωA and store the result in ω'D modulo 2^32.", - latex: "\\omega'_D = (\\omega_A + 2^{32} - \\omega_B) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "sub_32", + opcode: 171, + description: "Subtract two 32-bit register values.", + latex: "\\omega'_D = \\mathcal{X}_4((\\omega_A + 2^{32} - (\\omega_B \\mod 2^{32})) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "and", - opcode: 23, - description: "Perform a bitwise AND between ωA and ωB and store the result in ω'D.", + name: "mul_32", + opcode: 172, + description: "Multiply two 32-bit register values.", + latex: "\\omega'_D = \\mathcal{X}_4((\\omega_A \\cdot \\omega_B) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "div_u_32", + opcode: 173, + description: "Unsigned division of two 32-bit values.", latex: - "\\forall i \\in \\mathbb{N}_{32}: \\mathbb{B}_4(\\omega'_D)_i = \\mathbb{B}_4(\\omega_A)_i \\land \\mathbb{B}_4(\\omega_B)_i", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + "\\omega'_D = \\begin{cases} 2^{64} - 1 & \\text{if } \\omega_B \\mod 2^{32} = 0 \\\\ (\\omega_A \\mod 2^{32}) \\div (\\omega_B \\mod 2^{32}) & \\text{otherwise} \\end{cases}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "xor", - opcode: 28, - description: "Perform a bitwise XOR between ωA and ωB and store the result in ω'D.", + name: "div_s_32", + opcode: 174, + description: "Signed division of two 32-bit values.", latex: - "\\forall i \\in \\mathbb{N}_{32}: \\mathbb{B}_4(\\omega'_D)_i = \\mathbb{B}_4(\\omega_A)_i \\oplus \\mathbb{B}_4(\\omega_B)_i", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + "\\omega'_D = \\begin{cases} 2^{64} - 1 & \\text{if } b = 0 \\\\ a & \\text{if } a = -2^{31} \\land b = -1 \\\\ Z_8^{-1}(|a \\div b|) & \\text{otherwise} \\end{cases} \\text{, where } a = Z_4(\\omega_A \\mod 2^{32}), b = Z_4(\\omega_B \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "or", - opcode: 12, - description: "Perform a bitwise OR between ωA and ωB and store the result in ω'D.", + name: "rem_u_32", + opcode: 175, + description: "Unsigned remainder of two 32-bit values.", latex: - "\\forall i \\in \\mathbb{N}_{32}: \\mathbb{B}_4(\\omega'_D)_i = \\mathbb{B}_4(\\omega_A)_i \\lor \\mathbb{B}_4(\\omega_B)_i", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + "\\omega'_D = \\begin{cases} \\mathcal{X}_4(\\omega_A) & \\text{if } \\omega_B \\mod 2^{32} = 0 \\\\ \\mathcal{X}_4((\\omega_A \\mod 2^{32}) \\mod (\\omega_B \\mod 2^{32})) & \\text{otherwise} \\end{cases}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "mul", - opcode: 34, - description: "Multiply ωA by ωB and store the result in ω'D modulo 2^32.", - latex: "\\omega'_D = (\\omega_A \\times \\omega_B) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "rem_s_32", + opcode: 176, + description: "Signed remainder of two 32-bit values.", + latex: + "\\omega'_D = \\begin{cases} Z_8^{-1}(a) & \\text{if } b = 0 \\\\ 0 & \\text{if } a = -2^{31} \\land b = -1 \\\\ Z_8^{-1}(a \\mod b) & \\text{otherwise} \\end{cases}, \\text{ where } a = Z_4(\\omega_A \\mod 2^{32}), b = Z_4(\\omega_B \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "mul_upper_s_s", - opcode: 5, - description: "Multiply the signed values of ωA and ωB, then store the upper half of the result in ω'D.", - latex: "\\omega'_D = \\mathbb{Z}_4^{-1}((\\mathbb{Z}_4(\\omega_A) \\times \\mathbb{Z}_4(\\omega_B)) + 2^{32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "shlo_1_32", + opcode: 177, + description: "Shift left logical by one position (32-bit).", + latex: "\\omega'_D = \\mathcal{X}_4((\\omega_A \\cdot 2^{\\nu_X} \\mod 32) \\mod 2^{32})", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "mul_upper_u_u", - opcode: 57, - description: "Multiply the unsigned values of ωA and ωB, then store the upper half of the result in ω'D.", - latex: "\\omega'_D = ((\\omega_A \\times \\omega_B) + 2^{32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "shlo_r_32", + opcode: 178, + description: "Shift right logical by one position (32-bit).", + latex: "\\omega'_D = \\mathcal{X}_4(((\\omega_A \\mod 2^{32}) \\div 2^{\\nu_X}) + 2^{\\nu_X} \\mod 32)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "mul_upper_s_u", - opcode: 81, - description: - "Multiply the signed value of ωA by the unsigned value of ωB, then store the upper half of the result in ω'D.", - latex: "\\omega'_D = \\mathbb{Z}_4^{-1}((\\mathbb{Z}_4(\\omega_A) \\times \\omega_B) + 2^{32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "shar_r_32", + opcode: 179, + description: "Arithmetic shift right by one position (32-bit).", + latex: "\\omega'_D = Z_8^{-1}(\\lfloor Z_4(\\omega_A \\mod 2^{32}) \\div 2^{\\nu_X} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "add_64", + opcode: 180, + description: "Add two 64-bit register values.", + latex: "\\omega'_D = (\\omega_A + \\omega_B) \\mod 2^{64}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "div_u", - opcode: 68, - description: - "Divide the unsigned value of ωA by ωB and store the result in ω'D. If ωB is zero, store 2^32 - 1 instead.", + name: "sub_64", + opcode: 181, + description: "Subtract two 64-bit register values.", + latex: "\\omega'_D = (\\omega_A + 2^{64} - \\omega_B) \\mod 2^{64}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "mul_64", + opcode: 182, + description: "Multiply two 64-bit register values.", + latex: "\\omega'_D = (\\omega_A \\cdot \\omega_B) \\mod 2^{64}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "div_u_64", + opcode: 183, + description: "Unsigned division of two 64-bit values.", latex: - "\\omega'_D = \\begin{cases} 2^{32} - 1 & \\text{if } \\omega_B = 0 \\\\ \\frac{\\omega_A}{\\omega_B} & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + "\\omega'_D = \\begin{cases} 2^{64} - 1 & \\text{if } \\omega_B = 0 \\\\ \\lfloor \\omega_A \\div \\omega_B \\rfloor & \\text{otherwise} \\end{cases}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "div_s", - opcode: 64, - description: - "Divide the signed value of ωA by ωB and store the result in ω'D. If ωB is zero or if division would overflow, store ωA instead.", + name: "div_s_64", + opcode: 184, + description: "Signed division of two 64-bit values.", latex: - "\\omega'_D = \\begin{cases} 2^{32} - 1 & \\text{if } \\omega_B = 0 \\\\ \\omega_A & \\text{if } \\mathbb{Z}_4(\\omega_A) = -2^{31} \\land \\mathbb{Z}_4(\\omega_B) = -1 \\\\ \\mathbb{Z}_4^{-1}(\\mathbb{Z}_4(\\omega_A) \\div \\mathbb{Z}_4(\\omega_B)) & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + "\\omega'_D = \\begin{cases} 2^{64} - 1 & \\text{if } \\omega_B = 0 \\\\ \\omega_A & \\text{if } Z_8(\\omega_A) = -2^{63} \\land Z_8(\\omega_B) = -1 \\\\ Z_8^{-1}(\\lfloor Z_8(\\omega_A) \\div Z_8(\\omega_B) \\rfloor) & \\text{otherwise} \\end{cases}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "rem_u", - opcode: 73, - description: - "Compute the remainder of unsigned division of ωA by ωB and store the result in ω'D. If ωB is zero, store ωA instead.", + name: "rem_u_64", + opcode: 185, + description: "Unsigned remainder of two 64-bit values.", latex: "\\omega'_D = \\begin{cases} \\omega_A & \\text{if } \\omega_B = 0 \\\\ \\omega_A \\mod \\omega_B & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "rem_s", - opcode: 70, - description: - "Compute the remainder of signed division of ωA by ωB and store the result in ω'D. If ωB is zero or if division would overflow, store ωA instead.", + name: "rem_s_64", + opcode: 186, + description: "Signed remainder of two 64-bit values.", latex: - "\\omega'_D = \\begin{cases} \\omega_A & \\text{if } \\omega_B = 0 \\\\ 0 & \\text{if } \\mathbb{Z}_4(\\omega_A) = -2^{31} \\land \\mathbb{Z}_4(\\omega_B) = -1 \\\\ \\mathbb{Z}_4^{-1}(\\mathbb{Z}_4(\\omega_A) \\mod \\mathbb{Z}_4(\\omega_B)) & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + "\\omega'_D = \\begin{cases} \\omega_A & \\text{if } \\omega_B = 0 \\\\ 0 & \\text{if } Z_8(\\omega_A) = -2^{63} \\land Z_8(\\omega_B) = -1 \\\\ Z_8^{-1}(Z_8(\\omega_A) \\mod Z_8(\\omega_B)) & \\text{otherwise} \\end{cases}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "set_lt_u", - opcode: 36, - description: "Set ω'D to 1 if ωA is less than ωB (unsigned comparison); otherwise, set it to 0.", - latex: "\\omega'_D = \\omega_A < \\omega_B", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "shlo_1_64", + opcode: 187, + description: "Shift left logical by one position (64-bit).", + latex: "\\omega'_D = (\\omega_A \\cdot 2^{\\nu_X \\mod 64}) \\mod 2^{64}", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "set_lt_s", - opcode: 58, - description: "Set ω'D to 1 if ωA is less than ωB (signed comparison); otherwise, set it to 0.", - latex: "\\omega'_D = \\mathbb{Z}_4(\\omega_A) < \\mathbb{Z}_4(\\omega_B)", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "shlo_r_64", + opcode: 188, + description: "Shift right logical by immediate value (64-bit).", + latex: "\\omega'_D = \\lfloor \\omega_A \\div 2^{\\omega_B \\mod 64} \\rfloor", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "shlo_l", - opcode: 55, - description: "Shift ωA left by a value of (2 * ωB) modulo 32 and store the result in ω'D.", - latex: "\\omega'_D = (\\omega_A \\times 2^{\\omega_B \\mod 32}) \\mod 2^{32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "shar_r_64", + opcode: 189, + description: "Arithmetic shift right by immediate value (64-bit).", + latex: "\\omega'_D = Z_8^{-1}(\\lfloor Z_8(\\omega_A) \\div 2^{\\omega_B \\mod 64} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "shlo_r", - opcode: 51, - description: "Shift ωA right by a value of (2 * ωB) modulo 32 and store the result in ω'D.", - latex: "\\omega'_D = \\omega_A \\div 2^{\\omega_B \\mod 32}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "and", + opcode: 190, + description: "Bitwise AND between two registers.", + latex: "\\forall i \\in \\mathbb{N}_4 : B_8(\\omega'_D) = B_8(\\omega_A) \\land B_8(\\omega_B)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { - name: "shar_r", - opcode: 77, - description: "Arithmetic shift right of ωA by ωB and store the result in ω'D.", - latex: "\\omega'_D = \\mathbb{Z}_4^{-1}(\\mathbb{Z}_4(\\omega_A) \\div 2^{\\omega_B \\mod 32})", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + name: "xor", + opcode: 191, + description: "Bitwise XOR operation between two registers.", + latex: "\\forall i \\in \\mathbb{N}_{64} : B_8(\\omega'_D)_i = B_8(\\omega_A)_i \\oplus B_8(\\omega_B)_i", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "or", + opcode: 192, + description: "Bitwise OR operation between two registers.", + latex: "\\forall i \\in \\mathbb{N}_{64} : B_8(\\omega'_D)_i = B_8(\\omega_A)_i \\lor B_8(\\omega_B)_i", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "mul_upper_s_s", + opcode: 193, + description: "Signed multiplication of two registers, upper half result.", + latex: "\\omega'_D = Z_8^{-1}(\\lfloor (Z_8(\\omega_A) \\cdot Z_8(\\omega_B)) \\div 2^{64} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "mul_upper_u_u", + opcode: 194, + description: "Unsigned multiplication of two registers, upper half result.", + latex: "\\omega'_D = \\lfloor (\\omega_A \\cdot \\omega_B) \\div 2^{64} \\rfloor", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "mul_upper_s_u", + opcode: 195, + description: "Signed-unsigned multiplication of two registers, upper half result.", + latex: "\\omega'_D = Z_8^{-1}(\\lfloor (Z_8(\\omega_A) \\cdot \\omega_B) \\div 2^{64} \\rfloor)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "set_lt_u", + opcode: 196, + description: "Set if less than (unsigned comparison).", + latex: "\\omega'_D = \\omega_A < \\omega_B", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", + }, + { + name: "set_lt_s", + opcode: 197, + description: "Set if less than (signed comparison).", + latex: "\\omega'_D = Z_8(\\omega_A) < Z_8(\\omega_B)", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { name: "cmov_iz", - opcode: 83, - description: "Move ωA to ω'D if ωB equals 0; otherwise, move ωD to ω'D.", + opcode: 198, + description: "Conditional move if zero.", latex: "\\omega'_D = \\begin{cases} \\omega_A & \\text{if } \\omega_B = 0 \\\\ \\omega_D & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, { name: "cmov_nz", - opcode: 84, - description: "Move ωA to ω'D if ωB does not equal 0; otherwise, move ωD to ω'D.", + opcode: 199, + description: "Conditional move if not zero.", latex: "\\omega'_D = \\begin{cases} \\omega_A & \\text{if } \\omega_B \\neq 0 \\\\ \\omega_D & \\text{otherwise} \\end{cases}", - linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/439ca37/279b01279b01", + linkInGrayPaperReader: "https://graypaper.fluffylabs.dev/#/5b732de/288303288303", }, ];