Changeset 225 in dev for trunk/abdev/BasicCompiler32/Compile_Calc_PushVar.cpp
- Timestamp:
- Jul 21, 2007, 11:47:40 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Calc_PushVar.cpp
r206 r225 1 1 #include "stdafx.h" 2 3 #include <Compiler.h> 2 4 3 5 #include "../BasicCompiler_Common/common.h" … … 8 10 if(pRelativeVar->bOffsetOffset){ 9 11 //fld ptr[ecx+offset] 10 op_fld_base_offset(type,REG_ECX,(int)pRelativeVar->offset);12 compiler.codeGenerator.op_fld_base_offset(type,REG_ECX,(int)pRelativeVar->offset); 11 13 obp-=sizeof(long); 12 14 pobj_GlobalVarSchedule->add(); … … 15 17 else{ 16 18 //mov ecx,offset 17 op_mov_RV(REG_ECX,(int)pRelativeVar->offset);19 compiler.codeGenerator.op_mov_RV(REG_ECX,(int)pRelativeVar->offset); 18 20 obp-=sizeof(long); 19 21 pobj_GlobalVarSchedule->add(); … … 21 23 22 24 //fld ptr[ecx] 23 op_fld_basereg(type,REG_ECX);25 compiler.codeGenerator.op_fld_basereg(type,REG_ECX); 24 26 } 25 27 } … … 30 32 if(pRelativeVar->bOffsetOffset){ 31 33 //fld ptr[ebp+ecx+offset] 32 op_fld_base_offset_ex(type,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET);34 compiler.codeGenerator.op_fld_base_offset_ex(type,REG_EBP,REG_ECX,(int)pRelativeVar->offset,USE_OFFSET); 33 35 obp-=sizeof(long); 34 36 AddLocalVarAddrSchedule(); … … 37 39 else{ 38 40 //fld ptr[ebp+offset] 39 op_fld_base_offset(type,REG_EBP,(int)pRelativeVar->offset);41 compiler.codeGenerator.op_fld_base_offset(type,REG_EBP,(int)pRelativeVar->offset); 40 42 obp-=sizeof(long); 41 43 AddLocalVarAddrSchedule(); … … 46 48 if(pRelativeVar->bOffsetOffset){ 47 49 //add ecx,qword ptr[ebp+offset] 48 op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);50 compiler.codeGenerator.op_add_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 49 51 obp-=sizeof(long); 50 52 AddLocalVarAddrSchedule(); … … 53 55 else{ 54 56 //mov ecx,qword ptr[ebp+offset] 55 op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);57 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 56 58 obp-=sizeof(long); 57 59 AddLocalVarAddrSchedule(); … … 64 66 directmem: 65 67 //fld ptr[ecx] 66 op_fld_basereg(type,REG_ECX);68 compiler.codeGenerator.op_fld_basereg(type,REG_ECX); 67 69 } 68 70 } … … 96 98 if(pRelativeVar->bOffsetOffset){ 97 99 //mov reg, ptr[ecx+offset] 98 op_mov_RM(varSize,reg,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32);100 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32); 99 101 } 100 102 else{ 101 103 //mov reg, ptr[offset] 102 op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset + offsetOf64Head,MOD_DISP32);104 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset + offsetOf64Head,MOD_DISP32); 103 105 } 104 106 obp-=sizeof(long); … … 109 111 if(pRelativeVar->bOffsetOffset){ 110 112 //add ecx,qword ptr[offset] 111 op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);113 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 112 114 } 113 115 else{ 114 116 //mov ecx,qword ptr[offset] 115 op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);117 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_NON,(int)pRelativeVar->offset,MOD_DISP32); 116 118 } 117 119 obp-=sizeof(long); … … 124 126 if(pRelativeVar->bOffsetOffset){ 125 127 //mov reg, ptr[ebp+ecx+offset] 126 op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET);128 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_EBP,REG_ECX,(int)pRelativeVar->offset + offsetOf64Head,USE_OFFSET); 127 129 } 128 130 else{ 129 131 //mov reg, ptr[ebp+offset] 130 op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32);132 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_EBP,(int)pRelativeVar->offset + offsetOf64Head,MOD_BASE_DISP32); 131 133 } 132 134 obp-=sizeof(long); … … 137 139 if(pRelativeVar->bOffsetOffset){ 138 140 //add ecx,qword ptr[ebp+offset] 139 op_add_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);141 compiler.codeGenerator.op_add_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 140 142 } 141 143 else{ 142 144 //mov ecx,qword ptr[ebp+offset] 143 op_mov_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32);145 compiler.codeGenerator.op_mov_RM(varSize,REG_ECX,REG_EBP,(int)pRelativeVar->offset,MOD_BASE_DISP32); 144 146 } 145 147 obp-=sizeof(long); … … 153 155 if( is64Head ){ 154 156 //mov reg, ptr[ecx] 155 op_mov_RM(varSize,reg,REG_ECX,offsetOf64Head,MOD_BASE_DISP8);157 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_ECX,offsetOf64Head,MOD_BASE_DISP8); 156 158 } 157 159 else{ 158 160 //mov reg, ptr[ecx] 159 op_mov_RM(varSize,reg,REG_ECX,0,MOD_BASE);161 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_ECX,0,MOD_BASE); 160 162 } 161 163 } … … 164 166 165 167 166 167 168 void PushDoubleVariable(RELATIVE_VAR *pRelativeVar){ 168 void PushLongVariable(RELATIVE_VAR *pRelativeVar){ 169 169 if(pRelativeVar->dwKind==VAR_GLOBAL){ 170 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 171 //push dword ptr[ecx+offset] 179 172 OpBuffer[obp++]=(char)0xFF; … … 184 177 } 185 178 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 179 //push dword ptr[offset] 194 180 OpBuffer[obp++]=(char)0xFF; … … 200 186 } 201 187 else if(pRelativeVar->dwKind==VAR_REFGLOBAL){ 202 SetError(300,NULL,cp); 188 //mov eax,dword ptr[offset] 189 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_NON, (int)pRelativeVar->offset, MOD_DISP32 ); 190 obp-=sizeof(long); 191 pobj_GlobalVarSchedule->add(); 192 obp+=sizeof(long); 193 194 if(pRelativeVar->bOffsetOffset){ 195 //add eax,ecx 196 compiler.codeGenerator.op_add_RR( REG_EAX, REG_ECX ); 197 } 198 199 //push dword ptr[eax] 200 compiler.codeGenerator.op_push_M( REG_EAX ); 203 201 } 204 202 else if(pRelativeVar->dwKind==VAR_LOCAL){ 205 203 if(pRelativeVar->bOffsetOffset){ 206 //add ecx,offset +sizeof(long)204 //add ecx,offset 207 205 OpBuffer[obp++]=(char)0x81; 208 206 OpBuffer[obp++]=(char)0xC1; 209 *((long *)(OpBuffer+obp))=pRelativeVar->offset +sizeof(long);207 *((long *)(OpBuffer+obp))=pRelativeVar->offset; 210 208 AddLocalVarAddrSchedule(); 211 209 obp+=sizeof(long); 212 210 213 211 //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 212 compiler.codeGenerator.PutOld( 213 (char)0xFF, 214 (char)0x74, 215 (char)0x0D, 216 (char)0x00 217 ); 218 } 219 else{ 238 220 //push dword ptr[ebp+offset] 239 221 OpBuffer[obp++]=(char)0xFF; … … 254 236 if(pRelativeVar->bOffsetOffset){ 255 237 //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; 238 compiler.codeGenerator.op_add_RR( REG_EAX, REG_ECX ); 239 } 264 240 265 241 //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; 242 compiler.codeGenerator.op_push_M( REG_EAX ); 358 243 } 359 244 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){ 360 245 //push dword ptr[ecx] 361 OpBuffer[obp++]=(char)0xFF; 362 OpBuffer[obp++]=(char)0x31; 246 compiler.codeGenerator.op_push_M( REG_ECX ); 363 247 } 364 248 } 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,ecx395 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,offset407 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,ecx440 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 eax457 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,ecx491 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,offset503 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,ecx536 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 eax553 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,ecx585 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,offset597 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,ecx630 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 eax647 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,ecx679 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,offset690 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,ecx721 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 eax736 op_push(REG_EAX);737 }
Note:
See TracChangeset
for help on using the changeset viewer.