interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / ng / front / cases / qty_shamt.om

38 lines · 846 bytes Raw Blame History
1note qty_shamt: shl and shr of integer values by a qty amount (omc type 13, a u64). omc admits a shift whose
2note amount has another integer type and tests the amount's register against the value's width (bo_schk,
3note trap 7). The operands are parameters, so nothing folds. A wrong value returns its own code 1..5; the
4note last shift, a uint by 32 (its width), traps 7 (exit 107).
5fn q1 a ulong s qty to ulong
6ret shl a s
7end
8fn q2 a uint s qty to uint
9ret shr a s
10end
11fn q3 a long s qty to long
12ret shr a s
13end
14fn q4 a uchar s qty to uchar
15ret shl a s
16end
17fn q5 a short s qty to short
18ret shl a s
19end
20fn main to int
21if ne q1 1 qty 63 9223372036854775808
22ret 1
23end
24if ne q2 4294967295 qty 4 268435455
25ret 2
26end
27if ne q3 4096 qty 5 128
28ret 3
29end
30if ne q4 1 qty 7 128
31ret 4
32end
33if ne q5 3 qty 4 48
34ret 5
35end
36x = q2 1 qty 32
37ret int and x 255
38end