static void defEmu( void ) { if( GET_FPU_EMU( CpuSwitches ) ) { DefSwitchMacro( "FPI" ); } else { DefSwitchMacro( "FPI87" ); } }
void AsmSysLine( char *buf ) /**************************/ { #if _CPU == 8086 AsmLine( buf, GET_FPU_EMU( CpuSwitches ) ); #else AsmLine( buf, FALSE ); #endif }
void AsmSysLine( char *buff ) /***************************/ { #if _CPU == 8086 AsmLine( buff, GET_FPU_EMU( ProcRevision ) ); #else AsmLine( buff, FALSE ); #endif }
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 }
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 }
static int GetByteSeq( void ) { int len; char *name; unsigned offset; unsigned fixword; int uses_auto; VBUF code_buffer; #if _CPU == 8086 bool use_fpu_emu = FALSE; #endif VbufInit( &code_buffer ); AsmSysInit(); PPCTL_ENABLE_MACROS(); NextToken(); len = 0; offset = 0; name = NULL; for( ;; ) { /* reserve at least ASM_BLOCK bytes in the buffer */ VbufReqd( &code_buffer, _RoundUp( len + ASM_BLOCK, ASM_BLOCK ) ); if( CurToken == T_STRING ) { AsmCodeAddress = len; AsmCodeBuffer = VbufBuffer( &code_buffer ); #if _CPU == 8086 AsmLine( Buffer, use_fpu_emu ); use_fpu_emu = FALSE; #else AsmLine( Buffer, FALSE ); #endif len = AsmCodeAddress; NextToken(); if( CurToken == T_COMMA ) { NextToken(); } } else if( CurToken == T_CONSTANT ) { #if _CPU == 8086 if( use_fpu_emu ) { AddAFix( len, NULL, FIX_SEG, 0 ); use_fpu_emu = FALSE; } #endif VbufBuffer( &code_buffer )[ len++ ] = U32Fetch( Constant64 ); NextToken(); } else { #if _CPU == 8086 use_fpu_emu = FALSE; #endif fixword = FixupKeyword(); if( fixword == FIXWORD_NONE ) break; if( fixword == FIXWORD_FLOAT ) { #if _CPU == 8086 if( GET_FPU_EMU( CpuSwitches ) ) { use_fpu_emu = TRUE; } #endif } else { /* seg or offset */ if( !IS_ID_OR_KEYWORD( CurToken ) ) { CErr1( ERR_EXPECTING_ID ); } else { name = strsave( Buffer ); offset = 0; NextToken(); if( CurToken == T_PLUS ) { NextToken(); if( CurToken == T_CONSTANT ) { offset = U32Fetch( Constant64 ); NextToken(); } } else if( CurToken == T_MINUS ) { NextToken(); if( CurToken == T_CONSTANT ) { offset = - U32Fetch( Constant64 ); NextToken(); } } } switch( fixword ) { case FIXWORD_RELOFF: #if _CPU == 8086 AddAFix( len, name, FIX_RELOFF16, offset ); len += 2; #else AddAFix( len, name, FIX_RELOFF32, offset ); len += 4; #endif break; case FIXWORD_OFFSET: #if _CPU == 8086 AddAFix( len, name, FIX_OFF16, offset ); len += 2; #else AddAFix( len, name, FIX_OFF32, offset ); len += 4; #endif break; case FIXWORD_SEGMENT: AddAFix( len, name, FIX_SEG, 0 ); len += 2; break; } } } VbufSetLen( &code_buffer, len ); } PPCTL_DISABLE_MACROS(); uses_auto = AsmSysInsertFixups( &code_buffer ); AsmSysFini(); VbufFree( &code_buffer ); return( uses_auto ); }
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; }
local int GetByteSeq( byte_seq **code ) /*************************************/ { unsigned char buff[MAXIMUM_BYTESEQ + 32]; char *name; unsigned long offset; fix_words fixword; int uses_auto; char too_many_bytes; #if _CPU == 8086 bool use_fpu_emu = FALSE; #endif AsmSysInit( buff ); CompFlags.pre_processing = 1; /* enable macros */ NextToken(); too_many_bytes = 0; uses_auto = 0; offset = 0; name = NULL; for( ;; ) { if( CurToken == T_STRING ) { /* 06-sep-91 */ #if _CPU == 8086 AsmLine( Buffer, GET_FPU_EMU( ProcRevision ) ); use_fpu_emu = FALSE; #else AsmLine( Buffer, FALSE ); #endif NextToken(); if( CurToken == T_COMMA ) { NextToken(); } } else if( CurToken == T_CONSTANT ) { #if _CPU == 8086 if( use_fpu_emu ) { AddAFix( AsmCodeAddress, NULL, FIX_SEG, 0 ); use_fpu_emu = FALSE; } #endif AsmCodeBuffer[AsmCodeAddress++] = Constant; NextToken(); } else { #if _CPU == 8086 use_fpu_emu = FALSE; #endif fixword = FixupKeyword(); if( fixword == FIXWORD_NONE ) break; if( fixword == FIXWORD_FLOAT ) { #if _CPU == 8086 if( GET_FPU_EMU( ProcRevision ) ) { use_fpu_emu = TRUE; } #endif } else { /* seg or offset */ if( CurToken != T_ID ) { CErr1( ERR_EXPECTING_ID ); } else { name = CStrSave( Buffer ); NextToken(); if( CurToken == T_PLUS ) { NextToken(); if( CurToken == T_CONSTANT ) { offset = Constant; NextToken(); } } else if( CurToken == T_MINUS ) { NextToken(); if( CurToken == T_CONSTANT ) { offset = -Constant; NextToken(); } } } switch( fixword ) { case FIXWORD_RELOFF: #if _CPU == 8086 AddAFix( AsmCodeAddress, name, FIX_RELOFF16, offset ); AsmCodeAddress += 2; #else AddAFix( AsmCodeAddress, name, FIX_RELOFF32, offset ); AsmCodeAddress += 4; #endif break; case FIXWORD_OFFSET: #if _CPU == 8086 AddAFix( AsmCodeAddress, name, FIX_OFF16, offset ); AsmCodeAddress += 2; #else AddAFix( AsmCodeAddress, name, FIX_OFF32, offset ); AsmCodeAddress += 4; #endif break; case FIXWORD_SEGMENT: AddAFix( AsmCodeAddress, name, FIX_SEG, 0 ); AsmCodeAddress += 2; break; } } } if( AsmCodeAddress > MAXIMUM_BYTESEQ ) { if( ! too_many_bytes ) { CErr1( ERR_TOO_MANY_BYTES_IN_PRAGMA ); too_many_bytes = 1; } AsmCodeAddress = 0; // reset index to we don't overrun buffer } } if( too_many_bytes ) { FreeAsmFixups(); uses_auto = 0; } else { uses_auto = InsertFixups( buff, AsmCodeAddress, code ); } CompFlags.pre_processing = 2; AsmSysFini(); return( uses_auto ); }
static bool GetByteSeq( byte_seq **code ) /**************************************/ { unsigned char buff[MAXIMUM_BYTESEQ + 32]; char *name; unsigned offset; fix_words fixword; bool uses_auto; bool too_many_bytes; #if _CPU == 8086 bool use_fpu_emu = false; #endif AsmSysInit( buff ); PPCTL_ENABLE_MACROS(); NextToken(); too_many_bytes = false; uses_auto = false; offset = 0; name = NULL; for( ;; ) { if( CurToken == T_STRING ) { #if _CPU == 8086 AsmLine( Buffer, use_fpu_emu ); use_fpu_emu = false; #else AsmLine( Buffer, false ); #endif NextToken(); if( CurToken == T_COMMA ) { NextToken(); } } else if( CurToken == T_CONSTANT ) { #if _CPU == 8086 if( use_fpu_emu ) { AddAFix( AsmCodeAddress, NULL, FIX_SEG, 0 ); use_fpu_emu = false; } #endif AsmCodeBuffer[AsmCodeAddress++] = (unsigned char)Constant; NextToken(); } else { #if _CPU == 8086 use_fpu_emu = false; #endif fixword = FixupKeyword(); if( fixword == FIXWORD_NONE ) break; if( fixword == FIXWORD_FLOAT ) { #if _CPU == 8086 if( GET_FPU_EMU( ProcRevision ) ) { use_fpu_emu = true; } #endif } else { /* seg or offset */ if( !IS_ID_OR_KEYWORD( CurToken ) ) { CErr1( ERR_EXPECTING_ID ); } else { name = CStrSave( Buffer ); NextToken(); if( CurToken == T_PLUS ) { NextToken(); if( CurToken == T_CONSTANT ) { offset = Constant; NextToken(); } } else if( CurToken == T_MINUS ) { NextToken(); if( CurToken == T_CONSTANT ) { offset = -(int)Constant; NextToken(); } } } switch( fixword ) { case FIXWORD_RELOFF: #if _CPU == 8086 AddAFix( AsmCodeAddress, name, FIX_RELOFF16, offset ); AsmCodeAddress += 2; #else AddAFix( AsmCodeAddress, name, FIX_RELOFF32, offset ); AsmCodeAddress += 4; #endif break; case FIXWORD_OFFSET: #if _CPU == 8086 AddAFix( AsmCodeAddress, name, FIX_OFF16, offset ); AsmCodeAddress += 2; #else AddAFix( AsmCodeAddress, name, FIX_OFF32, offset ); AsmCodeAddress += 4; #endif break; case FIXWORD_SEGMENT: AddAFix( AsmCodeAddress, name, FIX_SEG, 0 ); AsmCodeAddress += 2; break; } } } if( AsmCodeAddress > MAXIMUM_BYTESEQ ) { if( !too_many_bytes ) { CErr1( ERR_TOO_MANY_BYTES_IN_PRAGMA ); too_many_bytes = true; } AsmCodeAddress = 0; // reset index to we don't overrun buffer } } PPCTL_DISABLE_MACROS(); if( too_many_bytes ) { uses_auto = false; } else { uses_auto = InsertFixups( buff, AsmCodeAddress, code ); } FreeAsmFixups(); AsmSysFini(); return( uses_auto ); }