about summary refs log tree commit diff stats
path: root/linux/apps/ex3.mu
blob: 4ae3e93deccbff1cd2d2a5bdb3a5e2de09461bfb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Add the first 10 numbers, and return the result in the exit code.
#
# To run:
#   $ ./translate ex3.mu
#   $ ./a.elf
# Expected result:
#   $ echo $?
#   55

fn main -> _/ebx: int {
  var result/ebx: int <- copy 0
  var i/eax: int <- copy 1
  {
    compare i, 0xa
    break-if->
    result <- add i
    i <- increment
    loop
  }
  return result
}