示例#1
0
char  *FindSymbol( uint_32 ref )
/******************************/
{
    fixup               *fix;
    char                *name;

    name = NULL;
    fix = FindFixup( ref, Segment );
    if( fix != NULL ) {
        name = GetFixName( fix );
        if( name == NULL ) {
            name = NewName( fix );
        }
    }
    return( name );
}
示例#2
0
char  *FindLabel( uint_32 ref, uint_32 addr, segment *seg )
/*********************************************************/
{
    char                *name;
    fixup               *fix;

    switch( _Class( seg ) ) {
    case TYPE_IMPORT:               /* fall through */
    case TYPE_COMDEF:
        name = FormSym( _Name( seg ) );
        break;
    case TYPE_GROUP:
        name = _Name( seg );
        break;
    default:
        if( ref == BAD_OFFSET ) {
            fix = NULL;
        } else {
            fix = FindFixup( ref, seg );
        }
        if( fix == NULL ) {
            name = FindExpName( addr, seg );
            if( name == NULL ) {
                AddLabel( addr, NULL, seg, false, false );
            }
        } else {
            name = GetFixName( fix );
            if( name == NULL ) {
                AddLabel( fix->imp_address, NULL, seg, false, false );
                name = FindExpName( fix->imp_address, seg );
            }
        }
        break;
    }
    return( name );
}
示例#3
0
void  EmitModule()
/****************/

{
    char                *name;
    import_sym          *imp;
    char                sp_buf[ _MAX_PATH2 ];
    char                *root_name;

    if( ( Options & FORM_ASSEMBLER ) == 0 ) {
        EmitNL();
        DoEmit( MSG_MODULE );
        EmitLine( Mod->name );
        if( Mod->main ) {
            EmitLine( "MAIN MODULE " );
        }
        if( Mod->start != NULL ) {
            DoEmit( MSG_START_ADDR );
            name = GetFixName( Mod->start );
            if( name == NULL ) {
                name = NewName( Mod->start );
            }
            Emit( name );
            EmitNL();
        }
    } else {
        _splitpath2( Mod->name, sp_buf, NULL, NULL, &root_name, NULL );
        if( DO_UNIX ) {
            EmitBlanks( LABEL_LEN );
            EmitSpaced( ".file", OPCODE_LEN );
            Emit( "\"" );
            Emit( root_name );
            Emit( "\"" );
            EmitNL();
        } else {
            if( RetFarUsed ) {
                EmitRetFMacro();
            }
            if( Is32BitObj ) EmitLine( ".386p" );
            EmitBlanks( LABEL_LEN );
            EmitSpaced( "NAME", OPCODE_LEN );
            EmitLine( root_name );
        }
        if( ( Options & FORM_DO_WTK )  &&  HaveWtk() ) {
            Emit( "INCLUDE" );
            EmitBlanks( LABEL_LEN - 7 );
            EmitLine( "67MACROS.EQU" );
        }
    }
    for( imp = Mod->imports; imp != NULL; imp = imp->next_imp ) {
        switch( imp->class ) {
        case TYPE_IMPORT:
            if( !DO_UNIX
                && ( Options & FORM_ASSEMBLER )
                && imp->public
                && !imp->exported
                && strcmp( imp->name, WTLBASEStr ) != 0 ) {
                EmitBlanks( LABEL_LEN );
                EmitSpaced( "EXTRN", OPCODE_LEN );
                EmitSym( imp->name, 0 );
                Emit( ":BYTE" );        // so that output would assemble
                EmitNL();
            }
            break;
        case TYPE_COMDEF:
            if( DO_UNIX ) {
                if( imp->public ) {
                    EmitBlanks( LABEL_LEN );
                    EmitSpaced( ".globl", OPCODE_LEN );
                    EmitLine( imp->name );
                }
                EmitBlanks( LABEL_LEN );
                EmitSpaced( ".lcomm", OPCODE_LEN );
                EmitSym( imp->name, 0 );
                Emit( ", " );
            } else {
                if( imp->public ) {
                    EmitBlanks( LABEL_LEN );
                    EmitSpaced( "COMM", OPCODE_LEN );
                } else {
                    if( Options & FORM_ASSEMBLER ) {
                        DoEmitError( MSG_LCL_COMM_WONT_ASM );
                    }
                    EmitBlanks( LABEL_LEN );
                    EmitSpaced( "LCOMM", OPCODE_LEN );
                }
                if( imp->far_common ) {
                    Emit( "FAR  " );
                } else {
                    Emit( "NEAR " );
                }
                EmitSym( imp->name, 0 );
                Emit( ":BYTE:" );
            }
            EmitHex( imp->u.size );
            EmitNL();
            break;
        }