Conversion From Floating-Point Number To Unsigned Integer Word; Floating-Point Selection - IBM A2 User Manual

Table of Contents

Advertisement

User's Manual
A2 Processor
fctiw[z] f2,f1
stfd
f2,disp(r1)
lwa
r3,disp+4(r1) #load word algebraic
E.2.2 Conversion from Floating-Point Number to Unsigned Integer Word
The full Convert to Unsigned Integer Word function can be implemented using the following sequence,
assuming that the floating-point value to be converted is in FPR(1), the result is returned in GPR(3), and a
doubleword at displacement disp from the address in GPR(1) can be used as scratch space.
fctiwu[z]
f2,f1
stfd
f2,disp(r1)
lwa
r3,disp+4(r1)
E.3 Floating-Point Selection
This section provides examples of how the fsel instruction can be used to implement floating-point minimum
and maximum functions, and certain simple forms of if-then-else constructions, without branching.
The examples show program fragments in an imaginary, C-like, high-level programming language, and the
corresponding program fragment using fsel and other Book III-E instructions. In the examples, a, b, x, y, and
z are floating-point variables, which are assumed to be in FPRs fa, fb, fx, fy, and fz. FPR fs is assumed to be
available for scratch space.
Programming Note: Care must be taken in using fsel if IEEE 754 compatibility is required, or if the values
being tested can be NaNs or infinities; see Notes on page 863.
Programming Examples
Page 862 of 864
#convert to integer
#store float
#(use lwz on a 32-bit
#implementation)
#convert to unsigned integer
#store float
#load word algebraic
#(use lwz on a 32-bit
#implementation)
Version 1.3
October 23, 2012

Advertisement

Table of Contents
loading

Table of Contents