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 / text.om
| 1 | target x86linux |
| 2 | note Bytes, ASCII whitespace separated words, and newline bytes. Bounded input. |
| 3 | fn run args view uchar 4096 out edit ulong 512 count ulong to ulong |
| 4 | if gt count 4096 |
| 5 | trap 3 |
| 6 | end |
| 7 | words = ulong 0 |
| 8 | lines = ulong 0 |
| 9 | inside = false |
| 10 | for i ulong count |
| 11 | c = get args i |
| 12 | space = or eq c 32 and ge c 9 le c 13 |
| 13 | if eq c 10 |
| 14 | lines = add lines 1 |
| 15 | end |
| 16 | if space |
| 17 | inside = false |
| 18 | else |
| 19 | if not inside |
| 20 | words = add words 1 |
| 21 | end |
| 22 | inside = true |
| 23 | end |
| 24 | end |
| 25 | put out 0 count |
| 26 | put out 1 words |
| 27 | put out 2 lines |
| 28 | ret 24 |
| 29 | end |