aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / x86 / tools / arithmetic.om
| 1 | target x86linux |
| 2 | note Local ABI: signed operation 1 add, 2 subtract, 3 multiply, 4 divide. |
| 3 | note Checked arithmetic traps retain the compiler's overflow and zero semantics. |
| 4 | fn run args view long 512 out edit long 512 count ulong to ulong |
| 5 | if ne count 24 |
| 6 | trap 3 |
| 7 | end |
| 8 | op = get args 0 |
| 9 | a = get args 1 |
| 10 | b = get args 2 |
| 11 | v = long 0 |
| 12 | if eq op 1 |
| 13 | v = add a b |
| 14 | else |
| 15 | if eq op 2 |
| 16 | v = sub a b |
| 17 | else |
| 18 | if eq op 3 |
| 19 | v = mul a b |
| 20 | else |
| 21 | if eq op 4 |
| 22 | v = div a b |
| 23 | else |
| 24 | trap 3 |
| 25 | end |
| 26 | end |
| 27 | end |
| 28 | end |
| 29 | put out 0 v |
| 30 | ret 8 |
| 31 | end |