Reactos
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/*
7Module Name:
8
9 tools.cpp
10
11Abstract:
12
13 This module contains some useful functions for data manipulation.
14
15Environment:
16
17 */
18///////////////////////////////////////////////////////////////////////////////
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24//----------------
25
26#include "tools.h"
27
28//----------------
29
30#ifdef _X86_
31
32__declspec (naked)
33void
34__fastcall
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)
49void
50__fastcall
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)
65void
66__fastcall
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)
80void
81__fastcall
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)
95void
96__fastcall
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)
112void
113__fastcall
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)
129void
130__fastcall
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)
147void
148__fastcall
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