• Keine Ergebnisse gefunden

Fixed Point Arithmetic

Im Dokument UPDATE NOTICE (Seite 61-67)

User Operations

2.2 Fixed Point Arithmetic

For fixed point arithmetic the PDP-10 has instructions for performing ad- dition, subtraction, multiplication and division of numbers in single and double precision fixed point format ($1.41, although double precision is not instructions that involve only single length numbers and are especially suited for handling smaller integers, particularly those of eighteen bits or less such as addresses, bytes, and character codes. For double precision the add and subtract instructions involve only double length numbers, whereas multiply supplies a quadruple length product, and divide uses a quadruple

tected can only set the arithmetic flags and the hardware does not clear them, so the program must clear them before an instruction if they are to give meaningful information about the instruction afterward. However, the program can check the flags following a series of instructions to determine whether the entire series was free of the types of error detected. Besides indicating error types, the carry flags facilitate performing multiple preci- sion arithmetic.

SUB Subtract

I 274 IM[ A 111 x 1 Y I

0 67 89 12 I3 14 I7 IS 35

Subtract the operand specified by M from AC and place the result in the specified destination If the difference is 2 235 set Trap 1, Overflow and Carry 1; the result stored has a minus sign but a magnitude in positive form equal to the difference less 2 35. If the difference is < -235 set Trap 1, Overflow and Carry 0; the result stored has a plus sign but a magnitude in negative form equal to the difference plus 235. Set both carry flags if the signs of the operands are the same and AC is the greater or the two are equal, or the signs of the operands differ and AC is negative.

SUB Subtract 274

SUBI Subtract immediate 275

SUBM Subtract to Memory 276

SUBB Subtract to Both 297

Multiply

h7 8’3 I2 I.3 14 I7 111 3s

Multiply AC by the operand specified by M, and place the high order word of the double length result in the specified destination. If

M

specifies AC as a destination, place the low order word in AC + 1. If both operands are -235 set Trap 1 and Overflow; the double length result stored is -270.

MUL MULI MULM MULB

Multiply 224

Multiply Immediate 225

Multiply to Memory 226

Multiply to Both 227

CAUTION

In the KAlO,,an AC operand of -235 is treated as though it were + 235, producing the incorrect sign in the product.

User Operations 2-13

IMUL Integer Multiply

220 piq A 111 x 1 Y

0 61 89 12 13 14 17 18 35

Multiply AC by the operand specified by M, and place the sign and the 35 low order magnitude bits of the product in the specified destination. Set Trap 1 and Overflow if the product is 2 235 or < -235 (i.e. if the high order word of the double length product is not null); the high order word is lost.

IMUL IMULI IMULM IMULB

Integer Multiply

Integer Multiply Immediate Integer Multiply to Memory Integer Multiply to Both

220 221 222 223

DIV Divide

234 IM] A 111 X 1 Y 1

0 67 89 I2 13 14 17 I8 35

If the high order word of the magnitude of the double length number in AC,AC + 1 is greater than or equal to the magnitude of the operand speci- fied by M, set Trap 1, Overflow and No Divide, and go immediately to the next instruction without affecting the original AC or memory operand in any way. Otherwise divide the double length number contained in AC,AC + 1 by the specified operand, calculating a quotient of 35 magnitude bits including leading zeros Place the unrounded quotient in the specified destination. If M specifies AC as a destination, place the remainder, with the same sign as the dividend, in AC + 1.

DIV Divide 234

DIVI Divide Immediate 235

DIVM Divide to Memory 236

DIVB Divide to Both 237

Notes. The magnitude restriction is required since the quotient devel- oped would exceed 36 bits.

IDIV Integer Divide

230 IA41 A 111 X 1 Y I

0 67 89 12 13 14 17 18 35

If the operand specified by M is zero, or AC contains -235 and the operand specified by M is -1 (except in the KSlO), set Trap 1, Overflow and No Divide, and go immediately to the next instruction without affecting the original AC or memory operand in any way. Otherwise divide AC by the

2-14 User Operations June 1982

-’

i

specified operand, calculating a quotient of 36 magnitude bits including leading zeros. Place the unrounded quotient in the specified destination If M specifies AC as the destination, place the remainder, with the same sign as the dividend; in AC + 1.

IDIV integer Divide 230

IDlVl Integer Divide Immediate 231

IDIVM Integer Divide to Memory 232

IDIVB Integer Divide to Both 233

CAIJTION

In the KSlO, dividing -235 by -1 gives -235 with no error indication. In the KAlO, KIlO, and a KLlO with microcode version before 271 (which includes all single-section KLlOs), the overflow action is also triggered by attempting to divide -2% by + 1.

Double Precision Instructions4

There are just four instructions for the four basic operations, and they have no modes. All use AC and memory operands and place the result in the accumulators. Memory operands are double length in location

E,E +

1. Most AC operands are double length in AC,AC + 1, but products and dividends are quadruple length in AC,AC + l,AC + 2,AC + 3, and the double length remainder in division is placed in AC +2,AC +3. Double length numbers have the same format as the products and dividends of single precision instructions discussed above. In quadruple length numbers AC contains the highest order word; the magnitude is the 140-bit string in bits 1-35 of the four words, the sign is in bit 0 of the highest order word, and copies of the sign are kept in bit 0 of the other three words.

DADD Double Add

I

114 1 A 111 x 1 Y 1

u a9 I2 13 14 17 18 35

Add the operand in location

E,E + 1

to AC,AC + 1 and place the result in AC,AC + 1. If the sum is 3 270, set Trap 1, Overflow and Carry 1; the result stored has a minus sign but a magnitude in positive form equal to the sum less 270. If the sum is < -270, set Trap 1, Overflow and Carry 0; the result stored has a plus sign but a magnitude in negative form equal to the sum plus 270. Set both flags if both summands are negative, or their signs differ and their magnitudes are equal or the positive one is the greater in magnitude.

4 In the KIlO and KAlO these instructions are trapped as unassigned codes.

June 1982 User Operations 2-15

DSUB Double Subtract

IJ a9 12 1314 17 18 35

Subtract the operand in location

E,E +

1 from AC,AC + 1 and place the re- sult in AC,AC + 1. If the difference is 2 270, set Trap 1, Overflow and Carry 1; the result stored has a minus sign but a magnitude in positive form equal to the difference less 2 70. If the difference is < -270, set Trap 1, Overflow and Carry 0; the result stored has a plus sign but a magnitude in negative form equal to the difference plus 2 70. Set both carry flags if the signs of the operands are the same and AC,AC + 1 is the greater or the two are equal, or the signs of the operands differ and AC,AC + 1 is negative.

DMUb Double Multiply

I 116 1 A IfI X 1 Y I

0 a9 12 1314 17 IO 35

Multiply AC,AC + 1 by the operand in location

E,E +

1 and place the result in AC-AC +3. If both operands are -270, set Trap 1 and Overflow; the quadruple length result stored is -214’.

DDIV Double Divide

I 117 A I X Y 1

0 a9 12 1314 17 la 35

If the high order doubleword of the magnitude of the quadruple length number in AC-AC +3 is greater than or equal to the magnitude of the operand in location

E,E +

1, set Trap 1, Overflow and No Divide, and go immediately to the next instruction without affecting the original AC or memory operand in any way. Otherwise divide the quadruple jength num- ber contained in the accumulators by the operand in location

E,E +

1, calcu- lating a quotient of 70 magnitude bits including leading zeros. Place the unrounded quotient in AC,AC + 1, and the double length remainder, with the same sign as the dividend, in AC + 2,AC + 3.

-

2-16 User Operations

Im Dokument UPDATE NOTICE (Seite 61-67)