-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc.asm
112 lines (78 loc) · 1.66 KB
/
c.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
.text
.globl main
main:
addi $t1, $zero, 1
ldc1 $f10, zero
addi $t0, $zero, 0
while_input:
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
sw $v0, myArray($t0)
addi $t0, $t0, 4
addi $t1, $t1, 1
sll $zero, $zero, 0
sll $zero, $zero, 0
blt $t0, 40, while_input
harmonic_average:
addi $t0, $zero, 0
ldc1 $f8, one
sll $zero, $zero, 0
sll $zero, $zero, 0
while_harmonic:
lw $t2,myArray($t0)
addi $t0, $t0, 4
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
blt $t0, 40, 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"