void AsmSysMakeInlineAsmFunc( bool too_many_bytes ) /*************************************************/ { int code_length; SYM_HANDLE sym_handle; TREEPTR tree; bool uses_auto; char name[8]; /* unused parameters */ (void)too_many_bytes; code_length = AsmCodeAddress; if( code_length != 0 ) { sprintf( name, "F.%d", AsmFuncNum ); ++AsmFuncNum; CreateAux( name ); CurrInfo = (aux_info *)CMemAlloc( sizeof( aux_info ) ); *CurrInfo = WatcallInfo; CurrInfo->use = 1; CurrInfo->save = AsmRegsSaved; // indicate no registers saved uses_auto = InsertFixups( AsmCodeBuffer, code_length, &CurrInfo->code ); if( uses_auto ) { /* We want to force the calling routine to set up a [E]BP frame for the use of this pragma. This is done by saying the pragma modifies the [E]SP register. A kludge, but it works. */ HW_CTurnOff( CurrInfo->save, HW_SP ); } CurrEntry->info = CurrInfo; CurrEntry->next = AuxList; AuxList = CurrEntry; CurrEntry = NULL; sym_handle = MakeFunction( name, FuncNode( GetType( TYPE_VOID ), FLAG_NONE, NULL ) ); tree = LeafNode( OPR_FUNCNAME ); tree->op.u2.sym_handle = sym_handle; tree = ExprNode( tree, OPR_CALL, NULL ); tree->u.expr_type = GetType( TYPE_VOID ); AddStmt( tree ); } }
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 ); }