source: dev/BasicCompiler32/Compile_Calc_PushVar.cpp@ 60

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