CVT

VAX11

 

CVT     CONVERT

 

Purpose

convert a signed quantity to a different signed data type

Format

opcode src.rx, dst.wy

Operation

dst ß conversion of src;

Condition codes

N ß dst LSS 0;

Z ß dst EQL 0;

V ß {src cannot be represented in dst};

C ß 0;

Exceptions

Integer overflow

Floating overflow

Reserved operand

Operation codes

99        CVTBW          Convert Byte to Word

98        CVTBL            Convert Byte to Long

33        CVTWB          Convert Word to Byte

32        CVTWL          Convert Word to Long

F6        CVTLB            Convert Long to Byte

F7        CVTLW          Convert Long to Word

4C       CVTBF            Convert Byte to Floating

6C       CVTBD           Convert Byte to Double.

4D       CVTWF          Convert Word to Floating

6D       CVTWD          Convert Word to Double

4E        CVTLF            Convert Long to Floating

6E        CVTLD           Convert Long to Double

48        CVTFB            Convert Floating to Byte

68        CVTDB           Convert Double to Byte

49        CVTFW          Convert Floating to Word

69        CVTDW          Convert Double to Word

4A       CVTFL            Convert Floating to Long

4B        CVTRFL         Convert Rounded Floating to Long

6A       CVTDL           Convert Double to Long

6B        CVTRDL         Convert Rounded Double to Long

56        CVTFD           Convert Floating to Double

76        CVTDF           Convert Double to Floating

Description

The source operand is converted to the data type of the destination operand and the destination operand is replaced by the result. For integer format, conversion of a shorter data type to a longer is done by sign extension; conversion of longer to a shorter is done by truncation of the higher numbered (most significant) bits. For floating format, the form of the con version is as follows:

CVTBF            exact                            CVTFW          truncated

CVTBD           exact                            CVTDW          truncated

CVTWF          exact                            CVTFL            truncated

CVTWD          exact                            CVTRFL         truncated

CVTLF            rounded                        CVTDL           truncated

CVTLD           exact                            CVTRDL         rounded

CVTFB            truncated                      CVTFD           exact

CVTDB           truncated                      CVTDF           rounded

Notes

1. Integer overflow occurs if any truncated 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 integer overflow. On integer overflow, the destination operand is replaced by the low order bits of the true results.

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 ß 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 in unaffected and the condition codes are unpredictable.

 

Example 1

 

 

.text

main: .word 0

 

      movb $-1, r1

      cvtbw r1, r2      # r2 will contain 0xFFFF

 

      clrl r2

 

      movl $0x123, r1

      cvtlb r1   , r2   # r2 will contain 0x23. V = 1

 

      halt