14.06.2015 Views

Power ISA™ Version 2.03 - Power.org

Power ISA™ Version 2.03 - Power.org

Power ISA™ Version 2.03 - Power.org

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Version</strong> <strong>2.03</strong><br />

RN Rounding Mode<br />

00 Round to Nearest<br />

01 Round toward Zero<br />

10 Round toward +Infinity<br />

11 Round toward -Infinity<br />

Let Z be the intermediate arithmetic result or the operand<br />

of a convert operation. If Z can be represented<br />

exactly in the target format, then the result in all rounding<br />

modes is Z as represented in the target format. If Z<br />

cannot be represented exactly in the target format, let<br />

Z1 and Z2 bound Z as the next larger and next smaller<br />

numbers representable in the target format. Then Z1 or<br />

Z2 can be used to approximate the result in the target<br />

format.<br />

Figure 50 shows the relation of Z, Z1, and Z2 in this<br />

case. The following rules specify the rounding in the<br />

four modes. “LSB” means “least significant bit”.<br />

Z2<br />

Z<br />

Z1<br />

Negative values<br />

By Incrementing LSB of Z<br />

Infinitely Precise Value<br />

By Truncating after LSB<br />

0<br />

Positive values<br />

Z2<br />

Z<br />

Z1<br />

Figure 50. Selection of Z1 and Z2<br />

Round to Nearest<br />

Choose the value that is closer to Z (Z1 or<br />

Z2). In case of a tie, choose the one that is<br />

even (least significant bit 0).<br />

Round toward Zero<br />

Choose the smaller in magnitude (Z1 or Z2).<br />

Round toward +Infinity<br />

Choose Z1.<br />

Round toward -Infinity<br />

Choose Z2.<br />

See Section 4.5.1, “Execution Model for IEEE Operations”<br />

on page 103 for a detailed explanation of rounding.<br />

4.4 Floating-Point Exceptions<br />

This architecture defines the following floating-point<br />

exceptions:<br />

Invalid Operation Exception<br />

SNaN<br />

Infinity-Infinity<br />

Infinity÷Infinity<br />

Zero÷Zero<br />

Infinity×Zero<br />

Invalid Compare<br />

Software-Defined Condition<br />

Invalid Square Root<br />

Invalid Integer Convert<br />

Zero Divide Exception<br />

Overflow Exception<br />

Underflow Exception<br />

Inexact Exception<br />

These exceptions, other than Invalid Operation Exception<br />

due to Software-Defined Condition, may occur during<br />

execution of computational instructions. An Invalid<br />

Operation Exception due to Software-Defined Condition<br />

occurs when a Move To FPSCR instruction sets<br />

FPSCR VXSOFT to 1.<br />

Each floating-point exception, and each category of<br />

Invalid Operation Exception, has an exception bit in the<br />

FPSCR. In addition, each floating-point exception has a<br />

corresponding enable bit in the FPSCR. The exception<br />

bit indicates occurrence of the corresponding exception.<br />

If an exception occurs, the corresponding enable<br />

bit governs the result produced by the instruction and,<br />

in conjunction with the FE0 and FE1 bits (see page 99),<br />

whether and how the system floating-point enabled<br />

exception error handler is invoked. (In general, the<br />

enabling specified by the enable bit is of invoking the<br />

system error handler, not of permitting the exception to<br />

occur. The occurrence of an exception depends only on<br />

the instruction and its inputs, not on the setting of any<br />

control bits. The only deviation from this general rule is<br />

that the occurrence of an Underflow Exception may<br />

depend on the setting of the enable bit.)<br />

A single instruction, other than mtfsfi or mtfsf, may set<br />

more than one exception bit only in the following cases:<br />

Inexact Exception may be set with Overflow<br />

Exception.<br />

Inexact Exception may be set with Underflow<br />

Exception.<br />

Invalid Operation Exception (SNaN) is set with<br />

Invalid Operation Exception (∞×0) for Multiply-Add<br />

instructions for which the values being multiplied<br />

are infinity and zero and the value being added is<br />

an SNaN.<br />

Invalid Operation Exception (SNaN) may be set<br />

with Invalid Operation Exception (Invalid Compare)<br />

for Compare Ordered instructions.<br />

Invalid Operation Exception (SNaN) may be set<br />

with Invalid Operation Exception (Invalid Integer<br />

Convert) for Convert To Integer instructions.<br />

98<br />

<strong>Power</strong> ISA -- Book I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!