Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


i need help in converting c lang fibonacci numb to mips assembly lang

globl main

main: # main has to be globalized
addu $s7, $0, $ra # save return address in global register

# fibonacci numbers example
la $s0, A # $s5 has starting add of A
addi $t0, $zero, 2 # i =2
addi $t1, $zero, 16 # last =16
add $s1, $zero, $s0

li $v0, 4
la $a0, start

lw $t2, 0($s1) # next data of A F[0] =0
add $t2, $zero, $t2
sw $t2, 0($s1)

li $v0, 4
la $a0, space # prints " "

lw $t2, 4($s1)
add $t2, $t2, 1 # prints next data of A F[1] =1
sw $t2, 4($s1)

This is what i have so far. I need halp with the array. I need to create two seperate loops one to add fibonacci numbers and one to print.
The c source code is :
/* fibonacci.c: simple Fibonacci numbers */
int main() {
int F0, F1, F2;
int i, last;
F0 = 0; F1 = 1;
i = 0; last = 16;
do {
F2 = F0 + F1;
printf("%i", F0);
printf(" ");
F0 = F1;
F1 = F2;
i = i + 1;
} while (i < last);
Sign In or Register to comment.