-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha11.asm
80 lines (62 loc) · 857 Bytes
/
a11.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
%macro write 2
mov rax,4
mov rbx,1
mov rcx, %1
mov rdx, %2
int 80h
%endmacro
%macro mprintf 1
mov rdi,formatpf
sub rsp,8
movsd xmm0, [%1]
mov rax,1
call printf
add rsp, 8
%endmacro
section .data
x: dq 100.21, 102.42, 104.63
formatpf db "%lf", 10, 0
size1: dq 3
section .bss
mean resq 1
variance resq 1
sd resq 1
section .text
extern printf
global main
main:
finit
;--mean--display--
fldz
mov rsi,00
mov rbx,x
mov rcx,[size1]
label:
fadd qword[rbx + rsi * 8]
inc rsi
loop label
fidiv word[size1]
fst qword[mean]
mprintf mean
;--variance--display--
mov rsi,00
mov rbx,x
mov rcx,[size1]
fldz
label1:
fld qword[rbx + rsi * 8]
fsub qword[mean]
fmul st0
fadd
inc rsi
dec rcx
jnz label1
fidiv word[size1]
fst qword[variance]
mprintf variance
;--std deviation--
fsqrt
fstp qword[sd]
mprintf sd
mov eax,1
int 80h