program Fibonacci {
section module {
std
}
section data {
int rax = 0
string str_0 = "enter how many numbers to output: "
string str_1 = " "
string str_2 = "out of range of 64-bit integer"
string str_3 = " done "
string fmt_int = "%lld "
string fmt_str = "%s "
string newline = "\n"
string input_buffer, 256
int n = 0
int a = 0
int b = 0
int temp = 0
int i = 0
}
section code {
start:
mov a, 0
mov b, 1
mov i, 2
mov n, 92
print fmt_str, str_0
getline input_buffer
to_int n, input_buffer
print fmt_int, a
print fmt_str, str_1
print newline
cmp n, 1
jle ELSE_0
print fmt_int, b
print fmt_str, str_1
print newline
ELSE_0:
cmp n, 1
jl OR_ONE_10
cmp n, 92
jle ELSE_4
OR_ONE_10:
print fmt_str, str_2
print newline
exit 0
ELSE_4:
WHILE_12:
cmp i, n
jge ENDWHILE_13
mov temp, a
add temp, b
mov a, b
mov b, temp
print fmt_int, b
print fmt_str, str_1
print newline
add i, 1
jmp WHILE_12
ENDWHILE_13:
print fmt_str, str_3
print newline
done
}
}