Changeset 234 in dev
- Timestamp:
- Jul 25, 2007, 11:21:25 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/CodeGenerator.cpp
r230 r234 99 99 /////////////////// 100 100 101 void CodeGenerator::op_mov_MV( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType ) 102 { 103 //mov ptr[base_reg+offset],value 104 105 if( op_size == sizeof(char) ) 106 { 107 pNativeCode->Put( (char)0xC6 ); 108 pNativeCode->Put( (char)(0x80|REGISTER_OPERAND(base_reg)) ); 109 pNativeCode->Put( offset, offsetScheduleType ); 110 pNativeCode->Put( (char)value ); 111 } 112 else if( op_size == sizeof(short) ) 113 { 114 pNativeCode->Put( (char)0x66 ); 115 pNativeCode->Put( (char)0xC7 ); 116 pNativeCode->Put( (char)(0x80|REGISTER_OPERAND(base_reg)) ); 117 pNativeCode->Put( offset, offsetScheduleType ); 118 pNativeCode->Put( (short)value ); 119 } 120 else if( op_size == sizeof(long) ) 121 { 122 pNativeCode->Put( (char)0xC7 ); 123 pNativeCode->Put( (char)(0x80|REGISTER_OPERAND(base_reg)) ); 124 pNativeCode->Put( offset, offsetScheduleType ); 125 pNativeCode->Put( value, valueScheduleType ); 126 } 127 } 101 128 void CodeGenerator::op_mov_RV(int reg,long offset, Schedule::Type scheduleType ){ 102 129 //mov reg,value … … 359 386 { 360 387 // add reg,offset 361 pNativeCode->Put( (char)0x81 ); 362 pNativeCode->Put( (char)(0xC0|REGISTER_OPERAND(reg)) ); 363 pNativeCode->Put( offset, scheduleType ); 388 389 if( reg == REG_EAX ) 390 { 391 // eaxのみ特殊 392 pNativeCode->Put( (char)0x05 ); 393 pNativeCode->Put( offset, scheduleType ); 394 } 395 else 396 { 397 pNativeCode->Put( (char)0x81 ); 398 pNativeCode->Put( (char)(0xC0|REGISTER_OPERAND(reg)) ); 399 pNativeCode->Put( offset, scheduleType ); 400 } 364 401 } 365 402 void CodeGenerator::op_add_RR( int reg1, int reg2 ) -
trunk/abdev/BasicCompiler32/Compile_Var.cpp
r233 r234 1033 1033 } 1034 1034 else if( type.IsWord() || type.IsInteger() ){ 1035 //mov ax,InitValue 1036 OpBuffer[obp++]=(char)0x66; 1037 OpBuffer[obp++]=(char)0xB8; 1038 *((WORD *)(OpBuffer+obp))=(WORD)i64data; 1039 obp+=sizeof(WORD); 1040 1041 //mov word ptr[ebp+offset],ax 1042 compiler.codeGenerator.op_mov_MR( sizeof(short), REG_EAX, REG_EBP, offset, MOD_BASE_DISP32, Schedule::LocalVar ); 1035 //mov word ptr[ebp+offset],InitValue 1036 compiler.codeGenerator.op_mov_MV( sizeof(short), REG_EBP, offset, Schedule::LocalVar, (long)i64data ); 1043 1037 } 1044 1038 else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){ 1045 1039 //mov byte ptr[ebp+offset],InitValue 1046 OpBuffer[obp++]=(char)0xC6; 1047 OpBuffer[obp++]=(char)0x85; 1048 *((long *)(OpBuffer+obp))=offset; 1049 AddLocalVarAddrSchedule(); 1050 obp+=sizeof(long); 1051 *((BYTE *)(OpBuffer+obp))=(BYTE)i64data; 1052 obp+=sizeof(BYTE); 1040 compiler.codeGenerator.op_mov_MV( sizeof(char), REG_EBP, offset, Schedule::LocalVar, (long)i64data ); 1053 1041 } 1054 1042 … … 1161 1149 1162 1150 //add eax,offset 1163 OpBuffer[obp++]=(char)0x05; 1164 *((long *)(OpBuffer+obp))=-pVar->GetOffsetAddress(); 1165 AddLocalVarAddrSchedule(); 1166 obp+=sizeof(long); 1151 compiler.codeGenerator.op_add_RV( REG_EAX, -pVar->GetOffsetAddress(), Schedule::LocalVar ); 1167 1152 1168 1153 //push eax -
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r225 r234 445 445 //未完成 446 446 //OpBuffer[obp++]=(char)0xCC; 447 447 448 448 449 -
trunk/abdev/BasicCompiler_Common/include/CodeGenerator.h
r232 r234 131 131 void __op_format(char op_prefix,char opcode1,char opcode2,int reg,int base_reg,int offset,char mod, Schedule::Type scheduleType = Schedule::None ); 132 132 public: 133 void op_mov_MV ( int op_size, int base_reg, long offset, Schedule::Type offsetScheduleType, long value, Schedule::Type valueScheduleType = Schedule::None ); 133 134 void op_mov_RV (int reg,long offset, Schedule::Type scheduleType = Schedule::None ); 134 135 void op_mov_RR (int reg1,int reg2); -
trunk/abdev/BasicCompiler_Common/src/LexicalScopingImpl.cpp
r226 r234 100 100 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_RCX,REG_RSP, 101 101 -pVar->GetOffsetAddress(), 102 MOD_BASE_DISP32); 103 obp-=sizeof(long); 104 AddLocalVarAddrSchedule(); 105 obp+=sizeof(long); 102 MOD_BASE_DISP32, 103 Schedule::LocalVar); 106 104 #else 107 105 //x86コード 108 106 109 107 //mov ecx,dword ptr[ebp+offset] 110 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32); 111 obp-=sizeof(long); 112 AddLocalVarAddrSchedule(); 113 obp+=sizeof(long); 108 compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_EBP,-pVar->GetOffsetAddress(),MOD_BASE_DISP32, Schedule::LocalVar ); 114 109 115 110 //push ecx
Note:
See TracChangeset
for help on using the changeset viewer.