aboutsummaryrefslogtreecommitdiff
path: root/examples/loop_sum.hdass
blob: bb8d115b3a6c227e4f741bc62ef702d7d836b8fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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

loop:
    rbx += rcx
    rcx -= 1
    if rcx != 0
        goto loop

    rdi = rbx
    rax = SYS_EXIT
    syscall
}