-
Notifications
You must be signed in to change notification settings - Fork 0
/
exponential.s
76 lines (61 loc) · 879 Bytes
/
exponential.s
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
.text
.globl __start
__start:
la $a0,mes
li $v0,4
syscall
li $v0,5
syscall
move $s0,$v0
move $a0, $v0
li $v0,1
syscall
la $a0,endl
li $v0,4
syscall
mtc1 $s0, $f1
cvt.s.w $f1,$f1
li $s1,8
li $s3,0
li.s $f5, 0.0
li $t0,0
li $t2,0
li.s $f2, 1.0 #x^n
li.s $f3, 1.0
li.s $f6, 1.0
li.s $f7, 1.0
mov.s $f4,$f1
loop:
beq $t0,$s1, end
loop2:
beq $t2, $t0, end2
mul.s $f2, $f2,$f1
addi $t2, $t2,1
j loop2
end2:
li $t2,0
fact:
beq $t2,$t0, end3
mul.s $f3,$f3,$f6
add.s $f6,$f6,$f7
addi $t2, $t2, 1
j fact
end3:
div.s $f2,$f2,$f3
add.s $f5,$f5,$f2
add $t0,$t0,1
li.s $f2,1.0
li.s $f3,1.0
li.s $f6,1.0
li $t2,0
j loop
end:
li $v0,2
mov.s $f12,$f5
syscall
exit:
li $v0,10
syscall
.data
mes: .asciiz "Give a number for x:"
endl: .asciiz "\n"