1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | #include "../BasicCompiler_Common/common.h"
|
---|
4 | #include "Opcode.h"
|
---|
5 |
|
---|
6 | void SetReg_RealVariable(int type,RELATIVE_VAR *pRelativeVar){
|
---|
7 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
8 | if(pRelativeVar->bOffsetOffset){
|
---|
9 | //fld ptr[ecx+offset]
|
---|
10 | op_fld_base_offset(type,REG_ECX,(int)pRelativeVar->offset);
|
---|
11 | obp-=sizeof(long);
|
---|
12 | pobj_GlobalVarSchedule->add();
|
---|
13 | obp+=sizeof(long);
|
---|
14 | }
|
---|
15 | else{
|
---|
16 | //mov ecx,offset
|
---|
17 | op_mov_RV(REG_ECX,(int)pRelativeVar->offset);
|
---|
18 | obp-=sizeof(long);
|
---|
19 | pobj_GlobalVarSchedule->add();
|
---|
20 | obp+=sizeof(long);
|
---|
21 |
|
---|
22 | //fld ptr[ecx]
|
---|
23 | op_fld_basereg(type,REG_ECX);
|
---|
24 | }
|
---|
25 | }
|
---|
26 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
27 | SetError(300,NULL,cp);
|
---|
28 | }
|
---|
29 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
30 | if(pRelativeVar->bOffsetOffset){
|
---|
31 | //fld ptr[ebp+ecx+offset]
|
---|
32 | op_fld_base_offset_ex(type,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET);
|
---|
33 | obp-=sizeof(long);
|
---|
34 | AddLocalVarAddrSchedule();
|
---|
35 | obp+=sizeof(long);
|
---|
36 | }
|
---|
37 | else{
|
---|
38 | //fld ptr[ebp+offset]
|
---|
39 | op_fld_base_offset(type,REG_EBP,(int)pRelativeVar->offset);
|
---|
40 | obp-=sizeof(long);
|
---|
41 | AddLocalVarAddrSchedule();
|
---|
42 | obp+=sizeof(long);
|
---|
43 | }
|
---|
44 | }
|
---|
45 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
46 | if(pRelativeVar->bOffsetOffset){
|
---|
47 | //add ecx,qword ptr[ebp+offset]
|
---|
48 | op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
49 | obp-=sizeof(long);
|
---|
50 | AddLocalVarAddrSchedule();
|
---|
51 | obp+=sizeof(long);
|
---|
52 | }
|
---|
53 | else{
|
---|
54 | //mov ecx,qword ptr[ebp+offset]
|
---|
55 | op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
56 | obp-=sizeof(long);
|
---|
57 | AddLocalVarAddrSchedule();
|
---|
58 | obp+=sizeof(long);
|
---|
59 | }
|
---|
60 |
|
---|
61 | goto directmem;
|
---|
62 | }
|
---|
63 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
64 | directmem:
|
---|
65 | //fld ptr[ecx]
|
---|
66 | op_fld_basereg(type,REG_ECX);
|
---|
67 | }
|
---|
68 | }
|
---|
69 | void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg, bool is64Head){
|
---|
70 | int varSize;
|
---|
71 |
|
---|
72 | varSize=GetTypeSize(type,-1);
|
---|
73 |
|
---|
74 | if(varSize==sizeof(_int64)){
|
---|
75 | //64ビットの場合はedx:eaxにロード
|
---|
76 | if(reg!=REG_EAX){
|
---|
77 | SetError(300,NULL,cp);
|
---|
78 | return;
|
---|
79 | }
|
---|
80 |
|
---|
81 | //下位32ビットをeaxにロード
|
---|
82 | SetReg_WholeVariable(DEF_LONG,pRelativeVar,REG_EAX);
|
---|
83 |
|
---|
84 | //上位32ビットをedxにロード
|
---|
85 | SetReg_WholeVariable(DEF_LONG,pRelativeVar,REG_EDX, true);
|
---|
86 |
|
---|
87 | return;
|
---|
88 | }
|
---|
89 |
|
---|
90 | int offsetOf64Head = 0;
|
---|
91 | if( is64Head ){
|
---|
92 | offsetOf64Head = sizeof(long);
|
---|
93 | }
|
---|
94 |
|
---|
95 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
96 | if(pRelativeVar->bOffsetOffset){
|
---|
97 | //mov reg, ptr[ecx+offset]
|
---|
98 | op_mov_RM(varSize,reg,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32);
|
---|
99 | }
|
---|
100 | else{
|
---|
101 | //mov reg, ptr[offset]
|
---|
102 | op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset + offsetOf64Head,MOD_DISP32);
|
---|
103 | }
|
---|
104 | obp-=sizeof(long);
|
---|
105 | pobj_GlobalVarSchedule->add();
|
---|
106 | obp+=sizeof(long);
|
---|
107 | }
|
---|
108 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
109 | if(pRelativeVar->bOffsetOffset){
|
---|
110 | //add ecx,qword ptr[offset]
|
---|
111 | op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);
|
---|
112 | }
|
---|
113 | else{
|
---|
114 | //mov ecx,qword ptr[offset]
|
---|
115 | op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);
|
---|
116 | }
|
---|
117 | obp-=sizeof(long);
|
---|
118 | pobj_GlobalVarSchedule->add();
|
---|
119 | obp+=sizeof(long);
|
---|
120 |
|
---|
121 | goto directmem;
|
---|
122 | }
|
---|
123 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
124 | if(pRelativeVar->bOffsetOffset){
|
---|
125 | //mov reg, ptr[ebp+ecx+offset]
|
---|
126 | op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET);
|
---|
127 | }
|
---|
128 | else{
|
---|
129 | //mov reg, ptr[ebp+offset]
|
---|
130 | op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32);
|
---|
131 | }
|
---|
132 | obp-=sizeof(long);
|
---|
133 | AddLocalVarAddrSchedule();
|
---|
134 | obp+=sizeof(long);
|
---|
135 | }
|
---|
136 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
137 | if(pRelativeVar->bOffsetOffset){
|
---|
138 | //add ecx,qword ptr[ebp+offset]
|
---|
139 | op_add_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
140 | }
|
---|
141 | else{
|
---|
142 | //mov ecx,qword ptr[ebp+offset]
|
---|
143 | op_mov_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
144 | }
|
---|
145 | obp-=sizeof(long);
|
---|
146 | AddLocalVarAddrSchedule();
|
---|
147 | obp+=sizeof(long);
|
---|
148 |
|
---|
149 | goto directmem;
|
---|
150 | }
|
---|
151 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
152 | directmem:
|
---|
153 | if( is64Head ){
|
---|
154 | //mov reg, ptr[ecx]
|
---|
155 | op_mov_RM(varSize,reg,REG_ECX,offsetOf64Head,MOD_BASE_DISP8);
|
---|
156 | }
|
---|
157 | else{
|
---|
158 | //mov reg, ptr[ecx]
|
---|
159 | op_mov_RM(varSize,reg,REG_ECX,0,MOD_BASE);
|
---|
160 | }
|
---|
161 | }
|
---|
162 | }
|
---|
163 |
|
---|
164 |
|
---|
165 |
|
---|
166 |
|
---|
167 |
|
---|
168 | void PushDoubleVariable(RELATIVE_VAR *pRelativeVar){
|
---|
169 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
170 | if(pRelativeVar->bOffsetOffset){
|
---|
171 | //push dword ptr[ecx+offset+sizeof(long)]
|
---|
172 | OpBuffer[obp++]=(char)0xFF;
|
---|
173 | OpBuffer[obp++]=(char)0xB1;
|
---|
174 | *((long *)(OpBuffer+obp))=pRelativeVar->offset+sizeof(long);
|
---|
175 | pobj_GlobalVarSchedule->add();
|
---|
176 | obp+=sizeof(long);
|
---|
177 |
|
---|
178 | //push dword ptr[ecx+offset]
|
---|
179 | OpBuffer[obp++]=(char)0xFF;
|
---|
180 | OpBuffer[obp++]=(char)0xB1;
|
---|
181 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
182 | pobj_GlobalVarSchedule->add();
|
---|
183 | obp+=sizeof(long);
|
---|
184 | }
|
---|
185 | else{
|
---|
186 | //push dword ptr[offset+sizeof(long)]
|
---|
187 | OpBuffer[obp++]=(char)0xFF;
|
---|
188 | OpBuffer[obp++]=(char)0x35;
|
---|
189 | *((long *)(OpBuffer+obp))=pRelativeVar->offset+sizeof(long);
|
---|
190 | pobj_GlobalVarSchedule->add();
|
---|
191 | obp+=sizeof(long);
|
---|
192 |
|
---|
193 | //push dword ptr[offset]
|
---|
194 | OpBuffer[obp++]=(char)0xFF;
|
---|
195 | OpBuffer[obp++]=(char)0x35;
|
---|
196 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
197 | pobj_GlobalVarSchedule->add();
|
---|
198 | obp+=sizeof(long);
|
---|
199 | }
|
---|
200 | }
|
---|
201 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
202 | SetError(300,NULL,cp);
|
---|
203 | }
|
---|
204 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
205 | if(pRelativeVar->bOffsetOffset){
|
---|
206 | //add ecx,offset+sizeof(long)
|
---|
207 | OpBuffer[obp++]=(char)0x81;
|
---|
208 | OpBuffer[obp++]=(char)0xC1;
|
---|
209 | *((long *)(OpBuffer+obp))=pRelativeVar->offset+sizeof(long);
|
---|
210 | AddLocalVarAddrSchedule();
|
---|
211 | obp+=sizeof(long);
|
---|
212 |
|
---|
213 | //push dword ptr[ebp+ecx]
|
---|
214 | OpBuffer[obp++]=(char)0xFF;
|
---|
215 | OpBuffer[obp++]=(char)0x74;
|
---|
216 | OpBuffer[obp++]=(char)0x0D;
|
---|
217 | OpBuffer[obp++]=(char)0x00;
|
---|
218 |
|
---|
219 | //sub ecx,sizeof(long)
|
---|
220 | OpBuffer[obp++]=(char)0x83;
|
---|
221 | OpBuffer[obp++]=(char)0xE9;
|
---|
222 | OpBuffer[obp++]=(char)0x04;
|
---|
223 |
|
---|
224 | //push dword ptr[ebp+ecx]
|
---|
225 | OpBuffer[obp++]=(char)0xFF;
|
---|
226 | OpBuffer[obp++]=(char)0x74;
|
---|
227 | OpBuffer[obp++]=(char)0x0D;
|
---|
228 | OpBuffer[obp++]=(char)0x00;
|
---|
229 | }
|
---|
230 | else{
|
---|
231 | //push dword ptr[ebp+offset+sizeof(long)]
|
---|
232 | OpBuffer[obp++]=(char)0xFF;
|
---|
233 | OpBuffer[obp++]=(char)0xB5;
|
---|
234 | *((long *)(OpBuffer+obp))=pRelativeVar->offset+sizeof(long);
|
---|
235 | AddLocalVarAddrSchedule();
|
---|
236 | obp+=sizeof(long);
|
---|
237 |
|
---|
238 | //push dword ptr[ebp+offset]
|
---|
239 | OpBuffer[obp++]=(char)0xFF;
|
---|
240 | OpBuffer[obp++]=(char)0xB5;
|
---|
241 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
242 | AddLocalVarAddrSchedule();
|
---|
243 | obp+=sizeof(long);
|
---|
244 | }
|
---|
245 | }
|
---|
246 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
247 | //mov eax,dword ptr[ebp+offset]
|
---|
248 | OpBuffer[obp++]=(char)0x8B;
|
---|
249 | OpBuffer[obp++]=(char)0x85;
|
---|
250 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
251 | AddLocalVarAddrSchedule();
|
---|
252 | obp+=sizeof(long);
|
---|
253 |
|
---|
254 | if(pRelativeVar->bOffsetOffset){
|
---|
255 | //add eax,ecx
|
---|
256 | OpBuffer[obp++]=(char)0x03;
|
---|
257 | OpBuffer[obp++]=(char)0xC1;
|
---|
258 | }
|
---|
259 |
|
---|
260 | //push dword ptr[eax+sizeof(long)]
|
---|
261 | OpBuffer[obp++]=(char)0xFF;
|
---|
262 | OpBuffer[obp++]=(char)0x70;
|
---|
263 | OpBuffer[obp++]=(char)0x04;
|
---|
264 |
|
---|
265 | //push dword ptr[eax]
|
---|
266 | OpBuffer[obp++]=(char)0xFF;
|
---|
267 | OpBuffer[obp++]=(char)0x30;
|
---|
268 | }
|
---|
269 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
270 | //push dword ptr[ecx+sizeof(long)]
|
---|
271 | OpBuffer[obp++]=(char)0xFF;
|
---|
272 | OpBuffer[obp++]=(char)0xB1;
|
---|
273 | *((long *)(OpBuffer+obp))=sizeof(long);
|
---|
274 | obp+=sizeof(long);
|
---|
275 |
|
---|
276 | //push dword ptr[ecx]
|
---|
277 | OpBuffer[obp++]=(char)0xFF;
|
---|
278 | OpBuffer[obp++]=(char)0x31;
|
---|
279 | }
|
---|
280 | }
|
---|
281 | void PushLongVariable(RELATIVE_VAR *pRelativeVar){
|
---|
282 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
283 | if(pRelativeVar->bOffsetOffset){
|
---|
284 | //push dword ptr[ecx+offset]
|
---|
285 | OpBuffer[obp++]=(char)0xFF;
|
---|
286 | OpBuffer[obp++]=(char)0xB1;
|
---|
287 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
288 | pobj_GlobalVarSchedule->add();
|
---|
289 | obp+=sizeof(long);
|
---|
290 | }
|
---|
291 | else{
|
---|
292 | //push dword ptr[offset]
|
---|
293 | OpBuffer[obp++]=(char)0xFF;
|
---|
294 | OpBuffer[obp++]=(char)0x35;
|
---|
295 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
296 | pobj_GlobalVarSchedule->add();
|
---|
297 | obp+=sizeof(long);
|
---|
298 | }
|
---|
299 | }
|
---|
300 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
301 | //mov eax,dword ptr[offset]
|
---|
302 | op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
|
---|
303 | obp-=sizeof(long);
|
---|
304 | pobj_GlobalVarSchedule->add();
|
---|
305 | obp+=sizeof(long);
|
---|
306 |
|
---|
307 | if(pRelativeVar->bOffsetOffset){
|
---|
308 | //add eax,ecx
|
---|
309 | OpBuffer[obp++]=(char)0x03;
|
---|
310 | OpBuffer[obp++]=(char)0xC1;
|
---|
311 | }
|
---|
312 |
|
---|
313 | //push dword ptr[eax]
|
---|
314 | OpBuffer[obp++]=(char)0xFF;
|
---|
315 | OpBuffer[obp++]=(char)0x30;
|
---|
316 | }
|
---|
317 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
318 | if(pRelativeVar->bOffsetOffset){
|
---|
319 | //add ecx,offset
|
---|
320 | OpBuffer[obp++]=(char)0x81;
|
---|
321 | OpBuffer[obp++]=(char)0xC1;
|
---|
322 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
323 | AddLocalVarAddrSchedule();
|
---|
324 | obp+=sizeof(long);
|
---|
325 |
|
---|
326 | //push dword ptr[ebp+ecx]
|
---|
327 | OpBuffer[obp++]=(char)0xFF;
|
---|
328 | OpBuffer[obp++]=(char)0x74;
|
---|
329 | OpBuffer[obp++]=(char)0x0D;
|
---|
330 | OpBuffer[obp++]=(char)0x00;
|
---|
331 | }
|
---|
332 | else{
|
---|
333 | //push dword ptr[ebp+offset]
|
---|
334 | OpBuffer[obp++]=(char)0xFF;
|
---|
335 | OpBuffer[obp++]=(char)0xB5;
|
---|
336 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
337 | AddLocalVarAddrSchedule();
|
---|
338 | obp+=sizeof(long);
|
---|
339 | }
|
---|
340 | }
|
---|
341 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
342 | //mov eax,dword ptr[ebp+offset]
|
---|
343 | OpBuffer[obp++]=(char)0x8B;
|
---|
344 | OpBuffer[obp++]=(char)0x85;
|
---|
345 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
346 | AddLocalVarAddrSchedule();
|
---|
347 | obp+=sizeof(long);
|
---|
348 |
|
---|
349 | if(pRelativeVar->bOffsetOffset){
|
---|
350 | //add eax,ecx
|
---|
351 | OpBuffer[obp++]=(char)0x03;
|
---|
352 | OpBuffer[obp++]=(char)0xC1;
|
---|
353 | }
|
---|
354 |
|
---|
355 | //push dword ptr[eax]
|
---|
356 | OpBuffer[obp++]=(char)0xFF;
|
---|
357 | OpBuffer[obp++]=(char)0x30;
|
---|
358 | }
|
---|
359 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
360 | //push dword ptr[ecx]
|
---|
361 | OpBuffer[obp++]=(char)0xFF;
|
---|
362 | OpBuffer[obp++]=(char)0x31;
|
---|
363 | }
|
---|
364 | }
|
---|
365 | void PushIntegerVariable(RELATIVE_VAR *pRelativeVar){
|
---|
366 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
367 | if(pRelativeVar->bOffsetOffset){
|
---|
368 | //movsx eax,word ptr[ecx+offset]
|
---|
369 | OpBuffer[obp++]=(char)0x0F;
|
---|
370 | OpBuffer[obp++]=(char)0xBF;
|
---|
371 | OpBuffer[obp++]=(char)0x81;
|
---|
372 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
373 | pobj_GlobalVarSchedule->add();
|
---|
374 | obp+=sizeof(long);
|
---|
375 | }
|
---|
376 | else{
|
---|
377 | //movsx eax,word ptr[offset]
|
---|
378 | OpBuffer[obp++]=(char)0x0F;
|
---|
379 | OpBuffer[obp++]=(char)0xBF;
|
---|
380 | OpBuffer[obp++]=(char)0x05;
|
---|
381 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
382 | pobj_GlobalVarSchedule->add();
|
---|
383 | obp+=sizeof(long);
|
---|
384 | }
|
---|
385 | }
|
---|
386 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
387 | //mov ebx,dword ptr[offset]
|
---|
388 | op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
|
---|
389 | obp-=sizeof(long);
|
---|
390 | pobj_GlobalVarSchedule->add();
|
---|
391 | obp+=sizeof(long);
|
---|
392 |
|
---|
393 | if(pRelativeVar->bOffsetOffset){
|
---|
394 | //add ebx,ecx
|
---|
395 | OpBuffer[obp++]=(char)0x03;
|
---|
396 | OpBuffer[obp++]=(char)0xD9;
|
---|
397 | }
|
---|
398 |
|
---|
399 | //movsx eax,word ptr[ebx]
|
---|
400 | OpBuffer[obp++]=(char)0x0F;
|
---|
401 | OpBuffer[obp++]=(char)0xBF;
|
---|
402 | OpBuffer[obp++]=(char)0x03;
|
---|
403 | }
|
---|
404 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
405 | if(pRelativeVar->bOffsetOffset){
|
---|
406 | //add ecx,offset
|
---|
407 | OpBuffer[obp++]=(char)0x81;
|
---|
408 | OpBuffer[obp++]=(char)0xC1;
|
---|
409 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
410 | AddLocalVarAddrSchedule();
|
---|
411 | obp+=sizeof(long);
|
---|
412 |
|
---|
413 | //movsx eax,word ptr[ebp+ecx]
|
---|
414 | OpBuffer[obp++]=(char)0x0F;
|
---|
415 | OpBuffer[obp++]=(char)0xBF;
|
---|
416 | OpBuffer[obp++]=(char)0x44;
|
---|
417 | OpBuffer[obp++]=(char)0x0D;
|
---|
418 | OpBuffer[obp++]=(char)0x00;
|
---|
419 | }
|
---|
420 | else{
|
---|
421 | //movsx eax,word ptr[ebp+offset]
|
---|
422 | OpBuffer[obp++]=(char)0x0F;
|
---|
423 | OpBuffer[obp++]=(char)0xBF;
|
---|
424 | OpBuffer[obp++]=(char)0x85;
|
---|
425 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
426 | AddLocalVarAddrSchedule();
|
---|
427 | obp+=sizeof(long);
|
---|
428 | }
|
---|
429 | }
|
---|
430 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
431 | //mov ebx,dword ptr[ebp+offset]
|
---|
432 | OpBuffer[obp++]=(char)0x8B;
|
---|
433 | OpBuffer[obp++]=(char)0x9D;
|
---|
434 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
435 | AddLocalVarAddrSchedule();
|
---|
436 | obp+=sizeof(long);
|
---|
437 |
|
---|
438 | if(pRelativeVar->bOffsetOffset){
|
---|
439 | //add ebx,ecx
|
---|
440 | OpBuffer[obp++]=(char)0x03;
|
---|
441 | OpBuffer[obp++]=(char)0xD9;
|
---|
442 | }
|
---|
443 |
|
---|
444 | //movsx eax,word ptr[ebx]
|
---|
445 | OpBuffer[obp++]=(char)0x0F;
|
---|
446 | OpBuffer[obp++]=(char)0xBF;
|
---|
447 | OpBuffer[obp++]=(char)0x03;
|
---|
448 | }
|
---|
449 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
450 | //movsx eax,word ptr[ecx]
|
---|
451 | OpBuffer[obp++]=(char)0x0F;
|
---|
452 | OpBuffer[obp++]=(char)0xBF;
|
---|
453 | OpBuffer[obp++]=(char)0x01;
|
---|
454 | }
|
---|
455 |
|
---|
456 | //push eax
|
---|
457 | op_push(REG_EAX);
|
---|
458 | }
|
---|
459 | void PushWordVariable(RELATIVE_VAR *pRelativeVar){
|
---|
460 | //xor eax,eax(eaxを0に初期化する)
|
---|
461 | op_zero_reg(REG_EAX);
|
---|
462 |
|
---|
463 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
464 | if(pRelativeVar->bOffsetOffset){
|
---|
465 | //mov ax,word ptr[ecx+offset]
|
---|
466 | OpBuffer[obp++]=(char)0x66;
|
---|
467 | OpBuffer[obp++]=(char)0x8B;
|
---|
468 | OpBuffer[obp++]=(char)0x81;
|
---|
469 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
470 | pobj_GlobalVarSchedule->add();
|
---|
471 | obp+=sizeof(long);
|
---|
472 | }
|
---|
473 | else{
|
---|
474 | //mov ax,word ptr[offset]
|
---|
475 | OpBuffer[obp++]=(char)0x66;
|
---|
476 | OpBuffer[obp++]=(char)0xA1;
|
---|
477 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
478 | pobj_GlobalVarSchedule->add();
|
---|
479 | obp+=sizeof(long);
|
---|
480 | }
|
---|
481 | }
|
---|
482 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
483 | //mov ebx,dword ptr[offset]
|
---|
484 | op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
|
---|
485 | obp-=sizeof(long);
|
---|
486 | pobj_GlobalVarSchedule->add();
|
---|
487 | obp+=sizeof(long);
|
---|
488 |
|
---|
489 | if(pRelativeVar->bOffsetOffset){
|
---|
490 | //add ebx,ecx
|
---|
491 | OpBuffer[obp++]=(char)0x03;
|
---|
492 | OpBuffer[obp++]=(char)0xD9;
|
---|
493 | }
|
---|
494 |
|
---|
495 | //mov ax,word ptr[ebx]
|
---|
496 | OpBuffer[obp++]=(char)0x66;
|
---|
497 | OpBuffer[obp++]=(char)0x8B;
|
---|
498 | OpBuffer[obp++]=(char)0x03;
|
---|
499 | }
|
---|
500 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
501 | if(pRelativeVar->bOffsetOffset){
|
---|
502 | //add ecx,offset
|
---|
503 | OpBuffer[obp++]=(char)0x81;
|
---|
504 | OpBuffer[obp++]=(char)0xC1;
|
---|
505 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
506 | AddLocalVarAddrSchedule();
|
---|
507 | obp+=sizeof(long);
|
---|
508 |
|
---|
509 | //mov ax,word ptr[ebp+ecx]
|
---|
510 | OpBuffer[obp++]=(char)0x66;
|
---|
511 | OpBuffer[obp++]=(char)0x8B;
|
---|
512 | OpBuffer[obp++]=(char)0x44;
|
---|
513 | OpBuffer[obp++]=(char)0x0D;
|
---|
514 | OpBuffer[obp++]=(char)0x00;
|
---|
515 | }
|
---|
516 | else{
|
---|
517 | //mov ax,word ptr[ebp+offset]
|
---|
518 | OpBuffer[obp++]=(char)0x66;
|
---|
519 | OpBuffer[obp++]=(char)0x8B;
|
---|
520 | OpBuffer[obp++]=(char)0x85;
|
---|
521 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
522 | AddLocalVarAddrSchedule();
|
---|
523 | obp+=sizeof(long);
|
---|
524 | }
|
---|
525 | }
|
---|
526 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
527 | //mov ebx,dword ptr[ebp+offset]
|
---|
528 | OpBuffer[obp++]=(char)0x8B;
|
---|
529 | OpBuffer[obp++]=(char)0x9D;
|
---|
530 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
531 | AddLocalVarAddrSchedule();
|
---|
532 | obp+=sizeof(long);
|
---|
533 |
|
---|
534 | if(pRelativeVar->bOffsetOffset){
|
---|
535 | //add ebx,ecx
|
---|
536 | OpBuffer[obp++]=(char)0x03;
|
---|
537 | OpBuffer[obp++]=(char)0xD9;
|
---|
538 | }
|
---|
539 |
|
---|
540 | //mov ax,word ptr[ebx]
|
---|
541 | OpBuffer[obp++]=(char)0x66;
|
---|
542 | OpBuffer[obp++]=(char)0x8B;
|
---|
543 | OpBuffer[obp++]=(char)0x03;
|
---|
544 | }
|
---|
545 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
546 | //mov ax,word ptr[ecx]
|
---|
547 | OpBuffer[obp++]=(char)0x66;
|
---|
548 | OpBuffer[obp++]=(char)0x8B;
|
---|
549 | OpBuffer[obp++]=(char)0x01;
|
---|
550 | }
|
---|
551 |
|
---|
552 | //push eax
|
---|
553 | op_push(REG_EAX);
|
---|
554 | }
|
---|
555 | void PushCharVariable(RELATIVE_VAR *pRelativeVar){
|
---|
556 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
557 | if(pRelativeVar->bOffsetOffset){
|
---|
558 | //movsx eax,byte ptr[ecx+offset]
|
---|
559 | OpBuffer[obp++]=(char)0x0F;
|
---|
560 | OpBuffer[obp++]=(char)0xBE;
|
---|
561 | OpBuffer[obp++]=(char)0x81;
|
---|
562 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
563 | pobj_GlobalVarSchedule->add();
|
---|
564 | obp+=sizeof(long);
|
---|
565 | }
|
---|
566 | else{
|
---|
567 | //movsx eax,byte ptr[offset]
|
---|
568 | OpBuffer[obp++]=(char)0x0F;
|
---|
569 | OpBuffer[obp++]=(char)0xBE;
|
---|
570 | OpBuffer[obp++]=(char)0x05;
|
---|
571 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
572 | pobj_GlobalVarSchedule->add();
|
---|
573 | obp+=sizeof(long);
|
---|
574 | }
|
---|
575 | }
|
---|
576 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
577 | //mov ebx,dword ptr[offset]
|
---|
578 | op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
|
---|
579 | obp-=sizeof(long);
|
---|
580 | pobj_GlobalVarSchedule->add();
|
---|
581 | obp+=sizeof(long);
|
---|
582 |
|
---|
583 | if(pRelativeVar->bOffsetOffset){
|
---|
584 | //add ebx,ecx
|
---|
585 | OpBuffer[obp++]=(char)0x03;
|
---|
586 | OpBuffer[obp++]=(char)0xD9;
|
---|
587 | }
|
---|
588 |
|
---|
589 | //movsx eax,byte ptr[ebx]
|
---|
590 | OpBuffer[obp++]=(char)0x0F;
|
---|
591 | OpBuffer[obp++]=(char)0xBE;
|
---|
592 | OpBuffer[obp++]=(char)0x03;
|
---|
593 | }
|
---|
594 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
595 | if(pRelativeVar->bOffsetOffset){
|
---|
596 | //add ecx,offset
|
---|
597 | OpBuffer[obp++]=(char)0x81;
|
---|
598 | OpBuffer[obp++]=(char)0xC1;
|
---|
599 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
600 | AddLocalVarAddrSchedule();
|
---|
601 | obp+=sizeof(long);
|
---|
602 |
|
---|
603 | //movsx eax,byte ptr[ebp+ecx]
|
---|
604 | OpBuffer[obp++]=(char)0x0F;
|
---|
605 | OpBuffer[obp++]=(char)0xBE;
|
---|
606 | OpBuffer[obp++]=(char)0x44;
|
---|
607 | OpBuffer[obp++]=(char)0x0D;
|
---|
608 | OpBuffer[obp++]=(char)0x00;
|
---|
609 | }
|
---|
610 | else{
|
---|
611 | //movsx eax,byte ptr[ebp+offset]
|
---|
612 | OpBuffer[obp++]=(char)0x0F;
|
---|
613 | OpBuffer[obp++]=(char)0xBE;
|
---|
614 | OpBuffer[obp++]=(char)0x85;
|
---|
615 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
616 | AddLocalVarAddrSchedule();
|
---|
617 | obp+=sizeof(long);
|
---|
618 | }
|
---|
619 | }
|
---|
620 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
621 | //mov ebx,dword ptr[ebp+offset]
|
---|
622 | OpBuffer[obp++]=(char)0x8B;
|
---|
623 | OpBuffer[obp++]=(char)0x9D;
|
---|
624 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
625 | AddLocalVarAddrSchedule();
|
---|
626 | obp+=sizeof(long);
|
---|
627 |
|
---|
628 | if(pRelativeVar->bOffsetOffset){
|
---|
629 | //add ebx,ecx
|
---|
630 | OpBuffer[obp++]=(char)0x03;
|
---|
631 | OpBuffer[obp++]=(char)0xD9;
|
---|
632 | }
|
---|
633 |
|
---|
634 | //movsx eax,byte ptr[ebx]
|
---|
635 | OpBuffer[obp++]=(char)0x0F;
|
---|
636 | OpBuffer[obp++]=(char)0xBE;
|
---|
637 | OpBuffer[obp++]=(char)0x03;
|
---|
638 | }
|
---|
639 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
640 | //movsx eax,byte ptr[ecx]
|
---|
641 | OpBuffer[obp++]=(char)0x0F;
|
---|
642 | OpBuffer[obp++]=(char)0xBE;
|
---|
643 | OpBuffer[obp++]=(char)0x01;
|
---|
644 | }
|
---|
645 |
|
---|
646 | //push eax
|
---|
647 | op_push(REG_EAX);
|
---|
648 | }
|
---|
649 | void PushByteVariable(RELATIVE_VAR *pRelativeVar){
|
---|
650 | //xor eax,eax(eaxを0に初期化する)
|
---|
651 | op_zero_reg(REG_EAX);
|
---|
652 |
|
---|
653 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
654 | if(pRelativeVar->bOffsetOffset){
|
---|
655 | //mov al,byte ptr[ecx+offset]
|
---|
656 | OpBuffer[obp++]=(char)0x8A;
|
---|
657 | OpBuffer[obp++]=(char)0x81;
|
---|
658 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
659 | pobj_GlobalVarSchedule->add();
|
---|
660 | obp+=sizeof(long);
|
---|
661 | }
|
---|
662 | else{
|
---|
663 | //mov al,byte ptr[offset]
|
---|
664 | OpBuffer[obp++]=(char)0xA0;
|
---|
665 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
666 | pobj_GlobalVarSchedule->add();
|
---|
667 | obp+=sizeof(long);
|
---|
668 | }
|
---|
669 | }
|
---|
670 | else if(pRelativeVar->dwKind==VAR_REFGLOBAL){
|
---|
671 | //mov ebx,dword ptr[offset]
|
---|
672 | op_mov_RM( sizeof(long), REG_EBX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 );
|
---|
673 | obp-=sizeof(long);
|
---|
674 | pobj_GlobalVarSchedule->add();
|
---|
675 | obp+=sizeof(long);
|
---|
676 |
|
---|
677 | if(pRelativeVar->bOffsetOffset){
|
---|
678 | //add ebx,ecx
|
---|
679 | OpBuffer[obp++]=(char)0x03;
|
---|
680 | OpBuffer[obp++]=(char)0xD9;
|
---|
681 | }
|
---|
682 |
|
---|
683 | //mov al,byte ptr[ebx]
|
---|
684 | OpBuffer[obp++]=(char)0x8A;
|
---|
685 | OpBuffer[obp++]=(char)0x03;
|
---|
686 | }
|
---|
687 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
688 | if(pRelativeVar->bOffsetOffset){
|
---|
689 | //add ecx,offset
|
---|
690 | OpBuffer[obp++]=(char)0x81;
|
---|
691 | OpBuffer[obp++]=(char)0xC1;
|
---|
692 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
693 | AddLocalVarAddrSchedule();
|
---|
694 | obp+=sizeof(long);
|
---|
695 |
|
---|
696 | //mov al,byte ptr[ebp+ecx]
|
---|
697 | OpBuffer[obp++]=(char)0x8A;
|
---|
698 | OpBuffer[obp++]=(char)0x44;
|
---|
699 | OpBuffer[obp++]=(char)0x0D;
|
---|
700 | OpBuffer[obp++]=(char)0x00;
|
---|
701 | }
|
---|
702 | else{
|
---|
703 | //mov al,byte ptr[ebp+offset]
|
---|
704 | OpBuffer[obp++]=(char)0x8A;
|
---|
705 | OpBuffer[obp++]=(char)0x85;
|
---|
706 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
707 | AddLocalVarAddrSchedule();
|
---|
708 | obp+=sizeof(long);
|
---|
709 | }
|
---|
710 | }
|
---|
711 | else if(pRelativeVar->dwKind==VAR_REFLOCAL){
|
---|
712 | //mov ebx,dword ptr[ebp+offset]
|
---|
713 | OpBuffer[obp++]=(char)0x8B;
|
---|
714 | OpBuffer[obp++]=(char)0x9D;
|
---|
715 | *((long *)(OpBuffer+obp))=pRelativeVar->offset;
|
---|
716 | AddLocalVarAddrSchedule();
|
---|
717 | obp+=sizeof(long);
|
---|
718 |
|
---|
719 | if(pRelativeVar->bOffsetOffset){
|
---|
720 | //add ebx,ecx
|
---|
721 | OpBuffer[obp++]=(char)0x03;
|
---|
722 | OpBuffer[obp++]=(char)0xD9;
|
---|
723 | }
|
---|
724 |
|
---|
725 | //mov al,byte ptr[ebx]
|
---|
726 | OpBuffer[obp++]=(char)0x8A;
|
---|
727 | OpBuffer[obp++]=(char)0x03;
|
---|
728 | }
|
---|
729 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
730 | //mov al,byte ptr[ecx]
|
---|
731 | OpBuffer[obp++]=(char)0x8A;
|
---|
732 | OpBuffer[obp++]=(char)0x01;
|
---|
733 | }
|
---|
734 |
|
---|
735 | //push eax
|
---|
736 | op_push(REG_EAX);
|
---|
737 | }
|
---|