• Aucun résultat trouvé

Table 8-5. Decimal Arithmetic Sign Conventions

Dans le document Honeywell 2040 (Page 177-181)

OPERATION A-FIELD B-FIELD

TYPE OF ADD SIGN OF RESULT

SIGN SIGN

+

True

+

(Bit configuration of B)

+ -

Complement .Normalized sign of the

ADD operand of greater value

+

Complement (- = 10,

+ =

01)

- -

True

--

True

-+ +

Complement Normalized sign of the

SUBTRACT operand of greater value

Complement

(- =

10,

+

= 01)

- + -

True

+

(Bit configuration of B)

INDICATORS

Two indicators are set at the completion of every dec~rnal add and subtract operation:

the overflow indicator and the zero balance indicator. If a result is greater than the size of the B-field, the overflow indicator is turned on; if such a carry is not generated, the indicator is

. 1 2

unchanged.' The zero balance indicator signifie s either a zero or a nonzero sum. When a decimal operation produces a result equal to 0 (regardless of sign), the zero balance indicator is turned on; when the result of the operation does not equal 0, the indicator is turned off (the indicator is always turned on at the beginning of execution of a decimal add or subtract instruction).

The se indicator s are also set by decimal multiply and divide operations. The overflow indicator is turned on when a Decimal Divide instruction is performed in which the divisor is equal to O. The zero balance indicator is turned on if the product of a decimal multiply opera-tion is equal to O.

The settings of these indicators can be tested by a Branch on Condition Test instruction.

This instruction automatically turns off the overflow indicator. 2 The zero balance indicator is not changed by the branch instruction to te st it, but is changed only by the next decimal

arithm.etic instruction.

MULTIPLICA TION

The Multiply instruction causes the signed decimal integer in the A field (the multiplicand) to be multiplied by the signed decimal integer (the multiplier) which is stored in the leftmost locations of the B field. The signed product is stored, right-justified, in the B field.

lOnly a "true add" operation can turn the overflow indicator on (see Table 8-5).

2 The overflow indicator is turned off only when tested by the BCT instruction.

The B field must be large enough to insure an adequate number of locations for the develop-ment and storage of the product. Its length is therefore defined as the number of locations in the multiplier, plus the number of locations in the multiplicand, plus one (see Figure 8-3).

OPERATION:

aaaa

X

bbb

rFI::~~

LOCATION - . A .. 3A..,2A-l A CONTENTS -.

0

a a a

MULTIPLICAND (4 locations)

r

B FIELD (4+3+1 = 8 locations)~

B ADDRESpl t_

eBb

b

MULTIPLIER (3 locations)

Figure 8-3. A- and B -Fields in Multiply Operation

Word marks are required in the leftmost locations of the multiplicand and the multiplier.

All other locations in the B field must be clear of word marks. As shown in Figure 8-3, the rightmost location of the multiplier is defined as B - Na - 1, where B is the B address and Na is the number of locations in the A field.

The zone bits in the units positions of the multiplier and the multiplicand indicate the signs of the operands. The signs of these factors indicate the sign of the pr oduct according to the algebraic sign conventions shown in Table 8-6. The sign of the product is expressed in its normalized form (minus = 10, plus = 01).

Table 8-6. Multiply Sign Conventions

Sign of Multiplicand +

- +

-Sign of Multiplier +

- -

+

Sign of Product

+ + -

-Consider the following Decirn.al Multiply instruction.

EASYCODER

COOING FORM

PROBLEM _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ PROGRAMMER _ _ _ _ _ _ OATE _ _ _ _ _ PAGE_OF_

CARD

ii

LOCATION OPERATION OPERANDS

NUMBER eOOE

1 213 415 6 7 8 1415 2021 6263

I

:

At 5Q~ 7.,fA

Location 500 is the rightrn.ost location of a four-character field. Location 700 is the rightrn.ost location of an eight-character field. Location 695 (i. e., 700 - 4 - 1) is the right-rn.o st location of the rn.ultiplier.

80

LOCATION ~

CONTENTS ..

A ADDRESS

~

~

MULTIPLIER

B ADDRESS

~

