📄 float.c
字号:
DoubleOperand1.Sign = 0; return KiNormalizeDouble(&ContextBlock, &DoubleOperand1, 0); } else { break; } // // Floating move operation. // // Floating move is accomplished by moving the source operand // to the destination register. // case FLOAT_MOVE: if (Format == FORMAT_SINGLE) { // // Normalize the result and store in the destination // register. // return KiNormalizeSingle(&ContextBlock, &SingleOperand1, 0); } else if (Format == FORMAT_DOUBLE) { // // Normalize the result and store in the destination // register. // return KiNormalizeDouble(&ContextBlock, &DoubleOperand1, 0); } else { break; } // // Floating negate operation. // // Floating absolute is accomplished by complementing the sign // of the floating value. // case FLOAT_NEGATE: if (Format == FORMAT_SINGLE) { // // Complement the sign, normalize the result, and store in the // destination register. // SingleOperand1.Sign ^= 0x1; return KiNormalizeSingle(&ContextBlock, &SingleOperand1, 0); } else if (Format == FORMAT_DOUBLE) { // // Complement the sign, normalize the result, and store in the // destination register. // DoubleOperand1.Sign ^= 0x1; return KiNormalizeDouble(&ContextBlock, &DoubleOperand1, 0); } else { break; } // // Floating compare single. // // This operation is performed after having separated out NaNs, // and therefore the only comparison predicates left are equal // and less. // // Floating compare single is accomplished by comparing signs, // then exponents, and finally the mantissa if necessary. // // N.B. The sign of zero is ignored. // case FLOAT_COMPARE_SINGLE: // // If either operand is zero, then set the sign of the operand // positive. // if ((SingleOperand1.Infinity == FALSE) && (SingleOperand1.Mantissa == 0)) { SingleOperand1.Sign = 0; SingleOperand1.Exponent = - 23; } if ((SingleOperand2.Infinity == FALSE) && (SingleOperand2.Mantissa == 0)) { SingleOperand2.Sign = 0; SingleOperand2.Exponent = - 23; } // // Compare signs first. // if (SingleOperand1.Sign < SingleOperand2.Sign) { // // The first operand is greater than the second operand. // CompareEqual = FALSE; CompareLess = FALSE; } else if (SingleOperand1.Sign > SingleOperand2.Sign) { // // The first operand is less than the second operand. // CompareEqual = FALSE; CompareLess = TRUE; } else { // // The operand signs are equal. // // If the sign of the operand is negative, then the sense of // the comparison is reversed. // if (SingleOperand1.Sign == 0) { // // Compare positive operand with positive operand. // if (SingleOperand1.Exponent > SingleOperand2.Exponent) { CompareEqual = FALSE; CompareLess = FALSE; } else if (SingleOperand1.Exponent < SingleOperand2.Exponent) { CompareEqual = FALSE; CompareLess = TRUE; } else { if (SingleOperand1.Mantissa > SingleOperand2.Mantissa) { CompareEqual = FALSE; CompareLess = FALSE; } else if (SingleOperand1.Mantissa < SingleOperand2.Mantissa) { CompareEqual = FALSE; CompareLess = TRUE; } else { CompareEqual = TRUE; CompareLess = FALSE; } } } else { // // Compare negative operand with negative operand. // if (SingleOperand2.Exponent > SingleOperand1.Exponent) { CompareEqual = FALSE; CompareLess = FALSE; } else if (SingleOperand2.Exponent < SingleOperand1.Exponent) { CompareEqual = FALSE; CompareLess = TRUE; } else { if (SingleOperand2.Mantissa > SingleOperand1.Mantissa) { CompareEqual = FALSE; CompareLess = FALSE; } else if (SingleOperand2.Mantissa < SingleOperand1.Mantissa) { CompareEqual = FALSE; CompareLess = TRUE; } else { CompareEqual = TRUE; CompareLess = FALSE; } } } } // // Form the condition code using the comparison information // and the compare function predicate bits. // if (((CompareLess != FALSE) && ((CompareFunction & COMPARE_LESS_MASK) != 0)) || ((CompareEqual != FALSE) && ((CompareFunction & COMPARE_EQUAL_MASK) != 0))) { ((PFSR)&pctx->Fsr)->CC = 1; } else { ((PFSR)&pctx->Fsr)->CC = 0; } pctx->Fir = ContextBlock.BranchAddress; return TRUE; // // Floating compare double. // // This operation is performed after having separated out NaNs, // and therefore the only comparison predicates left are equal // and less. // // Floating compare double is accomplished by comparing signs, // then exponents, and finally the mantissa if necessary. // // N.B. The sign of zero is ignored. // case FLOAT_COMPARE_DOUBLE: // // If either operand is zero, then set the sign of the operand // positive. // if ((DoubleOperand1.Infinity == FALSE) && (DoubleOperand1.MantissaHigh == 0)) { DoubleOperand1.Sign = 0; DoubleOperand1.Exponent = - 52; } if ((DoubleOperand2.Infinity == FALSE) && (DoubleOperand2.MantissaHigh == 0)) { DoubleOperand2.Sign = 0; DoubleOperand2.Exponent = - 52; } // // Compare signs first. // if (DoubleOperand1.Sign < DoubleOperand2.Sign) { // // The first operand is greater than the second operand. // CompareEqual = FALSE; CompareLess = FALSE; } else if (DoubleOperand1.Sign > DoubleOperand2.Sign) { // // The first operand is less than the second operand. // CompareEqual = FALSE; CompareLess = TRUE; } else { // // The operand signs are equal. // // If the sign of the operand is negative, then the sense of // the comparison is reversed. // if (DoubleOperand1.Sign == 0) { // // Compare positive operand with positive operand. // if (DoubleOperand1.Exponent > DoubleOperand2.Exponent) { CompareEqual = FALSE; CompareLess = FALSE; } else if (DoubleOperand1.Exponent < DoubleOperand2.Exponent) { CompareEqual = FALSE; CompareLess = TRUE; } else { if (DoubleOperand1.MantissaHigh > DoubleOperand2.MantissaHigh) { CompareEqual = FALSE; CompareLess = FALSE; } else if (DoubleOperand1.MantissaHigh < DoubleOperand2.MantissaHigh) { CompareEqual = FALSE; CompareLess = TRUE; } else { if (DoubleOperand1.MantissaLow > DoubleOperand2.MantissaLow) { CompareEqual = FALSE; CompareLess = FALSE; } else if (DoubleOperand1.MantissaLow < DoubleOperand2.MantissaLow) { CompareEqual = FALSE; CompareLess = TRUE; } else { CompareEqual = TRUE; CompareLess = FALSE; } } } } else { // // Compare negative operand with negative operand. // if (DoubleOperand2.Exponent > DoubleOperand1.Exponent) { CompareEqual = FALSE; CompareLess = FALSE; } else if (DoubleOperand2.Exponent < DoubleOperand1.Exponent) { CompareEqual = FALSE; CompareLess = TRUE; } else { if (DoubleOperand2.MantissaHigh > DoubleOperand1.MantissaHigh) { CompareEqual = FALSE; CompareLess = FALSE; } else if (DoubleOperand2.MantissaHigh < DoubleOperand1.MantissaHigh) { CompareEqual = FALSE; CompareLess = TRUE; } else { if (DoubleOperand2.MantissaLow > DoubleOperand1.MantissaLow) { CompareEqual = FALSE; CompareLess = FALSE; } else if (DoubleOperand2.MantissaLow < DoubleOperand1.MantissaLow) { CompareEqual = FALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -