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 / sh_mix.om

54 lines · 1286 bytes Raw Blame History
1note sh_mix: shl and shr whose value and amount have different integer types. omc admits them (omc.om
2note rdval: only a shift may mix its operand types) and checks the amount against the value's width
3note (bo_schk, trap 7). The operands are parameters, so nothing folds. Ten results, 8 bytes each,
4note little-endian (signed ones bitcast from long); exit 0. Expected bytes: groups4.expect.
5global o uchar 80
6fn put8 p ulong v ulong to void
7for j ulong 8
8put o add p j uchar and shr v mul j 8 255
9end
10end
11fn mx1 a ulong s uchar to ulong
12ret shl a s
13end
14fn mx2 a uint s ulong to uint
15ret shr a s
16end
17fn mx3 a byte s long to byte
18ret shr a s
19end
20fn mx4 a short s uchar to short
21ret shr a s
22end
23fn mx5 a long s ushort to long
24ret shl a s
25end
26fn mx6 a uchar s long to uchar
27ret shl a s
28end
29fn mx7 a ushort s int to ushort
30ret shr a s
31end
32fn mx8 a int s ulong to int
33ret shl a s
34end
35fn mx9 a uint s byte to uint
36ret shl a s
37end
38fn mx10 a ulong s uchar to ulong
39ret shl a s
40end
41fn main to int
42put8 0 mx1 1 40
43put8 8 ulong mx2 4026531840 28
44put8 16 bitcast ulong long mx3 -128 7
45put8 24 bitcast ulong long mx4 -32768 15
46put8 32 bitcast ulong mx5 3 61
47put8 40 ulong mx6 1 7
48put8 48 ulong mx7 65535 15
49put8 56 ulong mx8 1 30
50put8 64 ulong mx9 5 3
51put8 72 mx10 1 63
52w = write 1 o 0 80
53ret 0
54end