aboutsummaryrefslogtreecommitdiff
path: root/examples/loop_sum.hdass
blob: 59769145b766c50102f399204b2d192e640f7aad (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

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

    rdi = rbx
    rax = SYS_EXIT
    syscall
}