-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha.asm
66 lines (49 loc) · 977 Bytes
/
a.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
.text
.globl main
main:
ldc1 $f10, zero
addi $t0, $zero, 0
addi $t1, $zero, 1
while_input:
beq $t0, 40, harmonic_average
li $v0, 1
addi $a0, $t1, 0
syscall
li $v0, 4
la $a0, input_number_text
syscall
li $v0, 5
syscall
sw $v0, myArray($t0)
addi $t0, $t0, 4
addi $t1, $t1, 1
j while_input
harmonic_average:
addi $t0, $zero, 0
ldc1 $f8, one
while_harmonic:
beq $t0, 40, calculation
lw $t2,myArray($t0)
mtc1.d $t2, $f2
cvt.d.w $f2, $f2
div.d $f2, $f8, $f2
add.d $f4, $f4, $f2
addi $t0, $t0, 4
j while_harmonic
calculation:
ldc1 $f8, N
div.d $f12, $f8, $f4
exit:
li $v0, 4
la $a0, result_text
syscall
li $v0, 3
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"