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