program ArrayExample {
section module {
}
section data {
int rax = 0
int rbx = 0
int rcx = 0
float xmm0 = 0.0
float xmm1 = 0.0
string str_0 = "Array contents:"
string str_1 = "numbers["
string str_2 = "] = "
string fmt_int = "%lld "
string fmt_str = "%s "
string fmt_float = "%.6f "
string newline = "\n"
ptr numbers = null
int i = 0
}
section code {
start:
alloc numbers, 8, 5
mov i, 1
FOR_0:
cmp i, 5
jg ENDFOR_1
mov rbx, i
mul rbx, 10
cmp i, 1
jl IDX_OOB_4
cmp i, 5
jg IDX_OOB_4
jmp IDX_OK_3
IDX_OOB_4:
exit 1
IDX_OK_3:
mov rcx, i
sub rcx, 1
mov xmm0, rbx
store xmm0, numbers, rcx, 8
FOR_CONTINUE_2:
add i, 1
jmp FOR_0
ENDFOR_1:
print fmt_str, str_0
print newline
mov i, 1
FOR_5:
cmp i, 5
jg ENDFOR_6
print fmt_str, str_1
print fmt_int, i
print fmt_str, str_2
mov rcx, i
sub rcx, 1
load xmm1, numbers, rcx, 8
print fmt_float, xmm1
print newline
FOR_CONTINUE_7:
add i, 1
jmp FOR_5
ENDFOR_6:
free numbers
done
}
}