Exemple #1
0
void PragmaInit( void )
/*********************/
{
    int         cpu;
    int         fpu;

    pragmaAuxInfoInit();

    AsmFuncNum = 0;
    switch( GET_CPU( ProcRevision ) ) {
    case CPU_86:    cpu = 0; break;
    case CPU_186:   cpu = 1; break;
    case CPU_286:   cpu = 2; break;
    case CPU_386:   cpu = 3; break;
    case CPU_486:   cpu = 4; break;
    case CPU_586:   cpu = 5; break;
    case CPU_686:   cpu = 6; break;
#if _CPU == 8086
    default:        cpu = 0; break;
#else
    default:        cpu = 3; break;
#endif
    }
    switch( GET_FPU_LEVEL( ProcRevision ) ) {
    case FPU_NONE:  fpu = 0; break;
    case FPU_87:    fpu = 1; break;
//    case FPU_287:   fpu = 2; break;
    case FPU_387:   fpu = 3; break;
    case FPU_586:   fpu = 3; break;
    case FPU_686:   fpu = 3; break;
#if _CPU == 8086
    default:        fpu = 1; break;
#else
    default:        fpu = 3; break;
#endif
    }

#if _CPU == 8086
    AsmInit( 0, cpu, fpu, GET_FPU_EMU( ProcRevision ) );
#else
    AsmInit( 1, cpu, fpu, FALSE );
#endif
}
Exemple #2
0
static void assemblerInit(      // INITIALIZATION OF ASSEMBLER
    INITFINI* defn )            // - definition
{
    int         cpu;
    int         fpu;

    defn = defn;
    switch( GET_CPU( CpuSwitches ) ) {
    case CPU_86:    cpu = 0; break;
    case CPU_186:   cpu = 1; break;
    case CPU_286:   cpu = 2; break;
    case CPU_386:   cpu = 3; break;
    case CPU_486:   cpu = 4; break;
    case CPU_586:   cpu = 5; break;
    case CPU_686:   cpu = 6; break;
#if _CPU == 8086
    default:        cpu = 0; break;
#else
    default:        cpu = 3; break;
#endif
    }
    switch( GET_FPU_LEVEL( CpuSwitches ) ) {
    case FPU_NONE:  fpu = 0; break;
    case FPU_87:    fpu = 1; break;
//    case FPU_287:   fpu = 2; break;
    case FPU_387:   fpu = 3; break;
    case FPU_586:   fpu = 3; break;
    case FPU_686:   fpu = 3; break;
#if _CPU == 8086
    default:        fpu = 1; break;
#else
    default:        fpu = 3; break;
#endif
    }
#if _CPU == 8086
    AsmInit( 0, cpu, fpu, GET_FPU_EMU( CpuSwitches ) );
#else
    AsmInit( 1, cpu, fpu, FALSE );
#endif
}
Exemple #3
0
static void macroDefs( void )
{
    if( TargetSwitches & I_MATH_INLINE ) {
        DefSwitchMacro( "OM" );
    }
    switch( TargetSwitches & (BIG_DATA|BIG_CODE|CHEAP_POINTER|FLAT_MODEL) ) {
    case CHEAP_POINTER:
        DefSwitchMacro( "MS" );
        break;
    case BIG_CODE|CHEAP_POINTER:
        DefSwitchMacro( "MM" );
        break;
    case BIG_DATA|CHEAP_POINTER:
        DefSwitchMacro( "MC" );
        break;
    case BIG_CODE|BIG_DATA|CHEAP_POINTER:
        DefSwitchMacro( "ML" );
        break;
    case BIG_CODE|BIG_DATA:
        DefSwitchMacro( "MH" );
        break;
    case FLAT_MODEL|CHEAP_POINTER:
        DefSwitchMacro( "MF" );
        break;
    }
    if( TargetSwitches & FLOATING_FS ) {
        DefSwitchMacro( "ZFF" );
    } else {
        DefSwitchMacro( "ZFP" );
    }
    if( TargetSwitches & FLOATING_GS ) {
        DefSwitchMacro( "ZGF" );
    } else {
        DefSwitchMacro( "ZGP" );
    }
    if( TargetSwitches & FLOATING_DS ) {
        DefSwitchMacro( "ZDF" );
    } else {
        DefSwitchMacro( "ZDP" );
    }
    if( TargetSwitches & FLOATING_SS ) {
        DefSwitchMacro( "ZU" );
    }
    if( TargetSwitches & INDEXED_GLOBALS ) {
        DefSwitchMacro( "XGV" );
    }
    if( TargetSwitches & WINDOWS ) {
        DefSwitchMacro( "ZW" );
    }
    if( TargetSwitches & SMART_WINDOWS ) {
        DefSwitchMacro( "ZWS" );
    }
    if( TargetSwitches & NO_CALL_RET_TRANSFORM ) {
        DefSwitchMacro( "OC" );
    }
    if( TargetSwitches & NEED_STACK_FRAME ) {
        DefSwitchMacro( "OF" );
    }
    if( GenSwitches & NO_OPTIMIZATION ) {
        DefSwitchMacro( "OD" );
    }
    if( GenSwitches & RELAX_ALIAS ) {
        DefSwitchMacro( "OA" );
    }
    if( GenSwitches & BRANCH_PREDICTION ) {
        DefSwitchMacro( "OB" );
    }
    if( GenSwitches & LOOP_OPTIMIZATION ) {
        DefSwitchMacro( "OL" );
    }
    if( GenSwitches & INS_SCHEDULING ) {
        DefSwitchMacro( "OR" );
    }
    if( GenSwitches & FPU_ROUNDING_INLINE ) {
        DefSwitchMacro( "ZRI" );
    }
    if( GenSwitches & FPU_ROUNDING_OMIT ) {
        DefSwitchMacro( "ZRO" );
    }
    if( TargetSwitches & GEN_FWAIT_386 ) {
        DefSwitchMacro( "ZFW" );
    }
    if( CompFlags.signed_char ) {
        DefSwitchMacro( "J" );
    }
    if( CompFlags.use_pcheaders ) {
        DefSwitchMacro( "FH" );
    }
    if( CompFlags.no_pch_warnings ) {
        DefSwitchMacro( "FHQ" );
    }
    if( CompFlags.inline_intrinsics ) {
        DefSwitchMacro( "OI" );
    }
    if( CompFlags.zu_switch_used ) {
        DefSwitchMacro( "ZU" );
    }
    if( CompFlags.unique_functions ) {
        DefSwitchMacro( "OU" );
    }
#if _CPU == 386
    if( CompFlags.register_conventions ) {
        DefSwitchMacro( "3R" );
    } else {
        DefSwitchMacro( "3S" );
    }
#endif
    if( CompFlags.emit_names ) {
        DefSwitchMacro( "EN" );
    }
    if( CompFlags.save_restore_segregs ) {
        DefSwitchMacro( "R" );
    }
    if( CompFlags.zc_switch_used ) {
        DefSwitchMacro( "ZC" );
    }
    if( CompFlags.use_unicode ) {
        DefSwitchMacro( "ZK" );
    }
    if( CompFlags.sg_switch_used ) {
        DefSwitchMacro( "SG" );
    }
    if( CompFlags.st_switch_used ) {
        DefSwitchMacro( "ST" );
    }
    if( CompFlags.bm_switch_used ) {
        PreDefineStringMacro( "_MT" );
        DefSwitchMacro( "BM" );
    }
    if( CompFlags.bd_switch_used ) {
        DefSwitchMacro( "BD" );
    }
    if( CompFlags.br_switch_used ) {
        PreDefineStringMacro( "_DLL" );
        DefSwitchMacro( "BR" );
    }
    if( CompFlags.bw_switch_used ) {
        DefSwitchMacro( "BW" );
    }
    if( CompFlags.zm_switch_used ) {
        DefSwitchMacro( "ZM" );
    }
    if( CompFlags.ep_switch_used ) {
        DefSwitchMacro( "EP" );
    }
    if( CompFlags.ee_switch_used ) {
        DefSwitchMacro( "EE" );
    }
    switch( CompInfo.dt_method_speced ) {
      case DTM_DIRECT :
        DefSwitchMacro( "XDT" );
        DefSwitchMacro( "XD" );
        break;
      case DTM_DIRECT_SMALL :
        DefSwitchMacro( "XDS" );
        break;
      case DTM_TABLE :
        DefSwitchMacro( "XS" );
        break;
      case DTM_DIRECT_TABLE :
        DefSwitchMacro( "XST" );
        break;
      case DTM_TABLE_SMALL :
        DefSwitchMacro( "XSS" );
        break;
      DbgDefault( "macroDefs -- invalid exception switch" );
    }
    switch( GET_CPU( CpuSwitches ) ) {
    case CPU_86:
        DefSwitchMacro( "0" );
        break;
    case CPU_186:
        DefSwitchMacro( "1" );
        break;
    case CPU_286:
        DefSwitchMacro( "2" );
        break;
    case CPU_386:
        DefSwitchMacro( "3" );
        break;
    case CPU_486:
        DefSwitchMacro( "4" );
        break;
    case CPU_586:
        DefSwitchMacro( "5" );
        break;
    case CPU_686:
        DefSwitchMacro( "6" );
        break;
    }
    switch( GET_FPU_LEVEL( CpuSwitches ) ) {
    case FPU_NONE:
        CompFlags.op_switch_used = 0;
        DefSwitchMacro( "FPC" );
        break;
    case FPU_87:
        DefSwitchMacro( "FP287" );
        defEmu();
        break;
    case FPU_387:
        DefSwitchMacro( "FP387" );
        defEmu();
        break;
    case FPU_586:
        DefSwitchMacro( "FP5" );
        defEmu();
        break;
    case FPU_686:
        DefSwitchMacro( "FP6" );
        defEmu();
        break;
    }
    if( CompFlags.op_switch_used ) {
        DefSwitchMacro( "OP" );
    }
    PreDefineStringMacro( "_INTEGRAL_MAX_BITS=64" );
#if _CPU == 386
    PreDefineStringMacro( "_STDCALL_SUPPORTED" );
#endif
    if( CompFlags.oldmacros_enabled ) {
#if _CPU == 8086
        if( TargetSwitches & WINDOWS ) {
            PreDefineStringMacro( "SOMLINK=__cdecl" );
            PreDefineStringMacro( "SOMDLINK=__far" );
        }
#else
        PreDefineStringMacro( "SOMLINK=_Syscall" );
        PreDefineStringMacro( "SOMDLINK=_Syscall" );
#endif
    }
}
Exemple #4
0
static void setMemoryModel( OPT_STORAGE *data, mem_model_control control )
{
    char model;
    unsigned bit;

    if( data->mem_model == OPT_mem_model_default ) {
#if _CPU == 8086
        data->mem_model = OPT_mem_model_ms;
#else
        data->mem_model = OPT_mem_model_mf;
#endif
    }
#if _CPU == 386
    if( control & MMC_NETWARE ) {
        data->mem_model = OPT_mem_model_ms;
    }
#endif
    bit = 0;
    if( CompFlags.oldmacros_enabled ) {
        switch( data->mem_model ) {
        case OPT_mem_model_ms:
            PreDefineStringMacro( "M_" MM_ARCH "SM" );
            break;
        case OPT_mem_model_mm:
            PreDefineStringMacro( "M_" MM_ARCH "MM" );
            break;
        case OPT_mem_model_ml:
            PreDefineStringMacro( "M_" MM_ARCH "LM" );
            break;
        case OPT_mem_model_mc:
            PreDefineStringMacro( "M_" MM_ARCH "CM" );
            break;
#if _CPU == 8086
        case OPT_mem_model_mh:
            PreDefineStringMacro( "M_" MM_ARCH "HM" );
            break;
#else
        case OPT_mem_model_mfi:
        case OPT_mem_model_mf:
            PreDefineStringMacro( "M_" MM_ARCH "FM" );
            break;
#endif
        default:
            break;
        }
    }
    DataPtrSize = TARGET_POINTER;
    CodePtrSize = TARGET_POINTER;
    switch( data->mem_model ) {
    case OPT_mem_model_ms:
        model = 's';
        PreDefineStringMacro( "_M_" MM_ARCH "SM" );
        PreDefineStringMacro( "__SMALL__" );
        CompFlags.strings_in_code_segment = 0;
        TargetSwitches &= ~CONST_IN_CODE;
        bit |= CHEAP_POINTER;
        break;
    case OPT_mem_model_mm:
        model = 'm';
        WatcallInfo.cclass |= FAR_CALL;
        CodePtrSize = TARGET_FAR_POINTER;
        PreDefineStringMacro( "_M_" MM_ARCH "MM" );
        PreDefineStringMacro( "__MEDIUM__" );
        CompFlags.strings_in_code_segment = 0;
        TargetSwitches &= ~CONST_IN_CODE;
        bit |= BIG_CODE | CHEAP_POINTER;
        break;
    case OPT_mem_model_mc:
        model = 'c';
        PreDefineStringMacro( "_M_" MM_ARCH "CM" );
        PreDefineStringMacro( "__COMPACT__" );
        DataPtrSize = TARGET_FAR_POINTER;
        bit |= BIG_DATA | CHEAP_POINTER;
        break;
    case OPT_mem_model_ml:
        model = 'l';
        PreDefineStringMacro( "_M_" MM_ARCH "LM" );
        PreDefineStringMacro( "__LARGE__" );
        WatcallInfo.cclass |= FAR_CALL;
        CodePtrSize = TARGET_FAR_POINTER;
        DataPtrSize = TARGET_FAR_POINTER;
        bit |= BIG_CODE | BIG_DATA | CHEAP_POINTER;
        break;
#if _CPU == 8086
    case OPT_mem_model_mh:
        model = 'h';
        PreDefineStringMacro( "_M_" MM_ARCH "HM" );
        PreDefineStringMacro( "__HUGE__" );
        WatcallInfo.cclass |= FAR_CALL;
        CodePtrSize = TARGET_FAR_POINTER;
        DataPtrSize = TARGET_FAR_POINTER;
        bit |= BIG_CODE | BIG_DATA;
        break;
#else
    case OPT_mem_model_mfi:
        CompFlags.mfi_switch_used = 1;
        /* fall thru */
    case OPT_mem_model_mf:
        model = 's';
        PreDefineStringMacro( "_M_" MM_ARCH "FM" );
        PreDefineStringMacro( "__FLAT__" );
        bit |= FLAT_MODEL | CHEAP_POINTER;
        break;
#endif
    default:
        DbgNever();
    }
// setup default "floating" segment registers
#if _CPU == 8086
    bit |= FLOATING_ES;
#else
    // 386 flat model needs at least one floating segment register
    bit |= FLOATING_GS;
    if( (bit & FLAT_MODEL) == 0 ) {
        bit |= FLOATING_ES;
    }
#endif
    if( bit & BIG_DATA ) {
        bit |= FLOATING_DS;
    }
    if( control & ( MMC_DS | MMC_WIN ) ) {
        bit &= ~FLOATING_DS;
    } else {
        TargetSwitches &= ~ FLOATING_DS;
    }
    if( control & MMC_FS ) {
        bit &= ~FLOATING_FS;
    } else {
        TargetSwitches &= ~ FLOATING_FS;
    }
    if( control & MMC_GS ) {
        bit &= ~FLOATING_GS;
    } else {
        TargetSwitches &= ~ FLOATING_GS;
    }
    TargetSwitches &= ~( FLAT_MODEL | BIG_CODE | BIG_DATA | CHEAP_POINTER | FLOATING_ES );
    TargetSwitches |= bit;
#if _CPU == 8086
    if( data->bm ) { // .DLL
        strcpy( DLL_CLIB_Name, "2clibmt?" );
    } else {
        if( control & MMC_WIN ) {
            strcpy( DLL_CLIB_Name, "2clib?" );
        } else {
            strcpy( DLL_CLIB_Name, "2clibdl?" );
        }
    }
    if( data->bm ) {
        strcpy( CLIB_Name, "2clibmt?" );
    } else if( data->bd ) {
        if( control & MMC_WIN ) {
            strcpy( CLIB_Name, "2clib?" );
        } else {
            strcpy( CLIB_Name, "2clibdl?" );
        }
    } else {
        strcpy( CLIB_Name, "2clib?" );
    }
    if( CompFlags.excs_enabled ) {
        if( data->bm ) { // .DLL
            strcpy( DLL_WCPPLIB_Name, "4plbxmt?" );
        } else {
            if( control & MMC_WIN ) {
                strcpy( DLL_WCPPLIB_Name, "4plbx?" );
            } else {
                strcpy( DLL_WCPPLIB_Name, "4plbxmt?" );
            }
        }
        if( data->bm ) {
            strcpy( WCPPLIB_Name, "4plbxmt?" );
        } else if( data->bd ) {
            if( control & MMC_WIN ) {
                strcpy( WCPPLIB_Name, "4plbx?" );
            } else {
                strcpy( WCPPLIB_Name, "4plbxmt?" );
            }
        } else {
            strcpy( WCPPLIB_Name, "4plbx?" );
        }
    } else {
        if( data->bm ) { // .DLL
            strcpy( DLL_WCPPLIB_Name, "4plibmt?" );
        } else {
            if( control & MMC_WIN ) {
                strcpy( DLL_WCPPLIB_Name, "4plib?" );
            } else {
                strcpy( DLL_WCPPLIB_Name, "4plibmt?" );
            }
        }
        if( data->bm ) {
            strcpy( WCPPLIB_Name, "4plibmt?" );
        } else if( data->bd ) {
            if( control & MMC_WIN ) {
                strcpy( WCPPLIB_Name, "4plib?" );
            } else {
                strcpy( WCPPLIB_Name, "4plibmt?" );
            }
        } else {
            strcpy( WCPPLIB_Name, "4plib?" );
        }
    }
    if( GET_FPU_EMU( CpuSwitches ) ) {
        strcpy( MATHLIB_Name, "7math87?" );
        EmuLib_Name = "8emu87";
    } else if( GET_FPU_LEVEL( CpuSwitches ) == FPU_NONE ) {
        strcpy( MATHLIB_Name, "5math?" );
        EmuLib_Name = NULL;
    } else {
        strcpy( MATHLIB_Name, "7math87?" );
        EmuLib_Name = "8noemu87";
    }
#else
    if( CompFlags.register_conventions ) {
        model = 'r';
        PreDefineStringMacro( "__3R__" );
    } else {
        model = 's';
        PreDefineStringMacro( "__3S__" );
    }
    strcpy( CDLL_Name, "1clb?dll" );
    strcpy( CLIB_Name, "2clib3?" );
    strcpy( DLL_CLIB_Name, "2clib3?" );
    if( CompFlags.excs_enabled ) {
        strcpy( WCPPDLL_Name, "3plb?dllx" );
        if( data->bm ) { // .DLL
            strcpy( DLL_WCPPLIB_Name, "4plbxmt3?" );
        } else {
            if( control & MMC_WIN ) {
                strcpy( DLL_WCPPLIB_Name, "4plbx3?" );
            } else {
                strcpy( DLL_WCPPLIB_Name, "4plbxmt3?" );
            }
        }
        if( data->bm ) {
            strcpy( WCPPLIB_Name, "4plbxmt3?" );
        } else if( data->bd ) {
            if( control & MMC_WIN ) {
                strcpy( WCPPLIB_Name, "4plbx3?" );
            } else {
                strcpy( WCPPLIB_Name, "4plbxmt3?" );
            }
        } else {
            strcpy( WCPPLIB_Name, "4plbx3?" );
        }
    } else {
        strcpy( WCPPDLL_Name, "3plb?dll" );
        if( data->bm ) { // .DLL
            strcpy( DLL_WCPPLIB_Name, "4plibmt3?" );
        } else {
            if( control & MMC_WIN ) {
                strcpy( DLL_WCPPLIB_Name, "4plib3?" );
            } else {
                strcpy( DLL_WCPPLIB_Name, "4plibmt3?" );
            }
        }
        if( data->bm ) {
            strcpy( WCPPLIB_Name, "4plibmt3?" );
        } else if( data->bd ) {
            if( control & MMC_WIN ) {
                strcpy( WCPPLIB_Name, "4plib3?" );
            } else {
                strcpy( WCPPLIB_Name, "4plibmt3?" );
            }
        } else {
            strcpy( WCPPLIB_Name, "4plib3?" );
        }
    }
    if( GET_FPU_EMU( CpuSwitches ) ) {
        if( data->br ) {
            strcpy( MATHLIB_Name, "7mt7?dll" );
        } else {
            strcpy( MATHLIB_Name, "7math387?" );
        }
        EmuLib_Name = "8emu387";
    } else if( GET_FPU_LEVEL( CpuSwitches ) == FPU_NONE ) {
        if( data->br ) {
            strcpy( MATHLIB_Name, "5mth?dll" );
        } else {
            strcpy( MATHLIB_Name, "5math3?" );
        }
        EmuLib_Name = NULL;
    } else {
        if( data->br ) {
            strcpy( MATHLIB_Name, "7mt7?dll" );
        } else {
            strcpy( MATHLIB_Name, "7math387?" );
        }
        EmuLib_Name = "8noemu387";
    }
    *strchr( CDLL_Name, '?' ) = model;
    *strchr( WCPPDLL_Name, '?' ) = model;
#endif
    *strchr( CLIB_Name, '?' ) = model;
    *strchr( MATHLIB_Name, '?' ) = model;
    *strchr( WCPPLIB_Name, '?' ) = model;
    *strchr( DLL_CLIB_Name, '?' ) = model;
    *strchr( DLL_WCPPLIB_Name, '?' ) = model;
}