-
Notifications
You must be signed in to change notification settings - Fork 0
/
sseutils.nasm
153 lines (137 loc) · 1.96 KB
/
sseutils.nasm
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
; --------------------------------------------------
; Macro per il linking di file oggetto
; NASM con la C standard library e
; alcune utility per l'uso di SSE
;
; Uso:
; %include "sseutils.nasm"
; (da specificare nel file sorgente NASM
; prima della section .data)
; --------------------------------------------------
; Fabrizio Angiulli, 4/6/2011
;
extern printf
section .bss
dbuf: resq 1
section .data
dmask: db '%f ',0
cr: db 10,0
br1: db '( ',0
br2: db ')',10,0
%macro start 0
push ebp
mov ebp, esp
pushad
%endmacro
%macro stop 0
popad
mov esp, ebp
pop ebp
ret
%endmacro
%macro prints 1
pushad
push %1
call printf
add esp, 4
popad
%endmacro
%macro dprint 1
pushad
mov eax,[%1+4]
push eax
mov eax,[%1]
push eax
push dmask
call printf
add esp, 12
popad
%endmacro
%macro sprint 1
finit
fld dword [%1]
fst qword [dbuf]
dprint dbuf
%endmacro
%macro printss 1
sprint %1
prints cr
%endmacro
%macro printps 2
prints br1
push edx
push ecx
mov edx, %1
mov ecx, %2
%%loopps:
sprint edx
sprint edx+4
sprint edx+8
sprint edx+12
add edx, 16
dec ecx
jnz %%loopps
pop ecx
pop edx
prints br2
%endmacro
%macro vprintps 2
prints br1
push edx
push ecx
mov edx, %1
mov ecx, %2
%%loopps:
sprint edx
sprint edx+4
sprint edx+8
sprint edx+12
sprint edx+16
sprint edx+20
sprint edx+24
sprint edx+28
add edx, 32
dec ecx
jnz %%loopps
pop ecx
pop edx
prints br2
%endmacro
%macro printsd 1
dprint %1
prints cr
%endmacro
%macro printpd 2
prints br1
push edx
push ecx
mov edx, %1
mov ecx, %2
%%looppd:
dprint edx
dprint edx+8
add edx, 16
dec ecx
jnz %%looppd
pop ecx
pop edx
prints br2
%endmacro
%macro vprintpd 2
prints br1
push edx
push ecx
mov edx, %1
mov ecx, %2
%%looppd:
dprint edx
dprint edx+8
dprint edx+16
dprint edx+24
add edx, 32
dec ecx
jnz %%looppd
pop ecx
pop edx
prints br2
%endmacro