-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb.asm
128 lines (87 loc) · 1.87 KB
/
b.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
.text
.globl main
main:
ldc1 $f10, zero
addi $t0, $zero, 0
addi $t1, $zero, 1
sll $zero, $zero, 0
sll $zero, $zero, 0
while_input:
beq $t0, 40, harmonic_average
li $v0, 1
addi $a0, $t1, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
syscall
li $v0, 4
la $a0, input_number_text
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
syscall
li $v0, 5
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
syscall
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
sw $v0, myArray($t0)
addi $t0, $t0, 4
addi $t1, $t1, 1
sll $zero, $zero, 0
sll $zero, $zero, 0
j while_input
harmonic_average:
addi $t0, $zero, 0
ldc1 $f8, one
sll $zero, $zero, 0
sll $zero, $zero, 0
while_harmonic:
beq $t0, 40, calculation
lw $t2,myArray($t0)
mtc1.d $t2, $f2
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
cvt.d.w $f2, $f2
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
div.d $f2, $f8, $f2
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
add.d $f4, $f4, $f2
addi $t0, $t0, 4
sll $zero, $zero, 0
sll $zero, $zero, 0
j while_harmonic
calculation:
ldc1 $f8, N
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
div.d $f12, $f8, $f4
exit:
li $v0, 4
la $a0, result_text
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
syscall
li $v0, 3
sll $zero, $zero, 0
sll $zero, $zero, 0
sll $zero, $zero, 0
syscall
.data
myArray: .space 40
zero: .double 0.0
one: .double 1.0
N: .double 10.0
input_number_text: .asciiz ". Lütfen Sayi Giriniz: "
result_text: .asciiz "\nGirmis Oldugunuz Sayilarin Harmonik Ortalamasi: "
ln: .asciiz "\n"