void Compile_Logical_X ( Compiler * compiler, int32 op ) { int optFlag = CheckOptimizeOperands ( compiler, 5 ) ; if ( optFlag == OPTIMIZE_DONE ) return ; else if ( optFlag ) { // TODO : this optimization somehow is *very* little used, why is that ?!? // assumes we have unordered operands in eax, ecx _Compile_Group1 ( op, REG, REG, EAX, ECX, 0, 0, CELL ) ; _Compile_TEST_Reg_To_Reg ( EAX, EAX ) ; _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ZERO, N ) ; // not less than 0 == greater than 0 Word *zero = Compiler_WordStack ( compiler, 0 ) ; _Word_CompileAndRecord_PushEAX ( zero ) ; } else { // operands are still on the stack _Compile_Move_StackN_To_Reg ( EAX, DSP, 0 ) ; //_Compile_Group1 ( int32 code, int32 toRegOrMem, int32 mod, int32 reg, int32 rm, int32 sib, int32 disp, int32 osize ) _Compile_Group1 ( op, REG, MEM, EAX, DSP, 0, - 4, CELL ) ; _Compile_Stack_DropN ( DSP, 2 ) ; _Compile_TEST_Reg_To_Reg ( EAX, EAX ) ; _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ZERO, N ) ; // not less than 0 == greater than 0 Word *zero = Compiler_WordStack ( compiler, 0 ) ; _Word_CompileAndRecord_PushEAX ( zero ) ; } }
void Compile_X_Group5 ( Compiler * compiler, int32 op, int32 rlFlag ) { //if ( CheckOptimizeOperands ( _Context_->Compiler0, 4 ) ) int optFlag = CheckOptimizeOperands ( compiler, 5 ) ; if ( optFlag == OPTIMIZE_DONE ) return ; else if ( optFlag ) { if ( compiler->Optimizer->OptimizeFlag & OPTIMIZE_IMM ) { _Compile_MoveImm_To_Reg ( EAX, compiler->Optimizer->Optimize_Imm, CELL ) ; compiler->Optimizer->Optimize_Mod = REG ; compiler->Optimizer->Optimize_Rm = EAX ; } _Compile_Group5 ( op, compiler->Optimizer->Optimize_Mod, compiler->Optimizer->Optimize_Rm, 0, compiler->Optimizer->Optimize_Disp, 0 ) ; _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ZERO, N ) ; // ?? // not less than 0 == greater than 0 if ( compiler->Optimizer->Optimize_Rm == EAX ) { if ( GetState ( _Context_, C_SYNTAX ) ) _Stack_DropN ( _Context_->Compiler0->WordStack, 2 ) ; Word * zero = Compiler_WordStack ( compiler, 0 ) ; Word *one = ( Word* ) Compiler_WordStack ( compiler, - 1 ) ; // there is always only one arg for Group 5 instructions if ( ! ( one->CType & REGISTER_VARIABLE ) ) { _Word_CompileAndRecord_PushEAX ( zero ) ; } } } else { #if 0 if ( rlFlag == LVALUE ) { // assume lvalue on stack Compile_Move_TOS_To_EAX ( DSP ) ; _Compile_Group5 ( op, MEM, EAX, 0, 0, 0 ) ; } else { // assume rvalue on stack _Compile_Group5 ( op, MEM, DSP, 0, 0, 0 ) ; } #else Word *one = ( Word* ) Compiler_WordStack ( compiler, - 1 ) ; if ( one->CType & ( STACK_VARIABLE | LOCAL_VARIABLE | VARIABLE ) ) // *( ( cell* ) ( TOS ) ) += 1 ; { // assume lvalue on stack Compile_Move_TOS_To_EAX ( DSP ) ; _Compile_Group5 ( op, MEM, EAX, 0, 0, 0 ) ; _Compile_Stack_Drop ( DSP ) ; } else { // assume rvalue on stack _Compile_Group5 ( op, MEM, DSP, 0, 0, 0 ) ; } #endif } }
void Compile_X_Group5 ( Compiler * compiler, int32 op ) { //_Set_SCA ( 0 ) ; int optFlag = CheckOptimize ( compiler, 3 ) ; //Word *one = Compiler_WordStack ( - 1 ) ; // assumes two values ( n m ) on the DSP stack Word *one = Compiler_WordList ( 1 ) ; // assumes two values ( n m ) on the DSP stack if ( optFlag & OPTIMIZE_DONE ) return ; else if ( optFlag ) { if ( compiler->optInfo->OptimizeFlag & OPTIMIZE_IMM ) { _Compile_MoveImm_To_Reg ( EAX, compiler->optInfo->Optimize_Imm, CELL ) ; compiler->optInfo->Optimize_Mod = REG ; compiler->optInfo->Optimize_Rm = EAX ; } _Compile_Group5 ( op, compiler->optInfo->Optimize_Mod, compiler->optInfo->Optimize_Rm, 0, compiler->optInfo->Optimize_Disp, 0 ) ; } else if ( one && one->CProperty & ( PARAMETER_VARIABLE | LOCAL_VARIABLE | NAMESPACE_VARIABLE ) ) // *( ( cell* ) ( TOS ) ) += 1 ; { SetHere ( one->Coding ) ; _Compile_GetVarLitObj_RValue_To_Reg ( one, EAX, 1 ) ; //_Compile_Group5 ( int32 code, int32 mod, int32 rm, int32 sib, int32 disp, int32 size ) _Compile_Group5 ( op, REG, EAX, 0, 0, 0 ) ; // ++ == += :: -- == -= so : _Compile_SetVarLitObj_With_Reg ( one, EAX, ECX ) ; } else { // assume rvalue on stack _Compile_Group5 ( op, MEM, DSP, 0, 0, 0 ) ; } _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ZERO_CC, NZ, 3 ) ; // ?? // not less than 0 == greater than 0 }
void _Compile_SET_tttn_REG ( int32 ttt, int32 negFlag, int32 reg ) { _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ttt, negFlag ) ; _Compile_Int8 ( ( byte ) 0x0f ) ; _Compile_Int8 ( ( 0x9 << 4 ) | ( ttt << 1 ) | negFlag ) ; _Compile_Int8 ( _CalculateModRmByte ( REG, 0x00, reg, 0, 0 ) ) ; }
void Compile_X_Group1 ( Compiler * compiler, int32 op, int32 ttt, int32 n ) { int optFlag = CheckOptimize ( compiler, 5 ) ; if ( optFlag == OPTIMIZE_DONE ) return ; else if ( optFlag ) { _Compile_optInfo_X_Group1 ( compiler, op ) ; _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ttt, n, 3 ) ; // not less than 0 == greater than 0 if ( compiler->optInfo->Optimize_Rm != DSP ) // if the result is to a reg and not tos { _Word_CompileAndRecord_PushReg ( Compiler_WordList ( 0 ), compiler->optInfo->Optimize_Reg ) ; //compiler->optInfo->Optimize_Rm ) ; // 0 : ?!? should be the exact variable } } else { Compile_Pop_To_EAX ( DSP ) ; //_Compile_X_Group1 ( int32 code, int32 toRegOrMem, int32 mod, int32 reg, int32 rm, int32 sib, int32 disp, int32 osize ) _Compile_X_Group1 ( op, MEM, MEM, EAX, DSP, 0, 0, CELL ) ; // result is on TOS _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ttt, n, 3 ) ; // not less than 0 == greater than 0 //_Word_CompileAndRecord_PushEAX ( Compiler_WordList ( 0 ) ) ; } }
void Compile_X_Group1 ( Compiler * compiler, int32 op, int32 ttt, int32 n ) { //byte * afterCodePtr ; //if ( CheckOptimizeOperands ( compiler, 5 ) ) int optFlag = CheckOptimizeOperands ( compiler, 5 ) ; if ( optFlag == OPTIMIZE_DONE ) return ; else if ( optFlag ) { // Compile_SUBI( mod, operandReg, offset, immediateData, size ) if ( compiler->Optimizer->OptimizeFlag & OPTIMIZE_IMM ) { _Compile_Group1_Immediate ( op, compiler->Optimizer->Optimize_Mod, compiler->Optimizer->Optimize_Rm, compiler->Optimizer->Optimize_Disp, compiler->Optimizer->Optimize_Imm, CELL ) ; } else { _Compile_Group1 ( op, compiler->Optimizer->Optimize_Dest_RegOrMem, compiler->Optimizer->Optimize_Mod, compiler->Optimizer->Optimize_Reg, compiler->Optimizer->Optimize_Rm, 0, compiler->Optimizer->Optimize_Disp, CELL ) ; } _Compiler_Setup_BI_tttn ( _Context_->Compiler0, ttt, n ) ; // not less than 0 == greater than 0 if ( compiler->Optimizer->Optimize_Rm != DSP ) // if the result is not already tos { if ( GetState ( _Context_, C_SYNTAX ) ) _Stack_DropN ( _Context_->Compiler0->WordStack, 2 ) ; Word * zero = Compiler_WordStack ( compiler, 0 ) ; _Word_CompileAndRecord_PushEAX ( zero ) ; } } else { Compile_Pop_To_EAX ( DSP ) ; _Compile_Group1 ( op, MEM, MEM, EAX, DSP, 0, 0, CELL ) ; //afterCodePtr = Here ; } //return afterCodePtr ; }