GBDKライブラリドキュメント
GBDK libraries documentation

Prev
5章 ライブラリ
Chapter 5.Libraries

Next

浮動小数点サポート - fp_long.s
Floating point support - fp_long.s

数形式
Number format

GBDKの中で使用される数符号づけは実装することがより容易な形フィートポンドオペレーションに選ばれました。 Unfortunatly、それ、doesnt、任意の標準だがそれに一致する、ルーチンの促進をサポートします。 より低い3バイトが仮数を含んでいる一方、高いバイトは符号と結果を含んでいます。
The number encoding used in GBDK was chosen make fp operations easier to implement.Unfortunatly it doesnt conform to any standards but it does help speed the routines.The high byte contains the sign and exponent, while the lower three bytes contain the mantissa.

結果の最も重要なビットは数が負の場合、セットされる符号ビットです。 より低い7ビットは0x40のまわりで偏見的である結果です。 仮数は標準化され、最も重要なビット中の通常暗黙のものを含んでいます。 負の数のための仮数が2補足の中にないことに注目します。 0は、0である仮数と結果の両方によってどちらかによって表わされます。
The most significant bit of the exponent is the sign bit which is set if the number is negative.The lower seven bits are the exponent biased around 0x40.The mantissa is normalised and includes the normally implicit one in the most significant bit.Note that the mantissa for a negative number is not in twos complement.A zero is represented by either by both the mantissa and exponent being zero.

いくつかの例:
Some examples:


Notes

コア浮動小数点ライブラリ関数fadd、fdiv、fsub、fmulは、 HI-TECH SoftwareフリーのCP/M Cコンパイラの中のアルゴリズムにはじめに基づきました。 しかしながら、コードは完全に再度書かれており、最適化されており、HI-TECHのコードとの通過する類似点を今単に運びます。
The core floating point library functions fadd, fdiv, fsub and fmul were originally based on the algorithims in HI-TECH Software 's free CP/M C compiler.However the code has been almost completly re-written and optimised and now only bears a passing resemblance to HI-TECH's code.

関数の左側の引数はHLDEに、右側はスタックのトップに格納されます。 ほとんどの関数はRAMの中で静的雑記用のレジスタを使用します、どれ、不運に手段リエントラントではありません。 このセクションの関数のほぼすべてがfloatを引数としてfloatを返します、形式は次のセクションとは異なります。
The left hand argument to a function is stored in HLDE and the right hand on the top of the stack.Most functions use static scratch registers in RAM which unfortunatly means that they arnt re-enterant.As almost all of the functions in this section take floats as parameters and return floats, the format is different to the following sections.

関数
Functions

.fadd32
.fadd32

解説
Description

HLDE上で浮動小数点付加物とスタック上の浮動小数点数を実行する、削除されたスタック数を備えたHLDEに結果を返しします。
Perform a floating point addition on HLDE and the floating point number on the stack, returining the result in HLDE with the stack number removed.

手法
Method

2つのオペランドは回復されます、またスタックunjunked。 符号はオペランドと比較された大きさの両方から取り除かれます。 大きさの差が24ビット以上の場合、より大きな数が返されます。 そうでなければ、より小さな数は右シフトされます。また、両方が同じ大きさを持っているまで、その大きさは増加します。 オペランドがはじめに負だった場合、その大きさが負されます。 大きさは加えられます。また、新しい仮数は計算しました。
The two operands are recovered and the stack unjunked.The sign is removed from both operands and the magnitudes compared.If the difference in magnitude is greater than 24 bits then the greater number is returned.If not, the smaller number is shifted right and its magnitude increased until both have the same magnitude.If an operand was originally negative, its magnitude is negated.The magnitudes are added and the new mantissa computed.

.fsub32
.fsub32

解説
Description

HLDEの中の値からスタック上の浮動小数点数を減算し、HLDEに結果を返します。
Subtract the floating point number on the stack from the value in HLDE, returning the result in HLDE

手法
Method

スタックオペランドの符号ビットをトグルします。 右オペランドを負するスタックオペランド上の符号ビットが、トグルで留められます。 その後、実行は .fadd32 に渡ります。
The sign bit on the stack operand is toggled which negates the right operand.Execution then falls through to .fadd32

.fmul32
.fmul32

解説
Description

HLDEの中の数とスタック上の数で浮動小数点乗算を実行します。 HLDEに結果を返し、スタックオペランドを削除します。
Performs a floating point multiplication on the number in HLDE and the one on the stack.Returns the result in HLDE with the stack operand removed.

手法
Method

積は、HLBC、DE.ft1.ft0の中の右オペランドと、.fw.の中の左オペランドに最初に格納されます、積はzeroedされます、乗算は2つのオペランドの仮数の上で行われます。 乗算は標準(右シフト-加える、場合、キャリー)であるが、最大の48の代わりに32ビット以内の結果を維持する、少数の策略を使用します。 その後、Hが0であるまで、HLDEは下へ変えられます。 変更の数は合成の結果を与えるために2つのオペランドの結果に加えられます。 最終的に、符号ビットは、オペランドの符号のXORによって計算されます。
The product is stored in HLBC, the right hand operand in DE.ft1.ft0 and the left hand operand in .fw. First the product is zeroed then a multiplication is done on the mantissas of the two operands.The multiply is a standard (right shift - add if carry) but uses a few tricks to keep the result within 32 bits instead of the maximum 48.HLDE is then shifted down until H is zero.The number of shifts is added to the exponents of the two operands to give the resultant exponent.Finally the sign bit is computed by a XOR of the signs of the operands.

.fdiv32
.fdiv32

解説
Description

スタック上の値によってHLDEに浮動小数点数を除算します。 withtにHLDEとスタックunjunkedの中の結果を返します。
Divide the floating point number in HLDE by the value on the stack.Return witht the result in HLDE and the stack unjunked.

手法
Method

除数はHLBC、DE.fw1.fw0の中の被除数と、被除数の仮数が割られる.q.の中のquotentに格納されます、除数の仮数。 これは標準を使用します、匹敵する(引き算をする、場合、未満で)2つの手法によって乗算します。 その後、商はHLDEにコピーされ、Hが0であるまで、ちょうど回転します。 結果は、左オペランドの結果に変更の数を加えてと右オペランドの結果を引くことによって計算されます。 符号ビットはオペランドの符号のXORを使用して、計算されます。
The divisor is stored in HLBC, the dividend in DE.fw1.fw0 and the quotent in .q. The mantissa of the dividend is divided by the mantissa of the divisor.This uses the standard compare - subtract if less than - multiply by two method.The quotient is then copied into HLDE and rotated right until H is zero.The exponent is calculated by adding the number of shifts to the exponent of the left operand and subtracting the exponent of the right operand.The sign bit is calculated using an XOR of the sign of the operands.



Prev
ホーム
Home

Next
ライブラリ
Libraries

Up
フルスクリーングラフィックス - drawing.h
Full screen graphics - drawing.h
 1