-
Notifications
You must be signed in to change notification settings - Fork 0
/
mipsfibonacci.asm
87 lines (81 loc) · 1.1 KB
/
mipsfibonacci.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.data
tab: .asciiz " "
pt: .asciiz "."
enter: .asciiz "\n"
grtable: .asciiz "Golden Ratio Table \nA B B/A\n"
name: .asciiz "Name: Jason Jackrel"
comma: .asciiz ", "
fibseq: .asciiz "15 terms of Fibonacci sequence \n"
.text
.globl main
main:
li $v0, 4
la $a0, name
syscall
li $v0, 4
la $a0, enter
syscall
li $v0, 4
la $a0, fibseq
syscall
addi $s2, $zero, 0
addi $s1, $zero, 1
fibloop:
li $v0, 1
move $a0, $s0
syscall
li $v0, 4
la $a0, comma
syscall
bge $s0, 377, fibloopend
addi $s2, $s1, 0
addi $s1, $s0, 0
add $s0, $s1, $s2
j fibloop
fibloopend:
li $v0, 4
la $a0, enter
syscall
li $v0, 4
la $a0, grtable
syscall
addi $t0, $zero ,1
addi $t1, $zero ,2
loop:
add $t2, $t1, $t0
li $v0, 1
move $a0, $t1
syscall
li $v0, 4
la $a0, tab
syscall
li $v0, 1
move $a0, $t2
syscall
li $v0, 4
la $a0, tab
syscall
mul $t4, $t2, 100000
div $t5, $t4, $t1
div $t3, $t5, 100000
sub $t5, $t5, 100000
li $v0, 1
move $a0, $t3
syscall
li $v0, 4
la $a0, pt
syscall
li $v0, 1
move $a0, $t5
syscall
addi $t0, $t1, 0
addi $t1, $t2, 0
add $t2, $t1, $t0
li $v0, 4
la $a0, enter
syscall
bge $t2, 610, loopend
j loop
loopend:
li $v0, 10
syscall