Beispiel #1
0
static void jumpExtend( int far_flag )
/*************************************/
{
    token_idx   i;
    unsigned    next_ins_size;
    char        buffer[MAX_LINE_LEN];
    char        *p;
    size_t      len;

    /* there MUST be a conditional jump instruction in asmbuffer */
    for( i = 0; ; i++ ) {
        if( ( AsmBuffer[i].class == TC_INSTR )
            && IS_JMP( AsmBuffer[i].u.token ) ) {
            break;
        }
    }

    AsmNote( 4, EXTENDING_JUMP );

    p = buffer + getJumpNegation( AsmBuffer[i].u.token, buffer );
    if( far_flag ) {
        next_ins_size = Code->use32 ? 7 : 5;
    } else {
        next_ins_size = Code->use32 ? 5 : 3;
    }
    sprintf( buffer + strlen( buffer ), " SHORT $+%d ", next_ins_size + 2 );
    InputQueueLine( buffer );
    p = buffer;
    if( far_flag ) {
        p = CATLIT( p, "jmpf " );
    } else {
        p = CATLIT( p, "jmp " );
    }
    for( i++; AsmBuffer[i].class != TC_FINAL; i++ ) {
        switch( AsmBuffer[i].class ) {
        case TC_NUM:
            p += sprintf( p, "%lu", AsmBuffer[i].u.value );
            break;
        case TC_OP_SQ_BRACKET:
            *p++ = '[';
            break;
        case TC_CL_SQ_BRACKET:
            *p++ = ']';
            break;
        default:
            len = strlen( AsmBuffer[i].string_ptr );
            p = CATSTR( p, AsmBuffer[i].string_ptr, len );
            break;
        }
    }
    *p = '\0';
    InputQueueLine( buffer );
    return;
}
Beispiel #2
0
static void FarCallToNear( void )
/*******************************/
{
    token_idx   i;
    char        buffer[MAX_LINE_LEN];
    char        *p;
    size_t      len;

    /* there MUST be a call instruction in asmbuffer */
    for( i = 0; ; i++ ) {
        if( ( AsmBuffer[i].class == TC_INSTR )
            && ( AsmBuffer[i].u.token == T_CALL ) ) {
            break;
        }
    }
    if( Parse_Pass == PASS_2 )
        AsmNote( 4, CALL_FAR_TO_NEAR );
    InputQueueLine( "PUSH CS" );
    p = buffer;
#if defined( _STANDALONE_ )
    if( Options.mode & MODE_IDEAL ) {
        p = CATLIT( p, "CALL NEAR " );
    } else {
        p = CATLIT( p, "CALL NEAR PTR " );
    }
#else
    p = CATLIT( p, "CALL NEAR PTR " );
#endif
    for( i++; AsmBuffer[i].class != TC_FINAL; i++ ) {
        switch( AsmBuffer[i].class ) {
        case TC_NUM:
            p += sprintf( p, "%lu", AsmBuffer[i].u.value );
            break;
        case TC_OP_SQ_BRACKET:
            *p++ = '[';
            break;
        case TC_CL_SQ_BRACKET:
            *p++ = ']';
            break;
        default:
            len = strlen( AsmBuffer[i].string_ptr );
            p = CATSTR( p, AsmBuffer[i].string_ptr, len );
            break;
        }
    }
    *p = '\0';
    InputQueueLine( buffer );
    return;
}
Beispiel #3
0
static void jumpExtend( int far_flag )
/*************************************/
{
    unsigned    i;
    unsigned    next_ins_size;
    char        buffer[MAX_LINE_LEN];

    /* there MUST be a conditional jump instruction in asmbuffer */
    for( i = 0; ; i++ ) {
        if( ( AsmBuffer[i]->class == TC_INSTR )
            && IS_JMP( AsmBuffer[i]->u.token ) ) {
            break;
        }
    }

    AsmNote( 4, EXTENDING_JUMP );

    getJumpNegation( AsmBuffer[i]->u.token, buffer, MAX_LINE_LEN );
    if( far_flag ) {
        next_ins_size = Code->use32 ? 7 : 5;
    } else {
        next_ins_size = Code->use32 ? 5 : 3;
    }
    sprintf( buffer + strlen( buffer ), " SHORT $+%d ", next_ins_size + 2 );
    InputQueueLine( buffer );
    if( far_flag ) {
        strcpy( buffer, "jmpf " );
    } else {
        strcpy( buffer, "jmp " );
    }
    for( i++; AsmBuffer[i]->class != TC_FINAL; i++ ) {
        switch( AsmBuffer[i]->class ) {
        case TC_NUM:
            itoa( AsmBuffer[i]->u.value, buffer + strlen( buffer ), 10 );
            break;
        case TC_OP_SQ_BRACKET:
            strcat( buffer, "[" );
            break;
        case TC_CL_SQ_BRACKET:
            strcat( buffer, "]" );
            break;
        default:
            strcat( buffer, AsmBuffer[i]->string_ptr );
            break;
        }
    }
    InputQueueLine( buffer );
    return;
}
Beispiel #4
0
static void FarCallToNear( void )
/*******************************/
{
    unsigned i;
    char buffer[MAX_LINE_LEN];

    /* there MUST be a call instruction in asmbuffer */
    for( i = 0; ; i++ ) {
        if( ( AsmBuffer[i]->class == TC_INSTR )
            && ( AsmBuffer[i]->u.token == T_CALL ) ) {
            break;
        }
    }
    if( Parse_Pass == PASS_2 )
        AsmNote( 4, CALL_FAR_TO_NEAR );
    InputQueueLine( "PUSH CS" );
#if defined( _STANDALONE_ )
    if( Options.mode & MODE_IDEAL ) {
        strcpy( buffer, "CALL NEAR " );
    } else {
        strcpy( buffer, "CALL NEAR PTR " );
    }
#else
    strcpy( buffer, "CALL NEAR PTR " );
#endif
    for( i++; AsmBuffer[i]->class != TC_FINAL; i++ ) {
        switch( AsmBuffer[i]->class ) {
        case TC_NUM:
            itoa( AsmBuffer[i]->u.value, buffer+strlen( buffer ), 10 );
            break;
        case TC_OP_SQ_BRACKET:
            strcat( buffer, "[" );
            break;
        case TC_CL_SQ_BRACKET:
            strcat( buffer, "]" );
            break;
        default:
            strcat( buffer, AsmBuffer[i]->string_ptr );
            break;
        }
    }
    InputQueueLine( buffer );
    return;
}
Beispiel #5
0
static void SetMemoryModel( void )
/********************************/
{
    char buffer[20];
    char *model;

    switch( memory_model ) {
    case 'c':
        model = "COMPACT";
        break;
    case 'f':
        model = "FLAT";
        break;
    case 'h':
        model = "HUGE";
        break;
    case 'l':
        model = "LARGE";
        break;
    case 'm':
        model = "MEDIUM";
        break;
    case 's':
        model = "SMALL";
        break;
    case 't':
        model = "TINY";
        break;
    default:
        return;
    }

    if( Options.mode & MODE_IDEAL ) {
        strcpy( buffer, "MODEL " );
    } else {
        strcpy( buffer, ".MODEL " );
    }
    strcat( buffer, model );
    InputQueueLine( buffer );
}