Changeset 234 in dev for trunk/abdev/BasicCompiler32


Ignore:
Timestamp:
Jul 25, 2007, 11:21:25 AM (17 years ago)
Author:
dai_9181
Message:
 
Location:
trunk/abdev/BasicCompiler32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/CodeGenerator.cpp

    r230 r234  
    9999///////////////////
    100100
     101void 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}
    101128void CodeGenerator::op_mov_RV(int reg,long offset, Schedule::Type scheduleType ){
    102129    //mov reg,value
     
    359386{
    360387    // 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    }
    364401}
    365402void CodeGenerator::op_add_RR( int reg1, int reg2 )
  • trunk/abdev/BasicCompiler32/Compile_Var.cpp

    r233 r234  
    10331033    }
    10341034    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 );
    10431037    }
    10441038    else if( type.IsSByte() || type.IsByte() || type.IsBoolean() ){
    10451039        //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 );
    10531041    }
    10541042
     
    11611149
    11621150            //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 );
    11671152
    11681153            //push eax
  • trunk/abdev/BasicCompiler32/MakePeHdr.cpp

    r225 r234  
    445445        //未完成
    446446        //OpBuffer[obp++]=(char)0xCC;
     447
    447448
    448449
Note: See TracChangeset for help on using the changeset viewer.