Hi
Here is the fibonaci function
#
# fibo.pasm
#
# int fibo(int i) {
# int a,b,c = 0;
# if(i == 1 || i == 2) {
# a = 1;
# } else {
# i = i - 2;
# a = 1;
# b = 1;
# while(i != 0) {
# c = a;
# a = a + b;
# b = c;
# i--;
# }
# }
# return a;
# }
#
# I1: result (a)
# I2: n (i)
# I3: temp (b)
# I4: temp (c)
# I5: scratch
#
# implement loop some day
main:
set I2, 24
# calling convent n in I2
fibo: set S1, "(Fibonacis function)\n"
print S1
set I5, 1
eq I2, I5, done1, or
or: set I5, 2
eq I2, I5, done1, else
else: dec I2, 2
set I1, 1
set I3, 1
set I5, 0
eq I2, I5, done2, while
while: set I4, I1
add I1, I1,I3
set I3, I4
dec I2
eq I2, 0, done2, while
done1: set I1,1
done2: print I1
set S2, "\n"
print S2
end
# Enjoy,