68000 Implementation of 32-Bit floating-Point Addition and Multiplication

Subroutines

On this program, two useful subroutines were utilized. The first is the subroutine for normalizing the operands, product and sum. This has been called many times by the main program. The second subroutine is the subroutine that handles addition and multiplication of special numbers and exceptions.

1. Subroutine for normalizing operands, sum and product
A normalization of the operand is required if the operand is on ‘denormalized’ form. This happens if the exponent is zero and the mantissa is non-zero. The subroutine accepts the exponent and the mantissa of the operand that needs to be normalized and returns the normalized mantissa and exponent. To handle normalization for the product, a dummy register, D0 is used that will store the 24 bit LSB of the product but in case of normalizing operands and sum, D0 is cleared to zero.

The algorithm for this sub-routine first test if the operand is zero or the 24th bit is ‘1’. If the test satisfies either of the conditions, no normalization is required. Otherwise, the program proceeds on the normalization procedure.

The normalization procedure just continuously shifts the mantissa to the left until a bit ‘1’ is placed on the 24th bit. Every shift must have a corresponding decrement on the exponent. For the case of normalizing the product, after shifting the 24 bit MSB of the product to the left, the MSB of the 24 bit LSB is copied on the LSB of the 24 bit MSB.

2. Subroutine for adding and multiplying infinity and NaN
This subroutine is called if the exponent of either of both operands is equal to 255, which corresponds to a value equal to either infinity or NaN. This subroutine performs the addition and multiplication for these exceptions and special number. The following table summarize the sum and product of some possible combinations of operands.

Sign Exponent Mantissa Value
Operand 1 1 11111111 00000… -inf
Operand 2 0 10001000 01000… Real number
Sum 1 11111111 00000… -inf
Product 1 11111111 00000… -inf
Operand 1 1 11111111 00000… -inf
Operand 2 0 11111111 00000… +inf
Sum

undefined

Product

undefined

Operand 1 1 11111111 01000… NaN
Operand 2 0 11111111 00000… +inf
Sum

undefined

Product

undefined

Operand 1 0 11111111 00000… +inf
Operand 2 1 00000000 00000… zero
Sum 0 11111111 00000… +inf
Product 1 00000000 00000… zero
Operand 1 1 11111111 00000… -inf
Operand 2 1 11111111 00000… -inf
Sum 1 11111111 00000… -inf
Product 0 11111111 00000… +inf


Table 1: Some of possible inputs that involve infinite and NaN values of operand

Base from the above table, if either or both of the sum or product is undefined or the operation involve a NaN operand, no sum or product is written on the memory location $3000.

Flow Chart of the algorithm

Click the following link to view the flow chart.
Figure 2: Flow Chart for inputing operands
Figure 3: Flow Chart for Addition
Figure 4: Flow Chart for multiplication
Figure 5: Flow Chart of the subroutine that handle the addition and multiplication of operands with a value equal to infinity or Not A Number

Source Code

To view the source code, click the following .x68 file
alfiemp2.x68

page 1 | page 2 | page 3

Linkblog

Sponsored Links