hi all,

i got a program that calculates the fibonacci numbers and prints them out, looks something like this:

main:

li $s0, 0

li $s1, 1

loop:

slt $t0, $s1, $s0

bgtz $t0, done

addu $s2, $s0, $s1

move $s0, $s1

move $s1, $s2

li $v0, 1

move $a0, $s2

syscall

j loop

done:

jr $ra

so ok when i execute it it gives me a list of fibonacci numbers. i would have expected a infinite loop however the last number it gave me was 1836131903

and then the next thing it gave me was -1323752223

can any1 explain this?

it cant be because it reached the maximum value a register can store right? because a register has 32 bits therefore stores up to 4billion, however if the program kept going the next number should have been 1836131903 + 1134903170 = 2971035037 which is < 4 billion so it should have been ok?

pls help! XD

EDIT: o i just found that the last two fibonnaci numbers added together gives:

1836131903 + 1134903170 = 2971035037

and the max number a 32 bit register can store is 2^32

and if compute:

2971035037 - 2^32 = -1323752223

the maths is all there pls someone explain to me!