Back
MASM : CONVERSION : ITOF
ITOF:

Syntax:

Description:

The ITOF (integer to float) instruction interprets the data stored on the two banks of register Rs0 as 64-bit integer numbers, and yields their double precision (64-bits) floating point representations. The result is then written to register Rd3 according to the bank select Bs3. The data on Rs0 is accessed through Port0 of the register file, and the result is written via Port3 of the register file. The scheme of conversion is presented below.

A double precision floating point bit string f[63:0] encodes three values:

  • The sign bit: s = f[63]

  • The exponent: e = f[62:52]

  • The mantissa: m = f[51:0]

The value represented by f[63:0] is given by:

val(f[63:0]) = (-1)s * 2(e-0x3ff) * (1 + f[51]*2-1 + f[50]*2-2 + ... + f[0]*2-52)

Thus, the conversion process of a 64-bit integer string i[63:0] into a 64-bit floating point string f[63:0] consists of finding the values of s, e and m. These are found in the following steps:

    if (i[63] == 1) then s = 1 else s = 0

Having found the sign bit, we assume below that i[63:0] is positive.

    e = msb(i[63:0]) + 0x3ff

where msb denotes the most significant bit

    if (msb(i[63:0]) <= 52)
    then
        m = i[msb-1:0] << (52-msb) (non-rounding case)
    else
        m  = i[msb-1:0] >> (msb-52)
        sb = or( i[msb-54:0] )   ( sb = sticky-bit )
        rb = i[msb-53]           ( rb = round-bit  )
        lb = i[msb-52]           ( lb = least-significant-bit )
        if((lb == 1 && rb == 1 && sb == 0) || (rb == 1 && sb == 1))
            then 
                m = m + 1
                e = e + m[52]

Example:

	i   = 0x7ffffffffffffe00
	s   = 0
	msb = 62
	e   = 62 + 0x3ff = 0x43d
	m   = ( 0x3ffffffffffffe00 ) >> 10 = 0x000fffffffffffff
	sb  = or( i[8:0] ) = 0
	rb  = i[9]  = 1
	lb  = i[10] = 1
	m   = 0x000fffffffffffff + 1 = 0x0010000000000000
	e   = e + 1 = 0x43e
	f   = s | ( e << 52 ) | m[51:0] = 0x43e0000000000000

Microcode Pattern:

Takes 6 cycles to execute.
    Example: ITOF 0xb 2 0xa

	  
MPC  BS3 C3 P3 P2 P1 P0
-----------------------
I2F  0    0 00 00 00 0a
 -   0    0 00 00 00 00
 -   0    0 00 00 00 00
 -   0    0 00 00 00 00
 -   0    0 00 00 00 00
 -   2    0 0b 00 00 00

	  
Exceptions :

None

Example :

ITOF 0xb 2 0xa  
	!! writes the double representation of the
	!! high bank of register 0xa into the high
	!! bank of register 0xb (Note: Bs3 = 2, high)

APE Group Zeuthen. 2003
$Id
$Id: syntax.php,v 1.8 2004/08/04 09:25:34 noe Exp $