CVT Instruction

Purpose:To convert a Signed quantity to a different data type.
Format:opcode src.rx, dst.wy
Operation:dst <- converted src;
Condition
Codes:
N <- dst LSS 0;
Z <- dst EQL 0;
V <- {src cannot be represented in dst};
C <- 0;
Exceptions:Integer Overflow;
Floating Point Overflow
Reserved Operand (Floating Point)
Opcodes:
99CVTBWConvert Byte to Word 98CVTBLConvert Byte to Long
4CCVTBFConvert Byte to Float 6CCVTBDConvert Byte to Double
33CVTWBConvert Word to Byte 32CVTWLConvert Word to Long
4DCVTWFConvert Word to Float 6DCVTWDConvert Word to Double
F6CVTLBConvert Long to Byte F7CVTLWConvert Long to Word
4ECVTLFConvert Long to Float 6ECVTLDConvert Long to Double
48CVTFBConvert Float to Byte 49CVTFWConvert Float to Word
4ACVTFLConvert Float to Long 4BCVTRFLConvert Rounded Float to Long
56CVTFDConvert Float to Double 68CVTDBConvert Double to Byte
69CVTDWConvert Double to Word 6ACVTDLConvert Double to Long
6BCVTRDLConvert Double Rounded to Long 76CVTDFConvert Double to Float
Description: The source operand is convert to the data type of the destination operand and the destination operand is replaced by the result. The source operand is unaffected.

For integer format, conversion of a shorter data type to a longer data type is done by sign extension. A conversion of a longer data type to a shorter data type is done by truncation of the most significant bit.

For floating format, teh conversions are as follows:
CVTBF exact CVTFB truncated
CVTBD exact CVTDB truncated
CVTWF exact CVTFW truncated
CVTWD exact CVTDW truncated
CVTLF rounded CVTFL truncated
CVTLD exact CVTDL truncated
CVTFD exact CVTDF rounded
CVTRFL rounded CVTRDL rounded

Notes:
1.
Integer overflow occurs if any trucated bits of the source operand are not equal to the sign bit of the destination operand.
2.
Only converts with an integer destination operand can result in an integer overflow. On integer overflow, the destination operand is replaced by the low order bits of the true result.
3.
Only CVTDF can result in floating overflow. On floating overflow, the destination operand is replaced by an operand of all 0 bits except for a sign bit of 1 (a reserved operand). N <- 1; Z &lf- 0; V <-1; and C <- 0.
4.
Only converts with a floating point source operand can result in a reserved operand fault. On a reserved operand fault, the destination operand is unaffected and the condition codes are unpredictable.