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-b/prompts/bytes.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-b / prompts / bytes.system.txt` 96 lines ยท 5181 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: bytes 23 24 Write the program as OSC binary IR (spec/one-layer-format.md), spelled as hexadecimal: two hex 25 digits per byte (0-9, a-f or A-F); spaces and line breaks between bytes are ignored; nothing else 26 is allowed. The bytes are read by a strict decoder: any byte out of place refuses the whole program. 27 28 All integers are little-endian, no padding. Use format version 1 (no struct table). 29 30 Unit: 31 7 bytes magic 4f 53 43 31 49 52 00 32 1 byte version: 01 33 2 bytes number of functions, 1..32, then each function record 34 35 Function record: 36 1 + n name: length n (1..63), then n ASCII bytes [A-Za-z_][A-Za-z0-9_]*, unique in the unit 37 1 number of parameters P (0..6) 38 type return type 39 2 number of registers R (P..480), then R types: registers 0..P-1 are the parameters in 40 order, registers P..R-1 are locals 41 2 number of blocks B (1..512), then per block: 4 bytes index of its first instruction, 42 4 bytes instruction count. Blocks cover the instructions in order without gaps: 43 block 0 starts at 0, each next block starts where the previous ended. Block 0 is the entry. 44 4 number of instructions, then the instructions 45 2 00 00 (empty "requires" text) 46 2 00 00 (empty "ensures" text) 47 48 Type: one byte: 0 void (return type only), 1 bool, 2 u8, 3 u16, 4 u32, 5 u64, 6 i8, 7 i16, 8 i32, 49 9 i64; or an array reference: 0a, then kind (1 own, 2 shared, 3 mut), element type byte (1..9), 50 2 bytes length (1..64). 51 52 Instruction: one opcode byte, then its fields. r = 2-byte register / block / function index; 53 ff ff means "none". 54 01 CONST r dst, 8 bytes value (the value as a 64-bit number: unsigned zero-extended, signed 55 sign-extended two's complement, bool 0 or 1) 56 02 MOV r dst, r a dst = a 57 03 BIN 1 sub, r dst, r a, r b sub: 1 add 2 sub 3 mul 4 div 5 rem 6 and 7 or 8 xor 9 shl 10 shr 58 04 UN 1 sub, r dst, r a sub: 1 neg 2 bitwise-not 3 logical-not (bool) 59 05 CMP 1 sub, r dst, r a, r b sub: 1 eq 2 ne 3 lt 4 le 5 gt 6 ge; dst is bool 60 06 CAST r dst, r a dst = a converted to dst's integer type 61 07 ALLOC r dst, r a dst (own array) = new array, every element = a 62 08 RELEASE r a give back own array a 63 09 LOAD r dst, r a, r b dst = a[b] 64 0a STORE r a, r b, r c a[b] = c (a is own or mut) 65 0b CALL r dst (ff ff for a void callee), r function index (an EARLIER function), 1 nargs, 66 nargs x r arg 67 0c TRAP 1 code (1..14) stop with that trap 68 0d BR r block continue at block 69 0e CBR r a (bool), r then-block, r else-block 70 0f RET r a (ff ff in a void function) 71 72 Rules: every block ends with exactly one BR, CBR or RET, and only its last instruction is one 73 (a TRAP does not end a block). Types agree (BIN/CMP: a and b the same type; BIN and UN: dst the 74 same type as a). Every register is read only after it is written on every path to the read 75 (parameters count as written). No recursion: a function calls only functions before it. 76 77 Example. Task: function clamp_sub, parameters u32 u32, returns u32: a - b when a >= b, else 0. 78 Registers: 0 a (u32), 1 b (u32), 2 bool, 3 u32, 4 u32. 79 80 ``` 81 `4f5343314952000101000963` `6c616d705f737562` 82 02 04 0500 04 04 01 04 04 83 0300 `00000000` `02000000` `02000000` `02000000` `04000000` `02000000` 84 `06000000` 85 05 06 0200 0000 0100 86 0e 0200 0100 0200 87 03 02 0300 0000 0100 88 0f 0300 89 01 0400 `0000000000000000` 90 0f 0400 91 0000 0000 92 ``` 93 94 (Line by line: magic, version 1, one function, name "clamp_sub"; 2 params, returns u32, 95 5 registers u32 u32 bool u32 u32; 3 blocks at 0+2, 2+2, 4+2; 6 instructions; CMP ge r2 = r0 >= r1; 96 CBR r2 -> block 1 else block 2; BIN sub r3 = r0 - r1; RET r3; CONST r4 = 0; RET r4; empty contracts.)