source: trunk/src/win32k/misc/asmutils.asm@ 1467

Last change on this file since 1467 was 1467, checked in by bird, 26 years ago

Corrections to make win32k work.
(And now it does work, at least at my test machine...)

File size: 2.8 KB
Line 
1; $Id: asmutils.asm,v 1.3 1999-10-27 02:02:59 bird Exp $
2;
3; asmutils - assembly utility functions
4;
5; Copyright (c) 1998-1999 knut st. osmundsen
6;
7; Project Odin Software License can be found in LICENSE.TXT
8;
9 .386p
10
11;
12; Include files
13;
14 include devsegdf.inc
15
16;
17; Exported symbols
18;
19 public GetCS
20 public GetDS
21 public GetES
22 public GetFS
23 public GetGS
24 public GetSS
25 public Int3
26 public _memrevmov@12
27 public _memmov@12
28; public DisableInterrupts
29; public EnableInterrupts
30
31
32CODE32 segment
33 assume CS:CODE32, DS:FLAT, SS:NOTHING
34
35GetCS proc near
36 xor eax,eax
37 mov ax,cs
38 ret
39GetCS endp
40
41
42GetDS proc near
43 xor eax,eax
44 mov ax,ds
45 ret
46GetDS endp
47
48
49GetES proc near
50 xor eax,eax
51 mov ax,es
52 ret
53GetES endp
54
55
56GetFS proc near
57 xor eax,eax
58 mov ax,fs
59 ret
60GetFS endp
61
62
63GetGS PROC NEAR
64 xor eax,eax
65 mov ax,gs
66 ret
67GetGS ENDP
68
69
70GetSS PROC NEAR
71 xor eax,eax
72 mov ax,ss
73 ret
74GetSS ENDP
75
76
77Int3 PROC NEAR
78 push ebp
79 mov ebp,esp
80 int 3
81 pop ebp
82 ret
83Int3 ENDP
84
85
86;DisableInterrupts PROC NEAR
87; cli
88; ret
89;DisableInterrupts ENDP
90
91;EnableInterrupts PROC NEAR
92; sti
93; ret
94;EnableInterrupts ENDP
95
96
97;void __stdcall memrevmov(void *pTo, void* pFrom, unsigned int Len);
98pTo EQU dword ptr [ebp+08]
99pFrom EQU dword ptr [ebp+12]
100Len EQU dword ptr [ebp+16]
101_memrevmov@12 PROC NEAR
102 push ebp
103 mov ebp,esp
104 push esi
105 push edi
106
107
108 mov edi,pTo
109 mov esi,pFrom
110 mov ecx,Len
111
112 ;test if (pTo+4 <= pFrom) then use dword_move else byte_move
113 dec edi
114 dec esi
115 mov eax,edi
116 sub eax,esi
117 cmp eax,4
118 jg memrevmov_loopbyte
119 memrevmov_loopdword::
120 mov eax,[esi+ecx]
121 mov [edi+ecx],eax
122 sub ecx,4
123 cmp ecx,4
124 jg memrevmov_loopdword
125
126 memrevmov_loopbyte::
127 mov al,[esi+ecx]
128 mov [edi+ecx],al
129 loop memrevmov_loopbyte
130
131 pop edi
132 pop esi
133 pop ebp
134 ret 12
135_memrevmov@12 ENDP
136
137;void __stdcall memmov(void *p, signed int off, unsigned int len);
138p EQU dword ptr [ebp+08]
139off EQU dword ptr [ebp+12]
140len EQU dword ptr [ebp+16]
141_memmov@12 PROC NEAR
142 push ebp
143 mov ebp,esp
144 push esi
145 push edi
146
147 mov ecx,len
148 mov esi,p
149 mov edi,esi
150 mov eax,off
151 test eax, 80000000h
152 ja memmov_neg
153
154 add edi,eax
155 dec edi
156 dec esi
157
158 cmp eax,4
159 jg memrevmov_loopbyte
160 memmov_loopdword:
161 mov eax,[esi+ecx]
162 mov [edi+ecx],eax
163 sub ecx,4
164 cmp ecx,4
165 jl memrevmov_loopdword
166
167 memmov_loopbyte:
168 mov al,[esi+ecx]
169 mov [edi+ecx],al
170 loop memrevmov_loopbyte
171
172 memmov_end:
173 pop edi
174 pop esi
175 pop ebp
176 ret 12
177
178 memmov_neg:
179 ;this don't work!!!
180 neg eax
181 sub edi,eax
182
183 cmp eax,4
184 jg memmov_neg_byte
185 and ecx,NOT 03h
186 rep movsd
187
188 mov ecx,len
189 and ecx,03h
190 memmov_neg_byte:
191 rep movsb
192
193 jmp memmov_end
194_memmov@12 ENDP
195
196
197CODE32 ends
198end
Note: See TracBrowser for help on using the repository browser.