about summary refs log tree commit diff stats
path: root/apps/factorial.mu
blob: f306de25b4d91dd8f76ed796965fa56effa8ad24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
fn main -> result/ebx: int {
  var tmp/eax: int <- factorial 5
  result <- copy tmp
}

fn factorial n: int -> result/eax: int {
  compare n 1
  {
    break-if->
    result <- copy 1
  }
  {
    break-if-<=
    var tmp/ecx: int <- copy n
    tmp <- decrement
    result <- factorial tmp
    result <- multiply n
  }
}