Пример #1
0
void
_Compile_Call_NoOptimize ( byte * callAddr )
{
    int32 imm = _CalculateOffsetForCallOrJump ( Here + 1, callAddr, 0 ) ;
    // _Compile_InstructionX86 ( opCode, mod, reg, rm, modFlag, sib, disp, imm, immSize )
    _Compile_InstructionX86 ( CALLI32, 0, 0, 0, 0, 0, 0, imm, INT_T ) ;
    // push rstack here + 5
    // _Compile_MoveImm_To_Reg ( EAX, callToAddr, CELL ) ;
    //_Compile_JumpToReg ( EAX ) ;
}
Пример #2
0
void
Compile_JCC ( int32 negFlag, int32 ttt, byte * jmpToAddr )
{
    unsigned int disp ;
    if ( jmpToAddr )
    {
        disp = _CalculateOffsetForCallOrJump ( Here + 1, jmpToAddr, 1 ) ;
    }
    else disp = 0 ; // allow this function to be used to have a delayed compile of the actual address
    _Compile_JCC ( negFlag, ttt, disp ) ;
}
Пример #3
0
void
_Compile_JCC ( int32 negFlag, int32 ttt, byte * jmpToAddr )
{
    unsigned int disp ;
    if ( jmpToAddr )
    {
        disp = _CalculateOffsetForCallOrJump ( Here + 1, jmpToAddr, 1 ) ;
    }
    else disp = 0 ; // allow this function to be used to have a delayed compile of the actual address
    _Compile_Int8 ( 0xf ) ; // little endian ordering
    _Compile_Int8 ( 0x8 << 4 | ttt << 1 | negFlag ) ; // little endian ordering
    _Compile_Int32 ( disp ) ;
}
Пример #4
0
void
_Compile_JumpToAddress ( byte * jmpToAddr ) // runtime
{
#if 1
    if ( jmpToAddr != ( Here + 5 ) ) // optimization : don't need to jump to the next instruction
    {
        int imm = _CalculateOffsetForCallOrJump ( Here + 1, jmpToAddr, 1 ) ;
        // _Compile_InstructionX86 ( opCode, mod, reg, rm, modFlag, sib, disp, imm, immSize )
        _Compile_InstructionX86 ( 0xe9, 0, 0, 0, 0, 0, 0, imm, INT ) ; // with jmp instruction : disp is compiled an immediate offset
    }
#else
    _Compile_MoveImm_To_EAX ( jumpToAddr ) ;
    _Compile_Group5 ( JMP, 0, 0, 0, 0 ) ;
#endif
}
Пример #5
0
void
_Compile_Call ( byte * callAddr )
{
#if 0 // ABI == 64 // ?? why doesn't this work ??
    //_Compile_MoveImm_To_Reg ( EAX, (cell) callAddr, CELL ) ;
    //_CompileInstructionX86 ( 0, CALL_JMP_MOD_RM, 0, 2, EAX, 1, 0, 0, 0, CELL_T ) ; // 2 : for call

    _Compile_MoveImm_To_Reg ( EAX, ( int32 ) callAddr, INT ) ;
    _Compile_Group5 ( CALL, 0, 0, 0, 0 ) ;
#else
    {
        int32 imm = _CalculateOffsetForCallOrJump ( Here + 1, callAddr, 1 ) ;
        // _Compile_InstructionX86 ( opCode, mod, reg, rm, modFlag, sib, disp, imm, immSize )
        _Compile_InstructionX86 ( CALLI32, 0, 0, 0, 0, 0, 0, imm, INT_T ) ;
    }
#endif
}
Пример #6
0
void
_SetOffsetForCallOrJump ( byte * compileAtAddress, byte * jmpToAddr, int32 optimizeFlag )
{
    int32 offset = _CalculateOffsetForCallOrJump ( compileAtAddress, jmpToAddr, optimizeFlag ) ;
    * ( ( int32* ) compileAtAddress ) = offset ;
}
Пример #7
0
void
Compile_Call ( byte * callAddr )
{
    int32 imm = _CalculateOffsetForCallOrJump ( Here + 1, callAddr, 1 ) ;
    _Compile_Call ( imm ) ;
}