aboutsummaryrefslogtreecommitdiff
path: root/examples/loop_sum.hdass
blob: 130f05557fed795a6795428907b7ee087b0535de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[entry: main]

// Sums 5 + 4 + 3 + 2 + 1 = 15 with a countdown loop, returns it as the status.
const SYS_EXIT = 60

proc main
{
    rbx = 0 // running total
    rcx = 5 // counter

    while .countdown rcx > 0
    {
        rbx += rcx
        rcx -= 1
    }

    rdi = rbx
    rax = SYS_EXIT
    syscall
}