1 ////////////////////////////////////////////////////////////////////
2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3 // All rights reserved
4 // This file was released under the GPLv2 on June 2015.
5 ////////////////////////////////////////////////////////////////////
6 /*
7 Module Name:
8
9 tools.cpp
10
11 Abstract:
12
13 This module contains some useful functions for data manipulation.
14
15 Environment:
16
17 */
18 ///////////////////////////////////////////////////////////////////////////////
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 //----------------
25
26 #include "tools.h"
27
28 //----------------
29
30 #ifdef _X86_
31
32 __declspec (naked)
33 void
34 __fastcall
_MOV_DD_SWP(void * a,void * b)35 _MOV_DD_SWP(
36 void* a, // ECX
37 void* b // EDX
38 )
39 {
40 _asm {
41 mov eax,[edx]
42 bswap eax
43 mov [ecx],eax
44 ret
45 }
46 }
47
48 __declspec (naked)
49 void
50 __fastcall
_MOV_DW_SWP(void * a,void * b)51 _MOV_DW_SWP(
52 void* a, // ECX
53 void* b // EDX
54 )
55 {
56 _asm {
57 mov ax,[edx]
58 rol ax,8
59 mov [ecx],ax
60 ret
61 }
62 }
63
64 __declspec (naked)
65 void
66 __fastcall
_REVERSE_DD(void * a)67 _REVERSE_DD(
68 void* a // ECX
69 )
70 {
71 _asm {
72 mov eax,[ecx]
73 bswap eax
74 mov [ecx],eax
75 ret
76 }
77 }
78
79 __declspec (naked)
80 void
81 __fastcall
_REVERSE_DW(void * a)82 _REVERSE_DW(
83 void* a // ECX
84 )
85 {
86 _asm {
87 mov ax,[ecx]
88 rol ax,8
89 mov [ecx],ax
90 ret
91 }
92 }
93
94 __declspec (naked)
95 void
96 __fastcall
_MOV_DW2DD_SWP(void * a,void * b)97 _MOV_DW2DD_SWP(
98 void* a, // ECX
99 void* b // EDX
100 )
101 {
102 _asm {
103 mov ax,[edx]
104 rol ax,8
105 mov [ecx+2],ax
106 mov [ecx],0
107 ret
108 }
109 }
110
111 __declspec (naked)
112 void
113 __fastcall
_MOV_MSF(void * a,void * b)114 _MOV_MSF(
115 void* a, // ECX
116 void* b // EDX
117 )
118 {
119 _asm {
120 mov eax,[edx]
121 mov [ecx],ax
122 shr eax,16
123 mov [ecx+2],al
124 ret
125 }
126 }
127
128 __declspec (naked)
129 void
130 __fastcall
_MOV_MSF_SWP(void * a,void * b)131 _MOV_MSF_SWP(
132 void* a, // ECX
133 void* b // EDX
134 )
135 {
136 _asm {
137 mov eax,[edx]
138 mov [ecx+2],al
139 bswap eax
140 shr eax,8
141 mov [ecx],ax
142 ret
143 }
144 }
145
146 __declspec (naked)
147 void
148 __fastcall
_XCHG_DD(void * a,void * b)149 _XCHG_DD(
150 void* a, // ECX
151 void* b // EDX
152 )
153 {
154 _asm {
155 mov eax,[edx]
156 xchg eax,[ecx]
157 mov [edx],eax
158 ret
159 }
160 }
161
162 #endif _X86_
163
164 #ifdef __cplusplus
165 };
166 #endif
167