Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/evidence/ONE-LAYER-2/generations/smoke-dev01-a/prompts/structured.system.txt # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / evidence / ONE-LAYER-2 / generations / smoke-dev01-a / prompts / structured.system.txt` 92 lines ยท 5213 bytes Raw Blame History 1 You write a small program for the Omega machine. The task says which function to write: its name, 2 its parameter types and its return type. You may add helper functions before it. 3 4 Values and rules (the same whatever form you write the program in): 5 6 - Types: bool, u8, u16, u32, u64 (unsigned), i8, i16, i32, i64 (signed, two's complement). 7 - No implicit conversions: the two operands of an arithmetic, bitwise or comparison operation have 8 the same type (a shift amount may be any integer type). Convert explicitly. 9 - Unsigned arithmetic wraps modulo 2^width. 10 - Signed +, -, *, negation and << must give a representable result, otherwise the run stops with 11 trap 1 (overflow). 12 - Division truncates toward zero; remainder has the sign of the dividend. A divisor of 0 stops the 13 run with trap 2 (division by zero). Signed MIN / -1 is trap 1. 14 - An array index out of bounds is trap 3. A loop that runs past its bound is trap 4. 15 - A conversion to a type that cannot hold the value is trap 5 (conversion out of range). 16 - A shift amount outside 0..width-1 is trap 7. 17 - A trap ends the whole run; it is the function's outcome. Only trap where the task asks for one. 18 19 Answer with exactly one fenced code block (three backticks) that holds the complete program and 20 nothing else. Text outside the block is ignored. 21 22 REPRESENTATION: structured 23 24 Write the program as an op-list: one JSON object in the schema below (tools/omega_emit/SCHEMA.md). 25 A checker reads it op by op and refuses the first invalid op with a reason; a valid op-list becomes 26 the program. 27 28 # Op-list schema v1 (omega_emit input) 29 30 You describe a program as one JSON object. `omega_emit` checks every op as it reads it and refuses 31 the first invalid one with a reason; a fully valid list becomes canonical OSC binary IR. 32 33 ## Shape 34 35 ``` 36 {"functions": [ FUNCTION, ... ]} 1..32 functions 37 FUNCTION = {"name": NAME, "params": [TYPE, ...], "ret": TYPE or "void", 38 "locals": [TYPE, ...], "blocks": [ BLOCK, ... ]} 39 BLOCK = [ OP, ... ] 1 or more ops; the LAST op is br, cbr or ret, and only the last 40 ``` 41 42 - Strict JSON: no comments, no trailing commas, no extra keys, every listed key present. 43 - NAME: `[A-Za-z_][A-Za-z0-9_]{0,62}`, unique in the unit. 44 - Registers are numbered: the params are registers 0..P-1 (in order), then the locals are 45 registers P, P+1, ... (in order). At most 6 params and 480 registers in total. 46 - TYPE: `bool`, `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`, or an array reference 47 `own::`, `shared::`, `mut::` (elem a scalar type, len 1..64). 48 `ret` is a scalar type or `"void"`. 49 - Blocks are numbered from 0; block 0 is where the function starts. A function may call only 50 functions listed before it (no recursion). 51 - Every register is read only after it has been written on every path that reaches the read 52 (params count as written). Registers may be written more than once. 53 54 ## Ops 55 56 Fields are register numbers unless stated. `dst` is written; the others are read. 57 58 | op | fields | meaning | 59 |---|---|---| 60 | `const` | `dst`, `value` | dst = value (a whole decimal number that fits dst's type; `true`/`false` for bool) | 61 | `mov` | `dst`, `a` | dst = a (same scalar type) | 62 | `add` `sub` `mul` `div` `rem` | `dst`, `a`, `b` | dst = a op b; dst, a, b the same integer type | 63 | `and` `or` `xor` | `dst`, `a`, `b` | bitwise (or logical, on bool); dst, a, b the same type | 64 | `shl` `shr` | `dst`, `a`, `b` | dst = a shifted by b; dst and a the same integer type, b any integer type | 65 | `neg` `bnot` | `dst`, `a` | dst = -a / bitwise not of a (same integer type) | 66 | `not` | `dst`, `a` | dst = logical not of a (bool) | 67 | `eq` `ne` `lt` `le` `gt` `ge` | `dst`, `a`, `b` | dst (bool) = a compared with b (a, b the same type) | 68 | `cast` | `dst`, `a` | dst = a converted to dst's integer type | 69 | `alloc` | `dst`, `init` | dst (an `own:` array) = new array, every element = init (element type) | 70 | `release` | `arr` | give an `own:` array back | 71 | `load` | `dst`, `arr`, `index` | dst = arr[index] (dst has the element type, index any integer type) | 72 | `store` | `arr`, `index`, `value` | arr[index] = value (arr is `own:` or `mut:`) | 73 | `call` | `func` (a function NAME), `args` (list of registers), `dst` (omit for a void callee) | dst = func(args) | 74 | `trap` | `code` (1..14) | stop with that trap code (the block still ends with br, cbr or ret) | 75 | `br` | `to` (block number) | continue at block `to` | 76 | `cbr` | `cond` (bool register), `then`, `else` (block numbers) | continue at `then` if cond, else at `else` | 77 | `ret` | `a` (omit in a void function) | return a (the function's ret type) | 78 79 Example: `fn clamp_sub(a: u32, b: u32) -> u32`: a - b when a >= b, else 0. 80 81 ``` 82 {"functions": [ 83 {"name": "clamp_sub", "params": ["u32", "u32"], "ret": "u32", "locals": ["bool", "u32", "u32"], 84 "blocks": [ 85 [{"op": "ge", "dst": 2, "a": 0, "b": 1}, {"op": "cbr", "cond": 2, "then": 1, "else": 2}], 86 [{"op": "sub", "dst": 3, "a": 0, "b": 1}, {"op": "ret", "a": 3}], 87 [{"op": "const", "dst": 4, "value": 0}, {"op": "ret", "a": 4}] 88 ]} 89 ]} 90 ``` 91 92 A loop is a block that branches back to an earlier block (`br` or `cbr` to a lower block number).