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

Testing Procedure

Aside from some inputs that involve operand with a value representing infinity and NaN illustrated in table 1, the program was tested in other possible values of input. The resulting output of the program for the sum and product are correct. Two test case for the addition of floating point numbers was downloaded from the internet, http://www.cs.wisc.edu/~smoler/x86text/lect.notes/arith.flpt.html, and http://www.cgmi.inf.uni-konstanz.de/lectures/ws2003_int
roductiontocomputerscience1/exercise03/CS1_Lecture-Week3.4.pdf, were inputed that test the effectivity of the program. One of the two test input are as follow:

Operand 1: 0 10001010 00100101001001000000000 (45129200)
Operand 2: 0 01111110 10000000000000000000000 (3F400000)
Sum: 0 10001010 00100101001111000000000 (45129E00)

The other method to test the correctness of the program output is by manually calculating the sum and product of the two operands and comparing it if the computed results match to the output of the program.

The following is an example of testing the effectivity of the program. The sum and the product in the table are the outputs of the program. What follows, are the manual calculation of sum and product.

1. test input number 1

Binary Hexadecimal
Operand 1 0 10001000 00110000000000000000001 44180001 Positive real number
Operand 2 1 10001110 10000000000000000000011 C7400003 Negative real number
Sum 1 10001110 01111011010000000000011 C73DA003 Negative real number
Product 1 10010111 11001000000000000000101 CBE40005 Negative real number

The sum can be verified if correct using manual calculation:

Step 1: show hidden 1 of the mantissa
Mantissa of operand 1: 100110000000000000000001
Mantissa of operand 2: 110000000000000000000011

Step 2: shift the mantissa of the 1st operand equal to the difference in exponent (142-136=6)
Mantissa of operand 1: 000000100110000000000000
Mantissa of operand 2: 110000000000000000000011
Complement of the mantissa of operand 2: 11111111001111111111111111111101

Step 3: Add the mantissa. Since the sum is negative, complement it.
Sum of the mantissas (unsigned): 101111011010000000000011

Step 4: hide the ‘1’ in 24th bit then combine the sign, exponent and mantissa. The sum will be,
1 10001110 01111011010000000000011
which is equal to the computed value

To verify the output product;

step 1: multiply the mantissa
48-bit product of mantissas: 011100100000000000000010 100010000000000000000011
sum of exponents: 100010110

step 2: normalize and truncate
mantissa: 111001000000000000000101
exponent - 127: 10010111

step 3: hide the ‘1’ in 24th bit then combine the sign, exponent and mantissa. The product will be,
1 10010111 11001000000000000000101
which is equal to the computed value

2. Test input number 2

Binary Hexadecimal
Operand 1 0 00001010 00110000000000000000001 5180001 Positive real number
Operand 2 1 00000000 01000000000000000000001 80200001 Negative denormalized #
Sum 0 00001010 00101111111100000000001 517F801 Positive real number
Product

Underflow occur

Underflow occur

Manual calculation for Addition
Step 1: since operand 2 is in denormalized form, normalize it first before addition
Normalized mantissa of operand 2: 100000000000000000000100
Exponent of the normalized operand 2: 00000010

Step 2: Align operand 2 by shifting it to the right equal to the difference in exponent, (10-2=8). Since operand 2 is negative, complement it first before addition.
Mantissa of operand 1:100110000000000000000001
Mantissa of operand 2: 000000001000000000000000
Complement of the mantissa of operand 2: 11111111111111111000000000000000
Sum of mantissas: 100101111000000000000001

Step 3: Hide the ‘1’ on the 24th bit of the sum. Then combine the sign, exponent and mantissa into IEEE format. The calculated sum is:
0 00001010 00101111000000000000001
which is equal to the output of the program

The sum of the exponents of the two operand minus a bias of 127 is less than 0, therefore, underflow occur in multiplication.

Common Problems

The common problem encountered in doing this Machine Problem is the scarcity of data registers for storing data. Unlike other high level programming languages like C and C++, there are almost infinite number of variables to store the necessary data and addresses. In 68000, only 8 data registers and 8 address registers are available. In doing the program, there are instances that we have to clear or change the content of certain data register that may be used later to make it usable for the current procedure. Thus, we have to make a code that reloads the necessary data for the next procedure where it is needed. Thus, the code becomes longer.

page 1 | page 2 | page 3

Linkblog

Sponsored Links