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 / tests / a64efi / om2.om
| 1 | note tests/a64efi/om2.om: `target a64efi` then `om2` (the lines run.sh puts first, with efirt.om). |
| 2 | note An OM-2 form (an unsized array parameter) and globals read and written, with no pinned register: |
| 3 | note the program prints ==B, om2 7 26, ==E through efi 13. |
| 4 | global obuf uchar 32 |
| 5 | global acc ulong 4 |
| 6 | |
| 7 | fn sum a view uchar * n ulong to ulong |
| 8 | s = ulong 0 |
| 9 | for i ulong n |
| 10 | s = add s ulong get a i |
| 11 | end |
| 12 | ret s |
| 13 | end |
| 14 | |
| 15 | fn main to ulong |
| 16 | t = new uchar 4 0 |
| 17 | put t 0 5 |
| 18 | put t 1 6 |
| 19 | put t 2 7 |
| 20 | put t 3 8 |
| 21 | put acc 1 7 |
| 22 | put acc 2 sum t 4 |
| 23 | put obuf 0 61 |
| 24 | put obuf 1 61 |
| 25 | put obuf 2 66 |
| 26 | put obuf 3 10 |
| 27 | put obuf 4 111 |
| 28 | put obuf 5 109 |
| 29 | put obuf 6 50 |
| 30 | put obuf 7 32 |
| 31 | put obuf 8 uchar add 48 get acc 1 |
| 32 | put obuf 9 32 |
| 33 | put obuf 10 uchar add 48 div get acc 2 10 |
| 34 | put obuf 11 uchar add 48 rem get acc 2 10 |
| 35 | put obuf 12 10 |
| 36 | put obuf 13 61 |
| 37 | put obuf 14 61 |
| 38 | put obuf 15 69 |
| 39 | put obuf 16 10 |
| 40 | r = efi 13 0 obuf 0 17 |
| 41 | ret 0 |
| 42 | end |