Changeset 36 in dev for BasicCompiler32
- Timestamp:
- Jan 20, 2007, 4:55:26 AM (18 years ago)
- Location:
- BasicCompiler32
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/CParameter.cpp
r31 r36 658 658 ParmSize+=sizeof(long); 659 659 } 660 else if(DummyTypeInfo.type==DEF_CHAR||DummyTypeInfo.type==DEF_BYTE ){660 else if(DummyTypeInfo.type==DEF_CHAR||DummyTypeInfo.type==DEF_BYTE||DummyTypeInfo.type==DEF_BOOLEAN){ 661 661 ChangeTypeToByte(CalcType); 662 662 ParmSize+=sizeof(long); -
BasicCompiler32/Compile_Calc.cpp
r28 r36 318 318 void ChangeTypeToInteger(int OldType){ 319 319 //現在のスタックの内容をInteger型に変換する 320 if(OldType==DEF_BYTE|| 320 if(OldType==DEF_BOOLEAN|| 321 OldType==DEF_BYTE|| 321 322 OldType==DEF_WORD||OldType==DEF_INTEGER) return; 322 323 else if(OldType==DEF_CHAR){ … … 567 568 ///////////////////////////////////////////////// 568 569 569 if(VarType==DEF_CHAR||VarType==DEF_BYTE){ 570 if(VarType==DEF_BOOLEAN){ 571 //bool 572 SetBooleanVariable(CalcType,&VarRelativeVar); 573 } 574 else if(VarType==DEF_CHAR||VarType==DEF_BYTE){ 570 575 //8ビット整数型変数へスタックの内容を格納する 571 576 Set8Variable(CalcType,VarRelativeVar.dwKind,VarRelativeVar.offset,VarRelativeVar.bOffsetOffset); -
BasicCompiler32/Compile_ProcOp.cpp
r34 r36 777 777 obp+=sizeof(long); 778 778 } 779 else if(i3==DEF_CHAR||i3==DEF_BYTE ){779 else if(i3==DEF_CHAR||i3==DEF_BYTE||i3==DEF_BOOLEAN){ 780 780 //xor eax,eax(eaxを0に初期化する) 781 781 op_zero_reg(REG_EAX); -
BasicCompiler32/Compile_Set_Var.cpp
r28 r36 874 874 } 875 875 } 876 void SetBooleanVariable(int type,RELATIVE_VAR *pRelative){ 877 if(type==DEF_DOUBLE){ 878 // TODO: 実装 879 } 880 else if(type==DEF_SINGLE){ 881 // TODO: 実装 882 } 883 else if(type==DEF_INT64||type==DEF_QWORD){ 884 // TODO: 実装 885 886 //pop eax 887 op_pop(REG_EAX); 888 889 //cmp eax,0 890 op_cmp_value(GetTypeSize(type,-1),REG_EAX,0); 891 892 //setne al 893 op_setne( REG_EAX ); 894 895 //pop ecx 896 op_pop(REG_ECX); 897 898 //cmp ecx,0 899 op_cmp_value(GetTypeSize(type,-1),REG_ECX,0); 900 901 //setne cl 902 op_setne( REG_ECX ); 903 904 //or al,cl 905 op_or_RR( sizeof( _int8 ), REG_EAX, REG_ECX ); 906 } 907 else{ 908 if(!IsWholeNumberType(type)){ 909 //不正な型の場合 910 SetError(9,NULL,cp); 911 return; 912 } 913 914 //pop eax 915 op_pop(REG_EAX); 916 } 917 918 //cmp eax,0 919 op_cmp_value(GetTypeSize(type,-1),REG_EAX,0); 920 921 //setne al 922 op_setne( REG_EAX ); 923 924 //push eax 925 op_push(REG_EAX); 926 927 Set8Variable(DEF_BYTE,pRelative->dwKind,pRelative->offset,pRelative->bOffsetOffset); 928 } -
BasicCompiler32/Compile_Statement.cpp
r34 r36 1011 1011 type1==DEF_WORD|| 1012 1012 type1==DEF_CHAR|| 1013 type1==DEF_BYTE) CaseTypeSize=sizeof(long); 1013 type1==DEF_BYTE|| 1014 type1==DEF_BOOLEAN) CaseTypeSize=sizeof(long); 1014 1015 else{ 1015 1016 CaseTypeSize=GetTypeSize(type1,lpIndex); -
BasicCompiler32/Compile_Var.cpp
r34 r36 837 837 else if(type==DEF_INTEGER||type==DEF_WORD) 838 838 *(WORD *)(initGlobalBuf+offset)=(WORD)i64data; 839 else if(type==DEF_CHAR||type==DEF_BYTE )839 else if(type==DEF_CHAR||type==DEF_BYTE||type==DEF_BOOLEAN) 840 840 *(BYTE *)(initGlobalBuf+offset)=(BYTE)i64data; 841 841 //String型が未完成 … … 1050 1050 obp+=sizeof(long); 1051 1051 } 1052 else if(type==DEF_CHAR||type==DEF_BYTE ){1052 else if(type==DEF_CHAR||type==DEF_BYTE||type==DEF_BOOLEAN){ 1053 1053 //mov byte ptr[ebp+offset],InitValue 1054 1054 OpBuffer[obp++]=(char)0xC6; -
BasicCompiler32/NumOpe.cpp
r35 r36 57 57 op_push(REG_EBX); 58 58 } 59 else if(type==DEF_DWORD||type==DEF_WORD||type==DEF_BYTE|| 59 else if(type==DEF_DWORD||type==DEF_WORD||type==DEF_BYTE||type==DEF_BOOLEAN|| 60 60 IsPtrType(type)){ 61 61 //push eax … … 418 418 PushCharVariable(&RelativeVar); 419 419 } 420 else if(i2==DEF_BYTE ){420 else if(i2==DEF_BYTE||i2==DEF_BOOLEAN){ 421 421 PushByteVariable(&RelativeVar); 422 422 } … … 718 718 i3=(long)i64data; 719 719 720 if(i2==DEF_CHAR||i2==DEF_BYTE ) i3=i3&0x000000FF;720 if(i2==DEF_CHAR||i2==DEF_BYTE||i2==DEF_BOOLEAN) i3=i3&0x000000FF; 721 721 if(i2==DEF_INTEGER||i2==DEF_WORD) i3=i3&0x0000FFFF; 722 722 -
BasicCompiler32/NumOpe_Logical.cpp
r3 r36 450 450 } 451 451 452 if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){ 452 if( type[sp - 1] == DEF_BOOLEAN ){ 453 //pop eax 454 op_pop( REG_EAX ); 455 456 //cmp eax,0 457 op_cmp_value(GetTypeSize(type[sp-1],-1),REG_EAX,0); 458 459 //setne al 460 op_setne( REG_EAX ); 461 462 //and eax,000000FFh 463 op_and_RV(REG_EAX,(int)0xFF); 464 465 //neg 466 op_neg( REG_EAX ); 467 468 //sbb eax, eax 469 op_sbb_RR( REG_EAX, REG_EAX ); 470 471 //add eax, 1 472 op_add_RV8( REG_EAX, 1 ); 473 474 //push eax 475 op_push( REG_EAX ); 476 } 477 else if(type[sp-1]==DEF_INT64||type[sp-1]==DEF_QWORD){ 453 478 //////////////////// 454 479 // 64ビット整数演算 -
BasicCompiler32/NumOpe_Relation.cpp
r3 r36 84 84 OpBuffer[obp++]=(char)0xE0; 85 85 86 //mov ecx, 0xFFFFFFFF87 OpBuffer[obp++]=(char)0xB9; 88 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;86 //mov ecx,1 87 OpBuffer[obp++]=(char)0xB9; 88 *((long *)(OpBuffer+obp))=1; 89 89 obp+=sizeof(long); 90 90 … … 166 166 OpBuffer[TrueSchedule]=obp-(TrueSchedule+1); 167 167 168 //mov eax, 0FFFFFFFFh168 //mov eax,1 169 169 OpBuffer[obp++]=(char)0xB8; 170 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;170 *((long *)(OpBuffer+obp))=1; 171 171 obp+=sizeof(long); 172 172 … … 199 199 op_sub_esp(4); 200 200 201 //mov ecx, 0FFFFFFFFh202 OpBuffer[obp++]=(char)0xB9; 203 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;201 //mov ecx,1 202 OpBuffer[obp++]=(char)0xB9; 203 *((long *)(OpBuffer+obp))=1; 204 204 obp+=sizeof(long); 205 205 … … 235 235 236 236 sp--; 237 type_stack[sp-1]=DEF_ LONG;237 type_stack[sp-1]=DEF_BOOLEAN; 238 238 239 239 *pStackPointer=sp; … … 320 320 OpBuffer[obp++]=(char)0xE0; 321 321 322 //mov ecx, 0xFFFFFFFF323 OpBuffer[obp++]=(char)0xB9; 324 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;322 //mov ecx,1 323 OpBuffer[obp++]=(char)0xB9; 324 *((long *)(OpBuffer+obp))=1; 325 325 obp+=sizeof(long); 326 326 … … 404 404 OpBuffer[TrueSchedule]=obp-(TrueSchedule+1); 405 405 406 //mov eax, 0FFFFFFFFh406 //mov eax,1 407 407 OpBuffer[obp++]=(char)0xB8; 408 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;408 *((long *)(OpBuffer+obp))=1; 409 409 obp+=sizeof(long); 410 410 … … 437 437 op_sub_esp(4); 438 438 439 //mov ecx, 0FFFFFFFFh440 OpBuffer[obp++]=(char)0xB9; 441 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;439 //mov ecx,1 440 OpBuffer[obp++]=(char)0xB9; 441 *((long *)(OpBuffer+obp))=1; 442 442 obp+=sizeof(long); 443 443 … … 473 473 474 474 sp--; 475 type_stack[sp-1]=DEF_ LONG;475 type_stack[sp-1]=DEF_BOOLEAN; 476 476 477 477 *pStackPointer=sp; … … 561 561 OpBuffer[obp++]=(char)0xE0; 562 562 563 //mov ecx, 0xFFFFFFFF564 OpBuffer[obp++]=(char)0xB9; 565 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;563 //mov ecx,1 564 OpBuffer[obp++]=(char)0xB9; 565 *((long *)(OpBuffer+obp))=1; 566 566 obp+=sizeof(long); 567 567 … … 656 656 OpBuffer[TrueSchedule2]=obp-(TrueSchedule2+1); 657 657 658 //mov eax, 0FFFFFFFFh658 //mov eax,1 659 659 OpBuffer[obp++]=(char)0xB8; 660 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;660 *((long *)(OpBuffer+obp))=1; 661 661 obp+=sizeof(long); 662 662 … … 678 678 op_sub_esp(4); 679 679 680 //mov ecx, 0FFFFFFFFh681 OpBuffer[obp++]=(char)0xB9; 682 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;680 //mov ecx,1 681 OpBuffer[obp++]=(char)0xB9; 682 *((long *)(OpBuffer+obp))=1; 683 683 obp+=sizeof(long); 684 684 … … 714 714 715 715 sp--; 716 type_stack[sp-1]=DEF_ LONG;716 type_stack[sp-1]=DEF_BOOLEAN; 717 717 718 718 *pStackPointer=sp; … … 798 798 OpBuffer[obp++]=(char)0xE0; 799 799 800 //mov ecx, 0xFFFFFFFF801 OpBuffer[obp++]=(char)0xB9; 802 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;800 //mov ecx,1 801 OpBuffer[obp++]=(char)0xB9; 802 *((long *)(OpBuffer+obp))=1; 803 803 obp+=sizeof(long); 804 804 … … 893 893 OpBuffer[TrueSchedule2]=obp-(TrueSchedule2+1); 894 894 895 //mov eax, 0FFFFFFFFh895 //mov eax,1 896 896 OpBuffer[obp++]=(char)0xB8; 897 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;897 *((long *)(OpBuffer+obp))=1; 898 898 obp+=sizeof(long); 899 899 … … 915 915 op_sub_esp(4); 916 916 917 //mov ecx, 0FFFFFFFFh918 OpBuffer[obp++]=(char)0xB9; 919 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;917 //mov ecx,1 918 OpBuffer[obp++]=(char)0xB9; 919 *((long *)(OpBuffer+obp))=1; 920 920 obp+=sizeof(long); 921 921 … … 947 947 948 948 sp--; 949 type_stack[sp-1]=DEF_ LONG;949 type_stack[sp-1]=DEF_BOOLEAN; 950 950 951 951 *pStackPointer=sp; … … 1029 1029 OpBuffer[obp++]=(char)0xE0; 1030 1030 1031 //mov ecx, 0xFFFFFFFF1032 OpBuffer[obp++]=(char)0xB9; 1033 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;1031 //mov ecx,1 1032 OpBuffer[obp++]=(char)0xB9; 1033 *((long *)(OpBuffer+obp))=1; 1034 1034 obp+=sizeof(long); 1035 1035 … … 1096 1096 OpBuffer[TrueSchedule2]=obp-(TrueSchedule2+1); 1097 1097 1098 //mov eax, 0FFFFFFFFh1098 //mov eax,1 1099 1099 OpBuffer[obp++]=(char)0xB8; 1100 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;1100 *((long *)(OpBuffer+obp))=1; 1101 1101 obp+=sizeof(long); 1102 1102 … … 1126 1126 OpBuffer[obp++]=(char)0x05; 1127 1127 1128 //mov eax, 0FFFFFFFFh1128 //mov eax,1 1129 1129 OpBuffer[obp++]=(char)0xB8; 1130 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;1130 *((long *)(OpBuffer+obp))=1; 1131 1131 obp+=sizeof(long); 1132 1132 … … 1138 1138 1139 1139 sp--; 1140 type[sp-1]=DEF_ LONG;1140 type[sp-1]=DEF_BOOLEAN; 1141 1141 1142 1142 *pStackPointer=sp; … … 1220 1220 OpBuffer[obp++]=(char)0xE0; 1221 1221 1222 //mov ecx, 0xFFFFFFFF1223 OpBuffer[obp++]=(char)0xB9; 1224 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;1222 //mov ecx,1 1223 OpBuffer[obp++]=(char)0xB9; 1224 *((long *)(OpBuffer+obp))=1; 1225 1225 obp+=sizeof(long); 1226 1226 … … 1276 1276 obp++; 1277 1277 1278 //mov eax, 0FFFFFFFFh1278 //mov eax,1 1279 1279 OpBuffer[obp++]=(char)0xB8; 1280 *((long *)(OpBuffer+obp))= 0xFFFFFFFF;1280 *((long *)(OpBuffer+obp))=1; 1281 1281 obp+=sizeof(long); 1282 1282 … … 1313 1313 OpBuffer[obp++]=(char)0xC3; 1314 1314 1315 //j z 5(次のmovを飛び越す)1315 //jnz 4(次のxorとjmpを飛び越す) 1316 1316 OpBuffer[obp++]=(char)0x74; 1317 OpBuffer[obp++]=(char)0x04; 1318 1319 //xor eax,eax 1320 OpBuffer[obp++]=(char)0x33; 1321 OpBuffer[obp++]=(char)0xC0; 1322 1323 //jmp 5 1324 OpBuffer[obp++]=(char)0xEB; 1317 1325 OpBuffer[obp++]=(char)0x05; 1318 1326 1319 //mov eax, 0FFFFFFFFh1327 //mov eax,1 1320 1328 OpBuffer[obp++]=(char)0xB8; 1321 *((long *)(OpBuffer+obp))=0xFFFFFFFF; 1322 obp+=sizeof(long); 1323 1324 //not eax 1325 OpBuffer[obp++]=(char)0xF7; 1326 OpBuffer[obp++]=(char)0xD0; 1329 *((long *)(OpBuffer+obp))=1; 1330 obp+=sizeof(long); 1327 1331 1328 1332 //mov dword ptr[esp],eax … … 1333 1337 1334 1338 sp--; 1335 type[sp-1]=DEF_ LONG;1339 type[sp-1]=DEF_BOOLEAN; 1336 1340 1337 1341 *pStackPointer=sp; -
BasicCompiler32/NumOpe_TypeOperation.cpp
r3 r36 87 87 op_push(REG_EAX); 88 88 } 89 else if(type==DEF_BYTE ){89 else if(type==DEF_BYTE||type==DEF_BOOLEAN){ 90 90 //pop eax 91 91 op_pop(REG_EAX); -
BasicCompiler32/Opcode.h
r34 r36 140 140 void Set16Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset); 141 141 void Set8Variable(int type,DWORD VarKind,DWORD offset,BOOL bOffsetOffset); 142 void SetBooleanVariable(int type,RELATIVE_VAR *pRelative); 142 143 143 144 //increment.cpp … … 296 297 void op_sub_RV8 (int reg,char cValue); 297 298 void op_sbb_RV8 (int reg,char cValue); 299 void op_sbb_RR ( int reg1, int reg2 ); 298 300 void op_and_RV (int reg,int value); 301 void op_or_RR ( int op_size, int reg1, int reg2 ); 302 void op_neg ( int reg ); 299 303 void op_cdq (); 300 304 … … 306 310 void op_add_esp(int num); 307 311 void op_sub_esp(int num); 312 void op_cmp_value(int op_size,int reg,char byte_data); 313 void op_setne( int reg ); 308 314 void op_test(int reg1,int reg2); 309 315 void op_fld_ptr_esp(int type); -
BasicCompiler32/VarList.cpp
r3 r36 128 128 temporary[1]=0; 129 129 sprintf(lptv->item.pszText,"%s %d(&H%X)'%s'",VarName,byteData,byteData,temporary); 130 } 131 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS); 132 } 133 else if(type==DEF_BOOLEAN){ 134 if(ReadProcessMemory(hDebugProcess,(void *)offset,&byteData,sizeof(BYTE),&dwAccessByte)){ 135 if( byteData ) lstrcpy( temporary, "True" ); 136 else lstrcpy( temporary, "False" ); 137 sprintf(lptv->item.pszText,"%s %s",VarName,temporary); 130 138 } 131 139 else sprintf(lptv->item.pszText,"%s %s",VarName,STRING_CANNOTACCESS); -
BasicCompiler32/increment.cpp
r11 r36 92 92 op_movsx_R32R8(reg,reg); 93 93 } 94 else if(type==DEF_BYTE ){94 else if(type==DEF_BYTE||type==DEF_BOOLEAN){ 95 95 //and reg,000000FFh 96 96 op_and_RV(reg,(int)0xFF); … … 102 102 op_movsx_R16R8(reg,reg); 103 103 } 104 else if(type==DEF_BYTE ){104 else if(type==DEF_BYTE||type==DEF_BOOLEAN){ 105 105 //and reg,000000FFh 106 106 op_and_RV(reg,(int)0xFF); -
BasicCompiler32/op32_main.cpp
r3 r36 360 360 OpBuffer[obp++]=cValue; 361 361 } 362 void op_sbb_RR( int reg1, int reg2 ){ 363 //sbb reg1,reg2 364 365 //オペコード 366 OpBuffer[obp++]=(char)0x1B; 367 368 //レジスタ 369 OpBuffer[obp++]=(char)(0xC0| REGISTER_OPERAND(reg1)<<3 | REGISTER_OPERAND(reg2)); 370 } 371 362 372 363 373 … … 370 380 //and reg,value 371 381 372 //16ビット演算の命令プリフィックス 373 char op_prefix=0; 374 375 //オペコード 376 char opcode=(char)0x81; 377 378 __op_format(op_prefix,opcode,0,0,reg,value,MOD_REG); 382 if(reg==REG_RAX){ 383 //eaxのみ特殊 384 385 // [8bit rex] 0010 0101 [32bit offset] 386 OpBuffer[obp++]=(char)0x25; 387 *((long *)(OpBuffer+obp))=value; 388 obp+=sizeof(long); 389 } 390 else{ 391 //16ビット演算の命令プリフィックス 392 char op_prefix=0; 393 394 //オペコード 395 char opcode=(char)0x81; 396 397 __op_format(op_prefix,opcode,0,0,reg,value,MOD_REG); 398 } 399 } 400 401 void op_or_RR( int op_size, int reg1, int reg2 ){ 402 //16ビット演算のプリフィックス 403 if(op_size==sizeof(short)) OpBuffer[obp++]=(char)0x66; 404 405 //オペコード 406 if(op_size==sizeof(char)) OpBuffer[obp++]=(char)0x0A; 407 else OpBuffer[obp++]=(char)0x0B; 408 409 //レジスタ 410 OpBuffer[obp++]=(char)(0xC0| REGISTER_OPERAND(reg1)<<3 | REGISTER_OPERAND(reg2)); 411 } 412 413 414 415 void op_neg( int reg ){ 416 //neg reg 417 418 //オペコード 419 OpBuffer[obp++]=(char)0xF7; 420 421 //レジスタ 422 OpBuffer[obp++]=(char)(0xD8| REGISTER_OPERAND(reg)); 379 423 } 380 424 … … 481 525 OpBuffer[obp++]=(char)num; 482 526 } 527 } 528 529 530 531 ///////////////////// 532 // cmp関連 533 ///////////////////// 534 void op_cmp_value(int op_size,int reg,char byte_data){ 535 //cmp reg,byte_data 536 537 if(op_size==sizeof(char)&®==REG_EAX){ 538 //alレジスタの場合は特殊 539 OpBuffer[obp++]=(char)0x3C; 540 541 //8ビット値 542 OpBuffer[obp++]=byte_data; 543 544 return; 545 } 546 547 //16ビット演算のプリフィックス 548 if(op_size==sizeof(short)) OpBuffer[obp++]=(char)0x66; 549 550 //オペコード 551 if(op_size==sizeof(char)) OpBuffer[obp++]=(char)0x80; 552 else OpBuffer[obp++]=(char)0x83; 553 554 //レジスタ 555 OpBuffer[obp++]=(char)(0xF8| REGISTER_OPERAND(reg)); 556 557 //8ビット値 558 OpBuffer[obp++]=byte_data; 559 } 560 void op_setne( int reg ){ 561 //オペコード 562 OpBuffer[obp++]=(char)0x0F; 563 OpBuffer[obp++]=(char)0x95; 564 565 //レジスタ 566 OpBuffer[obp++]=(char)( 0xC0 | REGISTER_OPERAND(reg) ); 483 567 } 484 568
Note:
See TracChangeset
for help on using the changeset viewer.