The data in the A-field is multiplied by the data in the field whose rightmost location is 695, and the product is stored, right-justified, in the B-field. All B-field zone bits are cleared to 0 I S (except in the units position, which contains the sign of the product). At the end of the operation, the multiplier is no longer present in the leftmost positions of the B-field, since all B-field locations to the left of the most significant digit of the product are set to O's. Thus, the multiplier should be pre served in another storage field if it is to be used more than once.

The result of the multiply operation is shown below.

LOCATION-..

CONTENTS--.

DIVISION

A FIELD IS NOT DISTURBED

PRODUCT IS STORED IN B FIELD, RIGHT-JUSTIFIED. ALL INSIGNIFICANT HIGH-ORDER CHARACTERS ARE SET TO ZEROS

---~---

PRODUCT

The Divide instruction causes the signed decimal integer in the A-field (the divisor) to be divided into the signed decimal ~nteger whose leftmost location is the B-address of the instruc-tion (the dividend). The quotient is developed and stored in the leftmost locainstruc-tions of the B-field,

and the remainder is stored in the rightmost locations of the B-field. 1 To insure an adequate number of storage locations for the development of the quotient, the length of the B-field is determined by adding Ito the sum of the number of character locations in the divisor and dividend (see Figure 8-4).

The leftmost location of the dividend is defined by the B-address of the Divide instruction.

The rightmost location

F.

e., the units position) is the first character location to the right of the B-address to have one of its zone bits not equal to O. As shown in Figure 8-4, all B-field locations to the left of the dividend must contain 0 I S prior to the divide operation.

A word mark is required in the leftmost location of the divisor. The dividend mayor may not contain a word mark.

I Note that the B "field" in a divide operation does not define the B-operand but is a group of storage locations within which the B-operand (the dividend) is contained.

OPERATION:

xxx)yyyy

BEFORE EXECUTION

~A FIELD~ r

B FIELD (3+4+1=8 locationS)1

A ADDREjS B ADDRESS

LOCATION ... A;"Z A~l A

B ... 4 B'-l

B·2 B-1

-'

B Btl B+2 B+3

CONTENTS-..

@

x x 0 0 0 0 y y y y

...

.

DIVISOR DIVIDEND

(3 locations) (4 locations)

AFTER EXECUTION

B-Na +N dd-2

B-Na+Ndd

~-

B+Ndd-l

LOCATION --- A~Z A~l A B"'4 B"l

B"'2.

BiM:l B

B+l

BfZ

B+3

CONTENTS ...

®

x x q q q

q

0 r r r

, . .

QUOTIENT REMAINDER

Figure 8-4. Factor Locations in Divide Operation

The signs of the operands are indicated by the zone bits in the units positions of the divisor and dividend. Algebraic sign control is used to determine the sign of the quotient (see Tabl~ 8-7). The sign of the quotient is expressed in its normalized form (minus

=

10, plus

=

01).

The sign of the remainder is always the same as that of the dividend (in value if not in bit con-figuration); its form is normalized if the sign of the dividend is normalized •.

Table 8-7. Divide Sign Conventions

Sign of Divisor + +

-

-Sign of Dividend +

-

+

-Sign of Remainder +

-

+

-Sign of Quotien t +

- -

+

Since the pre sence of a signed digit in the dividend specifie sits rightmo st location, the units position of the dividend must contain a normalized sign and the zone bits of all other dividend characters must be O.

When division is -completed, the signed decimal quotient is stored in the leftmost locations of the B-field; the units position of the quotient is in location B - N + N - 2, where N is the

. - a dd a

number of locations in the A-field and Ndd is the number of locations in the dividend. The signed decimal remainder appears in locations B+Ndd-l, B+N

dd-2, etc. through location B-Na +Ndd• The character location separating the quotient and the remainder is cleared to 0 (see Figure 8-4).

In the following example, the divisor is a two-character field whose rightmost location is location 450 and the dividend is a four-character integer whose leftmost location is location 950.

EASYCODER

COOING FORM

PROBLEM PROGRAMMER DATE PAGE OF

CARD

Dans le document Honeywell 2040 (Page 177-181)

Documents relatifs