- Timestamp:
- Jul 25, 2007, 11:54:20 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/CodeGenerator.cpp
r234 r235 710 710 void CodeGenerator::op_push_M( int base_reg ) 711 711 { 712 // push dword ptr[base_reg] 713 __op_format( (char)0xFF, (char)0x30, base_reg ); 712 if( base_reg == REG_EBP ) 713 { 714 op_push_M( base_reg, 0 ); 715 } 716 else 717 { 718 // push dword ptr[base_reg] 719 __op_format( (char)0xFF, (char)0x30, base_reg ); 720 } 714 721 } 715 722 void CodeGenerator::op_push_M( int base_reg, long offset, Schedule::Type scheduleType ) … … 1158 1165 ///////////////////////////// 1159 1166 1167 void CodeGenerator::op_call_R( int reg ) 1168 { 1169 // call reg 1170 pNativeCode->Put( (char)0xFF ); 1171 pNativeCode->Put( (char)(0xD0|REGISTER_OPERAND(reg)) ); 1172 } 1160 1173 void CodeGenerator::op_call(const UserProc *pUserProc){ 1161 1174 pUserProc->Using(); -
trunk/abdev/BasicCompiler32/Compile_CallProc.cpp
r225 r235 79 79 80 80 //mov eax,dword ptr[eax] 81 OpBuffer[obp++]=(char)0x8B; 82 OpBuffer[obp++]=(char)0x00; 81 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EAX, 0, MOD_BASE ); 83 82 84 83 //call eax 85 OpBuffer[obp++]=(char)0xFF; 86 OpBuffer[obp++]=(char)0xD0; 84 compiler.codeGenerator.op_call_R( REG_EAX ); 87 85 88 86 … … 325 323 326 324 //mov edx,dword ptr[ecx] 327 OpBuffer[obp++]=(char)0x8B; 328 OpBuffer[obp++]=(char)0x11; 325 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, 0, MOD_BASE ); 329 326 330 327 i2 = pobj_c->GetFuncNumInVtbl( pUserProc ); -
trunk/abdev/BasicCompiler32/Compile_Func.cpp
r227 r235 154 154 155 155 //push 0 156 OpBuffer[obp++]=(char)0x6A; 157 OpBuffer[obp++]=(char)0x00; 156 compiler.codeGenerator.op_push_V( 0 ); 158 157 159 158 //push eax … … 161 160 162 161 //fild qword ptr[esp] 163 OpBuffer[obp++]=(char)0xDF; 164 OpBuffer[obp++]=(char)0x2C; 165 OpBuffer[obp++]=(char)0x24; 162 compiler.codeGenerator.op_fld_ptr_esp(DEF_INT64); 166 163 167 164 //add esp,8 … … 213 210 if(bArrayHead) typeSize*=JumpSubScripts(subscripts); 214 211 215 //mov eax,TypeSize 216 OpBuffer[obp++]=(char)0xB8; 217 *((long *)(OpBuffer+obp))=typeSize; 218 obp+=sizeof(long); 212 //mov eax,typeSize 213 compiler.codeGenerator.op_mov_RV( REG_EAX, typeSize ); 219 214 } 220 215 void Opcode_Func_AddressOf( const char *name ){ … … 296 291 297 292 //mov edx,dword ptr[ecx] 298 OpBuffer[obp++]=(char)0x8B; 299 OpBuffer[obp++]=(char)0x11; 293 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_ECX, 0, MOD_BASE ); 300 294 301 295 int i2 = pobj_c->GetFuncNumInVtbl( pUserProc ); … … 419 413 420 414 //fld qword ptr[eax] 421 OpBuffer[obp++]=(char)0xDD; 422 OpBuffer[obp++]=(char)0x00; 415 compiler.codeGenerator.PutOld( 416 (char)0xDD, 417 (char)0x00 418 ); 423 419 } 424 420 else if(type==DEF_SINGLE||type==DEF_DWORD){ … … 427 423 428 424 //mov eax,dword ptr[eax] 429 OpBuffer[obp++]=(char)0x8B; 430 OpBuffer[obp++]=(char)0x00; 425 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EAX, 0, MOD_BASE ); 431 426 } 432 427 else if(type==DEF_QWORD){ … … 448 443 449 444 //mov ax,word ptr[ebx] 450 OpBuffer[obp++]=(char)0x66; 451 OpBuffer[obp++]=(char)0x8B; 452 OpBuffer[obp++]=(char)0x03; 445 compiler.codeGenerator.op_mov_RM( sizeof(short), REG_EAX, REG_EBX, 0, MOD_BASE ); 453 446 } 454 447 else if(type==DEF_BYTE){ … … 460 453 461 454 //mov al,byte ptr[ebx] 462 OpBuffer[obp++]=(char)0x8A; 463 OpBuffer[obp++]=(char)0x03; 455 compiler.codeGenerator.op_mov_RM( sizeof(char), REG_EAX, REG_EBX, 0, MOD_BASE ); 464 456 } 465 457 } -
trunk/abdev/BasicCompiler32/Compile_Object.cpp
r225 r235 84 84 85 85 //add eax,TypeSize 86 OpBuffer[obp++]=(char)0x05; 87 *((long *)(OpBuffer+obp))=ObjectSize; 88 obp+=sizeof(long); 86 compiler.codeGenerator.op_add_RV( REG_EAX, ObjectSize ); 89 87 90 88 //sub ebx,1 … … 119 117 120 118 //※添え字上限値であることを考慮 121 //add eax,1 122 OpBuffer[obp++]=(char)0x83; 123 OpBuffer[obp++]=(char)0xC0; 124 OpBuffer[obp++]=(char)0x01; 119 //inc eax 120 compiler.codeGenerator.op_inc( REG_EAX ); 125 121 126 122 //オブジェクトの個数をebxに一時保持 127 123 //※ebxは関数が呼ばれても不変 128 124 //mov ebx,eax 129 OpBuffer[obp++]=(char)0x8B; 130 OpBuffer[obp++]=(char)0xD8; 125 compiler.codeGenerator.op_mov_RR( REG_EBX, REG_EAX ); 131 126 132 127 //imul eax,size 133 OpBuffer[obp++]=(char)0x69; 134 OpBuffer[obp++]=(char)0xC0; 135 *((long *)(OpBuffer+obp))=typeSize; 136 obp+=sizeof(long); 128 compiler.codeGenerator.op_imul_RV( REG_EAX, typeSize ); 137 129 138 130 //add eax,OBJECT_HEAD_SIZE 139 OpBuffer[obp++]=(char)0x05; 140 *((long *)(OpBuffer+obp))=OBJECT_HEAD_SIZE; 141 obp+=sizeof(long); 131 compiler.codeGenerator.op_add_RV8( REG_EAX, (char)OBJECT_HEAD_SIZE ); 142 132 143 133 //push eax … … 148 138 //※ebxは関数が呼ばれても不変 149 139 //mov ebx,1 150 OpBuffer[obp++]=(char)0xBB; 151 *((long *)(OpBuffer+obp))=1; 152 obp+=sizeof(long); 140 compiler.codeGenerator.op_mov_RV( REG_EBX, 1 ); 153 141 154 142 //push size + OBJECT_HEAD_SIZE 155 OpBuffer[obp++]=(char)0x68; 156 *((long *)(OpBuffer+obp))=typeSize + OBJECT_HEAD_SIZE; 157 obp+=sizeof(long); 143 compiler.codeGenerator.op_push_V( typeSize + OBJECT_HEAD_SIZE ); 158 144 } 159 145 … … 188 174 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EBX, REG_EAX, 0, MOD_BASE ); 189 175 190 //add eax,sizeof(DWORD) 191 OpBuffer[obp++]=(char)0x05; 192 *((long *)(OpBuffer+obp))=sizeof(DWORD); 193 obp+=sizeof(long); 194 176 //add eax,sizeof(long) 177 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 195 178 196 179 //mov ecx,TypeSize 197 OpBuffer[obp++]=(char)0xB9; 198 *((long *)(OpBuffer+obp))=typeSize; 199 obp+=sizeof(long); 180 compiler.codeGenerator.op_mov_RV( REG_ECX, typeSize ); 200 181 201 182 //mov dword ptr[eax],ecx(オブジェクトのサイズ) 202 183 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_ECX, REG_EAX, 0, MOD_BASE ); 203 184 204 //add eax,sizeof(DWORD) 205 OpBuffer[obp++]=(char)0x05; 206 *((long *)(OpBuffer+obp))=sizeof(DWORD); 207 obp+=sizeof(long); 185 //add eax,sizeof(long) 186 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 208 187 209 188 … … 220 199 compiler.codeGenerator.op_mov_MR( sizeof(long), REG_ECX, REG_EAX, 0, MOD_BASE ); 221 200 222 //add eax,sizeof(DWORD) 223 OpBuffer[obp++]=(char)0x05; 224 *((long *)(OpBuffer+obp))=sizeof(DWORD); 225 obp+=sizeof(long); 201 //add eax,sizeof(long) 202 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 226 203 227 204 228 205 // リザーブ領域 229 //add eax,sizeof(DWORD) 230 OpBuffer[obp++]=(char)0x05; 231 *((long *)(OpBuffer+obp))=sizeof(DWORD); 232 obp+=sizeof(long); 206 //add eax,sizeof(long) 207 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 233 208 234 209 … … 264 239 265 240 //mov ebx,dword ptr[eax](オブジェクトの個数) 266 OpBuffer[obp++]=(char)0x8B; 267 OpBuffer[obp++]=(char)0x18; 268 269 //add eax,sizeof(DWORD) 270 OpBuffer[obp++]=(char)0x05; 271 *((long *)(OpBuffer+obp))=sizeof(DWORD); 272 obp+=sizeof(long); 241 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EBX, REG_EAX, 0, MOD_BASE ); 242 243 //add eax,sizeof(long) 244 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 273 245 274 246 275 247 //mov esi,dword ptr[eax](オブジェクトのサイズ) 276 OpBuffer[obp++]=(char)0x8B; 277 OpBuffer[obp++]=(char)0x30; 278 279 //add eax,sizeof(DWORD) 280 OpBuffer[obp++]=(char)0x05; 281 *((long *)(OpBuffer+obp))=sizeof(DWORD); 282 obp+=sizeof(long); 248 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_ESI, REG_EAX, 0, MOD_BASE ); 249 250 //add eax,sizeof(long) 251 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 283 252 284 253 285 254 //mov edx,dword ptr[eax](デストラクタの関数ポインタ) 286 OpBuffer[obp++]=(char)0x8B; 287 OpBuffer[obp++]=(char)0x10; 288 289 //add eax,sizeof(DWORD) 290 OpBuffer[obp++]=(char)0x05; 291 *((long *)(OpBuffer+obp))=sizeof(DWORD); 292 obp+=sizeof(long); 255 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EDX, REG_EAX, 0, MOD_BASE ); 256 257 //add eax,sizeof(long) 258 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 293 259 294 260 295 261 // リザーブ領域 296 //add eax,sizeof(DWORD) 297 OpBuffer[obp++]=(char)0x05; 298 *((long *)(OpBuffer+obp))=sizeof(DWORD); 299 obp+=sizeof(long); 262 //add eax,sizeof(long) 263 compiler.codeGenerator.op_add_RV8( REG_EAX, sizeof(long) ); 300 264 301 265 302 266 //mov ecx,eax 303 OpBuffer[obp++]=(char)0x8B; 304 OpBuffer[obp++]=(char)0xC8; 267 compiler.codeGenerator.op_mov_RR( REG_ECX, REG_EAX ); 305 268 306 269 … … 319 282 320 283 //call edx 321 OpBuffer[obp++]=(char)0xFF; 322 OpBuffer[obp++]=(char)0xD2; 284 compiler.codeGenerator.op_call_R( REG_EDX ); 323 285 324 286 //pop edx -
trunk/abdev/BasicCompiler32/Compile_ProcOp.cpp
r231 r235 18 18 if( userProc.GetName() == "_System_GetEip" ){ 19 19 //mov eax,dword ptr[esp] 20 OpBuffer[obp++]=(char)0x8B; 21 OpBuffer[obp++]=(char)0x04; 22 OpBuffer[obp++]=(char)0x24; 20 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_ESP, 0, MOD_BASE ); 23 21 24 22 //ret … … 379 377 380 378 //mov ebp,esp 381 OpBuffer[obp++]=(char)0x8B; 382 OpBuffer[obp++]=(char)0xEC; 379 compiler.codeGenerator.op_mov_RR( REG_EBP, REG_ESP ); 383 380 384 381 //push ebx … … 386 383 387 384 //push esi 388 OpBuffer[obp++]=(char)0x56;385 compiler.codeGenerator.op_push( REG_ESI ); 389 386 390 387 //push edi 391 OpBuffer[obp++]=(char)0x57;388 compiler.codeGenerator.op_push( REG_EDI ); 392 389 393 390 if( !pUserProc->ReturnType().IsNull() ){ … … 457 454 458 455 //push dword ptr[ebp](以前のebp) 459 OpBuffer[obp++]=(char)0xFF; 460 OpBuffer[obp++]=(char)0x75; 461 OpBuffer[obp++]=(char)0x00; 456 compiler.codeGenerator.op_push_M( REG_EBP ); 462 457 463 458 //call _DebugSys_StartProc … … 728 723 729 724 //pop edi 730 OpBuffer[obp++]=(char)0x5F;725 compiler.codeGenerator.op_pop( REG_EDI ); 731 726 732 727 //pop esi 733 OpBuffer[obp++]=(char)0x5E;728 compiler.codeGenerator.op_pop( REG_ESI ); 734 729 735 730 //pop ebx … … 752 747 753 748 //mov esp,ebp 754 OpBuffer[obp++]=(char)0x8B; 755 OpBuffer[obp++]=(char)0xE5; 749 compiler.codeGenerator.op_mov_RR( REG_ESP, REG_EBP ); 756 750 757 751 //pop ebp -
trunk/abdev/BasicCompiler32/NumOpe_TypeOperation.cpp
r225 r235 72 72 73 73 //and eax,0000FFFFh 74 OpBuffer[obp++]=(char)0x25; 75 *((long *)(OpBuffer+obp))=0x0000FFFF; 76 obp+=sizeof(long); 74 compiler.codeGenerator.op_and_RV( REG_EAX, 0x0000FFFF ); 77 75 78 76 //push eax … … 94 92 95 93 //and eax,000000FFh 96 OpBuffer[obp++]=(char)0x25; 97 *((long *)(OpBuffer+obp))=0x000000FF; 98 obp+=sizeof(long); 94 compiler.codeGenerator.op_and_RV( REG_EAX, 0x000000FF ); 99 95 100 96 //push eax … … 118 114 119 115 //and eax,000000FFh 120 OpBuffer[obp++]=(char)0x25; 121 *((long *)(OpBuffer+obp))=0x000000FF; 122 obp+=sizeof(long); 116 compiler.codeGenerator.op_and_RV( REG_EAX, 0x000000FF ); 123 117 124 118 //push eax -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r234 r235 195 195 void fpu_cast_end(); 196 196 197 void op_call_R( int reg ); 197 198 void op_call(const UserProc *pUserProc); 198 199 void op_ret();
Note:
See TracChangeset
for help on using the changeset viewer.